Passed
Push — master ( c42a10...eadd35 )
by Brian
04:45
created
includes/class-getpaid-invoice-notification-emails.php 2 patches
Indentation   +451 added lines, -451 removed lines patch added patch discarded remove patch
@@ -12,492 +12,492 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Invoice_Notification_Emails {
14 14
 
15
-	/**
16
-	 * The array of invoice email actions.
17
-	 *
18
-	 * @param array
19
-	 */
20
-	public $invoice_actions;
21
-
22
-	/**
23
-	 * Class constructor
24
-	 *
25
-	 */
26
-	public function __construct() {
27
-
28
-		$this->invoice_actions = apply_filters(
29
-			'getpaid_notification_email_invoice_triggers',
30
-			array(
31
-				'getpaid_new_invoice'                   => array( 'new_invoice', 'user_invoice' ),
32
-				'getpaid_invoice_status_wpi-cancelled'  => 'cancelled_invoice',
33
-				'getpaid_invoice_status_wpi-failed'     => 'failed_invoice',
34
-				'getpaid_invoice_status_wpi-onhold'     => 'onhold_invoice',
35
-				'getpaid_invoice_status_wpi-processing' => 'processing_invoice',
36
-				'getpaid_invoice_status_publish'        => 'completed_invoice',
37
-				'getpaid_invoice_status_wpi-renewal'    => 'completed_invoice',
38
-				'getpaid_invoice_status_wpi-refunded'   => 'refunded_invoice',
39
-				'getpaid_new_customer_note'             => 'user_note',
40
-				'getpaid_daily_maintenance'             => 'overdue',
41
-			)
42
-		);
43
-
44
-		$this->init_hooks();
45
-
46
-	}
47
-
48
-	/**
49
-	 * Registers email hooks.
50
-	 */
51
-	public function init_hooks() {
52
-
53
-		add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 );
54
-		add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 );
55
-
56
-		foreach ( $this->invoice_actions as $hook => $email_type ) {
57
-			$this->init_email_type_hook( $hook, $email_type );
58
-		}
59
-	}
60
-
61
-	/**
62
-	 * Registers an email hook for an invoice action.
63
-	 * 
64
-	 * @param string $hook
65
-	 * @param string|array $email_type
66
-	 */
67
-	public function init_email_type_hook( $hook, $email_type ) {
68
-
69
-		$email_type = wpinv_parse_list( $email_type );
70
-
71
-		foreach ( $email_type as $type ) {
72
-
73
-			$email = new GetPaid_Notification_Email( $type );
74
-
75
-			// Abort if it is not active.
76
-			if ( ! $email->is_active() ) {
77
-				continue;
78
-			}
79
-
80
-			if ( method_exists( $this, $type ) ) {
81
-				add_action( $hook, array( $this, $type ), 100, 2 );
82
-				continue;
83
-			}
84
-
85
-			do_action( 'getpaid_invoice_init_email_type_hook', $type, $hook );
86
-		}
87
-
88
-	}
89
-
90
-	/**
91
-	 * Filters invoice merge tags.
92
-	 *
93
-	 * @param array $merge_tags
94
-	 * @param mixed|WPInv_Invoice|WPInv_Subscription $object
95
-	 */
96
-	public function invoice_merge_tags( $merge_tags, $object ) {
97
-
98
-		if ( is_a( $object, 'WPInv_Invoice' ) ) {
99
-			return array_merge(
100
-				$merge_tags,
101
-				$this->get_invoice_merge_tags( $object )
102
-			);
103
-		}
104
-
105
-		if ( is_a( $object, 'WPInv_Subscription' ) ) {
106
-			return array_merge(
107
-				$merge_tags,
108
-				$this->get_invoice_merge_tags( $object->get_parent_payment() )
109
-			);
110
-		}
111
-
112
-		return $merge_tags;
113
-
114
-	}
115
-
116
-	/**
117
-	 * Generates invoice merge tags.
118
-	 *
119
-	 * @param WPInv_Invoice $invoice
120
-	 * @return array
121
-	 */
122
-	public function get_invoice_merge_tags( $invoice ) {
123
-
124
-		// Abort if it does not exist.
125
-		if ( ! $invoice->get_id() ) {
126
-			return array();
127
-		}
128
-
129
-		$merge_tags = array(
130
-			'{name}'                => sanitize_text_field( $invoice->get_user_full_name() ),
131
-			'{full_name}'           => sanitize_text_field( $invoice->get_user_full_name() ),
132
-			'{first_name}'          => sanitize_text_field( $invoice->get_first_name() ),
133
-			'{last_name}'           => sanitize_text_field( $invoice->get_last_name() ),
134
-			'{email}'               => sanitize_email( $invoice->get_email() ),
135
-			'{invoice_number}'      => sanitize_text_field( $invoice->get_number() ),
136
-			'{invoice_currency}'    => sanitize_text_field( $invoice->get_currency() ),
137
-			'{invoice_total}'       => sanitize_text_field( wpinv_price( $invoice->get_total(), $invoice->get_currency() ) ),
138
-			'{invoice_link}'        => esc_url( $invoice->get_view_url() ),
139
-			'{invoice_pay_link}'    => esc_url( $invoice->get_checkout_payment_url() ),
140
-			'{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ),
141
-			'{invoice_date}'        => getpaid_format_date_value( $invoice->get_date_created() ),
142
-			'{invoice_due_date}'    => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ),
143
-			'{invoice_quote}'       => sanitize_text_field( strtolower( $invoice->get_label() ) ),
144
-			'{invoice_label}'       => sanitize_text_field( ucfirst( $invoice->get_label() ) ),
145
-			'{invoice_description}' => wp_kses_post( $invoice->get_description() ),
146
-			'{subscription_name}'   => wp_kses_post( $invoice->get_subscription_name() ),
147
-			'{is_was}'              => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
148
-		);
149
-
150
-		$payment_form_data = $invoice->get_meta( 'payment_form_data', true );
151
-
152
-		if ( is_array( $payment_form_data ) ) {
153
-
154
-			foreach ( $payment_form_data as $label => $value ) {
155
-
156
-				$label = preg_replace( '/[^a-z0-9]+/', '_', strtolower( $label ) );
157
-				$value = is_array( $value ) ? implode( ', ', $value ) : $value;
158
-
159
-				if ( is_scalar ( $value ) ) {
160
-					$merge_tags[ "{{$label}}" ] = wp_kses_post( $value );
161
-				}
162
-
163
-			}
164
-
165
-		}
166
-
167
-		return apply_filters( 'getpaid_invoice_email_merge_tags', $merge_tags, $invoice );
168
-	}
169
-
170
-	/**
171
-	 * Helper function to send an email.
172
-	 *
173
-	 * @param WPInv_Invoice $invoice
174
-	 * @param GetPaid_Notification_Email $email
175
-	 * @param string $type
176
-	 * @param string|array $recipients
177
-	 * @param array $extra_args Extra template args.
178
-	 */
179
-	public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) {
180
-
181
-		do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email );
182
-
183
-		$skip = $invoice->is_free() && wpinv_get_option( 'skip_email_free_invoice' );
184
-		if ( apply_filters( 'getpaid_skip_invoice_email', $skip, $type, $invoice ) ) {
185
-			return;
186
-		}
187
-
188
-		$mailer     = new GetPaid_Notification_Email_Sender();
189
-		$merge_tags = $email->get_merge_tags();
190
-
191
-		$result = $mailer->send(
192
-			apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ),
193
-			$email->add_merge_tags( $email->get_subject(), $merge_tags ),
194
-			$email->get_content( $merge_tags, $extra_args ),
195
-			$email->get_attachments()
196
-		);
197
-
198
-		// Maybe send a copy to the admin.
199
-		if ( $email->include_admin_bcc() ) {
200
-			$mailer->send(
201
-				wpinv_get_admin_email(),
202
-				$email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ),
203
-				$email->get_content( $merge_tags ),
204
-				$email->get_attachments()
205
-			);
206
-		}
207
-
208
-		if ( $result ) {
209
-			$invoice->add_system_note(
210
-				sprintf(
211
-					__( 'Successfully sent %s notification email to %s.', 'invoicing' ),
212
-					sanitize_key( $type ),
213
-					$email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
214
-				)
215
-			);
216
-		} else {
217
-			$invoice->add_system_note(
218
-				sprintf(
219
-					__( 'Failed sending %s notification email to %s.', 'invoicing' ),
220
-					sanitize_key( $type ),
221
-					$email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
222
-				)
223
-			);	
224
-		}
225
-
226
-		do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email );
227
-
228
-		return $result;
229
-	}
230
-
231
-	/**
232
-	 * Also send emails to any cc users.
233
-	 *
234
-	 * @param array $recipients
235
-	 * @param GetPaid_Notification_Email $email
236
-	 */
237
-	public function filter_email_recipients( $recipients, $email ) {
238
-
239
-		if ( ! $email->is_admin_email() ) {
240
-			$cc   = $email->object->get_email_cc();
241
-			$cc_2 = get_user_meta( $email->object->get_user_id(), '_wpinv_email_cc', true );
242
-
243
-			if ( ! empty( $cc ) ) {
244
-				$cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
245
-				$recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
246
-			}
247
-
248
-			if ( ! empty( $cc_2 ) ) {
249
-				$cc_2 = array_map( 'sanitize_email', wpinv_parse_list( $cc_2 ) );
250
-				$recipients = array_filter( array_unique( array_merge( $recipients, $cc_2 ) ) );
251
-			}
252
-
253
-		}
254
-
255
-		return $recipients;
256
-
257
-	}
258
-
259
-	/**
260
-	 * Sends a new invoice notification.
261
-	 *
262
-	 * @param WPInv_Invoice $invoice
263
-	 */
264
-	public function new_invoice( $invoice ) {
265
-
266
-		// Only send this email for invoices created via the admin page.
267
-		if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_paid() || $this->is_payment_form_invoice( $invoice->get_id() ) ) {
268
-			return;
269
-		}
270
-
271
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
272
-		$recipient = wpinv_get_admin_email();
273
-
274
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
275
-
276
-	}
277
-
278
-	/**
279
-	 * Sends a cancelled invoice notification.
280
-	 *
281
-	 * @param WPInv_Invoice $invoice
282
-	 */
283
-	public function cancelled_invoice( $invoice ) {
284
-
285
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
286
-		$recipient = wpinv_get_admin_email();
287
-
288
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
289
-
290
-	}
291
-
292
-	/**
293
-	 * Sends a failed invoice notification.
294
-	 *
295
-	 * @param WPInv_Invoice $invoice
296
-	 */
297
-	public function failed_invoice( $invoice ) {
298
-
299
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
300
-		$recipient = wpinv_get_admin_email();
301
-
302
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
303
-
304
-	}
305
-
306
-	/**
307
-	 * Sends a notification whenever an invoice is put on hold.
308
-	 *
309
-	 * @param WPInv_Invoice $invoice
310
-	 */
311
-	public function onhold_invoice( $invoice ) {
312
-
313
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
314
-		$recipient = $invoice->get_email();
15
+    /**
16
+     * The array of invoice email actions.
17
+     *
18
+     * @param array
19
+     */
20
+    public $invoice_actions;
21
+
22
+    /**
23
+     * Class constructor
24
+     *
25
+     */
26
+    public function __construct() {
27
+
28
+        $this->invoice_actions = apply_filters(
29
+            'getpaid_notification_email_invoice_triggers',
30
+            array(
31
+                'getpaid_new_invoice'                   => array( 'new_invoice', 'user_invoice' ),
32
+                'getpaid_invoice_status_wpi-cancelled'  => 'cancelled_invoice',
33
+                'getpaid_invoice_status_wpi-failed'     => 'failed_invoice',
34
+                'getpaid_invoice_status_wpi-onhold'     => 'onhold_invoice',
35
+                'getpaid_invoice_status_wpi-processing' => 'processing_invoice',
36
+                'getpaid_invoice_status_publish'        => 'completed_invoice',
37
+                'getpaid_invoice_status_wpi-renewal'    => 'completed_invoice',
38
+                'getpaid_invoice_status_wpi-refunded'   => 'refunded_invoice',
39
+                'getpaid_new_customer_note'             => 'user_note',
40
+                'getpaid_daily_maintenance'             => 'overdue',
41
+            )
42
+        );
43
+
44
+        $this->init_hooks();
45
+
46
+    }
47
+
48
+    /**
49
+     * Registers email hooks.
50
+     */
51
+    public function init_hooks() {
52
+
53
+        add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 );
54
+        add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 );
55
+
56
+        foreach ( $this->invoice_actions as $hook => $email_type ) {
57
+            $this->init_email_type_hook( $hook, $email_type );
58
+        }
59
+    }
60
+
61
+    /**
62
+     * Registers an email hook for an invoice action.
63
+     * 
64
+     * @param string $hook
65
+     * @param string|array $email_type
66
+     */
67
+    public function init_email_type_hook( $hook, $email_type ) {
68
+
69
+        $email_type = wpinv_parse_list( $email_type );
70
+
71
+        foreach ( $email_type as $type ) {
72
+
73
+            $email = new GetPaid_Notification_Email( $type );
74
+
75
+            // Abort if it is not active.
76
+            if ( ! $email->is_active() ) {
77
+                continue;
78
+            }
79
+
80
+            if ( method_exists( $this, $type ) ) {
81
+                add_action( $hook, array( $this, $type ), 100, 2 );
82
+                continue;
83
+            }
84
+
85
+            do_action( 'getpaid_invoice_init_email_type_hook', $type, $hook );
86
+        }
87
+
88
+    }
89
+
90
+    /**
91
+     * Filters invoice merge tags.
92
+     *
93
+     * @param array $merge_tags
94
+     * @param mixed|WPInv_Invoice|WPInv_Subscription $object
95
+     */
96
+    public function invoice_merge_tags( $merge_tags, $object ) {
97
+
98
+        if ( is_a( $object, 'WPInv_Invoice' ) ) {
99
+            return array_merge(
100
+                $merge_tags,
101
+                $this->get_invoice_merge_tags( $object )
102
+            );
103
+        }
104
+
105
+        if ( is_a( $object, 'WPInv_Subscription' ) ) {
106
+            return array_merge(
107
+                $merge_tags,
108
+                $this->get_invoice_merge_tags( $object->get_parent_payment() )
109
+            );
110
+        }
111
+
112
+        return $merge_tags;
113
+
114
+    }
115
+
116
+    /**
117
+     * Generates invoice merge tags.
118
+     *
119
+     * @param WPInv_Invoice $invoice
120
+     * @return array
121
+     */
122
+    public function get_invoice_merge_tags( $invoice ) {
123
+
124
+        // Abort if it does not exist.
125
+        if ( ! $invoice->get_id() ) {
126
+            return array();
127
+        }
128
+
129
+        $merge_tags = array(
130
+            '{name}'                => sanitize_text_field( $invoice->get_user_full_name() ),
131
+            '{full_name}'           => sanitize_text_field( $invoice->get_user_full_name() ),
132
+            '{first_name}'          => sanitize_text_field( $invoice->get_first_name() ),
133
+            '{last_name}'           => sanitize_text_field( $invoice->get_last_name() ),
134
+            '{email}'               => sanitize_email( $invoice->get_email() ),
135
+            '{invoice_number}'      => sanitize_text_field( $invoice->get_number() ),
136
+            '{invoice_currency}'    => sanitize_text_field( $invoice->get_currency() ),
137
+            '{invoice_total}'       => sanitize_text_field( wpinv_price( $invoice->get_total(), $invoice->get_currency() ) ),
138
+            '{invoice_link}'        => esc_url( $invoice->get_view_url() ),
139
+            '{invoice_pay_link}'    => esc_url( $invoice->get_checkout_payment_url() ),
140
+            '{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ),
141
+            '{invoice_date}'        => getpaid_format_date_value( $invoice->get_date_created() ),
142
+            '{invoice_due_date}'    => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ),
143
+            '{invoice_quote}'       => sanitize_text_field( strtolower( $invoice->get_label() ) ),
144
+            '{invoice_label}'       => sanitize_text_field( ucfirst( $invoice->get_label() ) ),
145
+            '{invoice_description}' => wp_kses_post( $invoice->get_description() ),
146
+            '{subscription_name}'   => wp_kses_post( $invoice->get_subscription_name() ),
147
+            '{is_was}'              => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
148
+        );
149
+
150
+        $payment_form_data = $invoice->get_meta( 'payment_form_data', true );
151
+
152
+        if ( is_array( $payment_form_data ) ) {
153
+
154
+            foreach ( $payment_form_data as $label => $value ) {
155
+
156
+                $label = preg_replace( '/[^a-z0-9]+/', '_', strtolower( $label ) );
157
+                $value = is_array( $value ) ? implode( ', ', $value ) : $value;
158
+
159
+                if ( is_scalar ( $value ) ) {
160
+                    $merge_tags[ "{{$label}}" ] = wp_kses_post( $value );
161
+                }
162
+
163
+            }
164
+
165
+        }
166
+
167
+        return apply_filters( 'getpaid_invoice_email_merge_tags', $merge_tags, $invoice );
168
+    }
169
+
170
+    /**
171
+     * Helper function to send an email.
172
+     *
173
+     * @param WPInv_Invoice $invoice
174
+     * @param GetPaid_Notification_Email $email
175
+     * @param string $type
176
+     * @param string|array $recipients
177
+     * @param array $extra_args Extra template args.
178
+     */
179
+    public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) {
180
+
181
+        do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email );
182
+
183
+        $skip = $invoice->is_free() && wpinv_get_option( 'skip_email_free_invoice' );
184
+        if ( apply_filters( 'getpaid_skip_invoice_email', $skip, $type, $invoice ) ) {
185
+            return;
186
+        }
187
+
188
+        $mailer     = new GetPaid_Notification_Email_Sender();
189
+        $merge_tags = $email->get_merge_tags();
190
+
191
+        $result = $mailer->send(
192
+            apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ),
193
+            $email->add_merge_tags( $email->get_subject(), $merge_tags ),
194
+            $email->get_content( $merge_tags, $extra_args ),
195
+            $email->get_attachments()
196
+        );
197
+
198
+        // Maybe send a copy to the admin.
199
+        if ( $email->include_admin_bcc() ) {
200
+            $mailer->send(
201
+                wpinv_get_admin_email(),
202
+                $email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ),
203
+                $email->get_content( $merge_tags ),
204
+                $email->get_attachments()
205
+            );
206
+        }
207
+
208
+        if ( $result ) {
209
+            $invoice->add_system_note(
210
+                sprintf(
211
+                    __( 'Successfully sent %s notification email to %s.', 'invoicing' ),
212
+                    sanitize_key( $type ),
213
+                    $email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
214
+                )
215
+            );
216
+        } else {
217
+            $invoice->add_system_note(
218
+                sprintf(
219
+                    __( 'Failed sending %s notification email to %s.', 'invoicing' ),
220
+                    sanitize_key( $type ),
221
+                    $email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
222
+                )
223
+            );	
224
+        }
225
+
226
+        do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email );
227
+
228
+        return $result;
229
+    }
230
+
231
+    /**
232
+     * Also send emails to any cc users.
233
+     *
234
+     * @param array $recipients
235
+     * @param GetPaid_Notification_Email $email
236
+     */
237
+    public function filter_email_recipients( $recipients, $email ) {
238
+
239
+        if ( ! $email->is_admin_email() ) {
240
+            $cc   = $email->object->get_email_cc();
241
+            $cc_2 = get_user_meta( $email->object->get_user_id(), '_wpinv_email_cc', true );
242
+
243
+            if ( ! empty( $cc ) ) {
244
+                $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
245
+                $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
246
+            }
247
+
248
+            if ( ! empty( $cc_2 ) ) {
249
+                $cc_2 = array_map( 'sanitize_email', wpinv_parse_list( $cc_2 ) );
250
+                $recipients = array_filter( array_unique( array_merge( $recipients, $cc_2 ) ) );
251
+            }
252
+
253
+        }
254
+
255
+        return $recipients;
256
+
257
+    }
258
+
259
+    /**
260
+     * Sends a new invoice notification.
261
+     *
262
+     * @param WPInv_Invoice $invoice
263
+     */
264
+    public function new_invoice( $invoice ) {
265
+
266
+        // Only send this email for invoices created via the admin page.
267
+        if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_paid() || $this->is_payment_form_invoice( $invoice->get_id() ) ) {
268
+            return;
269
+        }
270
+
271
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
272
+        $recipient = wpinv_get_admin_email();
273
+
274
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
275
+
276
+    }
277
+
278
+    /**
279
+     * Sends a cancelled invoice notification.
280
+     *
281
+     * @param WPInv_Invoice $invoice
282
+     */
283
+    public function cancelled_invoice( $invoice ) {
284
+
285
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
286
+        $recipient = wpinv_get_admin_email();
287
+
288
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
289
+
290
+    }
291
+
292
+    /**
293
+     * Sends a failed invoice notification.
294
+     *
295
+     * @param WPInv_Invoice $invoice
296
+     */
297
+    public function failed_invoice( $invoice ) {
298
+
299
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
300
+        $recipient = wpinv_get_admin_email();
301
+
302
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
303
+
304
+    }
305
+
306
+    /**
307
+     * Sends a notification whenever an invoice is put on hold.
308
+     *
309
+     * @param WPInv_Invoice $invoice
310
+     */
311
+    public function onhold_invoice( $invoice ) {
312
+
313
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
314
+        $recipient = $invoice->get_email();
315 315
 
316
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
316
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
317 317
 
318
-	}
318
+    }
319 319
 
320
-	/**
321
-	 * Sends a notification whenever an invoice is marked as processing payment.
322
-	 *
323
-	 * @param WPInv_Invoice $invoice
324
-	 */
325
-	public function processing_invoice( $invoice ) {
320
+    /**
321
+     * Sends a notification whenever an invoice is marked as processing payment.
322
+     *
323
+     * @param WPInv_Invoice $invoice
324
+     */
325
+    public function processing_invoice( $invoice ) {
326 326
 
327
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
328
-		$recipient = $invoice->get_email();
327
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
328
+        $recipient = $invoice->get_email();
329 329
 
330
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
331
-
332
-	}
333
-
334
-	/**
335
-	 * Sends a notification whenever an invoice is paid.
336
-	 *
337
-	 * @param WPInv_Invoice $invoice
338
-	 */
339
-	public function completed_invoice( $invoice ) {
330
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
331
+
332
+    }
333
+
334
+    /**
335
+     * Sends a notification whenever an invoice is paid.
336
+     *
337
+     * @param WPInv_Invoice $invoice
338
+     */
339
+    public function completed_invoice( $invoice ) {
340 340
 
341
-		// (Maybe) abort if it is a renewal invoice.
342
-		if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) {
343
-			return;
344
-		}
341
+        // (Maybe) abort if it is a renewal invoice.
342
+        if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) {
343
+            return;
344
+        }
345 345
 
346
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
347
-		$recipient = $invoice->get_email();
346
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
347
+        $recipient = $invoice->get_email();
348 348
 
349
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
349
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
350 350
 
351
-	}
351
+    }
352 352
 
353
-	/**
354
-	 * Sends a notification whenever an invoice is refunded.
355
-	 *
356
-	 * @param WPInv_Invoice $invoice
357
-	 */
358
-	public function refunded_invoice( $invoice ) {
353
+    /**
354
+     * Sends a notification whenever an invoice is refunded.
355
+     *
356
+     * @param WPInv_Invoice $invoice
357
+     */
358
+    public function refunded_invoice( $invoice ) {
359 359
 
360
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
361
-		$recipient = $invoice->get_email();
360
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
361
+        $recipient = $invoice->get_email();
362 362
 
363
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
363
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
364 364
 
365
-	}
365
+    }
366 366
 
367
-	/**
368
-	 * Notifies a user about new invoices
369
-	 *
370
-	 * @param WPInv_Invoice $invoice
371
-	 * @param bool $force
372
-	 */
373
-	public function user_invoice( $invoice, $force = false ) {
367
+    /**
368
+     * Notifies a user about new invoices
369
+     *
370
+     * @param WPInv_Invoice $invoice
371
+     * @param bool $force
372
+     */
373
+    public function user_invoice( $invoice, $force = false ) {
374 374
 
375
-		if ( ! empty( $GLOBALS['wpinv_skip_invoice_notification'] ) ) {
376
-			return;
377
-		}
378
-
379
-		// Only send this email for invoices created via the admin page.
380
-		if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_paid() || ( empty( $force ) && $this->is_payment_form_invoice( $invoice->get_id() ) ) ) {
381
-			return;
382
-		}
375
+        if ( ! empty( $GLOBALS['wpinv_skip_invoice_notification'] ) ) {
376
+            return;
377
+        }
378
+
379
+        // Only send this email for invoices created via the admin page.
380
+        if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_paid() || ( empty( $force ) && $this->is_payment_form_invoice( $invoice->get_id() ) ) ) {
381
+            return;
382
+        }
383 383
 
384
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
385
-		$recipient = $invoice->get_email();
384
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
385
+        $recipient = $invoice->get_email();
386 386
 
387
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
387
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
388 388
 
389
-	}
390
-
391
-	/**
392
-	 * Checks if an invoice is a payment form invoice.
393
-	 *
394
-	 * @param int $invoice
395
-	 * @return bool
396
-	 */
397
-	public function is_payment_form_invoice( $invoice ) {
398
-		$is_payment_form_invoice = empty( $_GET['getpaid-admin-action'] ) && ( 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true ) || 'geodirectory' == get_post_meta( $invoice, 'wpinv_created_via', true ) );
399
-		return apply_filters( 'getpaid_invoice_notifications_is_payment_form_invoice', $is_payment_form_invoice, $invoice );
400
-	}
389
+    }
390
+
391
+    /**
392
+     * Checks if an invoice is a payment form invoice.
393
+     *
394
+     * @param int $invoice
395
+     * @return bool
396
+     */
397
+    public function is_payment_form_invoice( $invoice ) {
398
+        $is_payment_form_invoice = empty( $_GET['getpaid-admin-action'] ) && ( 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true ) || 'geodirectory' == get_post_meta( $invoice, 'wpinv_created_via', true ) );
399
+        return apply_filters( 'getpaid_invoice_notifications_is_payment_form_invoice', $is_payment_form_invoice, $invoice );
400
+    }
401 401
 
402
-	/**
403
-	 * Notifies admin about new invoice notes
404
-	 *
405
-	 * @param WPInv_Invoice $invoice
406
-	 * @param string $note
407
-	 */
408
-	public function user_note( $invoice, $note ) {
409
-
410
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
411
-		$recipient = $invoice->get_email();
402
+    /**
403
+     * Notifies admin about new invoice notes
404
+     *
405
+     * @param WPInv_Invoice $invoice
406
+     * @param string $note
407
+     */
408
+    public function user_note( $invoice, $note ) {
409
+
410
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
411
+        $recipient = $invoice->get_email();
412 412
 
413
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) );
414
-
415
-	}
416
-
417
-	/**
418
-	 * (Force) Sends overdue notices.
419
-	 *
420
-	 * @param WPInv_Invoice $invoice
421
-	 */
422
-	public function force_send_overdue_notice( $invoice ) {
423
-		$email = new GetPaid_Notification_Email( 'overdue', $invoice );
424
-		return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() );
425
-	}
426
-
427
-	/**
428
-	 * Sends overdue notices.
429
-	 *
430
-	 * @TODO: Create an invoices query class.
431
-	 */
432
-	public function overdue() {
433
-		global $wpdb;
434
-
435
-		$email = new GetPaid_Notification_Email( __FUNCTION__ );
436
-
437
-		// Fetch reminder days.
438
-		$reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
439
-
440
-		// Abort if non is set.
441
-		if ( empty( $reminder_days ) ) {
442
-			return;
443
-		}
444
-
445
-		// Retrieve date query.
446
-		$date_query = $this->get_date_query( $reminder_days );
447
-
448
-		// Invoices table.
449
-		$table = $wpdb->prefix . 'getpaid_invoices';
450
-
451
-		// Fetch invoices.
452
-		$invoices  = $wpdb->get_col(
453
-			"SELECT posts.ID FROM $wpdb->posts as posts
413
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) );
414
+
415
+    }
416
+
417
+    /**
418
+     * (Force) Sends overdue notices.
419
+     *
420
+     * @param WPInv_Invoice $invoice
421
+     */
422
+    public function force_send_overdue_notice( $invoice ) {
423
+        $email = new GetPaid_Notification_Email( 'overdue', $invoice );
424
+        return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() );
425
+    }
426
+
427
+    /**
428
+     * Sends overdue notices.
429
+     *
430
+     * @TODO: Create an invoices query class.
431
+     */
432
+    public function overdue() {
433
+        global $wpdb;
434
+
435
+        $email = new GetPaid_Notification_Email( __FUNCTION__ );
436
+
437
+        // Fetch reminder days.
438
+        $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
439
+
440
+        // Abort if non is set.
441
+        if ( empty( $reminder_days ) ) {
442
+            return;
443
+        }
444
+
445
+        // Retrieve date query.
446
+        $date_query = $this->get_date_query( $reminder_days );
447
+
448
+        // Invoices table.
449
+        $table = $wpdb->prefix . 'getpaid_invoices';
450
+
451
+        // Fetch invoices.
452
+        $invoices  = $wpdb->get_col(
453
+            "SELECT posts.ID FROM $wpdb->posts as posts
454 454
 			LEFT JOIN $table as invoices ON invoices.post_id = posts.ID
455 455
 			WHERE posts.post_type = 'wpi_invoice' AND posts.post_status = 'wpi-pending' $date_query");
456 456
 
457
-		foreach ( $invoices as $invoice ) {
457
+        foreach ( $invoices as $invoice ) {
458 458
 
459
-			// Only send this email for invoices created via the admin page.
460
-			if ( ! $this->is_payment_form_invoice( $invoice ) ) {
461
-				$invoice       = new WPInv_Invoice( $invoice );
462
-				$email->object = $invoice;
459
+            // Only send this email for invoices created via the admin page.
460
+            if ( ! $this->is_payment_form_invoice( $invoice ) ) {
461
+                $invoice       = new WPInv_Invoice( $invoice );
462
+                $email->object = $invoice;
463 463
 
464
-				if ( $invoice->needs_payment() ) {
465
-					$this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() );
466
-				}
464
+                if ( $invoice->needs_payment() ) {
465
+                    $this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() );
466
+                }
467 467
 
468
-			}
468
+            }
469 469
 
470
-		}
470
+        }
471 471
 
472
-	}
472
+    }
473 473
 
474
-	/**
475
-	 * Calculates the date query for an invoices query
476
-	 *
477
-	 * @param array $reminder_days
478
-	 * @return string
479
-	 */
480
-	public function get_date_query( $reminder_days ) {
474
+    /**
475
+     * Calculates the date query for an invoices query
476
+     *
477
+     * @param array $reminder_days
478
+     * @return string
479
+     */
480
+    public function get_date_query( $reminder_days ) {
481 481
 
482
-		$date_query = array(
483
-			'relation'  => 'OR'
484
-		);
482
+        $date_query = array(
483
+            'relation'  => 'OR'
484
+        );
485 485
 
486
-		foreach ( $reminder_days as $days ) {
487
-			$date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) );
486
+        foreach ( $reminder_days as $days ) {
487
+            $date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) );
488 488
 
489
-			$date_query[] = array(
490
-				'year'  => $date['year'],
491
-				'month' => $date['month'],
492
-				'day'   => $date['day'],
493
-			);
489
+            $date_query[] = array(
490
+                'year'  => $date['year'],
491
+                'month' => $date['month'],
492
+                'day'   => $date['day'],
493
+            );
494 494
 
495
-		}
495
+        }
496 496
 
497
-		$date_query = new WP_Date_Query( $date_query, 'invoices.due_date' );
497
+        $date_query = new WP_Date_Query( $date_query, 'invoices.due_date' );
498 498
 
499
-		return $date_query->get_sql();
499
+        return $date_query->get_sql();
500 500
 
501
-	}
501
+    }
502 502
 
503 503
 }
Please login to merge, or discard this patch.
Spacing   +125 added lines, -125 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
  * This class handles invoice notificaiton emails.
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 		$this->invoice_actions = apply_filters(
29 29
 			'getpaid_notification_email_invoice_triggers',
30 30
 			array(
31
-				'getpaid_new_invoice'                   => array( 'new_invoice', 'user_invoice' ),
31
+				'getpaid_new_invoice'                   => array('new_invoice', 'user_invoice'),
32 32
 				'getpaid_invoice_status_wpi-cancelled'  => 'cancelled_invoice',
33 33
 				'getpaid_invoice_status_wpi-failed'     => 'failed_invoice',
34 34
 				'getpaid_invoice_status_wpi-onhold'     => 'onhold_invoice',
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	public function init_hooks() {
52 52
 
53
-		add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 );
54
-		add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 );
53
+		add_filter('getpaid_get_email_merge_tags', array($this, 'invoice_merge_tags'), 10, 2);
54
+		add_filter('getpaid_invoice_email_recipients', array($this, 'filter_email_recipients'), 10, 2);
55 55
 
56
-		foreach ( $this->invoice_actions as $hook => $email_type ) {
57
-			$this->init_email_type_hook( $hook, $email_type );
56
+		foreach ($this->invoice_actions as $hook => $email_type) {
57
+			$this->init_email_type_hook($hook, $email_type);
58 58
 		}
59 59
 	}
60 60
 
@@ -64,25 +64,25 @@  discard block
 block discarded – undo
64 64
 	 * @param string $hook
65 65
 	 * @param string|array $email_type
66 66
 	 */
67
-	public function init_email_type_hook( $hook, $email_type ) {
67
+	public function init_email_type_hook($hook, $email_type) {
68 68
 
69
-		$email_type = wpinv_parse_list( $email_type );
69
+		$email_type = wpinv_parse_list($email_type);
70 70
 
71
-		foreach ( $email_type as $type ) {
71
+		foreach ($email_type as $type) {
72 72
 
73
-			$email = new GetPaid_Notification_Email( $type );
73
+			$email = new GetPaid_Notification_Email($type);
74 74
 
75 75
 			// Abort if it is not active.
76
-			if ( ! $email->is_active() ) {
76
+			if (!$email->is_active()) {
77 77
 				continue;
78 78
 			}
79 79
 
80
-			if ( method_exists( $this, $type ) ) {
81
-				add_action( $hook, array( $this, $type ), 100, 2 );
80
+			if (method_exists($this, $type)) {
81
+				add_action($hook, array($this, $type), 100, 2);
82 82
 				continue;
83 83
 			}
84 84
 
85
-			do_action( 'getpaid_invoice_init_email_type_hook', $type, $hook );
85
+			do_action('getpaid_invoice_init_email_type_hook', $type, $hook);
86 86
 		}
87 87
 
88 88
 	}
@@ -93,19 +93,19 @@  discard block
 block discarded – undo
93 93
 	 * @param array $merge_tags
94 94
 	 * @param mixed|WPInv_Invoice|WPInv_Subscription $object
95 95
 	 */
96
-	public function invoice_merge_tags( $merge_tags, $object ) {
96
+	public function invoice_merge_tags($merge_tags, $object) {
97 97
 
98
-		if ( is_a( $object, 'WPInv_Invoice' ) ) {
98
+		if (is_a($object, 'WPInv_Invoice')) {
99 99
 			return array_merge(
100 100
 				$merge_tags,
101
-				$this->get_invoice_merge_tags( $object )
101
+				$this->get_invoice_merge_tags($object)
102 102
 			);
103 103
 		}
104 104
 
105
-		if ( is_a( $object, 'WPInv_Subscription' ) ) {
105
+		if (is_a($object, 'WPInv_Subscription')) {
106 106
 			return array_merge(
107 107
 				$merge_tags,
108
-				$this->get_invoice_merge_tags( $object->get_parent_payment() )
108
+				$this->get_invoice_merge_tags($object->get_parent_payment())
109 109
 			);
110 110
 		}
111 111
 
@@ -119,52 +119,52 @@  discard block
 block discarded – undo
119 119
 	 * @param WPInv_Invoice $invoice
120 120
 	 * @return array
121 121
 	 */
122
-	public function get_invoice_merge_tags( $invoice ) {
122
+	public function get_invoice_merge_tags($invoice) {
123 123
 
124 124
 		// Abort if it does not exist.
125
-		if ( ! $invoice->get_id() ) {
125
+		if (!$invoice->get_id()) {
126 126
 			return array();
127 127
 		}
128 128
 
129 129
 		$merge_tags = array(
130
-			'{name}'                => sanitize_text_field( $invoice->get_user_full_name() ),
131
-			'{full_name}'           => sanitize_text_field( $invoice->get_user_full_name() ),
132
-			'{first_name}'          => sanitize_text_field( $invoice->get_first_name() ),
133
-			'{last_name}'           => sanitize_text_field( $invoice->get_last_name() ),
134
-			'{email}'               => sanitize_email( $invoice->get_email() ),
135
-			'{invoice_number}'      => sanitize_text_field( $invoice->get_number() ),
136
-			'{invoice_currency}'    => sanitize_text_field( $invoice->get_currency() ),
137
-			'{invoice_total}'       => sanitize_text_field( wpinv_price( $invoice->get_total(), $invoice->get_currency() ) ),
138
-			'{invoice_link}'        => esc_url( $invoice->get_view_url() ),
139
-			'{invoice_pay_link}'    => esc_url( $invoice->get_checkout_payment_url() ),
140
-			'{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ),
141
-			'{invoice_date}'        => getpaid_format_date_value( $invoice->get_date_created() ),
142
-			'{invoice_due_date}'    => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ),
143
-			'{invoice_quote}'       => sanitize_text_field( strtolower( $invoice->get_label() ) ),
144
-			'{invoice_label}'       => sanitize_text_field( ucfirst( $invoice->get_label() ) ),
145
-			'{invoice_description}' => wp_kses_post( $invoice->get_description() ),
146
-			'{subscription_name}'   => wp_kses_post( $invoice->get_subscription_name() ),
147
-			'{is_was}'              => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
130
+			'{name}'                => sanitize_text_field($invoice->get_user_full_name()),
131
+			'{full_name}'           => sanitize_text_field($invoice->get_user_full_name()),
132
+			'{first_name}'          => sanitize_text_field($invoice->get_first_name()),
133
+			'{last_name}'           => sanitize_text_field($invoice->get_last_name()),
134
+			'{email}'               => sanitize_email($invoice->get_email()),
135
+			'{invoice_number}'      => sanitize_text_field($invoice->get_number()),
136
+			'{invoice_currency}'    => sanitize_text_field($invoice->get_currency()),
137
+			'{invoice_total}'       => sanitize_text_field(wpinv_price($invoice->get_total(), $invoice->get_currency())),
138
+			'{invoice_link}'        => esc_url($invoice->get_view_url()),
139
+			'{invoice_pay_link}'    => esc_url($invoice->get_checkout_payment_url()),
140
+			'{invoice_receipt_link}'=> esc_url($invoice->get_receipt_url()),
141
+			'{invoice_date}'        => getpaid_format_date_value($invoice->get_date_created()),
142
+			'{invoice_due_date}'    => getpaid_format_date_value($invoice->get_due_date(), __('on receipt', 'invoicing')),
143
+			'{invoice_quote}'       => sanitize_text_field(strtolower($invoice->get_label())),
144
+			'{invoice_label}'       => sanitize_text_field(ucfirst($invoice->get_label())),
145
+			'{invoice_description}' => wp_kses_post($invoice->get_description()),
146
+			'{subscription_name}'   => wp_kses_post($invoice->get_subscription_name()),
147
+			'{is_was}'              => strtotime($invoice->get_due_date()) < current_time('timestamp') ? __('was', 'invoicing') : __('is', 'invoicing'),
148 148
 		);
149 149
 
150
-		$payment_form_data = $invoice->get_meta( 'payment_form_data', true );
150
+		$payment_form_data = $invoice->get_meta('payment_form_data', true);
151 151
 
152
-		if ( is_array( $payment_form_data ) ) {
152
+		if (is_array($payment_form_data)) {
153 153
 
154
-			foreach ( $payment_form_data as $label => $value ) {
154
+			foreach ($payment_form_data as $label => $value) {
155 155
 
156
-				$label = preg_replace( '/[^a-z0-9]+/', '_', strtolower( $label ) );
157
-				$value = is_array( $value ) ? implode( ', ', $value ) : $value;
156
+				$label = preg_replace('/[^a-z0-9]+/', '_', strtolower($label));
157
+				$value = is_array($value) ? implode(', ', $value) : $value;
158 158
 
159
-				if ( is_scalar ( $value ) ) {
160
-					$merge_tags[ "{{$label}}" ] = wp_kses_post( $value );
159
+				if (is_scalar($value)) {
160
+					$merge_tags["{{$label}}"] = wp_kses_post($value);
161 161
 				}
162 162
 
163 163
 			}
164 164
 
165 165
 		}
166 166
 
167
-		return apply_filters( 'getpaid_invoice_email_merge_tags', $merge_tags, $invoice );
167
+		return apply_filters('getpaid_invoice_email_merge_tags', $merge_tags, $invoice);
168 168
 	}
169 169
 
170 170
 	/**
@@ -176,12 +176,12 @@  discard block
 block discarded – undo
176 176
 	 * @param string|array $recipients
177 177
 	 * @param array $extra_args Extra template args.
178 178
 	 */
179
-	public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) {
179
+	public function send_email($invoice, $email, $type, $recipients, $extra_args = array()) {
180 180
 
181
-		do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email );
181
+		do_action('getpaid_before_send_invoice_notification', $type, $invoice, $email);
182 182
 
183
-		$skip = $invoice->is_free() && wpinv_get_option( 'skip_email_free_invoice' );
184
-		if ( apply_filters( 'getpaid_skip_invoice_email', $skip, $type, $invoice ) ) {
183
+		$skip = $invoice->is_free() && wpinv_get_option('skip_email_free_invoice');
184
+		if (apply_filters('getpaid_skip_invoice_email', $skip, $type, $invoice)) {
185 185
 			return;
186 186
 		}
187 187
 
@@ -189,41 +189,41 @@  discard block
 block discarded – undo
189 189
 		$merge_tags = $email->get_merge_tags();
190 190
 
191 191
 		$result = $mailer->send(
192
-			apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ),
193
-			$email->add_merge_tags( $email->get_subject(), $merge_tags ),
194
-			$email->get_content( $merge_tags, $extra_args ),
192
+			apply_filters('getpaid_invoice_email_recipients', wpinv_parse_list($recipients), $email),
193
+			$email->add_merge_tags($email->get_subject(), $merge_tags),
194
+			$email->get_content($merge_tags, $extra_args),
195 195
 			$email->get_attachments()
196 196
 		);
197 197
 
198 198
 		// Maybe send a copy to the admin.
199
-		if ( $email->include_admin_bcc() ) {
199
+		if ($email->include_admin_bcc()) {
200 200
 			$mailer->send(
201 201
 				wpinv_get_admin_email(),
202
-				$email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ),
203
-				$email->get_content( $merge_tags ),
202
+				$email->add_merge_tags($email->get_subject() . __(' - ADMIN BCC COPY', 'invoicing'), $merge_tags),
203
+				$email->get_content($merge_tags),
204 204
 				$email->get_attachments()
205 205
 			);
206 206
 		}
207 207
 
208
-		if ( $result ) {
208
+		if ($result) {
209 209
 			$invoice->add_system_note(
210 210
 				sprintf(
211
-					__( 'Successfully sent %s notification email to %s.', 'invoicing' ),
212
-					sanitize_key( $type ),
213
-					$email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
211
+					__('Successfully sent %s notification email to %s.', 'invoicing'),
212
+					sanitize_key($type),
213
+					$email->is_admin_email() ? __('admin') : __('the customer')
214 214
 				)
215 215
 			);
216 216
 		} else {
217 217
 			$invoice->add_system_note(
218 218
 				sprintf(
219
-					__( 'Failed sending %s notification email to %s.', 'invoicing' ),
220
-					sanitize_key( $type ),
221
-					$email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
219
+					__('Failed sending %s notification email to %s.', 'invoicing'),
220
+					sanitize_key($type),
221
+					$email->is_admin_email() ? __('admin') : __('the customer')
222 222
 				)
223 223
 			);	
224 224
 		}
225 225
 
226
-		do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email );
226
+		do_action('getpaid_after_send_invoice_notification', $type, $invoice, $email);
227 227
 
228 228
 		return $result;
229 229
 	}
@@ -234,20 +234,20 @@  discard block
 block discarded – undo
234 234
 	 * @param array $recipients
235 235
 	 * @param GetPaid_Notification_Email $email
236 236
 	 */
237
-	public function filter_email_recipients( $recipients, $email ) {
237
+	public function filter_email_recipients($recipients, $email) {
238 238
 
239
-		if ( ! $email->is_admin_email() ) {
239
+		if (!$email->is_admin_email()) {
240 240
 			$cc   = $email->object->get_email_cc();
241
-			$cc_2 = get_user_meta( $email->object->get_user_id(), '_wpinv_email_cc', true );
241
+			$cc_2 = get_user_meta($email->object->get_user_id(), '_wpinv_email_cc', true);
242 242
 
243
-			if ( ! empty( $cc ) ) {
244
-				$cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
245
-				$recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
243
+			if (!empty($cc)) {
244
+				$cc = array_map('sanitize_email', wpinv_parse_list($cc));
245
+				$recipients = array_filter(array_unique(array_merge($recipients, $cc)));
246 246
 			}
247 247
 
248
-			if ( ! empty( $cc_2 ) ) {
249
-				$cc_2 = array_map( 'sanitize_email', wpinv_parse_list( $cc_2 ) );
250
-				$recipients = array_filter( array_unique( array_merge( $recipients, $cc_2 ) ) );
248
+			if (!empty($cc_2)) {
249
+				$cc_2 = array_map('sanitize_email', wpinv_parse_list($cc_2));
250
+				$recipients = array_filter(array_unique(array_merge($recipients, $cc_2)));
251 251
 			}
252 252
 
253 253
 		}
@@ -261,17 +261,17 @@  discard block
 block discarded – undo
261 261
 	 *
262 262
 	 * @param WPInv_Invoice $invoice
263 263
 	 */
264
-	public function new_invoice( $invoice ) {
264
+	public function new_invoice($invoice) {
265 265
 
266 266
 		// Only send this email for invoices created via the admin page.
267
-		if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_paid() || $this->is_payment_form_invoice( $invoice->get_id() ) ) {
267
+		if (!$invoice->is_type('invoice') || $invoice->is_paid() || $this->is_payment_form_invoice($invoice->get_id())) {
268 268
 			return;
269 269
 		}
270 270
 
271
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
271
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
272 272
 		$recipient = wpinv_get_admin_email();
273 273
 
274
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
274
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
275 275
 
276 276
 	}
277 277
 
@@ -280,12 +280,12 @@  discard block
 block discarded – undo
280 280
 	 *
281 281
 	 * @param WPInv_Invoice $invoice
282 282
 	 */
283
-	public function cancelled_invoice( $invoice ) {
283
+	public function cancelled_invoice($invoice) {
284 284
 
285
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
285
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
286 286
 		$recipient = wpinv_get_admin_email();
287 287
 
288
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
288
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
289 289
 
290 290
 	}
291 291
 
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
 	 *
295 295
 	 * @param WPInv_Invoice $invoice
296 296
 	 */
297
-	public function failed_invoice( $invoice ) {
297
+	public function failed_invoice($invoice) {
298 298
 
299
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
299
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
300 300
 		$recipient = wpinv_get_admin_email();
301 301
 
302
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
302
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
303 303
 
304 304
 	}
305 305
 
@@ -308,12 +308,12 @@  discard block
 block discarded – undo
308 308
 	 *
309 309
 	 * @param WPInv_Invoice $invoice
310 310
 	 */
311
-	public function onhold_invoice( $invoice ) {
311
+	public function onhold_invoice($invoice) {
312 312
 
313
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
313
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
314 314
 		$recipient = $invoice->get_email();
315 315
 
316
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
316
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
317 317
 
318 318
 	}
319 319
 
@@ -322,12 +322,12 @@  discard block
 block discarded – undo
322 322
 	 *
323 323
 	 * @param WPInv_Invoice $invoice
324 324
 	 */
325
-	public function processing_invoice( $invoice ) {
325
+	public function processing_invoice($invoice) {
326 326
 
327
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
327
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
328 328
 		$recipient = $invoice->get_email();
329 329
 
330
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
330
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
331 331
 
332 332
 	}
333 333
 
@@ -336,17 +336,17 @@  discard block
 block discarded – undo
336 336
 	 *
337 337
 	 * @param WPInv_Invoice $invoice
338 338
 	 */
339
-	public function completed_invoice( $invoice ) {
339
+	public function completed_invoice($invoice) {
340 340
 
341 341
 		// (Maybe) abort if it is a renewal invoice.
342
-		if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) {
342
+		if ($invoice->is_renewal() && !wpinv_get_option('email_completed_invoice_renewal_active', false)) {
343 343
 			return;
344 344
 		}
345 345
 
346
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
346
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
347 347
 		$recipient = $invoice->get_email();
348 348
 
349
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
349
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
350 350
 
351 351
 	}
352 352
 
@@ -355,12 +355,12 @@  discard block
 block discarded – undo
355 355
 	 *
356 356
 	 * @param WPInv_Invoice $invoice
357 357
 	 */
358
-	public function refunded_invoice( $invoice ) {
358
+	public function refunded_invoice($invoice) {
359 359
 
360
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
360
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
361 361
 		$recipient = $invoice->get_email();
362 362
 
363
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
363
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
364 364
 
365 365
 	}
366 366
 
@@ -370,21 +370,21 @@  discard block
 block discarded – undo
370 370
 	 * @param WPInv_Invoice $invoice
371 371
 	 * @param bool $force
372 372
 	 */
373
-	public function user_invoice( $invoice, $force = false ) {
373
+	public function user_invoice($invoice, $force = false) {
374 374
 
375
-		if ( ! empty( $GLOBALS['wpinv_skip_invoice_notification'] ) ) {
375
+		if (!empty($GLOBALS['wpinv_skip_invoice_notification'])) {
376 376
 			return;
377 377
 		}
378 378
 
379 379
 		// Only send this email for invoices created via the admin page.
380
-		if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_paid() || ( empty( $force ) && $this->is_payment_form_invoice( $invoice->get_id() ) ) ) {
380
+		if (!$invoice->is_type('invoice') || $invoice->is_paid() || (empty($force) && $this->is_payment_form_invoice($invoice->get_id()))) {
381 381
 			return;
382 382
 		}
383 383
 
384
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
384
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
385 385
 		$recipient = $invoice->get_email();
386 386
 
387
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
387
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
388 388
 
389 389
 	}
390 390
 
@@ -394,9 +394,9 @@  discard block
 block discarded – undo
394 394
 	 * @param int $invoice
395 395
 	 * @return bool
396 396
 	 */
397
-	public function is_payment_form_invoice( $invoice ) {
398
-		$is_payment_form_invoice = empty( $_GET['getpaid-admin-action'] ) && ( 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true ) || 'geodirectory' == get_post_meta( $invoice, 'wpinv_created_via', true ) );
399
-		return apply_filters( 'getpaid_invoice_notifications_is_payment_form_invoice', $is_payment_form_invoice, $invoice );
397
+	public function is_payment_form_invoice($invoice) {
398
+		$is_payment_form_invoice = empty($_GET['getpaid-admin-action']) && ('payment_form' == get_post_meta($invoice, 'wpinv_created_via', true) || 'geodirectory' == get_post_meta($invoice, 'wpinv_created_via', true));
399
+		return apply_filters('getpaid_invoice_notifications_is_payment_form_invoice', $is_payment_form_invoice, $invoice);
400 400
 	}
401 401
 
402 402
 	/**
@@ -405,12 +405,12 @@  discard block
 block discarded – undo
405 405
 	 * @param WPInv_Invoice $invoice
406 406
 	 * @param string $note
407 407
 	 */
408
-	public function user_note( $invoice, $note ) {
408
+	public function user_note($invoice, $note) {
409 409
 
410
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
410
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
411 411
 		$recipient = $invoice->get_email();
412 412
 
413
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) );
413
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient, array('customer_note' => $note));
414 414
 
415 415
 	}
416 416
 
@@ -419,9 +419,9 @@  discard block
 block discarded – undo
419 419
 	 *
420 420
 	 * @param WPInv_Invoice $invoice
421 421
 	 */
422
-	public function force_send_overdue_notice( $invoice ) {
423
-		$email = new GetPaid_Notification_Email( 'overdue', $invoice );
424
-		return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() );
422
+	public function force_send_overdue_notice($invoice) {
423
+		$email = new GetPaid_Notification_Email('overdue', $invoice);
424
+		return $this->send_email($invoice, $email, 'overdue', $invoice->get_email());
425 425
 	}
426 426
 
427 427
 	/**
@@ -432,37 +432,37 @@  discard block
 block discarded – undo
432 432
 	public function overdue() {
433 433
 		global $wpdb;
434 434
 
435
-		$email = new GetPaid_Notification_Email( __FUNCTION__ );
435
+		$email = new GetPaid_Notification_Email(__FUNCTION__);
436 436
 
437 437
 		// Fetch reminder days.
438
-		$reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
438
+		$reminder_days = array_unique(wp_parse_id_list($email->get_option('days')));
439 439
 
440 440
 		// Abort if non is set.
441
-		if ( empty( $reminder_days ) ) {
441
+		if (empty($reminder_days)) {
442 442
 			return;
443 443
 		}
444 444
 
445 445
 		// Retrieve date query.
446
-		$date_query = $this->get_date_query( $reminder_days );
446
+		$date_query = $this->get_date_query($reminder_days);
447 447
 
448 448
 		// Invoices table.
449 449
 		$table = $wpdb->prefix . 'getpaid_invoices';
450 450
 
451 451
 		// Fetch invoices.
452
-		$invoices  = $wpdb->get_col(
452
+		$invoices = $wpdb->get_col(
453 453
 			"SELECT posts.ID FROM $wpdb->posts as posts
454 454
 			LEFT JOIN $table as invoices ON invoices.post_id = posts.ID
455 455
 			WHERE posts.post_type = 'wpi_invoice' AND posts.post_status = 'wpi-pending' $date_query");
456 456
 
457
-		foreach ( $invoices as $invoice ) {
457
+		foreach ($invoices as $invoice) {
458 458
 
459 459
 			// Only send this email for invoices created via the admin page.
460
-			if ( ! $this->is_payment_form_invoice( $invoice ) ) {
461
-				$invoice       = new WPInv_Invoice( $invoice );
460
+			if (!$this->is_payment_form_invoice($invoice)) {
461
+				$invoice       = new WPInv_Invoice($invoice);
462 462
 				$email->object = $invoice;
463 463
 
464
-				if ( $invoice->needs_payment() ) {
465
-					$this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() );
464
+				if ($invoice->needs_payment()) {
465
+					$this->send_email($invoice, $email, __FUNCTION__, $invoice->get_email());
466 466
 				}
467 467
 
468 468
 			}
@@ -477,14 +477,14 @@  discard block
 block discarded – undo
477 477
 	 * @param array $reminder_days
478 478
 	 * @return string
479 479
 	 */
480
-	public function get_date_query( $reminder_days ) {
480
+	public function get_date_query($reminder_days) {
481 481
 
482 482
 		$date_query = array(
483 483
 			'relation'  => 'OR'
484 484
 		);
485 485
 
486
-		foreach ( $reminder_days as $days ) {
487
-			$date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) );
486
+		foreach ($reminder_days as $days) {
487
+			$date = date_parse(date('Y-m-d', strtotime("-$days days", current_time('timestamp'))));
488 488
 
489 489
 			$date_query[] = array(
490 490
 				'year'  => $date['year'],
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 
495 495
 		}
496 496
 
497
-		$date_query = new WP_Date_Query( $date_query, 'invoices.due_date' );
497
+		$date_query = new WP_Date_Query($date_query, 'invoices.due_date');
498 498
 
499 499
 		return $date_query->get_sql();
500 500
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-item-details.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Item_Details {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the item.
@@ -270,35 +270,35 @@  discard block
 block discarded – undo
270 270
     }
271 271
 
272 272
     /**
273
-	 * Save meta box data.
274
-	 *
275
-	 * @param int $post_id
276
-	 */
277
-	public static function save( $post_id ) {
273
+     * Save meta box data.
274
+     *
275
+     * @param int $post_id
276
+     */
277
+    public static function save( $post_id ) {
278 278
 
279 279
         // Prepare the item.
280 280
         $item = new WPInv_Item( $post_id );
281 281
 
282 282
         // Load new data.
283 283
         $item->set_props(
284
-			array(
285
-				'price'                => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null,
286
-				'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
287
-				'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
288
-				'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
289
-				'is_dynamic_pricing'   => ! empty( $_POST['wpinv_name_your_price'] ),
284
+            array(
285
+                'price'                => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null,
286
+                'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
287
+                'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
288
+                'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
289
+                'is_dynamic_pricing'   => ! empty( $_POST['wpinv_name_your_price'] ),
290 290
                 'minimum_price'        => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null,
291
-				'is_recurring'         => ! empty( $_POST['wpinv_is_recurring'] ),
292
-				'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
293
-				'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1,
294
-				'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
295
-				'is_free_trial'        => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
296
-				'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
297
-				'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
298
-			)
291
+                'is_recurring'         => ! empty( $_POST['wpinv_is_recurring'] ),
292
+                'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
293
+                'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1,
294
+                'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
295
+                'is_free_trial'        => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
296
+                'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
297
+                'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
298
+            )
299 299
         );
300 300
 
301
-		$item->save();
302
-		do_action( 'getpaid_item_metabox_save', $post_id, $item );
303
-	}
301
+        $item->save();
302
+        do_action( 'getpaid_item_metabox_save', $post_id, $item );
303
+    }
304 304
 }
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,27 +21,27 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the item.
27
-        $item = new WPInv_Item( $post );
27
+        $item = new WPInv_Item($post);
28 28
 
29 29
         // Nonce field.
30
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
30
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
31 31
 
32 32
         // Set the currency position.
33 33
         $position = wpinv_currency_position();
34 34
 
35
-        if ( $position == 'left_space' ) {
35
+        if ($position == 'left_space') {
36 36
             $position = 'left';
37 37
         }
38 38
 
39
-        if ( $position == 'right_space' ) {
39
+        if ($position == 'right_space') {
40 40
             $position = 'right';
41 41
         }
42 42
 
43 43
         ?>
44
-        <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr( $item->get_type( 'edit' ) ); ?>" />
44
+        <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr($item->get_type('edit')); ?>" />
45 45
         <style>
46 46
             #poststuff .input-group-text,
47 47
             #poststuff .form-control {
@@ -55,21 +55,21 @@  discard block
 block discarded – undo
55 55
         </style>
56 56
         <div class='bsui' style='max-width: 600px;padding-top: 10px;'>
57 57
 
58
-            <?php do_action( 'wpinv_item_details_metabox_before_price', $item ); ?>
58
+            <?php do_action('wpinv_item_details_metabox_before_price', $item); ?>
59 59
             <div class="form-group row">
60
-                <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e( 'Item Price', 'invoicing' )?></span></label>
60
+                <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e('Item Price', 'invoicing')?></span></label>
61 61
                 <div class="col-sm-8">
62 62
                     <div class="row">
63 63
                         <div class="col-sm-4 getpaid-price-input">
64 64
                             <div class="input-group input-group-sm">
65
-                                <?php if( 'left' == $position ) : ?>
65
+                                <?php if ('left' == $position) : ?>
66 66
                                 <div class="input-group-prepend">
67 67
                                     <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
68 68
                                 </div>
69 69
                                 <?php endif; ?>
70
-                                <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control">
70
+                                <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control">
71 71
 
72
-                                <?php if( 'left' != $position ) : ?>
72
+                                <?php if ('left' != $position) : ?>
73 73
                                 <div class="input-group-append">
74 74
                                     <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
75 75
                                 </div>
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
                         </div>
80 80
                         <div class="col-sm-4 wpinv_show_if_recurring">
81 81
                             <?php
82
-                                _e( 'every' );
82
+                                _e('every');
83 83
                                 echo "&nbsp;";
84 84
                             ?>
85
-                            <input type="number" style="max-width: 60px;" value="<?php echo esc_attr( $item->get_recurring_interval( 'edit' ) ); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" />
85
+                            <input type="number" style="max-width: 60px;" value="<?php echo esc_attr($item->get_recurring_interval('edit')); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" />
86 86
                         </div>
87 87
                         <div class="col-sm-4 wpinv_show_if_recurring">
88 88
                             <?php
@@ -90,16 +90,16 @@  discard block
 block discarded – undo
90 90
                                     array(
91 91
                                         'id'               => 'wpinv_recurring_period',
92 92
                                         'name'             => 'wpinv_recurring_period',
93
-                                        'label'            => __( 'Period', 'invoicing' ),
94
-                                        'placeholder'      => __( 'Select Period', 'invoicing' ),
95
-                                        'value'            => $item->get_recurring_period( 'edit' ),
93
+                                        'label'            => __('Period', 'invoicing'),
94
+                                        'placeholder'      => __('Select Period', 'invoicing'),
95
+                                        'value'            => $item->get_recurring_period('edit'),
96 96
                                         'select2'          => true,
97 97
                                         'data-allow-clear' => 'false',
98 98
                                         'options'     => array(
99
-                                            'D'  => __( 'day(s)', 'invoicing' ),
100
-                                            'W'  => __( 'week(s)', 'invoicing' ),
101
-                                            'M'  => __( 'month(s)', 'invoicing' ),
102
-                                            'Y'  => __( 'year(s)', 'invoicing' ),
99
+                                            'D'  => __('day(s)', 'invoicing'),
100
+                                            'W'  => __('week(s)', 'invoicing'),
101
+                                            'M'  => __('month(s)', 'invoicing'),
102
+                                            'Y'  => __('year(s)', 'invoicing'),
103 103
                                         )
104 104
                                     )
105 105
                                 );
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
                             <?php
112 112
 
113 113
                                 // Dynamic pricing.
114
-                                if( $item->supports_dynamic_pricing() ) {
114
+                                if ($item->supports_dynamic_pricing()) {
115 115
 
116
-                                    do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item );
116
+                                    do_action('wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item);
117 117
 
118 118
                                     // NYP toggle.
119 119
                                     echo aui()->input(
@@ -121,31 +121,31 @@  discard block
 block discarded – undo
121 121
                                             'id'          => 'wpinv_name_your_price',
122 122
                                             'name'        => 'wpinv_name_your_price',
123 123
                                             'type'        => 'checkbox',
124
-                                            'label'       => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ),
124
+                                            'label'       => apply_filters('wpinv_name_your_price_toggle_text', __('Let customers name their price', 'invoicing')),
125 125
                                             'value'       => '1',
126 126
                                             'checked'     => $item->user_can_set_their_price(),
127 127
                                             'no_wrap'     => true,
128 128
                                         )
129 129
                                     );
130 130
 
131
-                                    do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item );
131
+                                    do_action('wpinv_item_details_metabox_dynamic_pricing_checkbox', $item);
132 132
 
133 133
                                 }
134 134
 
135 135
                                 // Subscriptions.
136
-                                do_action( 'wpinv_item_details_metabox_before_subscription_checkbox', $item );
136
+                                do_action('wpinv_item_details_metabox_before_subscription_checkbox', $item);
137 137
                                 echo aui()->input(
138 138
                                     array(
139 139
                                         'id'          => 'wpinv_is_recurring',
140 140
                                         'name'        => 'wpinv_is_recurring',
141 141
                                         'type'        => 'checkbox',
142
-                                        'label'       => apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Charge customers a recurring amount for this item', 'invoicing' ) ),
142
+                                        'label'       => apply_filters('wpinv_is_recurring_toggle_text', __('Charge customers a recurring amount for this item', 'invoicing')),
143 143
                                         'value'       => '1',
144 144
                                         'checked'     => $item->is_recurring(),
145 145
                                         'no_wrap'     => true,
146 146
                                     )
147 147
                                 );
148
-                                do_action( 'wpinv_item_details_metabox_subscription_checkbox', $item );
148
+                                do_action('wpinv_item_details_metabox_subscription_checkbox', $item);
149 149
 
150 150
                             ?>
151 151
                             <div class="wpinv_show_if_recurring">
@@ -155,30 +155,30 @@  discard block
 block discarded – undo
155 155
                     </div>
156 156
                 </div>
157 157
                 <div class="col-sm-1 pt-2 pl-0">
158
-                    <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e( 'Set the subscription price, billing interval and period.', 'invoicing' ); ?>"></span>
158
+                    <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e('Set the subscription price, billing interval and period.', 'invoicing'); ?>"></span>
159 159
                 </div>
160 160
             </div>
161
-            <?php do_action( 'wpinv_item_details_metabox_after_price', $item ); ?>
161
+            <?php do_action('wpinv_item_details_metabox_after_price', $item); ?>
162 162
 
163
-            <?php if( $item->supports_dynamic_pricing() ) : ?>
164
-                <?php do_action( 'wpinv_item_details_metabox_before_minimum_price', $item ); ?>
163
+            <?php if ($item->supports_dynamic_pricing()) : ?>
164
+                <?php do_action('wpinv_item_details_metabox_before_minimum_price', $item); ?>
165 165
                 <div class="wpinv_show_if_dynamic wpinv_minimum_price">
166 166
 
167 167
                     <div class="form-group row">
168 168
                         <label for="wpinv_minimum_price" class="col-sm-3 col-form-label">
169
-                            <?php _e( 'Minimum Price', 'invoicing' );?>
169
+                            <?php _e('Minimum Price', 'invoicing'); ?>
170 170
                         </label>
171 171
                         <div class="col-sm-8">
172 172
                             <div class="input-group input-group-sm">
173
-                                <?php if( 'left' == $position ) : ?>
173
+                                <?php if ('left' == $position) : ?>
174 174
                                     <div class="input-group-prepend">
175 175
                                         <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
176 176
                                     </div>
177 177
                                 <?php endif; ?>
178 178
 
179
-                                <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_minimum_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control">
179
+                                <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_minimum_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control">
180 180
 
181
-                                <?php if( 'left' != $position ) : ?>
181
+                                <?php if ('left' != $position) : ?>
182 182
                                     <div class="input-group-append">
183 183
                                         <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
184 184
                                     </div>
@@ -187,45 +187,45 @@  discard block
 block discarded – undo
187 187
                         </div>
188 188
 
189 189
                         <div class="col-sm-1 pt-2 pl-0">
190
-                            <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the minimum amount that users are allowed to set', 'invoicing' ); ?>"></span>
190
+                            <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the minimum amount that users are allowed to set', 'invoicing'); ?>"></span>
191 191
                         </div>
192 192
                     </div>
193 193
 
194 194
                 </div>
195
-                <?php do_action( 'wpinv_item_details_metabox_minimum_price', $item ); ?>
195
+                <?php do_action('wpinv_item_details_metabox_minimum_price', $item); ?>
196 196
             <?php endif; ?>
197 197
 
198
-            <?php do_action( 'wpinv_item_details_metabox_before_maximum_renewals', $item ); ?>
198
+            <?php do_action('wpinv_item_details_metabox_before_maximum_renewals', $item); ?>
199 199
             <div class="wpinv_show_if_recurring wpinv_maximum_renewals">
200 200
 
201 201
                 <div class="form-group row">
202 202
                     <label for="wpinv_recurring_limit" class="col-sm-3 col-form-label">
203
-                        <?php _e( 'Maximum Renewals', 'invoicing' );?>
203
+                        <?php _e('Maximum Renewals', 'invoicing'); ?>
204 204
                     </label>
205 205
                     <div class="col-sm-8">
206
-                        <input type="number" value="<?php echo esc_attr( $item->get_recurring_limit( 'edit' ) ); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" />
206
+                        <input type="number" value="<?php echo esc_attr($item->get_recurring_limit('edit')); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" />
207 207
                     </div>
208 208
                     <div class="col-sm-1 pt-2 pl-0">
209
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing' ); ?>"></span>
209
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing'); ?>"></span>
210 210
                     </div>
211 211
                 </div>
212 212
 
213 213
             </div>
214
-            <?php do_action( 'wpinv_item_details_metabox_maximum_renewals', $item ); ?>
214
+            <?php do_action('wpinv_item_details_metabox_maximum_renewals', $item); ?>
215 215
 
216
-            <?php do_action( 'wpinv_item_details_metabox_before_free_trial', $item ); ?>
216
+            <?php do_action('wpinv_item_details_metabox_before_free_trial', $item); ?>
217 217
             <div class="wpinv_show_if_recurring wpinv_free_trial">
218 218
 
219 219
                 <div class="form-group row">
220
-                    <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined( 'GETPAID_PAID_TRIALS_VERSION' ) ? _e( 'Free/Paid Trial', 'invoicing' ) : _e( 'Free Trial', 'invoicing' )?></label>
220
+                    <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined('GETPAID_PAID_TRIALS_VERSION') ? _e('Free/Paid Trial', 'invoicing') : _e('Free Trial', 'invoicing')?></label>
221 221
 
222 222
                     <div class="col-sm-8">
223 223
                         <div class="row">
224 224
                             <div class="col-sm-6">
225
-                                <?php $value = $item->has_free_trial() ? $item->get_trial_interval( 'edit' ) : 0;?>
225
+                                <?php $value = $item->has_free_trial() ? $item->get_trial_interval('edit') : 0; ?>
226 226
 
227 227
                                 <div>
228
-                                    <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr( $value ); ?>" >
228
+                                    <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr($value); ?>" >
229 229
                                 </div>
230 230
                             </div>
231 231
                             <div class="col-sm-6">
@@ -234,17 +234,17 @@  discard block
 block discarded – undo
234 234
                                         array(
235 235
                                             'id'               => 'wpinv_trial_period',
236 236
                                             'name'             => 'wpinv_trial_period',
237
-                                            'label'            => __( 'Trial Period', 'invoicing' ),
238
-                                            'placeholder'      => __( 'Trial Period', 'invoicing' ),
239
-                                            'value'            => $item->get_trial_period( 'edit' ),
237
+                                            'label'            => __('Trial Period', 'invoicing'),
238
+                                            'placeholder'      => __('Trial Period', 'invoicing'),
239
+                                            'value'            => $item->get_trial_period('edit'),
240 240
                                             'select2'          => true,
241 241
                                             'data-allow-clear' => 'false',
242 242
                                             'no_wrap'          => true,
243 243
                                             'options'          => array(
244
-                                                'D'  => __( 'day(s)', 'invoicing' ),
245
-                                                'W'  => __( 'week(s)', 'invoicing' ),
246
-                                                'M'  => __( 'month(s)', 'invoicing' ),
247
-                                                'Y'  => __( 'year(s)', 'invoicing' ),
244
+                                                'D'  => __('day(s)', 'invoicing'),
245
+                                                'W'  => __('week(s)', 'invoicing'),
246
+                                                'M'  => __('month(s)', 'invoicing'),
247
+                                                'Y'  => __('year(s)', 'invoicing'),
248 248
                                             )
249 249
                                         )
250 250
                                     );
@@ -255,15 +255,15 @@  discard block
 block discarded – undo
255 255
                     </div>
256 256
 
257 257
                     <div class="col-sm-1 pt-2 pl-0">
258
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'An optional period of time to wait before charging the first recurring payment.', 'invoicing' ); ?>"></span>
258
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('An optional period of time to wait before charging the first recurring payment.', 'invoicing'); ?>"></span>
259 259
                     </div>
260 260
 
261 261
                 </div>
262 262
 
263 263
             </div>
264
-            <?php do_action( 'wpinv_item_details_metabox__free_trial', $item ); ?>
264
+            <?php do_action('wpinv_item_details_metabox__free_trial', $item); ?>
265 265
 
266
-            <?php do_action( 'wpinv_item_details_metabox_item_details', $item ); ?>
266
+            <?php do_action('wpinv_item_details_metabox_item_details', $item); ?>
267 267
         </div>
268 268
         <?php
269 269
 
@@ -274,31 +274,31 @@  discard block
 block discarded – undo
274 274
 	 *
275 275
 	 * @param int $post_id
276 276
 	 */
277
-	public static function save( $post_id ) {
277
+	public static function save($post_id) {
278 278
 
279 279
         // Prepare the item.
280
-        $item = new WPInv_Item( $post_id );
280
+        $item = new WPInv_Item($post_id);
281 281
 
282 282
         // Load new data.
283 283
         $item->set_props(
284 284
 			array(
285
-				'price'                => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null,
286
-				'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
287
-				'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
288
-				'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
289
-				'is_dynamic_pricing'   => ! empty( $_POST['wpinv_name_your_price'] ),
290
-                'minimum_price'        => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null,
291
-				'is_recurring'         => ! empty( $_POST['wpinv_is_recurring'] ),
292
-				'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
293
-				'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1,
294
-				'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
295
-				'is_free_trial'        => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
296
-				'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
297
-				'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
285
+				'price'                => isset($_POST['wpinv_item_price']) ? getpaid_standardize_amount($_POST['wpinv_item_price']) : null,
286
+				'vat_rule'             => isset($_POST['wpinv_vat_rules']) ? wpinv_clean($_POST['wpinv_vat_rules']) : null,
287
+				'vat_class'            => isset($_POST['wpinv_vat_class']) ? wpinv_clean($_POST['wpinv_vat_class']) : null,
288
+				'type'                 => isset($_POST['wpinv_item_type']) ? wpinv_clean($_POST['wpinv_item_type']) : null,
289
+				'is_dynamic_pricing'   => !empty($_POST['wpinv_name_your_price']),
290
+                'minimum_price'        => isset($_POST['wpinv_minimum_price']) ? getpaid_standardize_amount($_POST['wpinv_minimum_price']) : null,
291
+				'is_recurring'         => !empty($_POST['wpinv_is_recurring']),
292
+				'recurring_period'     => isset($_POST['wpinv_recurring_period']) ? wpinv_clean($_POST['wpinv_recurring_period']) : null,
293
+				'recurring_interval'   => isset($_POST['wpinv_recurring_interval']) ? (int) $_POST['wpinv_recurring_interval'] : 1,
294
+				'recurring_limit'      => isset($_POST['wpinv_recurring_limit']) ? (int) $_POST['wpinv_recurring_limit'] : null,
295
+				'is_free_trial'        => isset($_POST['wpinv_trial_interval']) ? (0 != (int) $_POST['wpinv_trial_interval']) : null,
296
+				'trial_period'         => isset($_POST['wpinv_trial_period']) ? wpinv_clean($_POST['wpinv_trial_period']) : null,
297
+				'trial_interval'       => isset($_POST['wpinv_trial_interval']) ? (int) $_POST['wpinv_trial_interval'] : null,
298 298
 			)
299 299
         );
300 300
 
301 301
 		$item->save();
302
-		do_action( 'getpaid_item_metabox_save', $post_id, $item );
302
+		do_action('getpaid_item_metabox_save', $post_id, $item);
303 303
 	}
304 304
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-discount-details.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Discount_Details {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the discount.
@@ -396,35 +396,35 @@  discard block
 block discarded – undo
396 396
     }
397 397
 
398 398
     /**
399
-	 * Save meta box data.
400
-	 *
401
-	 * @param int $post_id
402
-	 */
403
-	public static function save( $post_id ) {
399
+     * Save meta box data.
400
+     *
401
+     * @param int $post_id
402
+     */
403
+    public static function save( $post_id ) {
404 404
 
405 405
         // Prepare the discount.
406 406
         $discount = new WPInv_Discount( $post_id );
407 407
 
408 408
         // Load new data.
409 409
         $discount->set_props(
410
-			array(
411
-				'code'                 => isset( $_POST['wpinv_discount_code'] ) ? wpinv_clean( $_POST['wpinv_discount_code'] ) : null,
412
-				'amount'               => isset( $_POST['wpinv_discount_amount'] ) ? floatval( $_POST['wpinv_discount_amount'] ) : null,
413
-				'start'                => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null,
414
-				'expiration'           => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null,
415
-				'is_single_use'        => ! empty( $_POST['wpinv_discount_single_use'] ),
410
+            array(
411
+                'code'                 => isset( $_POST['wpinv_discount_code'] ) ? wpinv_clean( $_POST['wpinv_discount_code'] ) : null,
412
+                'amount'               => isset( $_POST['wpinv_discount_amount'] ) ? floatval( $_POST['wpinv_discount_amount'] ) : null,
413
+                'start'                => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null,
414
+                'expiration'           => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null,
415
+                'is_single_use'        => ! empty( $_POST['wpinv_discount_single_use'] ),
416 416
                 'type'                 => isset( $_POST['wpinv_discount_type'] ) ? wpinv_clean( $_POST['wpinv_discount_type'] ) : null,
417
-				'is_recurring'         => ! empty( $_POST['wpinv_discount_recurring'] ),
418
-				'items'                => isset( $_POST['wpinv_discount_items'] ) ? wpinv_clean( $_POST['wpinv_discount_items'] ) : array(),
419
-				'excluded_items'       => isset( $_POST['wpinv_discount_excluded_items'] ) ? wpinv_clean( $_POST['wpinv_discount_excluded_items'] ) : array(),
417
+                'is_recurring'         => ! empty( $_POST['wpinv_discount_recurring'] ),
418
+                'items'                => isset( $_POST['wpinv_discount_items'] ) ? wpinv_clean( $_POST['wpinv_discount_items'] ) : array(),
419
+                'excluded_items'       => isset( $_POST['wpinv_discount_excluded_items'] ) ? wpinv_clean( $_POST['wpinv_discount_excluded_items'] ) : array(),
420 420
                 'required_items'       => isset( $_POST['wpinv_discount_required_items'] ) ? wpinv_clean( $_POST['wpinv_discount_required_items'] ) : array(),
421
-				'max_uses'             => isset( $_POST['wpinv_discount_max_uses'] ) ? intval( $_POST['wpinv_discount_max_uses'] ) : null,
422
-				'min_total'            => isset( $_POST['wpinv_discount_min_total'] ) ? floatval( $_POST['wpinv_discount_min_total'] ) : null,
423
-				'max_total'            => isset( $_POST['wpinv_discount_max_total'] ) ? floatval( $_POST['wpinv_discount_max_total'] ) : null,
424
-			)
421
+                'max_uses'             => isset( $_POST['wpinv_discount_max_uses'] ) ? intval( $_POST['wpinv_discount_max_uses'] ) : null,
422
+                'min_total'            => isset( $_POST['wpinv_discount_min_total'] ) ? floatval( $_POST['wpinv_discount_min_total'] ) : null,
423
+                'max_total'            => isset( $_POST['wpinv_discount_max_total'] ) ? floatval( $_POST['wpinv_discount_max_total'] ) : null,
424
+            )
425 425
         );
426 426
 
427
-		$discount->save();
428
-		do_action( 'getpaid_discount_metabox_save', $post_id, $discount );
429
-	}
427
+        $discount->save();
428
+        do_action( 'getpaid_discount_metabox_save', $post_id, $discount );
429
+    }
430 430
 }
Please login to merge, or discard this patch.
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,24 +21,24 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the discount.
27
-        $discount = new WPInv_Discount( $post );
27
+        $discount = new WPInv_Discount($post);
28 28
 
29 29
         // Nonce field.
30
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
30
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
31 31
 
32
-        do_action( 'wpinv_discount_form_top', $discount );
32
+        do_action('wpinv_discount_form_top', $discount);
33 33
 
34 34
         // Set the currency position.
35 35
         $position = wpinv_currency_position();
36 36
 
37
-        if ( $position == 'left_space' ) {
37
+        if ($position == 'left_space') {
38 38
             $position = 'left';
39 39
         }
40 40
 
41
-        if ( $position == 'right_space' ) {
41
+        if ($position == 'right_space') {
42 42
             $position = 'right';
43 43
         }
44 44
 
@@ -52,66 +52,66 @@  discard block
 block discarded – undo
52 52
         </style>
53 53
         <div class='bsui' style='max-width: 600px;padding-top: 10px;'>
54 54
 
55
-            <?php do_action( 'wpinv_discount_form_first', $discount ); ?>
55
+            <?php do_action('wpinv_discount_form_first', $discount); ?>
56 56
 
57
-            <?php do_action( 'wpinv_discount_form_before_code', $discount ); ?>
57
+            <?php do_action('wpinv_discount_form_before_code', $discount); ?>
58 58
             <div class="form-group row">
59 59
                 <label for="wpinv_discount_code" class="col-sm-3 col-form-label">
60
-                    <?php _e( 'Discount Code', 'invoicing' );?>
60
+                    <?php _e('Discount Code', 'invoicing'); ?>
61 61
                 </label>
62 62
                 <div class="col-sm-8">
63 63
                     <div class="row">
64 64
                         <div class="col-sm-12 form-group">
65
-                            <input type="text" value="<?php echo esc_attr( $discount->get_code( 'edit' ) ); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" />
65
+                            <input type="text" value="<?php echo esc_attr($discount->get_code('edit')); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" />
66 66
                         </div>
67 67
                         <div class="col-sm-12">
68 68
                             <?php
69
-                                do_action( 'wpinv_discount_form_before_single_use', $discount );
69
+                                do_action('wpinv_discount_form_before_single_use', $discount);
70 70
 
71 71
                                 echo aui()->input(
72 72
                                     array(
73 73
                                         'id'          => 'wpinv_discount_single_use',
74 74
                                         'name'        => 'wpinv_discount_single_use',
75 75
                                         'type'        => 'checkbox',
76
-                                        'label'       => __( 'Each customer can only use this discount once', 'invoicing' ),
76
+                                        'label'       => __('Each customer can only use this discount once', 'invoicing'),
77 77
                                         'value'       => '1',
78 78
                                         'checked'     => $discount->is_single_use(),
79 79
                                     )
80 80
                                 );
81 81
 
82
-                                do_action( 'wpinv_discount_form_single_use', $discount );
82
+                                do_action('wpinv_discount_form_single_use', $discount);
83 83
                             ?>
84 84
                         </div>
85 85
                         <div class="col-sm-12">
86 86
                             <?php
87
-                                do_action( 'wpinv_discount_form_before_recurring', $discount );
87
+                                do_action('wpinv_discount_form_before_recurring', $discount);
88 88
 
89 89
                                 echo aui()->input(
90 90
                                     array(
91 91
                                         'id'          => 'wpinv_discount_recurring',
92 92
                                         'name'        => 'wpinv_discount_recurring',
93 93
                                         'type'        => 'checkbox',
94
-                                        'label'       => __( 'Apply this discount to all recurring payments for subscriptions', 'invoicing' ),
94
+                                        'label'       => __('Apply this discount to all recurring payments for subscriptions', 'invoicing'),
95 95
                                         'value'       => '1',
96 96
                                         'checked'     => $discount->is_recurring(),
97 97
                                     )
98 98
                                 );
99 99
 
100
-                                do_action( 'wpinv_discount_form_recurring', $discount );
100
+                                do_action('wpinv_discount_form_recurring', $discount);
101 101
                             ?>
102 102
                         </div>
103 103
                     </div>
104 104
                 </div>
105 105
                 <div class="col-sm-1 pt-2 pl-0">
106
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter a discount code such as 10OFF.', 'invoicing' ); ?>"></span>
106
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter a discount code such as 10OFF.', 'invoicing'); ?>"></span>
107 107
                 </div>
108 108
             </div>
109
-            <?php do_action( 'wpinv_discount_form_code', $discount ); ?>
109
+            <?php do_action('wpinv_discount_form_code', $discount); ?>
110 110
 
111
-            <?php do_action( 'wpinv_discount_form_before_type', $discount ); ?>
111
+            <?php do_action('wpinv_discount_form_before_type', $discount); ?>
112 112
             <div class="form-group row">
113 113
                 <label for="wpinv_discount_type" class="col-sm-3 col-form-label">
114
-                    <?php _e( 'Discount Type', 'invoicing' );?>
114
+                    <?php _e('Discount Type', 'invoicing'); ?>
115 115
                 </label>
116 116
                 <div class="col-sm-8">
117 117
                     <?php
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
                             array(
120 120
                                 'id'               => 'wpinv_discount_type',
121 121
                                 'name'             => 'wpinv_discount_type',
122
-                                'label'            => __( 'Discount Type', 'invoicing' ),
123
-                                'placeholder'      => __( 'Select Discount Type', 'invoicing' ),
124
-                                'value'            => $discount->get_type( 'edit' ),
122
+                                'label'            => __('Discount Type', 'invoicing'),
123
+                                'placeholder'      => __('Select Discount Type', 'invoicing'),
124
+                                'value'            => $discount->get_type('edit'),
125 125
                                 'select2'          => true,
126 126
                                 'data-allow-clear' => 'false',
127 127
                                 'options'          => wpinv_get_discount_types()
@@ -130,19 +130,19 @@  discard block
 block discarded – undo
130 130
                     ?>
131 131
                 </div>
132 132
                 <div class="col-sm-1 pt-2 pl-0">
133
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Discount type.', 'invoicing' ); ?>"></span>
133
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Discount type.', 'invoicing'); ?>"></span>
134 134
                 </div>
135 135
             </div>
136
-            <?php do_action( 'wpinv_discount_form_type', $discount ); ?>
136
+            <?php do_action('wpinv_discount_form_type', $discount); ?>
137 137
 
138
-            <?php do_action( 'wpinv_discount_form_before_amount', $discount ); ?>
139
-            <div class="form-group row <?php echo esc_attr( $discount->get_type( 'edit' ) ); ?>" id="wpinv_discount_amount_wrap">
138
+            <?php do_action('wpinv_discount_form_before_amount', $discount); ?>
139
+            <div class="form-group row <?php echo esc_attr($discount->get_type('edit')); ?>" id="wpinv_discount_amount_wrap">
140 140
                 <label for="wpinv_discount_amount" class="col-sm-3 col-form-label">
141
-                    <?php _e( 'Discount Amount', 'invoicing' );?>
141
+                    <?php _e('Discount Amount', 'invoicing'); ?>
142 142
                 </label>
143 143
                 <div class="col-sm-8">
144 144
                     <div class="input-group input-group-sm">
145
-                        <?php if( 'left' == $position ) : ?>
145
+                        <?php if ('left' == $position) : ?>
146 146
                             <div class="input-group-prepend left wpinv-if-flat">
147 147
                                 <span class="input-group-text">
148 148
                                     <?php echo wpinv_currency_symbol(); ?>
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
                             </div>
151 151
                         <?php endif; ?>
152 152
 
153
-                        <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr( $discount->get_amount( 'edit' ) ); ?>" placeholder="0" class="form-control">
153
+                        <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr($discount->get_amount('edit')); ?>" placeholder="0" class="form-control">
154 154
 
155
-                        <?php if( 'right' == $position ) : ?>
155
+                        <?php if ('right' == $position) : ?>
156 156
                             <div class="input-group-prepend left wpinv-if-flat">
157 157
                                 <span class="input-group-text">
158 158
                                     <?php echo wpinv_currency_symbol(); ?>
@@ -165,15 +165,15 @@  discard block
 block discarded – undo
165 165
                     </div>
166 166
                 </div>
167 167
                 <div class="col-sm-1 pt-2 pl-0">
168
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?>"></span>
168
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the discount value. Ex: 10', 'invoicing'); ?>"></span>
169 169
                 </div>
170 170
             </div>
171
-            <?php do_action( 'wpinv_discount_form_amount', $discount ); ?>
171
+            <?php do_action('wpinv_discount_form_amount', $discount); ?>
172 172
 
173
-            <?php do_action( 'wpinv_discount_form_before_items', $discount ); ?>
173
+            <?php do_action('wpinv_discount_form_before_items', $discount); ?>
174 174
             <div class="form-group row">
175 175
                 <label for="wpinv_discount_items" class="col-sm-3 col-form-label">
176
-                    <?php _e( 'Items', 'invoicing' );?>
176
+                    <?php _e('Items', 'invoicing'); ?>
177 177
                 </label>
178 178
                 <div class="col-sm-8">
179 179
                     <?php
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
                             array(
182 182
                                 'id'               => 'wpinv_discount_items',
183 183
                                 'name'             => 'wpinv_discount_items[]',
184
-                                'label'            => __( 'Items', 'invoicing' ),
185
-                                'placeholder'      => __( 'Select Items', 'invoicing' ),
186
-                                'value'            => $discount->get_items( 'edit' ),
184
+                                'label'            => __('Items', 'invoicing'),
185
+                                'placeholder'      => __('Select Items', 'invoicing'),
186
+                                'value'            => $discount->get_items('edit'),
187 187
                                 'select2'          => true,
188 188
                                 'multiple'         => true,
189 189
                                 'data-allow-clear' => 'false',
@@ -193,15 +193,15 @@  discard block
 block discarded – undo
193 193
                     ?>
194 194
                 </div>
195 195
                 <div class="col-sm-1 pt-2 pl-0">
196
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing' ); ?>"></span>
196
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing'); ?>"></span>
197 197
                 </div>
198 198
             </div>
199
-            <?php do_action( 'wpinv_discount_form_items', $discount ); ?>
199
+            <?php do_action('wpinv_discount_form_items', $discount); ?>
200 200
 
201
-            <?php do_action( 'wpinv_discount_form_before_excluded_items', $discount ); ?>
201
+            <?php do_action('wpinv_discount_form_before_excluded_items', $discount); ?>
202 202
             <div class="form-group row">
203 203
                 <label for="wpinv_discount_excluded_items" class="col-sm-3 col-form-label">
204
-                    <?php _e( 'Excluded Items', 'invoicing' );?>
204
+                    <?php _e('Excluded Items', 'invoicing'); ?>
205 205
                 </label>
206 206
                 <div class="col-sm-8">
207 207
                     <?php
@@ -209,9 +209,9 @@  discard block
 block discarded – undo
209 209
                             array(
210 210
                                 'id'               => 'wpinv_discount_excluded_items',
211 211
                                 'name'             => 'wpinv_discount_excluded_items[]',
212
-                                'label'            => __( 'Excluded Items', 'invoicing' ),
213
-                                'placeholder'      => __( 'Select Items', 'invoicing' ),
214
-                                'value'            => $discount->get_excluded_items( 'edit' ),
212
+                                'label'            => __('Excluded Items', 'invoicing'),
213
+                                'placeholder'      => __('Select Items', 'invoicing'),
214
+                                'value'            => $discount->get_excluded_items('edit'),
215 215
                                 'select2'          => true,
216 216
                                 'multiple'         => true,
217 217
                                 'data-allow-clear' => 'false',
@@ -221,15 +221,15 @@  discard block
 block discarded – undo
221 221
                     ?>
222 222
                 </div>
223 223
                 <div class="col-sm-1 pt-2 pl-0">
224
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select all the items that are not allowed to use this discount.', 'invoicing' ); ?>"></span>
224
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select all the items that are not allowed to use this discount.', 'invoicing'); ?>"></span>
225 225
                 </div>
226 226
             </div>
227
-            <?php do_action( 'wpinv_discount_form_excluded_items', $discount ); ?>
227
+            <?php do_action('wpinv_discount_form_excluded_items', $discount); ?>
228 228
 
229
-            <?php do_action( 'wpinv_discount_form_before_required_items', $discount ); ?>
229
+            <?php do_action('wpinv_discount_form_before_required_items', $discount); ?>
230 230
             <div class="form-group row">
231 231
                 <label for="wpinv_discount_required_items" class="col-sm-3 col-form-label">
232
-                    <?php _e( 'Required Items', 'invoicing' );?>
232
+                    <?php _e('Required Items', 'invoicing'); ?>
233 233
                 </label>
234 234
                 <div class="col-sm-8">
235 235
                     <?php
@@ -237,9 +237,9 @@  discard block
 block discarded – undo
237 237
                             array(
238 238
                                 'id'               => 'wpinv_discount_required_items',
239 239
                                 'name'             => 'wpinv_discount_required_items[]',
240
-                                'label'            => __( 'Required Items', 'invoicing' ),
241
-                                'placeholder'      => __( 'Select Items', 'invoicing' ),
242
-                                'value'            => $discount->get_required_items( 'edit' ),
240
+                                'label'            => __('Required Items', 'invoicing'),
241
+                                'placeholder'      => __('Select Items', 'invoicing'),
242
+                                'value'            => $discount->get_required_items('edit'),
243 243
                                 'select2'          => true,
244 244
                                 'multiple'         => true,
245 245
                                 'data-allow-clear' => 'false',
@@ -249,15 +249,15 @@  discard block
 block discarded – undo
249 249
                     ?>
250 250
                 </div>
251 251
                 <div class="col-sm-1 pt-2 pl-0">
252
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select all the items that are required to be in the cart before using this discount.', 'invoicing' ); ?>"></span>
252
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select all the items that are required to be in the cart before using this discount.', 'invoicing'); ?>"></span>
253 253
                 </div>
254 254
             </div>
255
-            <?php do_action( 'wpinv_discount_form_required_items', $discount ); ?>
255
+            <?php do_action('wpinv_discount_form_required_items', $discount); ?>
256 256
 
257
-            <?php do_action( 'wpinv_discount_form_before_start', $discount ); ?>
257
+            <?php do_action('wpinv_discount_form_before_start', $discount); ?>
258 258
             <div class="form-group row">
259 259
                 <label for="wpinv_discount_start" class="col-sm-3 col-form-label">
260
-                    <?php _e( 'Start Date', 'invoicing' );?>
260
+                    <?php _e('Start Date', 'invoicing'); ?>
261 261
                 </label>
262 262
                 <div class="col-sm-8">
263 263
                     <?php
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
                                 'type'        => 'datepicker',
267 267
                                 'id'          => 'wpinv_discount_start',
268 268
                                 'name'        => 'wpinv_discount_start',
269
-                                'label'       => __( 'Start Date', 'invoicing' ),
269
+                                'label'       => __('Start Date', 'invoicing'),
270 270
                                 'placeholder' => 'YYYY-MM-DD 00:00',
271 271
                                 'class'       => 'form-control-sm',
272
-                                'value'       => $discount->get_start_date( 'edit' ),
272
+                                'value'       => $discount->get_start_date('edit'),
273 273
                                 'extra_attributes' => array(
274 274
                                     'data-enable-time' => 'true',
275 275
                                     'data-time_24hr'   => 'true',
@@ -280,15 +280,15 @@  discard block
 block discarded – undo
280 280
                     ?>
281 281
                 </div>
282 282
                 <div class="col-sm-1 pt-2 pl-0">
283
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?>"></span>
283
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?>"></span>
284 284
                 </div>
285 285
             </div>
286
-            <?php do_action( 'wpinv_discount_form_start', $discount ); ?>
286
+            <?php do_action('wpinv_discount_form_start', $discount); ?>
287 287
 
288
-            <?php do_action( 'wpinv_discount_form_before_expiration', $discount ); ?>
288
+            <?php do_action('wpinv_discount_form_before_expiration', $discount); ?>
289 289
             <div class="form-group row">
290 290
                 <label for="wpinv_discount_expiration" class="col-sm-3 col-form-label">
291
-                    <?php _e( 'Expiration Date', 'invoicing' );?>
291
+                    <?php _e('Expiration Date', 'invoicing'); ?>
292 292
                 </label>
293 293
                 <div class="col-sm-8">
294 294
                     <?php
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
                                 'type'        => 'datepicker',
298 298
                                 'id'          => 'wpinv_discount_expiration',
299 299
                                 'name'        => 'wpinv_discount_expiration',
300
-                                'label'       => __( 'Expiration Date', 'invoicing' ),
300
+                                'label'       => __('Expiration Date', 'invoicing'),
301 301
                                 'placeholder' => 'YYYY-MM-DD 00:00',
302 302
                                 'class'       => 'form-control-sm',
303
-                                'value'       => $discount->get_end_date( 'edit' ),
303
+                                'value'       => $discount->get_end_date('edit'),
304 304
                                 'extra_attributes' => array(
305 305
                                     'data-enable-time' => 'true',
306 306
                                     'data-time_24hr'   => 'true',
@@ -313,27 +313,27 @@  discard block
 block discarded – undo
313 313
                     ?>
314 314
                 </div>
315 315
                 <div class="col-sm-1 pt-2 pl-0">
316
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the date after which the discount will expire.', 'invoicing' ); ?>"></span>
316
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the date after which the discount will expire.', 'invoicing'); ?>"></span>
317 317
                 </div>
318 318
             </div>
319
-            <?php do_action( 'wpinv_discount_form_expiration', $discount ); ?>
319
+            <?php do_action('wpinv_discount_form_expiration', $discount); ?>
320 320
 
321
-            <?php do_action( 'wpinv_discount_form_before_min_total', $discount ); ?>
321
+            <?php do_action('wpinv_discount_form_before_min_total', $discount); ?>
322 322
             <div class="form-group row">
323 323
                 <label for="wpinv_discount_min_total" class="col-sm-3 col-form-label">
324
-                    <?php _e( 'Minimum Amount', 'invoicing' );?>
324
+                    <?php _e('Minimum Amount', 'invoicing'); ?>
325 325
                 </label>
326 326
                 <div class="col-sm-8">
327 327
                     <div class="input-group input-group-sm">
328
-                        <?php if( 'left' == $position ) : ?>
328
+                        <?php if ('left' == $position) : ?>
329 329
                             <div class="input-group-prepend">
330 330
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
331 331
                             </div>
332 332
                         <?php endif; ?>
333 333
 
334
-                        <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr( $discount->get_minimum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No minimum', 'invoicing' ); ?>" class="form-control">
334
+                        <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr($discount->get_minimum_total('edit')); ?>" placeholder="<?php esc_attr_e('No minimum', 'invoicing'); ?>" class="form-control">
335 335
 
336
-                        <?php if( 'left' != $position ) : ?>
336
+                        <?php if ('left' != $position) : ?>
337 337
                             <div class="input-group-append">
338 338
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
339 339
                             </div>
@@ -341,27 +341,27 @@  discard block
 block discarded – undo
341 341
                     </div>
342 342
                 </div>
343 343
                 <div class="col-sm-1 pt-2 pl-0">
344
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing' ); ?>"></span>
344
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing'); ?>"></span>
345 345
                 </div>
346 346
             </div>
347
-            <?php do_action( 'wpinv_discount_form_min_total', $discount ); ?>
347
+            <?php do_action('wpinv_discount_form_min_total', $discount); ?>
348 348
 
349
-            <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?>
349
+            <?php do_action('wpinv_discount_form_before_max_total', $discount); ?>
350 350
             <div class="form-group row">
351 351
                 <label for="wpinv_discount_max_total" class="col-sm-3 col-form-label">
352
-                    <?php _e( 'Maximum Amount', 'invoicing' );?>
352
+                    <?php _e('Maximum Amount', 'invoicing'); ?>
353 353
                 </label>
354 354
                 <div class="col-sm-8">
355 355
                     <div class="input-group input-group-sm">
356
-                        <?php if( 'left' == $position ) : ?>
356
+                        <?php if ('left' == $position) : ?>
357 357
                             <div class="input-group-prepend">
358 358
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
359 359
                             </div>
360 360
                         <?php endif; ?>
361 361
 
362
-                        <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr( $discount->get_maximum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No maximum', 'invoicing' ); ?>" class="form-control">
362
+                        <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr($discount->get_maximum_total('edit')); ?>" placeholder="<?php esc_attr_e('No maximum', 'invoicing'); ?>" class="form-control">
363 363
 
364
-                        <?php if( 'left' != $position ) : ?>
364
+                        <?php if ('left' != $position) : ?>
365 365
                             <div class="input-group-append">
366 366
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
367 367
                             </div>
@@ -369,30 +369,30 @@  discard block
 block discarded – undo
369 369
                     </div>
370 370
                 </div>
371 371
                 <div class="col-sm-1 pt-2 pl-0">
372
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing' ); ?>"></span>
372
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing'); ?>"></span>
373 373
                 </div>
374 374
             </div>
375
-            <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?>
375
+            <?php do_action('wpinv_discount_form_before_max_total', $discount); ?>
376 376
 
377
-            <?php do_action( 'wpinv_discount_form_before_max_uses', $discount ); ?>
377
+            <?php do_action('wpinv_discount_form_before_max_uses', $discount); ?>
378 378
             <div class="form-group row">
379 379
                 <label for="wpinv_discount_max_uses" class="col-sm-3 col-form-label">
380
-                    <?php _e( 'Maximum Uses', 'invoicing' );?>
380
+                    <?php _e('Maximum Uses', 'invoicing'); ?>
381 381
                 </label>
382 382
                 <div class="col-sm-8">
383
-                    <input type="text" value="<?php echo esc_attr( $discount->get_max_uses( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'Unlimited', 'invoicing' ); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" />
383
+                    <input type="text" value="<?php echo esc_attr($discount->get_max_uses('edit')); ?>" placeholder="<?php esc_attr_e('Unlimited', 'invoicing'); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" />
384 384
                 </div>
385 385
                 <div class="col-sm-1 pt-2 pl-0">
386
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum number of times that this discount code can be used.', 'invoicing' ); ?>"></span>
386
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum number of times that this discount code can be used.', 'invoicing'); ?>"></span>
387 387
                 </div>
388 388
             </div>
389
-            <?php do_action( 'wpinv_discount_form_max_uses', $discount ); ?>
389
+            <?php do_action('wpinv_discount_form_max_uses', $discount); ?>
390 390
 
391
-            <?php do_action( 'wpinv_discount_form_last', $discount ); ?>
391
+            <?php do_action('wpinv_discount_form_last', $discount); ?>
392 392
 
393 393
         </div>
394 394
         <?php
395
-        do_action( 'wpinv_discount_form_bottom', $post );
395
+        do_action('wpinv_discount_form_bottom', $post);
396 396
     }
397 397
 
398 398
     /**
@@ -400,31 +400,31 @@  discard block
 block discarded – undo
400 400
 	 *
401 401
 	 * @param int $post_id
402 402
 	 */
403
-	public static function save( $post_id ) {
403
+	public static function save($post_id) {
404 404
 
405 405
         // Prepare the discount.
406
-        $discount = new WPInv_Discount( $post_id );
406
+        $discount = new WPInv_Discount($post_id);
407 407
 
408 408
         // Load new data.
409 409
         $discount->set_props(
410 410
 			array(
411
-				'code'                 => isset( $_POST['wpinv_discount_code'] ) ? wpinv_clean( $_POST['wpinv_discount_code'] ) : null,
412
-				'amount'               => isset( $_POST['wpinv_discount_amount'] ) ? floatval( $_POST['wpinv_discount_amount'] ) : null,
413
-				'start'                => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null,
414
-				'expiration'           => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null,
415
-				'is_single_use'        => ! empty( $_POST['wpinv_discount_single_use'] ),
416
-                'type'                 => isset( $_POST['wpinv_discount_type'] ) ? wpinv_clean( $_POST['wpinv_discount_type'] ) : null,
417
-				'is_recurring'         => ! empty( $_POST['wpinv_discount_recurring'] ),
418
-				'items'                => isset( $_POST['wpinv_discount_items'] ) ? wpinv_clean( $_POST['wpinv_discount_items'] ) : array(),
419
-				'excluded_items'       => isset( $_POST['wpinv_discount_excluded_items'] ) ? wpinv_clean( $_POST['wpinv_discount_excluded_items'] ) : array(),
420
-                'required_items'       => isset( $_POST['wpinv_discount_required_items'] ) ? wpinv_clean( $_POST['wpinv_discount_required_items'] ) : array(),
421
-				'max_uses'             => isset( $_POST['wpinv_discount_max_uses'] ) ? intval( $_POST['wpinv_discount_max_uses'] ) : null,
422
-				'min_total'            => isset( $_POST['wpinv_discount_min_total'] ) ? floatval( $_POST['wpinv_discount_min_total'] ) : null,
423
-				'max_total'            => isset( $_POST['wpinv_discount_max_total'] ) ? floatval( $_POST['wpinv_discount_max_total'] ) : null,
411
+				'code'                 => isset($_POST['wpinv_discount_code']) ? wpinv_clean($_POST['wpinv_discount_code']) : null,
412
+				'amount'               => isset($_POST['wpinv_discount_amount']) ? floatval($_POST['wpinv_discount_amount']) : null,
413
+				'start'                => isset($_POST['wpinv_discount_start']) ? wpinv_clean($_POST['wpinv_discount_start']) : null,
414
+				'expiration'           => isset($_POST['wpinv_discount_expiration']) ? wpinv_clean($_POST['wpinv_discount_expiration']) : null,
415
+				'is_single_use'        => !empty($_POST['wpinv_discount_single_use']),
416
+                'type'                 => isset($_POST['wpinv_discount_type']) ? wpinv_clean($_POST['wpinv_discount_type']) : null,
417
+				'is_recurring'         => !empty($_POST['wpinv_discount_recurring']),
418
+				'items'                => isset($_POST['wpinv_discount_items']) ? wpinv_clean($_POST['wpinv_discount_items']) : array(),
419
+				'excluded_items'       => isset($_POST['wpinv_discount_excluded_items']) ? wpinv_clean($_POST['wpinv_discount_excluded_items']) : array(),
420
+                'required_items'       => isset($_POST['wpinv_discount_required_items']) ? wpinv_clean($_POST['wpinv_discount_required_items']) : array(),
421
+				'max_uses'             => isset($_POST['wpinv_discount_max_uses']) ? intval($_POST['wpinv_discount_max_uses']) : null,
422
+				'min_total'            => isset($_POST['wpinv_discount_min_total']) ? floatval($_POST['wpinv_discount_min_total']) : null,
423
+				'max_total'            => isset($_POST['wpinv_discount_max_total']) ? floatval($_POST['wpinv_discount_max_total']) : null,
424 424
 			)
425 425
         );
426 426
 
427 427
 		$discount->save();
428
-		do_action( 'getpaid_discount_metabox_save', $post_id, $discount );
428
+		do_action('getpaid_discount_metabox_save', $post_id, $discount);
429 429
 	}
430 430
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-address.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Invoice_Address {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the invoice.
@@ -366,18 +366,18 @@  discard block
 block discarded – undo
366 366
     }
367 367
 
368 368
     /**
369
-	 * Save meta box data.
370
-	 *
371
-	 * @param int $post_id
372
-	 */
373
-	public static function save( $post_id ) {
369
+     * Save meta box data.
370
+     *
371
+     * @param int $post_id
372
+     */
373
+    public static function save( $post_id ) {
374 374
 
375 375
         // Prepare the invoice.
376 376
         $invoice = new WPInv_Invoice( $post_id );
377 377
 
378 378
         // Load new data.
379 379
         $invoice->set_props(
380
-			array(
380
+            array(
381 381
                 'template'             => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null,
382 382
                 'email_cc'             => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null,
383 383
                 'disable_taxes'        => ! empty( $_POST['disable_taxes'] ),
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
                 'due_date'             => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null,
401 401
                 'number'               => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null,
402 402
                 'status'               => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null,
403
-			)
403
+            )
404 404
         );
405 405
 
406 406
         // Discount code.
@@ -465,6 +465,6 @@  discard block
 block discarded – undo
465 465
         }
466 466
 
467 467
         // Fires after an invoice is saved.
468
-		do_action( 'wpinv_invoice_metabox_saved', $invoice );
469
-	}
468
+        do_action( 'wpinv_invoice_metabox_saved', $invoice );
469
+    }
470 470
 }
Please login to merge, or discard this patch.
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the invoice.
27
-        $invoice  = new WPInv_Invoice( $post );
28
-        $customer = $invoice->exists() ? $invoice->get_user_id( 'edit' ) : get_current_user_id();
29
-        $customer = new WP_User( $customer );
30
-        $display  = sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email );
31
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
27
+        $invoice  = new WPInv_Invoice($post);
28
+        $customer = $invoice->exists() ? $invoice->get_user_id('edit') : get_current_user_id();
29
+        $customer = new WP_User($customer);
30
+        $display  = sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email);
31
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
32 32
 
33 33
         ?>
34 34
 
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
                         <div class="col-12 col-sm-6">
44 44
                             <div id="getpaid-invoice-user-id-wrapper" class="form-group">
45 45
                                 <div>
46
-                                    <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label>
46
+                                    <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label>
47 47
                                 </div>
48 48
                                 <div>
49
-                                    <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e( 'Search for a customer by email or name', 'invoicing' ); ?>">
50
-                                        <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html( $display ); ?> </option>)
49
+                                    <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e('Search for a customer by email or name', 'invoicing'); ?>">
50
+                                        <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html($display); ?> </option>)
51 51
                                     </select>
52 52
                                 </div>
53 53
                             </div>
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
                                             'type'        => 'text',
61 61
                                             'id'          => 'getpaid-invoice-new-user-email',
62 62
                                             'name'        => 'wpinv_email',
63
-                                            'label'       => __( 'Email', 'invoicing' ) . '<span class="required">*</span>',
63
+                                            'label'       => __('Email', 'invoicing') . '<span class="required">*</span>',
64 64
                                             'label_type'  => 'vertical',
65 65
                                             'placeholder' => '[email protected]',
66 66
                                             'class'       => 'form-control-sm',
@@ -70,18 +70,18 @@  discard block
 block discarded – undo
70 70
                             </div>
71 71
                         </div>
72 72
                         <div class="col-12 col-sm-6 form-group mt-sm-4">
73
-                            <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
73
+                            <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?>
74 74
                                 <a id="getpaid-invoice-fill-user-details" class="button button-small button-secondary" href="javascript:void(0)">
75 75
                                     <i aria-hidden="true" class="fa fa-refresh"></i>
76
-                                    <?php _e( 'Fill User Details', 'invoicing' );?>
76
+                                    <?php _e('Fill User Details', 'invoicing'); ?>
77 77
                                 </a>
78 78
                                 <a id="getpaid-invoice-create-new-user-button" class="button button-small button-secondary" href="javascript:void(0)">
79 79
                                     <i aria-hidden="true" class="fa fa-plus"></i>
80
-                                    <?php _e( 'Add New User', 'invoicing' );?>
80
+                                    <?php _e('Add New User', 'invoicing'); ?>
81 81
                                 </a>
82 82
                                 <a id="getpaid-invoice-cancel-create-new-user" class="button button-small button-secondary d-none" href="javascript:void(0)">
83 83
                                     <i aria-hidden="true" class="fa fa-close"></i>
84
-                                    <?php _e( 'Cancel', 'invoicing' );?>
84
+                                    <?php _e('Cancel', 'invoicing'); ?>
85 85
                                 </a>
86 86
                             <?php endif; ?>
87 87
                         </div>
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
                                         'type'        => 'text',
95 95
                                         'id'          => 'wpinv_first_name',
96 96
                                         'name'        => 'wpinv_first_name',
97
-                                        'label'       => __( 'First Name', 'invoicing' ),
97
+                                        'label'       => __('First Name', 'invoicing'),
98 98
                                         'label_type'  => 'vertical',
99 99
                                         'placeholder' => '',
100 100
                                         'class'       => 'form-control-sm',
101
-                                        'value'       => $invoice->get_first_name( 'edit' ),
101
+                                        'value'       => $invoice->get_first_name('edit'),
102 102
                                     )
103 103
                                 );
104 104
                             ?>
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
                                         'type'        => 'text',
111 111
                                         'id'          => 'wpinv_last_name',
112 112
                                         'name'        => 'wpinv_last_name',
113
-                                        'label'       => __( 'Last Name', 'invoicing' ),
113
+                                        'label'       => __('Last Name', 'invoicing'),
114 114
                                         'label_type'  => 'vertical',
115 115
                                         'placeholder' => '',
116 116
                                         'class'       => 'form-control-sm',
117
-                                        'value'       => $invoice->get_last_name( 'edit' ),
117
+                                        'value'       => $invoice->get_last_name('edit'),
118 118
                                     )
119 119
                                 );
120 120
                             ?>
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
                                         'type'        => 'text',
130 130
                                         'id'          => 'wpinv_company',
131 131
                                         'name'        => 'wpinv_company',
132
-                                        'label'       => __( 'Company', 'invoicing' ),
132
+                                        'label'       => __('Company', 'invoicing'),
133 133
                                         'label_type'  => 'vertical',
134 134
                                         'placeholder' => '',
135 135
                                         'class'       => 'form-control-sm',
136
-                                        'value'       => $invoice->get_company( 'edit' ),
136
+                                        'value'       => $invoice->get_company('edit'),
137 137
                                     )
138 138
                                 );
139 139
                             ?>
@@ -145,11 +145,11 @@  discard block
 block discarded – undo
145 145
                                         'type'        => 'text',
146 146
                                         'id'          => 'wpinv_vat_number',
147 147
                                         'name'        => 'wpinv_vat_number',
148
-                                        'label'       => __( 'Vat Number', 'invoicing' ),
148
+                                        'label'       => __('Vat Number', 'invoicing'),
149 149
                                         'label_type'  => 'vertical',
150 150
                                         'placeholder' => '',
151 151
                                         'class'       => 'form-control-sm getpaid-recalculate-prices-on-change',
152
-                                        'value'       => $invoice->get_vat_number( 'edit' ),
152
+                                        'value'       => $invoice->get_vat_number('edit'),
153 153
                                     )
154 154
                                 );
155 155
                             ?>
@@ -164,11 +164,11 @@  discard block
 block discarded – undo
164 164
                                         'type'        => 'text',
165 165
                                         'id'          => 'wpinv_address',
166 166
                                         'name'        => 'wpinv_address',
167
-                                        'label'       => __( 'Address', 'invoicing' ),
167
+                                        'label'       => __('Address', 'invoicing'),
168 168
                                         'label_type'  => 'vertical',
169 169
                                         'placeholder' => '',
170 170
                                         'class'       => 'form-control-sm',
171
-                                        'value'       => $invoice->get_address( 'edit' ),
171
+                                        'value'       => $invoice->get_address('edit'),
172 172
                                     )
173 173
                                 );
174 174
                             ?>
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
                                         'type'        => 'text',
181 181
                                         'id'          => 'wpinv_city',
182 182
                                         'name'        => 'wpinv_city',
183
-                                        'label'       => __( 'City', 'invoicing' ),
183
+                                        'label'       => __('City', 'invoicing'),
184 184
                                         'label_type'  => 'vertical',
185 185
                                         'placeholder' => '',
186 186
                                         'class'       => 'form-control-sm',
187
-                                        'value'       => $invoice->get_city( 'edit' ),
187
+                                        'value'       => $invoice->get_city('edit'),
188 188
                                     )
189 189
                                 );
190 190
                             ?>
@@ -198,11 +198,11 @@  discard block
 block discarded – undo
198 198
                                     array(
199 199
                                         'id'          => 'wpinv_country',
200 200
                                         'name'        => 'wpinv_country',
201
-                                        'label'       => __( 'Country', 'invoicing' ),
201
+                                        'label'       => __('Country', 'invoicing'),
202 202
                                         'label_type'  => 'vertical',
203
-                                        'placeholder' => __( 'Choose a country', 'invoicing' ),
203
+                                        'placeholder' => __('Choose a country', 'invoicing'),
204 204
                                         'class'       => 'form-control-sm getpaid-recalculate-prices-on-change',
205
-                                        'value'       => $invoice->get_country( 'edit' ),
205
+                                        'value'       => $invoice->get_country('edit'),
206 206
                                         'options'     => wpinv_get_country_list(),
207 207
                                         'data-allow-clear' => 'false',
208 208
                                         'select2'          => true,
@@ -213,20 +213,20 @@  discard block
 block discarded – undo
213 213
                         <div class="col-12 col-sm-6">
214 214
                             <?php
215 215
 
216
-                                $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) );
216
+                                $states = wpinv_get_country_states($invoice->get_country('edit'));
217 217
 
218
-                                if ( empty( $states ) ) {
218
+                                if (empty($states)) {
219 219
 
220 220
                                     echo aui()->input(
221 221
                                         array(
222 222
                                             'type'        => 'text',
223 223
                                             'id'          => 'wpinv_state',
224 224
                                             'name'        => 'wpinv_state',
225
-                                            'label'       => __( 'State', 'invoicing' ),
225
+                                            'label'       => __('State', 'invoicing'),
226 226
                                             'label_type'  => 'vertical',
227 227
                                             'placeholder' => '',
228 228
                                             'class'       => 'form-control-sm',
229
-                                            'value'       => $invoice->get_state( 'edit' ),
229
+                                            'value'       => $invoice->get_state('edit'),
230 230
                                         )
231 231
                                     );
232 232
 
@@ -236,11 +236,11 @@  discard block
 block discarded – undo
236 236
                                         array(
237 237
                                             'id'          => 'wpinv_state',
238 238
                                             'name'        => 'wpinv_state',
239
-                                            'label'       => __( 'State', 'invoicing' ),
239
+                                            'label'       => __('State', 'invoicing'),
240 240
                                             'label_type'  => 'vertical',
241
-                                            'placeholder' => __( 'Select a state', 'invoicing' ),
241
+                                            'placeholder' => __('Select a state', 'invoicing'),
242 242
                                             'class'       => 'form-control-sm',
243
-                                            'value'       => $invoice->get_state( 'edit' ),
243
+                                            'value'       => $invoice->get_state('edit'),
244 244
                                             'options'     => $states,
245 245
                                             'data-allow-clear' => 'false',
246 246
                                             'select2'          => true,
@@ -261,11 +261,11 @@  discard block
 block discarded – undo
261 261
                                         'type'        => 'text',
262 262
                                         'id'          => 'wpinv_zip',
263 263
                                         'name'        => 'wpinv_zip',
264
-                                        'label'       => __( 'Zip / Postal Code', 'invoicing' ),
264
+                                        'label'       => __('Zip / Postal Code', 'invoicing'),
265 265
                                         'label_type'  => 'vertical',
266 266
                                         'placeholder' => '',
267 267
                                         'class'       => 'form-control-sm',
268
-                                        'value'       => $invoice->get_zip( 'edit' ),
268
+                                        'value'       => $invoice->get_zip('edit'),
269 269
                                     )
270 270
                                 );
271 271
                             ?>
@@ -277,19 +277,19 @@  discard block
 block discarded – undo
277 277
                                         'type'        => 'text',
278 278
                                         'id'          => 'wpinv_phone',
279 279
                                         'name'        => 'wpinv_phone',
280
-                                        'label'       => __( 'Phone', 'invoicing' ),
280
+                                        'label'       => __('Phone', 'invoicing'),
281 281
                                         'label_type'  => 'vertical',
282 282
                                         'placeholder' => '',
283 283
                                         'class'       => 'form-control-sm',
284
-                                        'value'       => $invoice->get_phone( 'edit' ),
284
+                                        'value'       => $invoice->get_phone('edit'),
285 285
                                     )
286 286
                                 );
287 287
                             ?>
288 288
                         </div>
289 289
                     </div>
290 290
 
291
-                    <?php if ( ! apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) : ?>
292
-                        <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?>
291
+                    <?php if (!apply_filters('getpaid_use_new_invoice_items_metabox', false)) : ?>
292
+                        <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?>
293 293
 
294 294
                         <div class="row">
295 295
                             <div class="col-12 col-sm-6">
@@ -298,14 +298,14 @@  discard block
 block discarded – undo
298 298
                                         array(
299 299
                                             'id'          => 'wpinv_template',
300 300
                                             'name'        => 'wpinv_template',
301
-                                            'label'       => __( 'Template', 'invoicing' ),
301
+                                            'label'       => __('Template', 'invoicing'),
302 302
                                             'label_type'  => 'vertical',
303
-                                            'placeholder' => __( 'Choose a template', 'invoicing' ),
303
+                                            'placeholder' => __('Choose a template', 'invoicing'),
304 304
                                             'class'       => 'form-control-sm',
305
-                                            'value'       => $invoice->get_template( 'edit' ),
305
+                                            'value'       => $invoice->get_template('edit'),
306 306
                                             'options'     => array(
307
-                                                'quantity' => __( 'Quantity', 'invoicing' ),
308
-                                                'hours'    => __( 'Hours', 'invoicing' ),
307
+                                                'quantity' => __('Quantity', 'invoicing'),
308
+                                                'hours'    => __('Hours', 'invoicing'),
309 309
                                                 //'amount'   => __( 'Amount Only', 'invoicing' ),
310 310
                                             ),
311 311
                                             'data-allow-clear' => 'false',
@@ -322,11 +322,11 @@  discard block
 block discarded – undo
322 322
                                         array(
323 323
                                             'id'          => 'wpinv_currency',
324 324
                                             'name'        => 'wpinv_currency',
325
-                                            'label'       => __( 'Currency', 'invoicing' ),
325
+                                            'label'       => __('Currency', 'invoicing'),
326 326
                                             'label_type'  => 'vertical',
327
-                                            'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
327
+                                            'placeholder' => __('Select Invoice Currency', 'invoicing'),
328 328
                                             'class'       => 'form-control-sm getpaid-recalculate-prices-on-change',
329
-                                            'value'       => $invoice->get_currency( 'edit' ),
329
+                                            'value'       => $invoice->get_currency('edit'),
330 330
                                             'required'    => false,
331 331
                                             'data-allow-clear' => 'false',
332 332
                                             'select2'          => true,
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
                             </div>
339 339
                         </div>
340 340
 
341
-                        <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?>
341
+                        <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?>
342 342
                     <?php endif; ?>
343 343
 
344 344
                     <div class="row">
@@ -349,18 +349,18 @@  discard block
 block discarded – undo
349 349
                                         'type'        => 'text',
350 350
                                         'id'          => 'wpinv_company_id',
351 351
                                         'name'        => 'wpinv_company_id',
352
-                                        'label'       => __( 'Company ID', 'invoicing' ),
352
+                                        'label'       => __('Company ID', 'invoicing'),
353 353
                                         'label_type'  => 'vertical',
354 354
                                         'placeholder' => '',
355 355
                                         'class'       => 'form-control-sm',
356
-                                        'value'       => $invoice->get_company_id( 'edit' ),
356
+                                        'value'       => $invoice->get_company_id('edit'),
357 357
                                     )
358 358
                                 );
359 359
                             ?>
360 360
                         </div>
361 361
                     </div>
362 362
 
363
-                    <?php do_action( 'getpaid_after_metabox_invoice_address', $invoice ); ?>
363
+                    <?php do_action('getpaid_after_metabox_invoice_address', $invoice); ?>
364 364
             </div>
365 365
         <?php
366 366
     }
@@ -370,51 +370,51 @@  discard block
 block discarded – undo
370 370
 	 *
371 371
 	 * @param int $post_id
372 372
 	 */
373
-	public static function save( $post_id ) {
373
+	public static function save($post_id) {
374 374
 
375 375
         // Prepare the invoice.
376
-        $invoice = new WPInv_Invoice( $post_id );
376
+        $invoice = new WPInv_Invoice($post_id);
377 377
 
378 378
         // Load new data.
379 379
         $invoice->set_props(
380 380
 			array(
381
-                'template'             => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null,
382
-                'email_cc'             => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null,
383
-                'disable_taxes'        => ! empty( $_POST['disable_taxes'] ),
384
-                'currency'             => isset( $_POST['wpinv_currency'] ) ? wpinv_clean( $_POST['wpinv_currency'] ) : null,
385
-                'gateway'              => ( $invoice->needs_payment() && isset( $_POST['wpinv_gateway'] ) ) ? wpinv_clean( $_POST['wpinv_gateway'] ) : null,
386
-                'address'              => isset( $_POST['wpinv_address'] ) ? wpinv_clean( $_POST['wpinv_address'] ) : null,
387
-                'vat_number'           => isset( $_POST['wpinv_vat_number'] ) ? wpinv_clean( $_POST['wpinv_vat_number'] ) : null,
388
-                'company'              => isset( $_POST['wpinv_company'] ) ? wpinv_clean( $_POST['wpinv_company'] ) : null,
389
-                'company_id'           => isset( $_POST['wpinv_company_id'] ) ? wpinv_clean( $_POST['wpinv_company_id'] ) : null,
390
-                'zip'                  => isset( $_POST['wpinv_zip'] ) ? wpinv_clean( $_POST['wpinv_zip'] ) : null,
391
-                'state'                => isset( $_POST['wpinv_state'] ) ? wpinv_clean( $_POST['wpinv_state'] ) : null,
392
-                'city'                 => isset( $_POST['wpinv_city'] ) ? wpinv_clean( $_POST['wpinv_city'] ) : null,
393
-                'country'              => isset( $_POST['wpinv_country'] ) ? wpinv_clean( $_POST['wpinv_country'] ) : null,
394
-                'phone'                => isset( $_POST['wpinv_phone'] ) ? wpinv_clean( $_POST['wpinv_phone'] ) : null,
395
-                'first_name'           => isset( $_POST['wpinv_first_name'] ) ? wpinv_clean( $_POST['wpinv_first_name'] ) : null,
396
-                'last_name'            => isset( $_POST['wpinv_last_name'] ) ? wpinv_clean( $_POST['wpinv_last_name'] ) : null,
397
-                'author'               => isset( $_POST['post_author_override'] ) ? wpinv_clean( $_POST['post_author_override'] ) : null,
398
-                'date_created'         => isset( $_POST['date_created'] ) ? wpinv_clean( $_POST['date_created'] ) : null,
399
-                'date_completed'       => isset( $_POST['wpinv_date_completed'] ) ? wpinv_clean( $_POST['wpinv_date_completed'] ) : null,
400
-                'due_date'             => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null,
401
-                'number'               => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null,
402
-                'status'               => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null,
381
+                'template'             => isset($_POST['wpinv_template']) ? wpinv_clean($_POST['wpinv_template']) : null,
382
+                'email_cc'             => isset($_POST['wpinv_cc']) ? wpinv_clean($_POST['wpinv_cc']) : null,
383
+                'disable_taxes'        => !empty($_POST['disable_taxes']),
384
+                'currency'             => isset($_POST['wpinv_currency']) ? wpinv_clean($_POST['wpinv_currency']) : null,
385
+                'gateway'              => ($invoice->needs_payment() && isset($_POST['wpinv_gateway'])) ? wpinv_clean($_POST['wpinv_gateway']) : null,
386
+                'address'              => isset($_POST['wpinv_address']) ? wpinv_clean($_POST['wpinv_address']) : null,
387
+                'vat_number'           => isset($_POST['wpinv_vat_number']) ? wpinv_clean($_POST['wpinv_vat_number']) : null,
388
+                'company'              => isset($_POST['wpinv_company']) ? wpinv_clean($_POST['wpinv_company']) : null,
389
+                'company_id'           => isset($_POST['wpinv_company_id']) ? wpinv_clean($_POST['wpinv_company_id']) : null,
390
+                'zip'                  => isset($_POST['wpinv_zip']) ? wpinv_clean($_POST['wpinv_zip']) : null,
391
+                'state'                => isset($_POST['wpinv_state']) ? wpinv_clean($_POST['wpinv_state']) : null,
392
+                'city'                 => isset($_POST['wpinv_city']) ? wpinv_clean($_POST['wpinv_city']) : null,
393
+                'country'              => isset($_POST['wpinv_country']) ? wpinv_clean($_POST['wpinv_country']) : null,
394
+                'phone'                => isset($_POST['wpinv_phone']) ? wpinv_clean($_POST['wpinv_phone']) : null,
395
+                'first_name'           => isset($_POST['wpinv_first_name']) ? wpinv_clean($_POST['wpinv_first_name']) : null,
396
+                'last_name'            => isset($_POST['wpinv_last_name']) ? wpinv_clean($_POST['wpinv_last_name']) : null,
397
+                'author'               => isset($_POST['post_author_override']) ? wpinv_clean($_POST['post_author_override']) : null,
398
+                'date_created'         => isset($_POST['date_created']) ? wpinv_clean($_POST['date_created']) : null,
399
+                'date_completed'       => isset($_POST['wpinv_date_completed']) ? wpinv_clean($_POST['wpinv_date_completed']) : null,
400
+                'due_date'             => isset($_POST['wpinv_due_date']) ? wpinv_clean($_POST['wpinv_due_date']) : null,
401
+                'number'               => isset($_POST['wpinv_number']) ? wpinv_clean($_POST['wpinv_number']) : null,
402
+                'status'               => isset($_POST['wpinv_status']) ? wpinv_clean($_POST['wpinv_status']) : null,
403 403
 			)
404 404
         );
405 405
 
406 406
         // Discount code.
407
-        if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
407
+        if (!$invoice->is_paid() && !$invoice->is_refunded()) {
408 408
 
409
-            if ( isset( $_POST['wpinv_discount_code'] ) ) {
410
-                $invoice->set_discount_code( wpinv_clean( $_POST['wpinv_discount_code'] ) );
409
+            if (isset($_POST['wpinv_discount_code'])) {
410
+                $invoice->set_discount_code(wpinv_clean($_POST['wpinv_discount_code']));
411 411
             }
412 412
 
413
-            $discount = new WPInv_Discount( $invoice->get_discount_code() );
414
-            if ( $discount->exists() ) {
415
-                $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
413
+            $discount = new WPInv_Discount($invoice->get_discount_code());
414
+            if ($discount->exists()) {
415
+                $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
416 416
             } else {
417
-                $invoice->remove_discount( 'discount_code' );
417
+                $invoice->remove_discount('discount_code');
418 418
             }
419 419
 
420 420
             // Recalculate totals.
@@ -423,17 +423,17 @@  discard block
 block discarded – undo
423 423
         }
424 424
 
425 425
         // If we're creating a new user...
426
-        if ( ! empty( $_POST['wpinv_new_user'] ) && is_email( stripslashes( $_POST['wpinv_email'] ) ) ) {
426
+        if (!empty($_POST['wpinv_new_user']) && is_email(stripslashes($_POST['wpinv_email']))) {
427 427
 
428 428
             // Attempt to create the user.
429
-            $user = wpinv_create_user( sanitize_email( stripslashes( $_POST['wpinv_email'] ) ) );
429
+            $user = wpinv_create_user(sanitize_email(stripslashes($_POST['wpinv_email'])));
430 430
 
431 431
 
432 432
             // If successful, update the invoice author.
433
-            if ( is_numeric( $user ) ) {
434
-                $invoice->set_author( $user );
433
+            if (is_numeric($user)) {
434
+                $invoice->set_author($user);
435 435
             } else {
436
-                wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ );
436
+                wpinv_error_log($user->get_error_message(), __('Invoice add new user', 'invoicing'), __FILE__, __LINE__);
437 437
             }
438 438
         }
439 439
 
@@ -447,16 +447,16 @@  discard block
 block discarded – undo
447 447
         $GLOBALS['wpinv_skip_invoice_notification'] = false;
448 448
 
449 449
         // (Maybe) send new user notification.
450
-        $should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
451
-        if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) {
452
-            wp_send_new_user_notifications( $user, 'user' );
450
+        $should_send_notification = wpinv_get_option('disable_new_user_emails');
451
+        if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', empty($should_send_notification))) {
452
+            wp_send_new_user_notifications($user, 'user');
453 453
         }
454 454
 
455
-        if ( ! empty( $_POST['send_to_customer'] ) && ! $invoice->is_draft() ) {
456
-            getpaid()->get( 'invoice_emails' )->user_invoice( $invoice, true );
455
+        if (!empty($_POST['send_to_customer']) && !$invoice->is_draft()) {
456
+            getpaid()->get('invoice_emails')->user_invoice($invoice, true);
457 457
         }
458 458
 
459 459
         // Fires after an invoice is saved.
460
-		do_action( 'wpinv_invoice_metabox_saved', $invoice );
460
+		do_action('wpinv_invoice_metabox_saved', $invoice);
461 461
 	}
462 462
 }
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 2 patches
Indentation   +2609 added lines, -2609 removed lines patch added patch discarded remove patch
@@ -14,30 +14,30 @@  discard block
 block discarded – undo
14 14
 class WPInv_Invoice extends GetPaid_Data {
15 15
 
16 16
     /**
17
-	 * Which data store to load.
18
-	 *
19
-	 * @var string
20
-	 */
17
+     * Which data store to load.
18
+     *
19
+     * @var string
20
+     */
21 21
     protected $data_store_name = 'invoice';
22 22
 
23 23
     /**
24
-	 * This is the name of this object type.
25
-	 *
26
-	 * @var string
27
-	 */
24
+     * This is the name of this object type.
25
+     *
26
+     * @var string
27
+     */
28 28
     protected $object_type = 'invoice';
29 29
 
30 30
     /**
31
-	 * Item Data array. This is the core item data exposed in APIs.
32
-	 *
33
-	 * @since 1.0.19
34
-	 * @var array
35
-	 */
36
-	protected $data = array(
37
-		'parent_id'            => 0,
38
-		'status'               => 'wpi-pending',
39
-		'version'              => '',
40
-		'date_created'         => null,
31
+     * Item Data array. This is the core item data exposed in APIs.
32
+     *
33
+     * @since 1.0.19
34
+     * @var array
35
+     */
36
+    protected $data = array(
37
+        'parent_id'            => 0,
38
+        'status'               => 'wpi-pending',
39
+        'version'              => '',
40
+        'date_created'         => null,
41 41
         'date_modified'        => null,
42 42
         'due_date'             => null,
43 43
         'completed_date'       => null,
@@ -60,17 +60,17 @@  discard block
 block discarded – undo
60 60
         'state'                => null,
61 61
         'zip'                  => null,
62 62
         'company'              => null,
63
-		'company_id'           => null,
63
+        'company_id'           => null,
64 64
         'vat_number'           => null,
65 65
         'vat_rate'             => null,
66 66
         'address'              => null,
67 67
         'address_confirmed'    => false,
68 68
         'shipping'             => null,
69
-		'subtotal'             => 0,
69
+        'subtotal'             => 0,
70 70
         'total_discount'       => 0,
71 71
         'total_tax'            => 0,
72
-		'total_fees'           => 0,
73
-		'total'                => 0,
72
+        'total_fees'           => 0,
73
+        'total'                => 0,
74 74
         'fees'                 => array(),
75 75
         'discounts'            => array(),
76 76
         'taxes'                => array(),
@@ -82,22 +82,22 @@  discard block
 block discarded – undo
82 82
         'transaction_id'       => '',
83 83
         'currency'             => '',
84 84
         'disable_taxes'        => false,
85
-		'subscription_id'      => null,
86
-		'remote_subscription_id' => null,
87
-		'is_viewed'            => false,
88
-		'email_cc'             => '',
89
-		'template'             => 'quantity', // hours, amount only
90
-		'created_via'          => null,
85
+        'subscription_id'      => null,
86
+        'remote_subscription_id' => null,
87
+        'is_viewed'            => false,
88
+        'email_cc'             => '',
89
+        'template'             => 'quantity', // hours, amount only
90
+        'created_via'          => null,
91 91
     );
92 92
 
93 93
     /**
94
-	 * Stores meta in cache for future reads.
95
-	 *
96
-	 * A group must be set to to enable caching.
97
-	 *
98
-	 * @var string
99
-	 */
100
-	protected $cache_group = 'getpaid_invoices';
94
+     * Stores meta in cache for future reads.
95
+     *
96
+     * A group must be set to to enable caching.
97
+     *
98
+     * @var string
99
+     */
100
+    protected $cache_group = 'getpaid_invoices';
101 101
 
102 102
     /**
103 103
      * Stores a reference to the original WP_Post object
@@ -111,111 +111,111 @@  discard block
 block discarded – undo
111 111
      *
112 112
      * @var int
113 113
      */
114
-	protected $recurring_item = null;
114
+    protected $recurring_item = null;
115 115
 
116
-	/**
116
+    /**
117 117
      * Stores an array of item totals.
118
-	 *
119
-	 * e.g $totals['discount'] = array(
120
-	 * 		'initial'   => 10,
121
-	 * 		'recurring' => 10,
122
-	 * )
118
+     *
119
+     * e.g $totals['discount'] = array(
120
+     * 		'initial'   => 10,
121
+     * 		'recurring' => 10,
122
+     * )
123 123
      *
124 124
      * @var array
125 125
      */
126
-	protected $totals = array();
126
+    protected $totals = array();
127 127
 
128
-	/**
128
+    /**
129 129
      * Tax rate.
130
-	 *
130
+     *
131 131
      * @var float
132 132
      */
133
-	protected $tax_rate = 0;
133
+    protected $tax_rate = 0;
134 134
 
135
-	/**
136
-	 * Stores the status transition information.
137
-	 *
138
-	 * @since 1.0.19
139
-	 * @var bool|array
140
-	 */
141
-	protected $status_transition = false;
135
+    /**
136
+     * Stores the status transition information.
137
+     *
138
+     * @since 1.0.19
139
+     * @var bool|array
140
+     */
141
+    protected $status_transition = false;
142 142
 
143 143
     /**
144
-	 * Get the invoice if ID is passed, otherwise the invoice is new and empty.
145
-	 *
146
-	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
147
-	 */
144
+     * Get the invoice if ID is passed, otherwise the invoice is new and empty.
145
+     *
146
+     * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
147
+     */
148 148
     public function __construct( $invoice = 0 ) {
149 149
 
150 150
         parent::__construct( $invoice );
151 151
 
152
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
153
-			$this->set_id( (int) $invoice );
154
-		} elseif ( $invoice instanceof self ) {
155
-			$this->set_id( $invoice->get_id() );
156
-		} elseif ( ! empty( $invoice->ID ) ) {
157
-			$this->set_id( $invoice->ID );
158
-		} elseif ( is_array( $invoice ) ) {
159
-			$this->set_props( $invoice );
160
-
161
-			if ( isset( $invoice['ID'] ) ) {
162
-				$this->set_id( $invoice['ID'] );
163
-			}
164
-
165
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
166
-			$this->set_id( $invoice_id );
167
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
168
-			$this->set_id( $invoice_id );
169
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
170
-			$this->set_id( $invoice_id );
171
-		} else {
172
-			$this->set_object_read( true );
173
-		}
152
+        if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
153
+            $this->set_id( (int) $invoice );
154
+        } elseif ( $invoice instanceof self ) {
155
+            $this->set_id( $invoice->get_id() );
156
+        } elseif ( ! empty( $invoice->ID ) ) {
157
+            $this->set_id( $invoice->ID );
158
+        } elseif ( is_array( $invoice ) ) {
159
+            $this->set_props( $invoice );
160
+
161
+            if ( isset( $invoice['ID'] ) ) {
162
+                $this->set_id( $invoice['ID'] );
163
+            }
164
+
165
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
166
+            $this->set_id( $invoice_id );
167
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
168
+            $this->set_id( $invoice_id );
169
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
170
+            $this->set_id( $invoice_id );
171
+        } else {
172
+            $this->set_object_read( true );
173
+        }
174 174
 
175 175
         // Load the datastore.
176
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
176
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
177 177
 
178
-		if ( $this->get_id() > 0 ) {
178
+        if ( $this->get_id() > 0 ) {
179 179
             $this->post = get_post( $this->get_id() );
180 180
             $this->ID   = $this->get_id();
181
-			$this->data_store->read( $this );
181
+            $this->data_store->read( $this );
182 182
         }
183 183
 
184 184
     }
185 185
 
186 186
     /**
187
-	 * Given an invoice key/number, it returns its id.
188
-	 *
189
-	 *
190
-	 * @static
191
-	 * @param string $value The invoice key or number
192
-	 * @param string $field Either key, transaction_id or number.
193
-	 * @since 1.0.15
194
-	 * @return int
195
-	 */
196
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
187
+     * Given an invoice key/number, it returns its id.
188
+     *
189
+     *
190
+     * @static
191
+     * @param string $value The invoice key or number
192
+     * @param string $field Either key, transaction_id or number.
193
+     * @since 1.0.15
194
+     * @return int
195
+     */
196
+    public static function get_invoice_id_by_field( $value, $field = 'key' ) {
197 197
         global $wpdb;
198 198
 
199
-		// Trim the value.
200
-		$value = trim( $value );
199
+        // Trim the value.
200
+        $value = trim( $value );
201 201
 
202
-		if ( empty( $value ) ) {
203
-			return 0;
204
-		}
202
+        if ( empty( $value ) ) {
203
+            return 0;
204
+        }
205 205
 
206 206
         // Valid fields.
207 207
         $fields = array( 'key', 'number', 'transaction_id' );
208 208
 
209
-		// Ensure a field has been passed.
210
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
211
-			return 0;
212
-		}
209
+        // Ensure a field has been passed.
210
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
211
+            return 0;
212
+        }
213 213
 
214
-		// Maybe retrieve from the cache.
215
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
216
-		if ( false !== $invoice_id ) {
217
-			return $invoice_id;
218
-		}
214
+        // Maybe retrieve from the cache.
215
+        $invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
216
+        if ( false !== $invoice_id ) {
217
+            return $invoice_id;
218
+        }
219 219
 
220 220
         // Fetch from the db.
221 221
         $table       = $wpdb->prefix . 'getpaid_invoices';
@@ -223,10 +223,10 @@  discard block
 block discarded – undo
223 223
             $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
224 224
         );
225 225
 
226
-		// Update the cache with our data
227
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
226
+        // Update the cache with our data
227
+        wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
228 228
 
229
-		return $invoice_id;
229
+        return $invoice_id;
230 230
     }
231 231
 
232 232
     /**
@@ -252,83 +252,83 @@  discard block
 block discarded – undo
252 252
     */
253 253
 
254 254
     /**
255
-	 * Get parent invoice ID.
256
-	 *
257
-	 * @since 1.0.19
258
-	 * @param  string $context View or edit context.
259
-	 * @return int
260
-	 */
261
-	public function get_parent_id( $context = 'view' ) {
262
-		return (int) $this->get_prop( 'parent_id', $context );
255
+     * Get parent invoice ID.
256
+     *
257
+     * @since 1.0.19
258
+     * @param  string $context View or edit context.
259
+     * @return int
260
+     */
261
+    public function get_parent_id( $context = 'view' ) {
262
+        return (int) $this->get_prop( 'parent_id', $context );
263 263
     }
264 264
 
265 265
     /**
266
-	 * Get parent invoice.
267
-	 *
268
-	 * @since 1.0.19
269
-	 * @return WPInv_Invoice
270
-	 */
266
+     * Get parent invoice.
267
+     *
268
+     * @since 1.0.19
269
+     * @return WPInv_Invoice
270
+     */
271 271
     public function get_parent_payment() {
272 272
         return new WPInv_Invoice( $this->get_parent_id() );
273 273
     }
274 274
 
275 275
     /**
276
-	 * Alias for self::get_parent_payment().
277
-	 *
278
-	 * @since 1.0.19
279
-	 * @return WPInv_Invoice
280
-	 */
276
+     * Alias for self::get_parent_payment().
277
+     *
278
+     * @since 1.0.19
279
+     * @return WPInv_Invoice
280
+     */
281 281
     public function get_parent() {
282 282
         return $this->get_parent_payment();
283 283
     }
284 284
 
285 285
     /**
286
-	 * Get invoice status.
287
-	 *
288
-	 * @since 1.0.19
289
-	 * @param  string $context View or edit context.
290
-	 * @return string
291
-	 */
292
-	public function get_status( $context = 'view' ) {
293
-		return $this->get_prop( 'status', $context );
294
-	}
286
+     * Get invoice status.
287
+     *
288
+     * @since 1.0.19
289
+     * @param  string $context View or edit context.
290
+     * @return string
291
+     */
292
+    public function get_status( $context = 'view' ) {
293
+        return $this->get_prop( 'status', $context );
294
+    }
295 295
 	
296
-	/**
297
-	 * Retrieves an array of possible invoice statuses.
298
-	 *
299
-	 * @since 1.0.19
300
-	 * @return array
301
-	 */
302
-	public function get_all_statuses() {
303
-		return wpinv_get_invoice_statuses( true, true, $this );
304
-    }
305
-
306
-    /**
307
-	 * Get invoice status nice name.
308
-	 *
309
-	 * @since 1.0.19
310
-	 * @return string
311
-	 */
296
+    /**
297
+     * Retrieves an array of possible invoice statuses.
298
+     *
299
+     * @since 1.0.19
300
+     * @return array
301
+     */
302
+    public function get_all_statuses() {
303
+        return wpinv_get_invoice_statuses( true, true, $this );
304
+    }
305
+
306
+    /**
307
+     * Get invoice status nice name.
308
+     *
309
+     * @since 1.0.19
310
+     * @return string
311
+     */
312 312
     public function get_status_nicename() {
313
-		$statuses = $this->get_all_statuses();
313
+        $statuses = $this->get_all_statuses();
314 314
 
315 315
         $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
316 316
 
317 317
         return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
318 318
     }
319 319
 
320
-	/**
321
-	 * Retrieves the invoice status class
322
-	 *
323
-	 * @since  1.0.19
324
-	 * @return string
325
-	 */
326
-	public function get_status_class() {
327
-		$statuses = getpaid_get_invoice_status_classes();
328
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
329
-	}
320
+    /**
321
+     * Retrieves the invoice status class
322
+     *
323
+     * @since  1.0.19
324
+     * @return string
325
+     */
326
+    public function get_status_class() {
327
+        $statuses = getpaid_get_invoice_status_classes();
328
+        return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
329
+    }
330 330
 
331
-	/**
331
+    /**
332 332
      * Retrieves the invoice status label html
333 333
      *
334 334
      * @since  1.0.0
@@ -336,263 +336,263 @@  discard block
 block discarded – undo
336 336
      */
337 337
     public function get_status_label_html() {
338 338
 
339
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
340
-		$status       = sanitize_html_class( $this->get_status() );
341
-		$class        = esc_attr( $this->get_status_class() );
339
+        $status_label = sanitize_text_field( $this->get_status_nicename() );
340
+        $status       = sanitize_html_class( $this->get_status() );
341
+        $class        = esc_attr( $this->get_status_class() );
342 342
 
343
-		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
344
-	}
343
+        return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
344
+    }
345 345
 
346 346
     /**
347
-	 * Get plugin version when the invoice was created.
348
-	 *
349
-	 * @since 1.0.19
350
-	 * @param  string $context View or edit context.
351
-	 * @return string
352
-	 */
353
-	public function get_version( $context = 'view' ) {
354
-		return $this->get_prop( 'version', $context );
355
-	}
347
+     * Get plugin version when the invoice was created.
348
+     *
349
+     * @since 1.0.19
350
+     * @param  string $context View or edit context.
351
+     * @return string
352
+     */
353
+    public function get_version( $context = 'view' ) {
354
+        return $this->get_prop( 'version', $context );
355
+    }
356 356
 
357
-	/**
358
-	 * @deprecated
359
-	 */
360
-	public function get_invoice_date( $format = true ) {
361
-		$date      = getpaid_format_date( $this->get_date_completed() );
362
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
363
-		$formatted = getpaid_format_date( $date );
357
+    /**
358
+     * @deprecated
359
+     */
360
+    public function get_invoice_date( $format = true ) {
361
+        $date      = getpaid_format_date( $this->get_date_completed() );
362
+        $date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
363
+        $formatted = getpaid_format_date( $date );
364 364
 
365
-		if ( $format ) {
366
-			return $formatted;
367
-		}
365
+        if ( $format ) {
366
+            return $formatted;
367
+        }
368 368
 
369
-		return empty( $formatted ) ? '' : $date;
369
+        return empty( $formatted ) ? '' : $date;
370 370
 
371 371
     }
372 372
 
373 373
     /**
374
-	 * Get date when the invoice was created.
375
-	 *
376
-	 * @since 1.0.19
377
-	 * @param  string $context View or edit context.
378
-	 * @return string
379
-	 */
380
-	public function get_date_created( $context = 'view' ) {
381
-		return $this->get_prop( 'date_created', $context );
382
-	}
374
+     * Get date when the invoice was created.
375
+     *
376
+     * @since 1.0.19
377
+     * @param  string $context View or edit context.
378
+     * @return string
379
+     */
380
+    public function get_date_created( $context = 'view' ) {
381
+        return $this->get_prop( 'date_created', $context );
382
+    }
383 383
 	
384
-	/**
385
-	 * Alias for self::get_date_created().
386
-	 *
387
-	 * @since 1.0.19
388
-	 * @param  string $context View or edit context.
389
-	 * @return string
390
-	 */
391
-	public function get_created_date( $context = 'view' ) {
392
-		return $this->get_date_created( $context );
393
-    }
394
-
395
-    /**
396
-	 * Get GMT date when the invoice was created.
397
-	 *
398
-	 * @since 1.0.19
399
-	 * @param  string $context View or edit context.
400
-	 * @return string
401
-	 */
402
-	public function get_date_created_gmt( $context = 'view' ) {
384
+    /**
385
+     * Alias for self::get_date_created().
386
+     *
387
+     * @since 1.0.19
388
+     * @param  string $context View or edit context.
389
+     * @return string
390
+     */
391
+    public function get_created_date( $context = 'view' ) {
392
+        return $this->get_date_created( $context );
393
+    }
394
+
395
+    /**
396
+     * Get GMT date when the invoice was created.
397
+     *
398
+     * @since 1.0.19
399
+     * @param  string $context View or edit context.
400
+     * @return string
401
+     */
402
+    public function get_date_created_gmt( $context = 'view' ) {
403 403
         $date = $this->get_date_created( $context );
404 404
 
405 405
         if ( $date ) {
406 406
             $date = get_gmt_from_date( $date );
407 407
         }
408
-		return $date;
408
+        return $date;
409 409
     }
410 410
 
411 411
     /**
412
-	 * Get date when the invoice was last modified.
413
-	 *
414
-	 * @since 1.0.19
415
-	 * @param  string $context View or edit context.
416
-	 * @return string
417
-	 */
418
-	public function get_date_modified( $context = 'view' ) {
419
-		return $this->get_prop( 'date_modified', $context );
420
-	}
412
+     * Get date when the invoice was last modified.
413
+     *
414
+     * @since 1.0.19
415
+     * @param  string $context View or edit context.
416
+     * @return string
417
+     */
418
+    public function get_date_modified( $context = 'view' ) {
419
+        return $this->get_prop( 'date_modified', $context );
420
+    }
421 421
 
422
-	/**
423
-	 * Alias for self::get_date_modified().
424
-	 *
425
-	 * @since 1.0.19
426
-	 * @param  string $context View or edit context.
427
-	 * @return string
428
-	 */
429
-	public function get_modified_date( $context = 'view' ) {
430
-		return $this->get_date_modified( $context );
422
+    /**
423
+     * Alias for self::get_date_modified().
424
+     *
425
+     * @since 1.0.19
426
+     * @param  string $context View or edit context.
427
+     * @return string
428
+     */
429
+    public function get_modified_date( $context = 'view' ) {
430
+        return $this->get_date_modified( $context );
431 431
     }
432 432
 
433 433
     /**
434
-	 * Get GMT date when the invoice was last modified.
435
-	 *
436
-	 * @since 1.0.19
437
-	 * @param  string $context View or edit context.
438
-	 * @return string
439
-	 */
440
-	public function get_date_modified_gmt( $context = 'view' ) {
434
+     * Get GMT date when the invoice was last modified.
435
+     *
436
+     * @since 1.0.19
437
+     * @param  string $context View or edit context.
438
+     * @return string
439
+     */
440
+    public function get_date_modified_gmt( $context = 'view' ) {
441 441
         $date = $this->get_date_modified( $context );
442 442
 
443 443
         if ( $date ) {
444 444
             $date = get_gmt_from_date( $date );
445 445
         }
446
-		return $date;
446
+        return $date;
447 447
     }
448 448
 
449 449
     /**
450
-	 * Get the invoice due date.
451
-	 *
452
-	 * @since 1.0.19
453
-	 * @param  string $context View or edit context.
454
-	 * @return string
455
-	 */
456
-	public function get_due_date( $context = 'view' ) {
457
-		return $this->get_prop( 'due_date', $context );
450
+     * Get the invoice due date.
451
+     *
452
+     * @since 1.0.19
453
+     * @param  string $context View or edit context.
454
+     * @return string
455
+     */
456
+    public function get_due_date( $context = 'view' ) {
457
+        return $this->get_prop( 'due_date', $context );
458 458
     }
459 459
 
460 460
     /**
461
-	 * Alias for self::get_due_date().
462
-	 *
463
-	 * @since 1.0.19
464
-	 * @param  string $context View or edit context.
465
-	 * @return string
466
-	 */
467
-	public function get_date_due( $context = 'view' ) {
468
-		return $this->get_due_date( $context );
461
+     * Alias for self::get_due_date().
462
+     *
463
+     * @since 1.0.19
464
+     * @param  string $context View or edit context.
465
+     * @return string
466
+     */
467
+    public function get_date_due( $context = 'view' ) {
468
+        return $this->get_due_date( $context );
469 469
     }
470 470
 
471 471
     /**
472
-	 * Get the invoice GMT due date.
473
-	 *
474
-	 * @since 1.0.19
475
-	 * @param  string $context View or edit context.
476
-	 * @return string
477
-	 */
478
-	public function get_due_date_gmt( $context = 'view' ) {
472
+     * Get the invoice GMT due date.
473
+     *
474
+     * @since 1.0.19
475
+     * @param  string $context View or edit context.
476
+     * @return string
477
+     */
478
+    public function get_due_date_gmt( $context = 'view' ) {
479 479
         $date = $this->get_due_date( $context );
480 480
 
481 481
         if ( $date ) {
482 482
             $date = get_gmt_from_date( $date );
483 483
         }
484
-		return $date;
484
+        return $date;
485 485
     }
486 486
 
487 487
     /**
488
-	 * Alias for self::get_due_date_gmt().
489
-	 *
490
-	 * @since 1.0.19
491
-	 * @param  string $context View or edit context.
492
-	 * @return string
493
-	 */
494
-	public function get_gmt_date_due( $context = 'view' ) {
495
-		return $this->get_due_date_gmt( $context );
488
+     * Alias for self::get_due_date_gmt().
489
+     *
490
+     * @since 1.0.19
491
+     * @param  string $context View or edit context.
492
+     * @return string
493
+     */
494
+    public function get_gmt_date_due( $context = 'view' ) {
495
+        return $this->get_due_date_gmt( $context );
496 496
     }
497 497
 
498 498
     /**
499
-	 * Get date when the invoice was completed.
500
-	 *
501
-	 * @since 1.0.19
502
-	 * @param  string $context View or edit context.
503
-	 * @return string
504
-	 */
505
-	public function get_completed_date( $context = 'view' ) {
506
-		return $this->get_prop( 'completed_date', $context );
499
+     * Get date when the invoice was completed.
500
+     *
501
+     * @since 1.0.19
502
+     * @param  string $context View or edit context.
503
+     * @return string
504
+     */
505
+    public function get_completed_date( $context = 'view' ) {
506
+        return $this->get_prop( 'completed_date', $context );
507 507
     }
508 508
 
509 509
     /**
510
-	 * Alias for self::get_completed_date().
511
-	 *
512
-	 * @since 1.0.19
513
-	 * @param  string $context View or edit context.
514
-	 * @return string
515
-	 */
516
-	public function get_date_completed( $context = 'view' ) {
517
-		return $this->get_completed_date( $context );
510
+     * Alias for self::get_completed_date().
511
+     *
512
+     * @since 1.0.19
513
+     * @param  string $context View or edit context.
514
+     * @return string
515
+     */
516
+    public function get_date_completed( $context = 'view' ) {
517
+        return $this->get_completed_date( $context );
518 518
     }
519 519
 
520 520
     /**
521
-	 * Get GMT date when the invoice was was completed.
522
-	 *
523
-	 * @since 1.0.19
524
-	 * @param  string $context View or edit context.
525
-	 * @return string
526
-	 */
527
-	public function get_completed_date_gmt( $context = 'view' ) {
521
+     * Get GMT date when the invoice was was completed.
522
+     *
523
+     * @since 1.0.19
524
+     * @param  string $context View or edit context.
525
+     * @return string
526
+     */
527
+    public function get_completed_date_gmt( $context = 'view' ) {
528 528
         $date = $this->get_completed_date( $context );
529 529
 
530 530
         if ( $date ) {
531 531
             $date = get_gmt_from_date( $date );
532 532
         }
533
-		return $date;
533
+        return $date;
534 534
     }
535 535
 
536 536
     /**
537
-	 * Alias for self::get_completed_date_gmt().
538
-	 *
539
-	 * @since 1.0.19
540
-	 * @param  string $context View or edit context.
541
-	 * @return string
542
-	 */
543
-	public function get_gmt_completed_date( $context = 'view' ) {
544
-		return $this->get_completed_date_gmt( $context );
537
+     * Alias for self::get_completed_date_gmt().
538
+     *
539
+     * @since 1.0.19
540
+     * @param  string $context View or edit context.
541
+     * @return string
542
+     */
543
+    public function get_gmt_completed_date( $context = 'view' ) {
544
+        return $this->get_completed_date_gmt( $context );
545 545
     }
546 546
 
547 547
     /**
548
-	 * Get the invoice number.
549
-	 *
550
-	 * @since 1.0.19
551
-	 * @param  string $context View or edit context.
552
-	 * @return string
553
-	 */
554
-	public function get_number( $context = 'view' ) {
555
-		$number = $this->get_prop( 'number', $context );
548
+     * Get the invoice number.
549
+     *
550
+     * @since 1.0.19
551
+     * @param  string $context View or edit context.
552
+     * @return string
553
+     */
554
+    public function get_number( $context = 'view' ) {
555
+        $number = $this->get_prop( 'number', $context );
556 556
 
557
-		if ( empty( $number ) ) {
558
-			$number = $this->generate_number();
559
-			$this->set_number( $this->generate_number() );
560
-		}
557
+        if ( empty( $number ) ) {
558
+            $number = $this->generate_number();
559
+            $this->set_number( $this->generate_number() );
560
+        }
561 561
 
562
-		return $number;
562
+        return $number;
563 563
     }
564 564
 
565
-	/**
566
-	 * Set the invoice number.
567
-	 *
568
-	 * @since 1.0.19
569
-	 */
570
-	public function maybe_set_number() {
565
+    /**
566
+     * Set the invoice number.
567
+     *
568
+     * @since 1.0.19
569
+     */
570
+    public function maybe_set_number() {
571 571
         $number = $this->get_number();
572 572
 
573 573
         if ( empty( $number ) || $this->get_id() == $number ) {
574
-			$this->set_number( $this->generate_number() );
574
+            $this->set_number( $this->generate_number() );
575 575
         }
576 576
 
577
-	}
577
+    }
578 578
 
579 579
     /**
580
-	 * Get the invoice key.
581
-	 *
582
-	 * @since 1.0.19
583
-	 * @param  string $context View or edit context.
584
-	 * @return string
585
-	 */
586
-	public function get_key( $context = 'view' ) {
580
+     * Get the invoice key.
581
+     *
582
+     * @since 1.0.19
583
+     * @param  string $context View or edit context.
584
+     * @return string
585
+     */
586
+    public function get_key( $context = 'view' ) {
587 587
         return $this->get_prop( 'key', $context );
588
-	}
589
-
590
-	/**
591
-	 * Set the invoice key.
592
-	 *
593
-	 * @since 1.0.19
594
-	 */
595
-	public function maybe_set_key() {
588
+    }
589
+
590
+    /**
591
+     * Set the invoice key.
592
+     *
593
+     * @since 1.0.19
594
+     */
595
+    public function maybe_set_key() {
596 596
         $key = $this->get_key();
597 597
 
598 598
         if ( empty( $key ) ) {
@@ -603,140 +603,140 @@  discard block
 block discarded – undo
603 603
     }
604 604
 
605 605
     /**
606
-	 * Get the invoice type.
607
-	 *
608
-	 * @since 1.0.19
609
-	 * @param  string $context View or edit context.
610
-	 * @return string
611
-	 */
612
-	public function get_type( $context = 'view' ) {
606
+     * Get the invoice type.
607
+     *
608
+     * @since 1.0.19
609
+     * @param  string $context View or edit context.
610
+     * @return string
611
+     */
612
+    public function get_type( $context = 'view' ) {
613 613
         return $this->get_prop( 'type', $context );
614
-	}
615
-
616
-	/**
617
-	 * Returns the post type name.
618
-	 *
619
-	 * @since 1.0.19
620
-	 * @return string
621
-	 */
622
-	public function get_invoice_quote_type() {
614
+    }
615
+
616
+    /**
617
+     * Returns the post type name.
618
+     *
619
+     * @since 1.0.19
620
+     * @return string
621
+     */
622
+    public function get_invoice_quote_type() {
623 623
         return getpaid_get_post_type_label( $this->get_post_type(), false );
624 624
     }
625 625
 
626 626
     /**
627
-	 * Get the invoice post type label.
628
-	 *
629
-	 * @since 1.0.19
630
-	 * @param  string $context View or edit context.
631
-	 * @return string
632
-	 */
633
-	public function get_label( $context = 'view' ) {
627
+     * Get the invoice post type label.
628
+     *
629
+     * @since 1.0.19
630
+     * @param  string $context View or edit context.
631
+     * @return string
632
+     */
633
+    public function get_label( $context = 'view' ) {
634 634
         return getpaid_get_post_type_label( $this->get_post_type( $context ), false );
635
-	}
636
-
637
-	/**
638
-	 * Get the invoice post type.
639
-	 *
640
-	 * @since 1.0.19
641
-	 * @param  string $context View or edit context.
642
-	 * @return string
643
-	 */
644
-	public function get_post_type( $context = 'view' ) {
635
+    }
636
+
637
+    /**
638
+     * Get the invoice post type.
639
+     *
640
+     * @since 1.0.19
641
+     * @param  string $context View or edit context.
642
+     * @return string
643
+     */
644
+    public function get_post_type( $context = 'view' ) {
645 645
         return $this->get_prop( 'post_type', $context );
646 646
     }
647 647
 
648 648
     /**
649
-	 * Get the invoice mode.
650
-	 *
651
-	 * @since 1.0.19
652
-	 * @param  string $context View or edit context.
653
-	 * @return string
654
-	 */
655
-	public function get_mode( $context = 'view' ) {
649
+     * Get the invoice mode.
650
+     *
651
+     * @since 1.0.19
652
+     * @param  string $context View or edit context.
653
+     * @return string
654
+     */
655
+    public function get_mode( $context = 'view' ) {
656 656
         return $this->get_prop( 'mode', $context );
657 657
     }
658 658
 
659 659
     /**
660
-	 * Get the invoice path.
661
-	 *
662
-	 * @since 1.0.19
663
-	 * @param  string $context View or edit context.
664
-	 * @return string
665
-	 */
666
-	public function get_path( $context = 'view' ) {
660
+     * Get the invoice path.
661
+     *
662
+     * @since 1.0.19
663
+     * @param  string $context View or edit context.
664
+     * @return string
665
+     */
666
+    public function get_path( $context = 'view' ) {
667 667
         $path   = $this->get_prop( 'path', $context );
668
-		$prefix = $this->get_type();
668
+        $prefix = $this->get_type();
669 669
 
670
-		if ( 0 !== strpos( $path, $prefix ) ) {
671
-			$path = sanitize_title(  $prefix . '-' . $this->get_id()  );
672
-			$this->set_path( $path );
673
-		}
670
+        if ( 0 !== strpos( $path, $prefix ) ) {
671
+            $path = sanitize_title(  $prefix . '-' . $this->get_id()  );
672
+            $this->set_path( $path );
673
+        }
674 674
 
675
-		return $path;
675
+        return $path;
676 676
     }
677 677
 
678 678
     /**
679
-	 * Get the invoice name/title.
680
-	 *
681
-	 * @since 1.0.19
682
-	 * @param  string $context View or edit context.
683
-	 * @return string
684
-	 */
685
-	public function get_name( $context = 'view' ) {
679
+     * Get the invoice name/title.
680
+     *
681
+     * @since 1.0.19
682
+     * @param  string $context View or edit context.
683
+     * @return string
684
+     */
685
+    public function get_name( $context = 'view' ) {
686 686
         return $this->get_prop( 'title', $context );
687 687
     }
688 688
 
689 689
     /**
690
-	 * Alias of self::get_name().
691
-	 *
692
-	 * @since 1.0.19
693
-	 * @param  string $context View or edit context.
694
-	 * @return string
695
-	 */
696
-	public function get_title( $context = 'view' ) {
697
-		return $this->get_name( $context );
690
+     * Alias of self::get_name().
691
+     *
692
+     * @since 1.0.19
693
+     * @param  string $context View or edit context.
694
+     * @return string
695
+     */
696
+    public function get_title( $context = 'view' ) {
697
+        return $this->get_name( $context );
698 698
     }
699 699
 
700 700
     /**
701
-	 * Get the invoice description.
702
-	 *
703
-	 * @since 1.0.19
704
-	 * @param  string $context View or edit context.
705
-	 * @return string
706
-	 */
707
-	public function get_description( $context = 'view' ) {
708
-		return $this->get_prop( 'description', $context );
701
+     * Get the invoice description.
702
+     *
703
+     * @since 1.0.19
704
+     * @param  string $context View or edit context.
705
+     * @return string
706
+     */
707
+    public function get_description( $context = 'view' ) {
708
+        return $this->get_prop( 'description', $context );
709 709
     }
710 710
 
711 711
     /**
712
-	 * Alias of self::get_description().
713
-	 *
714
-	 * @since 1.0.19
715
-	 * @param  string $context View or edit context.
716
-	 * @return string
717
-	 */
718
-	public function get_excerpt( $context = 'view' ) {
719
-		return $this->get_description( $context );
712
+     * Alias of self::get_description().
713
+     *
714
+     * @since 1.0.19
715
+     * @param  string $context View or edit context.
716
+     * @return string
717
+     */
718
+    public function get_excerpt( $context = 'view' ) {
719
+        return $this->get_description( $context );
720 720
     }
721 721
 
722 722
     /**
723
-	 * Alias of self::get_description().
724
-	 *
725
-	 * @since 1.0.19
726
-	 * @param  string $context View or edit context.
727
-	 * @return string
728
-	 */
729
-	public function get_summary( $context = 'view' ) {
730
-		return $this->get_description( $context );
723
+     * Alias of self::get_description().
724
+     *
725
+     * @since 1.0.19
726
+     * @param  string $context View or edit context.
727
+     * @return string
728
+     */
729
+    public function get_summary( $context = 'view' ) {
730
+        return $this->get_description( $context );
731 731
     }
732 732
 
733 733
     /**
734
-	 * Returns the user info.
735
-	 *
736
-	 * @since 1.0.19
734
+     * Returns the user info.
735
+     *
736
+     * @since 1.0.19
737 737
      * @param  string $context View or edit context.
738
-	 * @return array
739
-	 */
738
+     * @return array
739
+     */
740 740
     public function get_user_info( $context = 'view' ) {
741 741
 
742 742
         $user_info = array(
@@ -751,669 +751,669 @@  discard block
 block discarded – undo
751 751
             'state'      => $this->get_state( $context ),
752 752
             'zip'        => $this->get_zip( $context ),
753 753
             'company'    => $this->get_company( $context ),
754
-			'company_id' => $this->get_company_id( $context ),
754
+            'company_id' => $this->get_company_id( $context ),
755 755
             'vat_number' => $this->get_vat_number( $context ),
756 756
             'discount'   => $this->get_discount_code( $context ),
757
-		);
757
+        );
758 758
 
759
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
759
+        return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
760 760
 
761 761
     }
762 762
 
763 763
     /**
764
-	 * Get the customer id.
765
-	 *
766
-	 * @since 1.0.19
767
-	 * @param  string $context View or edit context.
768
-	 * @return int
769
-	 */
770
-	public function get_author( $context = 'view' ) {
771
-		return (int) $this->get_prop( 'author', $context );
764
+     * Get the customer id.
765
+     *
766
+     * @since 1.0.19
767
+     * @param  string $context View or edit context.
768
+     * @return int
769
+     */
770
+    public function get_author( $context = 'view' ) {
771
+        return (int) $this->get_prop( 'author', $context );
772 772
     }
773 773
 
774 774
     /**
775
-	 * Alias of self::get_author().
776
-	 *
777
-	 * @since 1.0.19
778
-	 * @param  string $context View or edit context.
779
-	 * @return int
780
-	 */
781
-	public function get_user_id( $context = 'view' ) {
782
-		return $this->get_author( $context );
775
+     * Alias of self::get_author().
776
+     *
777
+     * @since 1.0.19
778
+     * @param  string $context View or edit context.
779
+     * @return int
780
+     */
781
+    public function get_user_id( $context = 'view' ) {
782
+        return $this->get_author( $context );
783 783
     }
784 784
 
785
-     /**
786
-	 * Alias of self::get_author().
787
-	 *
788
-	 * @since 1.0.19
789
-	 * @param  string $context View or edit context.
790
-	 * @return int
791
-	 */
792
-	public function get_customer_id( $context = 'view' ) {
793
-		return $this->get_author( $context );
785
+        /**
786
+         * Alias of self::get_author().
787
+         *
788
+         * @since 1.0.19
789
+         * @param  string $context View or edit context.
790
+         * @return int
791
+         */
792
+    public function get_customer_id( $context = 'view' ) {
793
+        return $this->get_author( $context );
794 794
     }
795 795
 
796 796
     /**
797
-	 * Get the customer's ip.
798
-	 *
799
-	 * @since 1.0.19
800
-	 * @param  string $context View or edit context.
801
-	 * @return string
802
-	 */
803
-	public function get_ip( $context = 'view' ) {
804
-		return $this->get_prop( 'user_ip', $context );
797
+     * Get the customer's ip.
798
+     *
799
+     * @since 1.0.19
800
+     * @param  string $context View or edit context.
801
+     * @return string
802
+     */
803
+    public function get_ip( $context = 'view' ) {
804
+        return $this->get_prop( 'user_ip', $context );
805 805
     }
806 806
 
807 807
     /**
808
-	 * Alias of self::get_ip().
809
-	 *
810
-	 * @since 1.0.19
811
-	 * @param  string $context View or edit context.
812
-	 * @return string
813
-	 */
814
-	public function get_user_ip( $context = 'view' ) {
815
-		return $this->get_ip( $context );
808
+     * Alias of self::get_ip().
809
+     *
810
+     * @since 1.0.19
811
+     * @param  string $context View or edit context.
812
+     * @return string
813
+     */
814
+    public function get_user_ip( $context = 'view' ) {
815
+        return $this->get_ip( $context );
816 816
     }
817 817
 
818
-     /**
819
-	 * Alias of self::get_ip().
820
-	 *
821
-	 * @since 1.0.19
822
-	 * @param  string $context View or edit context.
823
-	 * @return string
824
-	 */
825
-	public function get_customer_ip( $context = 'view' ) {
826
-		return $this->get_ip( $context );
818
+        /**
819
+         * Alias of self::get_ip().
820
+         *
821
+         * @since 1.0.19
822
+         * @param  string $context View or edit context.
823
+         * @return string
824
+         */
825
+    public function get_customer_ip( $context = 'view' ) {
826
+        return $this->get_ip( $context );
827 827
     }
828 828
 
829 829
     /**
830
-	 * Get the customer's first name.
831
-	 *
832
-	 * @since 1.0.19
833
-	 * @param  string $context View or edit context.
834
-	 * @return string
835
-	 */
836
-	public function get_first_name( $context = 'view' ) {
837
-		return $this->get_prop( 'first_name', $context );
830
+     * Get the customer's first name.
831
+     *
832
+     * @since 1.0.19
833
+     * @param  string $context View or edit context.
834
+     * @return string
835
+     */
836
+    public function get_first_name( $context = 'view' ) {
837
+        return $this->get_prop( 'first_name', $context );
838 838
     }
839 839
 
840 840
     /**
841
-	 * Alias of self::get_first_name().
842
-	 *
843
-	 * @since 1.0.19
844
-	 * @param  string $context View or edit context.
845
-	 * @return string
846
-	 */
847
-	public function get_user_first_name( $context = 'view' ) {
848
-		return $this->get_first_name( $context );
841
+     * Alias of self::get_first_name().
842
+     *
843
+     * @since 1.0.19
844
+     * @param  string $context View or edit context.
845
+     * @return string
846
+     */
847
+    public function get_user_first_name( $context = 'view' ) {
848
+        return $this->get_first_name( $context );
849 849
     }
850 850
 
851
-     /**
852
-	 * Alias of self::get_first_name().
853
-	 *
854
-	 * @since 1.0.19
855
-	 * @param  string $context View or edit context.
856
-	 * @return string
857
-	 */
858
-	public function get_customer_first_name( $context = 'view' ) {
859
-		return $this->get_first_name( $context );
851
+        /**
852
+         * Alias of self::get_first_name().
853
+         *
854
+         * @since 1.0.19
855
+         * @param  string $context View or edit context.
856
+         * @return string
857
+         */
858
+    public function get_customer_first_name( $context = 'view' ) {
859
+        return $this->get_first_name( $context );
860 860
     }
861 861
 
862 862
     /**
863
-	 * Get the customer's last name.
864
-	 *
865
-	 * @since 1.0.19
866
-	 * @param  string $context View or edit context.
867
-	 * @return string
868
-	 */
869
-	public function get_last_name( $context = 'view' ) {
870
-		return $this->get_prop( 'last_name', $context );
863
+     * Get the customer's last name.
864
+     *
865
+     * @since 1.0.19
866
+     * @param  string $context View or edit context.
867
+     * @return string
868
+     */
869
+    public function get_last_name( $context = 'view' ) {
870
+        return $this->get_prop( 'last_name', $context );
871 871
     }
872 872
 
873 873
     /**
874
-	 * Alias of self::get_last_name().
875
-	 *
876
-	 * @since 1.0.19
877
-	 * @param  string $context View or edit context.
878
-	 * @return string
879
-	 */
880
-	public function get_user_last_name( $context = 'view' ) {
881
-		return $this->get_last_name( $context );
874
+     * Alias of self::get_last_name().
875
+     *
876
+     * @since 1.0.19
877
+     * @param  string $context View or edit context.
878
+     * @return string
879
+     */
880
+    public function get_user_last_name( $context = 'view' ) {
881
+        return $this->get_last_name( $context );
882 882
     }
883 883
 
884 884
     /**
885
-	 * Alias of self::get_last_name().
886
-	 *
887
-	 * @since 1.0.19
888
-	 * @param  string $context View or edit context.
889
-	 * @return string
890
-	 */
891
-	public function get_customer_last_name( $context = 'view' ) {
892
-		return $this->get_last_name( $context );
885
+     * Alias of self::get_last_name().
886
+     *
887
+     * @since 1.0.19
888
+     * @param  string $context View or edit context.
889
+     * @return string
890
+     */
891
+    public function get_customer_last_name( $context = 'view' ) {
892
+        return $this->get_last_name( $context );
893 893
     }
894 894
 
895 895
     /**
896
-	 * Get the customer's full name.
897
-	 *
898
-	 * @since 1.0.19
899
-	 * @param  string $context View or edit context.
900
-	 * @return string
901
-	 */
902
-	public function get_full_name( $context = 'view' ) {
903
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
896
+     * Get the customer's full name.
897
+     *
898
+     * @since 1.0.19
899
+     * @param  string $context View or edit context.
900
+     * @return string
901
+     */
902
+    public function get_full_name( $context = 'view' ) {
903
+        return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
904 904
     }
905 905
 
906 906
     /**
907
-	 * Alias of self::get_full_name().
908
-	 *
909
-	 * @since 1.0.19
910
-	 * @param  string $context View or edit context.
911
-	 * @return string
912
-	 */
913
-	public function get_user_full_name( $context = 'view' ) {
914
-		return $this->get_full_name( $context );
907
+     * Alias of self::get_full_name().
908
+     *
909
+     * @since 1.0.19
910
+     * @param  string $context View or edit context.
911
+     * @return string
912
+     */
913
+    public function get_user_full_name( $context = 'view' ) {
914
+        return $this->get_full_name( $context );
915 915
     }
916 916
 
917 917
     /**
918
-	 * Alias of self::get_full_name().
919
-	 *
920
-	 * @since 1.0.19
921
-	 * @param  string $context View or edit context.
922
-	 * @return string
923
-	 */
924
-	public function get_customer_full_name( $context = 'view' ) {
925
-		return $this->get_full_name( $context );
918
+     * Alias of self::get_full_name().
919
+     *
920
+     * @since 1.0.19
921
+     * @param  string $context View or edit context.
922
+     * @return string
923
+     */
924
+    public function get_customer_full_name( $context = 'view' ) {
925
+        return $this->get_full_name( $context );
926 926
     }
927 927
 
928 928
     /**
929
-	 * Get the customer's phone number.
930
-	 *
931
-	 * @since 1.0.19
932
-	 * @param  string $context View or edit context.
933
-	 * @return string
934
-	 */
935
-	public function get_phone( $context = 'view' ) {
936
-		return $this->get_prop( 'phone', $context );
929
+     * Get the customer's phone number.
930
+     *
931
+     * @since 1.0.19
932
+     * @param  string $context View or edit context.
933
+     * @return string
934
+     */
935
+    public function get_phone( $context = 'view' ) {
936
+        return $this->get_prop( 'phone', $context );
937 937
     }
938 938
 
939 939
     /**
940
-	 * Alias of self::get_phone().
941
-	 *
942
-	 * @since 1.0.19
943
-	 * @param  string $context View or edit context.
944
-	 * @return string
945
-	 */
946
-	public function get_phone_number( $context = 'view' ) {
947
-		return $this->get_phone( $context );
940
+     * Alias of self::get_phone().
941
+     *
942
+     * @since 1.0.19
943
+     * @param  string $context View or edit context.
944
+     * @return string
945
+     */
946
+    public function get_phone_number( $context = 'view' ) {
947
+        return $this->get_phone( $context );
948 948
     }
949 949
 
950 950
     /**
951
-	 * Alias of self::get_phone().
952
-	 *
953
-	 * @since 1.0.19
954
-	 * @param  string $context View or edit context.
955
-	 * @return string
956
-	 */
957
-	public function get_user_phone( $context = 'view' ) {
958
-		return $this->get_phone( $context );
959
-    }
960
-
951
+     * Alias of self::get_phone().
952
+     *
953
+     * @since 1.0.19
954
+     * @param  string $context View or edit context.
955
+     * @return string
956
+     */
957
+    public function get_user_phone( $context = 'view' ) {
958
+        return $this->get_phone( $context );
959
+    }
960
+
961 961
     /**
962
-	 * Alias of self::get_phone().
963
-	 *
964
-	 * @since 1.0.19
965
-	 * @param  string $context View or edit context.
966
-	 * @return string
967
-	 */
968
-	public function get_customer_phone( $context = 'view' ) {
969
-		return $this->get_phone( $context );
962
+     * Alias of self::get_phone().
963
+     *
964
+     * @since 1.0.19
965
+     * @param  string $context View or edit context.
966
+     * @return string
967
+     */
968
+    public function get_customer_phone( $context = 'view' ) {
969
+        return $this->get_phone( $context );
970 970
     }
971 971
 
972 972
     /**
973
-	 * Get the customer's email address.
974
-	 *
975
-	 * @since 1.0.19
976
-	 * @param  string $context View or edit context.
977
-	 * @return string
978
-	 */
979
-	public function get_email( $context = 'view' ) {
980
-		return $this->get_prop( 'email', $context );
973
+     * Get the customer's email address.
974
+     *
975
+     * @since 1.0.19
976
+     * @param  string $context View or edit context.
977
+     * @return string
978
+     */
979
+    public function get_email( $context = 'view' ) {
980
+        return $this->get_prop( 'email', $context );
981 981
     }
982 982
 
983 983
     /**
984
-	 * Alias of self::get_email().
985
-	 *
986
-	 * @since 1.0.19
987
-	 * @param  string $context View or edit context.
988
-	 * @return string
989
-	 */
990
-	public function get_email_address( $context = 'view' ) {
991
-		return $this->get_email( $context );
984
+     * Alias of self::get_email().
985
+     *
986
+     * @since 1.0.19
987
+     * @param  string $context View or edit context.
988
+     * @return string
989
+     */
990
+    public function get_email_address( $context = 'view' ) {
991
+        return $this->get_email( $context );
992 992
     }
993 993
 
994 994
     /**
995
-	 * Alias of self::get_email().
996
-	 *
997
-	 * @since 1.0.19
998
-	 * @param  string $context View or edit context.
999
-	 * @return string
1000
-	 */
1001
-	public function get_user_email( $context = 'view' ) {
1002
-		return $this->get_email( $context );
995
+     * Alias of self::get_email().
996
+     *
997
+     * @since 1.0.19
998
+     * @param  string $context View or edit context.
999
+     * @return string
1000
+     */
1001
+    public function get_user_email( $context = 'view' ) {
1002
+        return $this->get_email( $context );
1003 1003
     }
1004 1004
 
1005 1005
     /**
1006
-	 * Alias of self::get_email().
1007
-	 *
1008
-	 * @since 1.0.19
1009
-	 * @param  string $context View or edit context.
1010
-	 * @return string
1011
-	 */
1012
-	public function get_customer_email( $context = 'view' ) {
1013
-		return $this->get_email( $context );
1006
+     * Alias of self::get_email().
1007
+     *
1008
+     * @since 1.0.19
1009
+     * @param  string $context View or edit context.
1010
+     * @return string
1011
+     */
1012
+    public function get_customer_email( $context = 'view' ) {
1013
+        return $this->get_email( $context );
1014 1014
     }
1015 1015
 
1016 1016
     /**
1017
-	 * Get the customer's country.
1018
-	 *
1019
-	 * @since 1.0.19
1020
-	 * @param  string $context View or edit context.
1021
-	 * @return string
1022
-	 */
1023
-	public function get_country( $context = 'view' ) {
1024
-		$country = $this->get_prop( 'country', $context );
1025
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1017
+     * Get the customer's country.
1018
+     *
1019
+     * @since 1.0.19
1020
+     * @param  string $context View or edit context.
1021
+     * @return string
1022
+     */
1023
+    public function get_country( $context = 'view' ) {
1024
+        $country = $this->get_prop( 'country', $context );
1025
+        return empty( $country ) ? wpinv_get_default_country() : $country;
1026 1026
     }
1027 1027
 
1028 1028
     /**
1029
-	 * Alias of self::get_country().
1030
-	 *
1031
-	 * @since 1.0.19
1032
-	 * @param  string $context View or edit context.
1033
-	 * @return string
1034
-	 */
1035
-	public function get_user_country( $context = 'view' ) {
1036
-		return $this->get_country( $context );
1029
+     * Alias of self::get_country().
1030
+     *
1031
+     * @since 1.0.19
1032
+     * @param  string $context View or edit context.
1033
+     * @return string
1034
+     */
1035
+    public function get_user_country( $context = 'view' ) {
1036
+        return $this->get_country( $context );
1037 1037
     }
1038 1038
 
1039 1039
     /**
1040
-	 * Alias of self::get_country().
1041
-	 *
1042
-	 * @since 1.0.19
1043
-	 * @param  string $context View or edit context.
1044
-	 * @return string
1045
-	 */
1046
-	public function get_customer_country( $context = 'view' ) {
1047
-		return $this->get_country( $context );
1040
+     * Alias of self::get_country().
1041
+     *
1042
+     * @since 1.0.19
1043
+     * @param  string $context View or edit context.
1044
+     * @return string
1045
+     */
1046
+    public function get_customer_country( $context = 'view' ) {
1047
+        return $this->get_country( $context );
1048 1048
     }
1049 1049
 
1050 1050
     /**
1051
-	 * Get the customer's state.
1052
-	 *
1053
-	 * @since 1.0.19
1054
-	 * @param  string $context View or edit context.
1055
-	 * @return string
1056
-	 */
1057
-	public function get_state( $context = 'view' ) {
1058
-		$state = $this->get_prop( 'state', $context );
1059
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1051
+     * Get the customer's state.
1052
+     *
1053
+     * @since 1.0.19
1054
+     * @param  string $context View or edit context.
1055
+     * @return string
1056
+     */
1057
+    public function get_state( $context = 'view' ) {
1058
+        $state = $this->get_prop( 'state', $context );
1059
+        return empty( $state ) ? wpinv_get_default_state() : $state;
1060 1060
     }
1061 1061
 
1062 1062
     /**
1063
-	 * Alias of self::get_state().
1064
-	 *
1065
-	 * @since 1.0.19
1066
-	 * @param  string $context View or edit context.
1067
-	 * @return string
1068
-	 */
1069
-	public function get_user_state( $context = 'view' ) {
1070
-		return $this->get_state( $context );
1063
+     * Alias of self::get_state().
1064
+     *
1065
+     * @since 1.0.19
1066
+     * @param  string $context View or edit context.
1067
+     * @return string
1068
+     */
1069
+    public function get_user_state( $context = 'view' ) {
1070
+        return $this->get_state( $context );
1071 1071
     }
1072 1072
 
1073 1073
     /**
1074
-	 * Alias of self::get_state().
1075
-	 *
1076
-	 * @since 1.0.19
1077
-	 * @param  string $context View or edit context.
1078
-	 * @return string
1079
-	 */
1080
-	public function get_customer_state( $context = 'view' ) {
1081
-		return $this->get_state( $context );
1074
+     * Alias of self::get_state().
1075
+     *
1076
+     * @since 1.0.19
1077
+     * @param  string $context View or edit context.
1078
+     * @return string
1079
+     */
1080
+    public function get_customer_state( $context = 'view' ) {
1081
+        return $this->get_state( $context );
1082 1082
     }
1083 1083
 
1084 1084
     /**
1085
-	 * Get the customer's city.
1086
-	 *
1087
-	 * @since 1.0.19
1088
-	 * @param  string $context View or edit context.
1089
-	 * @return string
1090
-	 */
1091
-	public function get_city( $context = 'view' ) {
1092
-		return $this->get_prop( 'city', $context );
1085
+     * Get the customer's city.
1086
+     *
1087
+     * @since 1.0.19
1088
+     * @param  string $context View or edit context.
1089
+     * @return string
1090
+     */
1091
+    public function get_city( $context = 'view' ) {
1092
+        return $this->get_prop( 'city', $context );
1093 1093
     }
1094 1094
 
1095 1095
     /**
1096
-	 * Alias of self::get_city().
1097
-	 *
1098
-	 * @since 1.0.19
1099
-	 * @param  string $context View or edit context.
1100
-	 * @return string
1101
-	 */
1102
-	public function get_user_city( $context = 'view' ) {
1103
-		return $this->get_city( $context );
1096
+     * Alias of self::get_city().
1097
+     *
1098
+     * @since 1.0.19
1099
+     * @param  string $context View or edit context.
1100
+     * @return string
1101
+     */
1102
+    public function get_user_city( $context = 'view' ) {
1103
+        return $this->get_city( $context );
1104 1104
     }
1105 1105
 
1106 1106
     /**
1107
-	 * Alias of self::get_city().
1108
-	 *
1109
-	 * @since 1.0.19
1110
-	 * @param  string $context View or edit context.
1111
-	 * @return string
1112
-	 */
1113
-	public function get_customer_city( $context = 'view' ) {
1114
-		return $this->get_city( $context );
1107
+     * Alias of self::get_city().
1108
+     *
1109
+     * @since 1.0.19
1110
+     * @param  string $context View or edit context.
1111
+     * @return string
1112
+     */
1113
+    public function get_customer_city( $context = 'view' ) {
1114
+        return $this->get_city( $context );
1115 1115
     }
1116 1116
 
1117 1117
     /**
1118
-	 * Get the customer's zip.
1119
-	 *
1120
-	 * @since 1.0.19
1121
-	 * @param  string $context View or edit context.
1122
-	 * @return string
1123
-	 */
1124
-	public function get_zip( $context = 'view' ) {
1125
-		return $this->get_prop( 'zip', $context );
1118
+     * Get the customer's zip.
1119
+     *
1120
+     * @since 1.0.19
1121
+     * @param  string $context View or edit context.
1122
+     * @return string
1123
+     */
1124
+    public function get_zip( $context = 'view' ) {
1125
+        return $this->get_prop( 'zip', $context );
1126 1126
     }
1127 1127
 
1128 1128
     /**
1129
-	 * Alias of self::get_zip().
1130
-	 *
1131
-	 * @since 1.0.19
1132
-	 * @param  string $context View or edit context.
1133
-	 * @return string
1134
-	 */
1135
-	public function get_user_zip( $context = 'view' ) {
1136
-		return $this->get_zip( $context );
1129
+     * Alias of self::get_zip().
1130
+     *
1131
+     * @since 1.0.19
1132
+     * @param  string $context View or edit context.
1133
+     * @return string
1134
+     */
1135
+    public function get_user_zip( $context = 'view' ) {
1136
+        return $this->get_zip( $context );
1137 1137
     }
1138 1138
 
1139 1139
     /**
1140
-	 * Alias of self::get_zip().
1141
-	 *
1142
-	 * @since 1.0.19
1143
-	 * @param  string $context View or edit context.
1144
-	 * @return string
1145
-	 */
1146
-	public function get_customer_zip( $context = 'view' ) {
1147
-		return $this->get_zip( $context );
1140
+     * Alias of self::get_zip().
1141
+     *
1142
+     * @since 1.0.19
1143
+     * @param  string $context View or edit context.
1144
+     * @return string
1145
+     */
1146
+    public function get_customer_zip( $context = 'view' ) {
1147
+        return $this->get_zip( $context );
1148 1148
     }
1149 1149
 
1150 1150
     /**
1151
-	 * Get the customer's company.
1152
-	 *
1153
-	 * @since 1.0.19
1154
-	 * @param  string $context View or edit context.
1155
-	 * @return string
1156
-	 */
1157
-	public function get_company( $context = 'view' ) {
1158
-		return $this->get_prop( 'company', $context );
1151
+     * Get the customer's company.
1152
+     *
1153
+     * @since 1.0.19
1154
+     * @param  string $context View or edit context.
1155
+     * @return string
1156
+     */
1157
+    public function get_company( $context = 'view' ) {
1158
+        return $this->get_prop( 'company', $context );
1159 1159
     }
1160 1160
 
1161 1161
     /**
1162
-	 * Alias of self::get_company().
1163
-	 *
1164
-	 * @since 1.0.19
1165
-	 * @param  string $context View or edit context.
1166
-	 * @return string
1167
-	 */
1168
-	public function get_user_company( $context = 'view' ) {
1169
-		return $this->get_company( $context );
1162
+     * Alias of self::get_company().
1163
+     *
1164
+     * @since 1.0.19
1165
+     * @param  string $context View or edit context.
1166
+     * @return string
1167
+     */
1168
+    public function get_user_company( $context = 'view' ) {
1169
+        return $this->get_company( $context );
1170 1170
     }
1171 1171
 
1172 1172
     /**
1173
-	 * Alias of self::get_company().
1174
-	 *
1175
-	 * @since 1.0.19
1176
-	 * @param  string $context View or edit context.
1177
-	 * @return string
1178
-	 */
1179
-	public function get_customer_company( $context = 'view' ) {
1180
-		return $this->get_company( $context );
1173
+     * Alias of self::get_company().
1174
+     *
1175
+     * @since 1.0.19
1176
+     * @param  string $context View or edit context.
1177
+     * @return string
1178
+     */
1179
+    public function get_customer_company( $context = 'view' ) {
1180
+        return $this->get_company( $context );
1181 1181
     }
1182 1182
 
1183
-	/**
1184
-	 * Get the customer's company id.
1185
-	 *
1186
-	 * @since 1.0.19
1187
-	 * @param  string $context View or edit context.
1188
-	 * @return string
1189
-	 */
1190
-	public function get_company_id( $context = 'view' ) {
1191
-		return $this->get_prop( 'company_id', $context );
1183
+    /**
1184
+     * Get the customer's company id.
1185
+     *
1186
+     * @since 1.0.19
1187
+     * @param  string $context View or edit context.
1188
+     * @return string
1189
+     */
1190
+    public function get_company_id( $context = 'view' ) {
1191
+        return $this->get_prop( 'company_id', $context );
1192 1192
     }
1193 1193
 
1194 1194
     /**
1195
-	 * Get the customer's vat number.
1196
-	 *
1197
-	 * @since 1.0.19
1198
-	 * @param  string $context View or edit context.
1199
-	 * @return string
1200
-	 */
1201
-	public function get_vat_number( $context = 'view' ) {
1202
-		return $this->get_prop( 'vat_number', $context );
1195
+     * Get the customer's vat number.
1196
+     *
1197
+     * @since 1.0.19
1198
+     * @param  string $context View or edit context.
1199
+     * @return string
1200
+     */
1201
+    public function get_vat_number( $context = 'view' ) {
1202
+        return $this->get_prop( 'vat_number', $context );
1203
+    }
1204
+
1205
+    /**
1206
+     * Alias of self::get_vat_number().
1207
+     *
1208
+     * @since 1.0.19
1209
+     * @param  string $context View or edit context.
1210
+     * @return string
1211
+     */
1212
+    public function get_user_vat_number( $context = 'view' ) {
1213
+        return $this->get_vat_number( $context );
1203 1214
     }
1204 1215
 
1205 1216
     /**
1206
-	 * Alias of self::get_vat_number().
1207
-	 *
1208
-	 * @since 1.0.19
1209
-	 * @param  string $context View or edit context.
1210
-	 * @return string
1211
-	 */
1212
-	public function get_user_vat_number( $context = 'view' ) {
1213
-		return $this->get_vat_number( $context );
1217
+     * Alias of self::get_vat_number().
1218
+     *
1219
+     * @since 1.0.19
1220
+     * @param  string $context View or edit context.
1221
+     * @return string
1222
+     */
1223
+    public function get_customer_vat_number( $context = 'view' ) {
1224
+        return $this->get_vat_number( $context );
1214 1225
     }
1215 1226
 
1216 1227
     /**
1217
-	 * Alias of self::get_vat_number().
1218
-	 *
1219
-	 * @since 1.0.19
1220
-	 * @param  string $context View or edit context.
1221
-	 * @return string
1222
-	 */
1223
-	public function get_customer_vat_number( $context = 'view' ) {
1224
-		return $this->get_vat_number( $context );
1228
+     * Get the customer's vat rate.
1229
+     *
1230
+     * @since 1.0.19
1231
+     * @param  string $context View or edit context.
1232
+     * @return string
1233
+     */
1234
+    public function get_vat_rate( $context = 'view' ) {
1235
+        return $this->get_prop( 'vat_rate', $context );
1225 1236
     }
1226 1237
 
1227
-    /**
1228
-	 * Get the customer's vat rate.
1229
-	 *
1230
-	 * @since 1.0.19
1231
-	 * @param  string $context View or edit context.
1232
-	 * @return string
1233
-	 */
1234
-	public function get_vat_rate( $context = 'view' ) {
1235
-		return $this->get_prop( 'vat_rate', $context );
1236
-    }
1237
-
1238
-    /**
1239
-	 * Alias of self::get_vat_rate().
1240
-	 *
1241
-	 * @since 1.0.19
1242
-	 * @param  string $context View or edit context.
1243
-	 * @return string
1244
-	 */
1245
-	public function get_user_vat_rate( $context = 'view' ) {
1246
-		return $this->get_vat_rate( $context );
1247
-    }
1248
-
1249
-    /**
1250
-	 * Alias of self::get_vat_rate().
1251
-	 *
1252
-	 * @since 1.0.19
1253
-	 * @param  string $context View or edit context.
1254
-	 * @return string
1255
-	 */
1256
-	public function get_customer_vat_rate( $context = 'view' ) {
1257
-		return $this->get_vat_rate( $context );
1258
-    }
1259
-
1260
-    /**
1261
-	 * Get the customer's address.
1262
-	 *
1263
-	 * @since 1.0.19
1264
-	 * @param  string $context View or edit context.
1265
-	 * @return string
1266
-	 */
1267
-	public function get_address( $context = 'view' ) {
1268
-		return $this->get_prop( 'address', $context );
1269
-    }
1270
-
1271
-    /**
1272
-	 * Alias of self::get_address().
1273
-	 *
1274
-	 * @since 1.0.19
1275
-	 * @param  string $context View or edit context.
1276
-	 * @return string
1277
-	 */
1278
-	public function get_user_address( $context = 'view' ) {
1279
-		return $this->get_address( $context );
1280
-    }
1281
-
1282
-    /**
1283
-	 * Alias of self::get_address().
1284
-	 *
1285
-	 * @since 1.0.19
1286
-	 * @param  string $context View or edit context.
1287
-	 * @return string
1288
-	 */
1289
-	public function get_customer_address( $context = 'view' ) {
1290
-		return $this->get_address( $context );
1291
-    }
1292
-
1293
-    /**
1294
-	 * Get whether the customer has viewed the invoice or not.
1295
-	 *
1296
-	 * @since 1.0.19
1297
-	 * @param  string $context View or edit context.
1298
-	 * @return bool
1299
-	 */
1300
-	public function get_is_viewed( $context = 'view' ) {
1301
-		return (bool) $this->get_prop( 'is_viewed', $context );
1302
-	}
1303
-
1304
-	/**
1305
-	 * Get other recipients for invoice communications.
1306
-	 *
1307
-	 * @since 1.0.19
1308
-	 * @param  string $context View or edit context.
1309
-	 * @return bool
1310
-	 */
1311
-	public function get_email_cc( $context = 'view' ) {
1312
-		return $this->get_prop( 'email_cc', $context );
1313
-	}
1314
-
1315
-	/**
1316
-	 * Get invoice template.
1317
-	 *
1318
-	 * @since 1.0.19
1319
-	 * @param  string $context View or edit context.
1320
-	 * @return bool
1321
-	 */
1322
-	public function get_template( $context = 'view' ) {
1323
-		return $this->get_prop( 'template', $context );
1324
-	}
1325
-
1326
-	/**
1327
-	 * Get invoice source.
1328
-	 *
1329
-	 * @since 1.0.19
1330
-	 * @param  string $context View or edit context.
1331
-	 * @return bool
1332
-	 */
1333
-	public function get_created_via( $context = 'view' ) {
1334
-		return $this->get_prop( 'created_via', $context );
1335
-	}
1336
-
1337
-	/**
1338
-	 * Get whether the customer has confirmed their address.
1339
-	 *
1340
-	 * @since 1.0.19
1341
-	 * @param  string $context View or edit context.
1342
-	 * @return bool
1343
-	 */
1344
-	public function get_address_confirmed( $context = 'view' ) {
1345
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1346
-    }
1347
-
1348
-    /**
1349
-	 * Alias of self::get_address_confirmed().
1350
-	 *
1351
-	 * @since 1.0.19
1352
-	 * @param  string $context View or edit context.
1353
-	 * @return bool
1354
-	 */
1355
-	public function get_user_address_confirmed( $context = 'view' ) {
1356
-		return $this->get_address_confirmed( $context );
1357
-    }
1358
-
1359
-    /**
1360
-	 * Alias of self::get_address().
1361
-	 *
1362
-	 * @since 1.0.19
1363
-	 * @param  string $context View or edit context.
1364
-	 * @return bool
1365
-	 */
1366
-	public function get_customer_address_confirmed( $context = 'view' ) {
1367
-		return $this->get_address_confirmed( $context );
1368
-    }
1369
-
1370
-	/**
1371
-	 * Get the shipping address.
1372
-	 *
1373
-	 * @since 1.0.19
1374
-	 * @return array|false
1375
-	 */
1376
-	public function get_shipping_address() {
1377
-
1378
-		$shipping_address = get_post_meta( $this->get_id(), 'shipping_address', true );
1379
-		return is_array( $shipping_address ) ? $shipping_address : false;
1380
-    }
1381
-
1382
-	/**
1383
-	 * Check if the invoice has a shipping address.
1384
-	 */
1385
-	public function has_shipping_address() {
1386
-		return false !== $this->get_shipping_address();
1387
-    }
1388
-
1389
-	/**
1390
-	 * Get the shipping amount.
1391
-	 *
1392
-	 * @since 1.0.19
1393
-	 * @param  string $context View or edit context.
1394
-	 * @return float
1395
-	 */
1396
-	public function get_shipping( $context = 'view' ) {
1397
-
1398
-		if ( $context = 'view' ) {
1399
-			return floatval( $this->get_prop( 'shipping', $context ) );
1400
-		}
1238
+    /**
1239
+     * Alias of self::get_vat_rate().
1240
+     *
1241
+     * @since 1.0.19
1242
+     * @param  string $context View or edit context.
1243
+     * @return string
1244
+     */
1245
+    public function get_user_vat_rate( $context = 'view' ) {
1246
+        return $this->get_vat_rate( $context );
1247
+    }
1248
+
1249
+    /**
1250
+     * Alias of self::get_vat_rate().
1251
+     *
1252
+     * @since 1.0.19
1253
+     * @param  string $context View or edit context.
1254
+     * @return string
1255
+     */
1256
+    public function get_customer_vat_rate( $context = 'view' ) {
1257
+        return $this->get_vat_rate( $context );
1258
+    }
1259
+
1260
+    /**
1261
+     * Get the customer's address.
1262
+     *
1263
+     * @since 1.0.19
1264
+     * @param  string $context View or edit context.
1265
+     * @return string
1266
+     */
1267
+    public function get_address( $context = 'view' ) {
1268
+        return $this->get_prop( 'address', $context );
1269
+    }
1270
+
1271
+    /**
1272
+     * Alias of self::get_address().
1273
+     *
1274
+     * @since 1.0.19
1275
+     * @param  string $context View or edit context.
1276
+     * @return string
1277
+     */
1278
+    public function get_user_address( $context = 'view' ) {
1279
+        return $this->get_address( $context );
1280
+    }
1281
+
1282
+    /**
1283
+     * Alias of self::get_address().
1284
+     *
1285
+     * @since 1.0.19
1286
+     * @param  string $context View or edit context.
1287
+     * @return string
1288
+     */
1289
+    public function get_customer_address( $context = 'view' ) {
1290
+        return $this->get_address( $context );
1291
+    }
1292
+
1293
+    /**
1294
+     * Get whether the customer has viewed the invoice or not.
1295
+     *
1296
+     * @since 1.0.19
1297
+     * @param  string $context View or edit context.
1298
+     * @return bool
1299
+     */
1300
+    public function get_is_viewed( $context = 'view' ) {
1301
+        return (bool) $this->get_prop( 'is_viewed', $context );
1302
+    }
1303
+
1304
+    /**
1305
+     * Get other recipients for invoice communications.
1306
+     *
1307
+     * @since 1.0.19
1308
+     * @param  string $context View or edit context.
1309
+     * @return bool
1310
+     */
1311
+    public function get_email_cc( $context = 'view' ) {
1312
+        return $this->get_prop( 'email_cc', $context );
1313
+    }
1314
+
1315
+    /**
1316
+     * Get invoice template.
1317
+     *
1318
+     * @since 1.0.19
1319
+     * @param  string $context View or edit context.
1320
+     * @return bool
1321
+     */
1322
+    public function get_template( $context = 'view' ) {
1323
+        return $this->get_prop( 'template', $context );
1324
+    }
1325
+
1326
+    /**
1327
+     * Get invoice source.
1328
+     *
1329
+     * @since 1.0.19
1330
+     * @param  string $context View or edit context.
1331
+     * @return bool
1332
+     */
1333
+    public function get_created_via( $context = 'view' ) {
1334
+        return $this->get_prop( 'created_via', $context );
1335
+    }
1336
+
1337
+    /**
1338
+     * Get whether the customer has confirmed their address.
1339
+     *
1340
+     * @since 1.0.19
1341
+     * @param  string $context View or edit context.
1342
+     * @return bool
1343
+     */
1344
+    public function get_address_confirmed( $context = 'view' ) {
1345
+        return (bool) $this->get_prop( 'address_confirmed', $context );
1346
+    }
1347
+
1348
+    /**
1349
+     * Alias of self::get_address_confirmed().
1350
+     *
1351
+     * @since 1.0.19
1352
+     * @param  string $context View or edit context.
1353
+     * @return bool
1354
+     */
1355
+    public function get_user_address_confirmed( $context = 'view' ) {
1356
+        return $this->get_address_confirmed( $context );
1357
+    }
1358
+
1359
+    /**
1360
+     * Alias of self::get_address().
1361
+     *
1362
+     * @since 1.0.19
1363
+     * @param  string $context View or edit context.
1364
+     * @return bool
1365
+     */
1366
+    public function get_customer_address_confirmed( $context = 'view' ) {
1367
+        return $this->get_address_confirmed( $context );
1368
+    }
1369
+
1370
+    /**
1371
+     * Get the shipping address.
1372
+     *
1373
+     * @since 1.0.19
1374
+     * @return array|false
1375
+     */
1376
+    public function get_shipping_address() {
1377
+
1378
+        $shipping_address = get_post_meta( $this->get_id(), 'shipping_address', true );
1379
+        return is_array( $shipping_address ) ? $shipping_address : false;
1380
+    }
1381
+
1382
+    /**
1383
+     * Check if the invoice has a shipping address.
1384
+     */
1385
+    public function has_shipping_address() {
1386
+        return false !== $this->get_shipping_address();
1387
+    }
1388
+
1389
+    /**
1390
+     * Get the shipping amount.
1391
+     *
1392
+     * @since 1.0.19
1393
+     * @param  string $context View or edit context.
1394
+     * @return float
1395
+     */
1396
+    public function get_shipping( $context = 'view' ) {
1397
+
1398
+        if ( $context = 'view' ) {
1399
+            return floatval( $this->get_prop( 'shipping', $context ) );
1400
+        }
1401 1401
  
1402
-		return $this->get_prop( 'shipping', $context );
1402
+        return $this->get_prop( 'shipping', $context );
1403 1403
     }
1404 1404
 
1405
-	public function has_shipping() {
1406
-		return defined( 'GETPAID_SHIPPING_CALCULATOR_VERSION' ) && null !== $this->get_prop( 'shipping', 'edit' );
1405
+    public function has_shipping() {
1406
+        return defined( 'GETPAID_SHIPPING_CALCULATOR_VERSION' ) && null !== $this->get_prop( 'shipping', 'edit' );
1407 1407
     }
1408 1408
 
1409 1409
     /**
1410
-	 * Get the invoice subtotal.
1411
-	 *
1412
-	 * @since 1.0.19
1413
-	 * @param  string $context View or edit context.
1414
-	 * @return float
1415
-	 */
1416
-	public function get_subtotal( $context = 'view' ) {
1410
+     * Get the invoice subtotal.
1411
+     *
1412
+     * @since 1.0.19
1413
+     * @param  string $context View or edit context.
1414
+     * @return float
1415
+     */
1416
+    public function get_subtotal( $context = 'view' ) {
1417 1417
         $subtotal = (float) $this->get_prop( 'subtotal', $context );
1418 1418
 
1419 1419
         // Backwards compatibility.
@@ -1425,198 +1425,198 @@  discard block
 block discarded – undo
1425 1425
     }
1426 1426
 
1427 1427
     /**
1428
-	 * Get the invoice discount total.
1429
-	 *
1430
-	 * @since 1.0.19
1431
-	 * @param  string $context View or edit context.
1432
-	 * @return float
1433
-	 */
1434
-	public function get_total_discount( $context = 'view' ) {
1435
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1428
+     * Get the invoice discount total.
1429
+     *
1430
+     * @since 1.0.19
1431
+     * @param  string $context View or edit context.
1432
+     * @return float
1433
+     */
1434
+    public function get_total_discount( $context = 'view' ) {
1435
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1436 1436
     }
1437 1437
 
1438 1438
     /**
1439
-	 * Get the invoice tax total.
1440
-	 *
1441
-	 * @since 1.0.19
1442
-	 * @param  string $context View or edit context.
1443
-	 * @return float
1444
-	 */
1445
-	public function get_total_tax( $context = 'view' ) {
1446
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1447
-	}
1439
+     * Get the invoice tax total.
1440
+     *
1441
+     * @since 1.0.19
1442
+     * @param  string $context View or edit context.
1443
+     * @return float
1444
+     */
1445
+    public function get_total_tax( $context = 'view' ) {
1446
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1447
+    }
1448 1448
 
1449
-	/**
1450
-	 * @deprecated
1451
-	 */
1452
-	public function get_final_tax( $currency = false ) {
1453
-		$tax = $this->get_total_tax();
1449
+    /**
1450
+     * @deprecated
1451
+     */
1452
+    public function get_final_tax( $currency = false ) {
1453
+        $tax = $this->get_total_tax();
1454 1454
 
1455 1455
         if ( $currency ) {
1456
-			return wpinv_price( $tax, $this->get_currency() );
1456
+            return wpinv_price( $tax, $this->get_currency() );
1457 1457
         }
1458 1458
 
1459 1459
         return $tax;
1460 1460
     }
1461 1461
 
1462 1462
     /**
1463
-	 * Get the invoice fees total.
1464
-	 *
1465
-	 * @since 1.0.19
1466
-	 * @param  string $context View or edit context.
1467
-	 * @return float
1468
-	 */
1469
-	public function get_total_fees( $context = 'view' ) {
1470
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1463
+     * Get the invoice fees total.
1464
+     *
1465
+     * @since 1.0.19
1466
+     * @param  string $context View or edit context.
1467
+     * @return float
1468
+     */
1469
+    public function get_total_fees( $context = 'view' ) {
1470
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1471 1471
     }
1472 1472
 
1473 1473
     /**
1474
-	 * Alias for self::get_total_fees().
1475
-	 *
1476
-	 * @since 1.0.19
1477
-	 * @param  string $context View or edit context.
1478
-	 * @return float
1479
-	 */
1480
-	public function get_fees_total( $context = 'view' ) {
1481
-		return $this->get_total_fees( $context );
1474
+     * Alias for self::get_total_fees().
1475
+     *
1476
+     * @since 1.0.19
1477
+     * @param  string $context View or edit context.
1478
+     * @return float
1479
+     */
1480
+    public function get_fees_total( $context = 'view' ) {
1481
+        return $this->get_total_fees( $context );
1482 1482
     }
1483 1483
 
1484 1484
     /**
1485
-	 * Get the invoice total.
1486
-	 *
1487
-	 * @since 1.0.19
1485
+     * Get the invoice total.
1486
+     *
1487
+     * @since 1.0.19
1488 1488
      * @return float
1489
-	 */
1490
-	public function get_total( $context = 'view' ) {
1491
-		$total = $this->get_prop( 'total', $context );
1492
-
1493
-		if ( $this->has_shipping() && $context == 'view' ) {
1494
-			$total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context );
1495
-		}
1496
-
1497
-		return wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1498
-	}
1499
-
1500
-	/**
1501
-	 * Retrieves the non-recurring total of items.
1502
-	 *
1503
-	 * @since 2.3.0
1504
-	 * @return float
1505
-	 */
1506
-	public function get_non_recurring_total() {
1507
-
1508
-		$subtotal = 0;
1509
-		foreach ( $this->get_items() as $item ) {
1510
-			if ( ! $item->is_recurring() ) {
1511
-				$subtotal += $item->get_sub_total();
1512
-			}
1513
-		}
1514
-
1515
-		foreach ( $this->get_fees() as $fee ) {
1516
-			if ( empty( $fee['recurring_fee'] ) ) {
1517
-				$subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1518
-			}
1519
-		}
1520
-
1521
-		$subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1489
+     */
1490
+    public function get_total( $context = 'view' ) {
1491
+        $total = $this->get_prop( 'total', $context );
1492
+
1493
+        if ( $this->has_shipping() && $context == 'view' ) {
1494
+            $total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context );
1495
+        }
1496
+
1497
+        return wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1498
+    }
1499
+
1500
+    /**
1501
+     * Retrieves the non-recurring total of items.
1502
+     *
1503
+     * @since 2.3.0
1504
+     * @return float
1505
+     */
1506
+    public function get_non_recurring_total() {
1507
+
1508
+        $subtotal = 0;
1509
+        foreach ( $this->get_items() as $item ) {
1510
+            if ( ! $item->is_recurring() ) {
1511
+                $subtotal += $item->get_sub_total();
1512
+            }
1513
+        }
1514
+
1515
+        foreach ( $this->get_fees() as $fee ) {
1516
+            if ( empty( $fee['recurring_fee'] ) ) {
1517
+                $subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1518
+            }
1519
+        }
1520
+
1521
+        $subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1522 1522
         return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this );
1523 1523
 
1524 1524
     }
1525 1525
 
1526
-	/**
1527
-	 * Get the invoice totals.
1528
-	 *
1529
-	 * @since 1.0.19
1526
+    /**
1527
+     * Get the invoice totals.
1528
+     *
1529
+     * @since 1.0.19
1530 1530
      * @return array
1531
-	 */
1532
-	public function get_totals() {
1533
-		return $this->totals;
1531
+     */
1532
+    public function get_totals() {
1533
+        return $this->totals;
1534 1534
     }
1535 1535
 
1536 1536
     /**
1537
-	 * Get the initial invoice total.
1538
-	 *
1539
-	 * @since 1.0.19
1537
+     * Get the initial invoice total.
1538
+     *
1539
+     * @since 1.0.19
1540 1540
      * @param  string $context View or edit context.
1541 1541
      * @return float
1542
-	 */
1542
+     */
1543 1543
     public function get_initial_total() {
1544 1544
 
1545
-		if ( empty( $this->totals ) ) {
1546
-			$this->recalculate_total();
1547
-		}
1545
+        if ( empty( $this->totals ) ) {
1546
+            $this->recalculate_total();
1547
+        }
1548 1548
 
1549
-		$tax      = $this->totals['tax']['initial'];
1550
-		$fee      = $this->totals['fee']['initial'];
1551
-		$discount = $this->totals['discount']['initial'];
1552
-		$subtotal = $this->totals['subtotal']['initial'];
1553
-		$total    = $tax + $fee - $discount + $subtotal;
1549
+        $tax      = $this->totals['tax']['initial'];
1550
+        $fee      = $this->totals['fee']['initial'];
1551
+        $discount = $this->totals['discount']['initial'];
1552
+        $subtotal = $this->totals['subtotal']['initial'];
1553
+        $total    = $tax + $fee - $discount + $subtotal;
1554 1554
 
1555
-		if ( 0 > $total ) {
1556
-			$total = 0;
1557
-		}
1555
+        if ( 0 > $total ) {
1556
+            $total = 0;
1557
+        }
1558 1558
 
1559
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1559
+        $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1560 1560
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1561
-	}
1561
+    }
1562 1562
 
1563
-	/**
1564
-	 * Get the recurring invoice total.
1565
-	 *
1566
-	 * @since 1.0.19
1563
+    /**
1564
+     * Get the recurring invoice total.
1565
+     *
1566
+     * @since 1.0.19
1567 1567
      * @param  string $context View or edit context.
1568 1568
      * @return float
1569
-	 */
1569
+     */
1570 1570
     public function get_recurring_total() {
1571 1571
 
1572
-		if ( empty( $this->totals ) ) {
1573
-			$this->recalculate_total();
1574
-		}
1572
+        if ( empty( $this->totals ) ) {
1573
+            $this->recalculate_total();
1574
+        }
1575 1575
 
1576
-		$tax      = $this->totals['tax']['recurring'];
1577
-		$fee      = $this->totals['fee']['recurring'];
1578
-		$discount = $this->totals['discount']['recurring'];
1579
-		$subtotal = $this->totals['subtotal']['recurring'];
1580
-		$total    = $tax + $fee - $discount + $subtotal;
1576
+        $tax      = $this->totals['tax']['recurring'];
1577
+        $fee      = $this->totals['fee']['recurring'];
1578
+        $discount = $this->totals['discount']['recurring'];
1579
+        $subtotal = $this->totals['subtotal']['recurring'];
1580
+        $total    = $tax + $fee - $discount + $subtotal;
1581 1581
 
1582
-		if ( 0 > $total ) {
1583
-			$total = 0;
1584
-		}
1582
+        if ( 0 > $total ) {
1583
+            $total = 0;
1584
+        }
1585 1585
 
1586
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1586
+        $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1587 1587
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1588
-	}
1588
+    }
1589 1589
 
1590
-	/**
1591
-	 * Returns recurring payment details.
1592
-	 *
1593
-	 * @since 1.0.19
1590
+    /**
1591
+     * Returns recurring payment details.
1592
+     *
1593
+     * @since 1.0.19
1594 1594
      * @param  string $field Optionally provide a field to return.
1595
-	 * @param string $currency Whether to include the currency.
1595
+     * @param string $currency Whether to include the currency.
1596 1596
      * @return float|string
1597
-	 */
1597
+     */
1598 1598
     public function get_recurring_details( $field = '', $currency = false ) {
1599 1599
 
1600
-		// Maybe recalculate totals.
1601
-		if ( empty( $this->totals ) ) {
1602
-			$this->recalculate_total();
1603
-		}
1600
+        // Maybe recalculate totals.
1601
+        if ( empty( $this->totals ) ) {
1602
+            $this->recalculate_total();
1603
+        }
1604 1604
 
1605
-		// Prepare recurring totals.
1605
+        // Prepare recurring totals.
1606 1606
         $data = apply_filters(
1607
-			'wpinv_get_invoice_recurring_details',
1608
-			array(
1609
-				'cart_details' => $this->get_cart_details(),
1610
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1611
-				'discount'     => $this->totals['discount']['recurring'],
1612
-				'tax'          => $this->totals['tax']['recurring'],
1613
-				'fee'          => $this->totals['fee']['recurring'],
1614
-				'total'        => $this->get_recurring_total(),
1615
-			),
1616
-			$this,
1617
-			$field,
1618
-			$currency
1619
-		);
1607
+            'wpinv_get_invoice_recurring_details',
1608
+            array(
1609
+                'cart_details' => $this->get_cart_details(),
1610
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1611
+                'discount'     => $this->totals['discount']['recurring'],
1612
+                'tax'          => $this->totals['tax']['recurring'],
1613
+                'fee'          => $this->totals['fee']['recurring'],
1614
+                'total'        => $this->get_recurring_total(),
1615
+            ),
1616
+            $this,
1617
+            $field,
1618
+            $currency
1619
+        );
1620 1620
 
1621 1621
         if ( isset( $data[$field] ) ) {
1622 1622
             return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
@@ -1626,166 +1626,166 @@  discard block
 block discarded – undo
1626 1626
     }
1627 1627
 
1628 1628
     /**
1629
-	 * Get the invoice fees.
1630
-	 *
1631
-	 * @since 1.0.19
1632
-	 * @param  string $context View or edit context.
1633
-	 * @return array
1634
-	 */
1635
-	public function get_fees( $context = 'view' ) {
1636
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1629
+     * Get the invoice fees.
1630
+     *
1631
+     * @since 1.0.19
1632
+     * @param  string $context View or edit context.
1633
+     * @return array
1634
+     */
1635
+    public function get_fees( $context = 'view' ) {
1636
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1637 1637
     }
1638 1638
 
1639 1639
     /**
1640
-	 * Get the invoice discounts.
1641
-	 *
1642
-	 * @since 1.0.19
1643
-	 * @param  string $context View or edit context.
1644
-	 * @return array
1645
-	 */
1646
-	public function get_discounts( $context = 'view' ) {
1647
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1640
+     * Get the invoice discounts.
1641
+     *
1642
+     * @since 1.0.19
1643
+     * @param  string $context View or edit context.
1644
+     * @return array
1645
+     */
1646
+    public function get_discounts( $context = 'view' ) {
1647
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1648 1648
     }
1649 1649
 
1650 1650
     /**
1651
-	 * Get the invoice taxes.
1652
-	 *
1653
-	 * @since 1.0.19
1654
-	 * @param  string $context View or edit context.
1655
-	 * @return array
1656
-	 */
1657
-	public function get_taxes( $context = 'view' ) {
1658
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1651
+     * Get the invoice taxes.
1652
+     *
1653
+     * @since 1.0.19
1654
+     * @param  string $context View or edit context.
1655
+     * @return array
1656
+     */
1657
+    public function get_taxes( $context = 'view' ) {
1658
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1659 1659
     }
1660 1660
 
1661 1661
     /**
1662
-	 * Get the invoice items.
1663
-	 *
1664
-	 * @since 1.0.19
1665
-	 * @param  string $context View or edit context.
1666
-	 * @return GetPaid_Form_Item[]
1667
-	 */
1668
-	public function get_items( $context = 'view' ) {
1662
+     * Get the invoice items.
1663
+     *
1664
+     * @since 1.0.19
1665
+     * @param  string $context View or edit context.
1666
+     * @return GetPaid_Form_Item[]
1667
+     */
1668
+    public function get_items( $context = 'view' ) {
1669 1669
         return $this->get_prop( 'items', $context );
1670
-	}
1670
+    }
1671 1671
 
1672
-	/**
1673
-	 * Get the invoice item ids.
1674
-	 *
1675
-	 * @since 1.0.19
1676
-	 * @return string
1677
-	 */
1678
-	public function get_item_ids() {
1679
-		return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1672
+    /**
1673
+     * Get the invoice item ids.
1674
+     *
1675
+     * @since 1.0.19
1676
+     * @return string
1677
+     */
1678
+    public function get_item_ids() {
1679
+        return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1680 1680
     }
1681 1681
 
1682 1682
     /**
1683
-	 * Get the invoice's payment form.
1684
-	 *
1685
-	 * @since 1.0.19
1686
-	 * @param  string $context View or edit context.
1687
-	 * @return int
1688
-	 */
1689
-	public function get_payment_form( $context = 'view' ) {
1690
-		return intval( $this->get_prop( 'payment_form', $context ) );
1683
+     * Get the invoice's payment form.
1684
+     *
1685
+     * @since 1.0.19
1686
+     * @param  string $context View or edit context.
1687
+     * @return int
1688
+     */
1689
+    public function get_payment_form( $context = 'view' ) {
1690
+        return intval( $this->get_prop( 'payment_form', $context ) );
1691 1691
     }
1692 1692
 
1693 1693
     /**
1694
-	 * Get the invoice's submission id.
1695
-	 *
1696
-	 * @since 1.0.19
1697
-	 * @param  string $context View or edit context.
1698
-	 * @return string
1699
-	 */
1700
-	public function get_submission_id( $context = 'view' ) {
1701
-		return $this->get_prop( 'submission_id', $context );
1694
+     * Get the invoice's submission id.
1695
+     *
1696
+     * @since 1.0.19
1697
+     * @param  string $context View or edit context.
1698
+     * @return string
1699
+     */
1700
+    public function get_submission_id( $context = 'view' ) {
1701
+        return $this->get_prop( 'submission_id', $context );
1702 1702
     }
1703 1703
 
1704 1704
     /**
1705
-	 * Get the invoice's discount code.
1706
-	 *
1707
-	 * @since 1.0.19
1708
-	 * @param  string $context View or edit context.
1709
-	 * @return string
1710
-	 */
1711
-	public function get_discount_code( $context = 'view' ) {
1712
-		return $this->get_prop( 'discount_code', $context );
1705
+     * Get the invoice's discount code.
1706
+     *
1707
+     * @since 1.0.19
1708
+     * @param  string $context View or edit context.
1709
+     * @return string
1710
+     */
1711
+    public function get_discount_code( $context = 'view' ) {
1712
+        return $this->get_prop( 'discount_code', $context );
1713 1713
     }
1714 1714
 
1715 1715
     /**
1716
-	 * Get the invoice's gateway.
1717
-	 *
1718
-	 * @since 1.0.19
1719
-	 * @param  string $context View or edit context.
1720
-	 * @return string
1721
-	 */
1722
-	public function get_gateway( $context = 'view' ) {
1723
-		return $this->get_prop( 'gateway', $context );
1716
+     * Get the invoice's gateway.
1717
+     *
1718
+     * @since 1.0.19
1719
+     * @param  string $context View or edit context.
1720
+     * @return string
1721
+     */
1722
+    public function get_gateway( $context = 'view' ) {
1723
+        return $this->get_prop( 'gateway', $context );
1724 1724
     }
1725 1725
 
1726 1726
     /**
1727
-	 * Get the invoice's gateway display title.
1728
-	 *
1729
-	 * @since 1.0.19
1730
-	 * @return string
1731
-	 */
1727
+     * Get the invoice's gateway display title.
1728
+     *
1729
+     * @since 1.0.19
1730
+     * @return string
1731
+     */
1732 1732
     public function get_gateway_title() {
1733 1733
         $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1734 1734
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1735 1735
     }
1736 1736
 
1737 1737
     /**
1738
-	 * Get the invoice's transaction id.
1739
-	 *
1740
-	 * @since 1.0.19
1741
-	 * @param  string $context View or edit context.
1742
-	 * @return string
1743
-	 */
1744
-	public function get_transaction_id( $context = 'view' ) {
1745
-		return $this->get_prop( 'transaction_id', $context );
1738
+     * Get the invoice's transaction id.
1739
+     *
1740
+     * @since 1.0.19
1741
+     * @param  string $context View or edit context.
1742
+     * @return string
1743
+     */
1744
+    public function get_transaction_id( $context = 'view' ) {
1745
+        return $this->get_prop( 'transaction_id', $context );
1746 1746
     }
1747 1747
 
1748 1748
     /**
1749
-	 * Get the invoice's currency.
1750
-	 *
1751
-	 * @since 1.0.19
1752
-	 * @param  string $context View or edit context.
1753
-	 * @return string
1754
-	 */
1755
-	public function get_currency( $context = 'view' ) {
1749
+     * Get the invoice's currency.
1750
+     *
1751
+     * @since 1.0.19
1752
+     * @param  string $context View or edit context.
1753
+     * @return string
1754
+     */
1755
+    public function get_currency( $context = 'view' ) {
1756 1756
         $currency = $this->get_prop( 'currency', $context );
1757 1757
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1758 1758
     }
1759 1759
 
1760 1760
     /**
1761
-	 * Checks if we are charging taxes for this invoice.
1762
-	 *
1763
-	 * @since 1.0.19
1764
-	 * @param  string $context View or edit context.
1765
-	 * @return bool
1766
-	 */
1767
-	public function get_disable_taxes( $context = 'view' ) {
1761
+     * Checks if we are charging taxes for this invoice.
1762
+     *
1763
+     * @since 1.0.19
1764
+     * @param  string $context View or edit context.
1765
+     * @return bool
1766
+     */
1767
+    public function get_disable_taxes( $context = 'view' ) {
1768 1768
         return (bool) $this->get_prop( 'disable_taxes', $context );
1769 1769
     }
1770 1770
 
1771 1771
     /**
1772
-	 * Retrieves the subscription id for an invoice.
1773
-	 *
1774
-	 * @since 1.0.19
1775
-	 * @param  string $context View or edit context.
1776
-	 * @return int
1777
-	 */
1772
+     * Retrieves the subscription id for an invoice.
1773
+     *
1774
+     * @since 1.0.19
1775
+     * @param  string $context View or edit context.
1776
+     * @return int
1777
+     */
1778 1778
     public function get_subscription_id( $context = 'view' ) {
1779
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1780
-	}
1781
-
1782
-	/**
1783
-	 * Retrieves the remote subscription id for an invoice.
1784
-	 *
1785
-	 * @since 1.0.19
1786
-	 * @param  string $context View or edit context.
1787
-	 * @return int
1788
-	 */
1779
+        return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1780
+    }
1781
+
1782
+    /**
1783
+     * Retrieves the remote subscription id for an invoice.
1784
+     *
1785
+     * @since 1.0.19
1786
+     * @param  string $context View or edit context.
1787
+     * @return int
1788
+     */
1789 1789
     public function get_remote_subscription_id( $context = 'view' ) {
1790 1790
         $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1791 1791
 
@@ -1798,12 +1798,12 @@  discard block
 block discarded – undo
1798 1798
     }
1799 1799
 
1800 1800
     /**
1801
-	 * Retrieves the payment meta for an invoice.
1802
-	 *
1803
-	 * @since 1.0.19
1804
-	 * @param  string $context View or edit context.
1805
-	 * @return array
1806
-	 */
1801
+     * Retrieves the payment meta for an invoice.
1802
+     *
1803
+     * @since 1.0.19
1804
+     * @param  string $context View or edit context.
1805
+     * @return array
1806
+     */
1807 1807
     public function get_payment_meta( $context = 'view' ) {
1808 1808
 
1809 1809
         return array(
@@ -1823,31 +1823,31 @@  discard block
 block discarded – undo
1823 1823
     }
1824 1824
 
1825 1825
     /**
1826
-	 * Retrieves the cart details for an invoice.
1827
-	 *
1828
-	 * @since 1.0.19
1829
-	 * @return array
1830
-	 */
1826
+     * Retrieves the cart details for an invoice.
1827
+     *
1828
+     * @since 1.0.19
1829
+     * @return array
1830
+     */
1831 1831
     public function get_cart_details() {
1832 1832
         $items        = $this->get_items();
1833 1833
         $cart_details = array();
1834 1834
 
1835 1835
         foreach ( $items as $item ) {
1836
-			$item->invoice_id = $this->get_id();
1836
+            $item->invoice_id = $this->get_id();
1837 1837
             $cart_details[]   = $item->prepare_data_for_saving();
1838 1838
         }
1839 1839
 
1840 1840
         return $cart_details;
1841
-	}
1841
+    }
1842 1842
 
1843
-	/**
1844
-	 * Retrieves the recurring item.
1845
-	 *
1846
-	 * @return null|GetPaid_Form_Item|int
1847
-	 */
1848
-	public function get_recurring( $object = false ) {
1843
+    /**
1844
+     * Retrieves the recurring item.
1845
+     *
1846
+     * @return null|GetPaid_Form_Item|int
1847
+     */
1848
+    public function get_recurring( $object = false ) {
1849 1849
 
1850
-		// Are we returning an object?
1850
+        // Are we returning an object?
1851 1851
         if ( $object ) {
1852 1852
             return $this->get_item( $this->recurring_item );
1853 1853
         }
@@ -1855,124 +1855,124 @@  discard block
 block discarded – undo
1855 1855
         return $this->recurring_item;
1856 1856
     }
1857 1857
 
1858
-	/**
1859
-	 * Retrieves the subscription name.
1860
-	 *
1861
-	 * @since 1.0.19
1862
-	 * @return string
1863
-	 */
1864
-	public function get_subscription_name() {
1858
+    /**
1859
+     * Retrieves the subscription name.
1860
+     *
1861
+     * @since 1.0.19
1862
+     * @return string
1863
+     */
1864
+    public function get_subscription_name() {
1865 1865
 
1866
-		// Retrieve the recurring name
1866
+        // Retrieve the recurring name
1867 1867
         $item = $this->get_recurring( true );
1868 1868
 
1869
-		// Abort if it does not exist.
1869
+        // Abort if it does not exist.
1870 1870
         if ( empty( $item ) ) {
1871 1871
             return '';
1872 1872
         }
1873 1873
 
1874
-		// Return the item name.
1874
+        // Return the item name.
1875 1875
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1876
-	}
1877
-
1878
-	/**
1879
-	 * Retrieves the view url.
1880
-	 *
1881
-	 * @since 1.0.19
1882
-	 * @return string
1883
-	 */
1884
-	public function get_view_url() {
1876
+    }
1877
+
1878
+    /**
1879
+     * Retrieves the view url.
1880
+     *
1881
+     * @since 1.0.19
1882
+     * @return string
1883
+     */
1884
+    public function get_view_url() {
1885 1885
         $invoice_url = get_permalink( $this->get_id() );
1886
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1886
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1887 1887
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1888
-	}
1888
+    }
1889 1889
 
1890
-	/**
1891
-	 * Retrieves the payment url.
1892
-	 *
1893
-	 * @since 1.0.19
1894
-	 * @return string
1895
-	 */
1896
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1890
+    /**
1891
+     * Retrieves the payment url.
1892
+     *
1893
+     * @since 1.0.19
1894
+     * @return string
1895
+     */
1896
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1897 1897
 
1898
-		// Retrieve the checkout url.
1898
+        // Retrieve the checkout url.
1899 1899
         $pay_url = wpinv_get_checkout_uri();
1900 1900
 
1901
-		// Maybe force ssl.
1901
+        // Maybe force ssl.
1902 1902
         if ( is_ssl() ) {
1903 1903
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1904 1904
         }
1905 1905
 
1906
-		// Add the invoice key.
1907
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1906
+        // Add the invoice key.
1907
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1908 1908
 
1909
-		// (Maybe?) add a secret
1909
+        // (Maybe?) add a secret
1910 1910
         if ( $secret ) {
1911 1911
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1912 1912
         }
1913 1913
 
1914 1914
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1915
-	}
1915
+    }
1916 1916
 	
1917
-	/**
1918
-	 * Retrieves the receipt url.
1919
-	 *
1920
-	 * @since 1.0.19
1921
-	 * @return string
1922
-	 */
1923
-	public function get_receipt_url() {
1924
-
1925
-		// Retrieve the checkout url.
1917
+    /**
1918
+     * Retrieves the receipt url.
1919
+     *
1920
+     * @since 1.0.19
1921
+     * @return string
1922
+     */
1923
+    public function get_receipt_url() {
1924
+
1925
+        // Retrieve the checkout url.
1926 1926
         $receipt_url = wpinv_get_success_page_uri();
1927 1927
 
1928
-		// Maybe force ssl.
1928
+        // Maybe force ssl.
1929 1929
         if ( is_ssl() ) {
1930 1930
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1931 1931
         }
1932 1932
 
1933
-		// Add the invoice key.
1934
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1933
+        // Add the invoice key.
1934
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1935 1935
 
1936 1936
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1937
-	}
1938
-
1939
-	/**
1940
-	 * Retrieves the remote transaction url.
1941
-	 *
1942
-	 * @since 1.6.0
1943
-	 * @return string
1944
-	 */
1945
-	public function get_transaction_url() {
1946
-		return apply_filters( 'getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this );
1947
-	}
1948
-
1949
-	/**
1950
-	 * Retrieves the default status.
1951
-	 *
1952
-	 * @since 1.0.19
1953
-	 * @return string
1954
-	 */
1955
-	public function get_default_status() {
1956
-
1957
-		$type   = $this->get_type();
1958
-		$status = "wpi-$type-pending";
1959
-		return str_replace( '-invoice', '', $status );
1960
-
1961
-	}
1962
-
1963
-    /**
1964
-	 * Magic method for accessing invoice properties.
1965
-	 *
1966
-	 * @since 1.0.15
1967
-	 * @access public
1968
-	 *
1969
-	 * @param string $key Discount data to retrieve
1970
-	 * @param  string $context View or edit context.
1971
-	 * @return mixed Value of the given invoice property (if set).
1972
-	 */
1973
-	public function get( $key, $context = 'view' ) {
1937
+    }
1938
+
1939
+    /**
1940
+     * Retrieves the remote transaction url.
1941
+     *
1942
+     * @since 1.6.0
1943
+     * @return string
1944
+     */
1945
+    public function get_transaction_url() {
1946
+        return apply_filters( 'getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this );
1947
+    }
1948
+
1949
+    /**
1950
+     * Retrieves the default status.
1951
+     *
1952
+     * @since 1.0.19
1953
+     * @return string
1954
+     */
1955
+    public function get_default_status() {
1956
+
1957
+        $type   = $this->get_type();
1958
+        $status = "wpi-$type-pending";
1959
+        return str_replace( '-invoice', '', $status );
1960
+
1961
+    }
1962
+
1963
+    /**
1964
+     * Magic method for accessing invoice properties.
1965
+     *
1966
+     * @since 1.0.15
1967
+     * @access public
1968
+     *
1969
+     * @param string $key Discount data to retrieve
1970
+     * @param  string $context View or edit context.
1971
+     * @return mixed Value of the given invoice property (if set).
1972
+     */
1973
+    public function get( $key, $context = 'view' ) {
1974 1974
         return $this->get_prop( $key, $context );
1975
-	}
1975
+    }
1976 1976
 
1977 1977
     /*
1978 1978
 	|--------------------------------------------------------------------------
@@ -1985,130 +1985,130 @@  discard block
 block discarded – undo
1985 1985
     */
1986 1986
 
1987 1987
     /**
1988
-	 * Magic method for setting invoice properties.
1989
-	 *
1990
-	 * @since 1.0.19
1991
-	 * @access public
1992
-	 *
1993
-	 * @param string $key Discount data to retrieve
1994
-	 * @param  mixed $value new value.
1995
-	 * @return mixed Value of the given invoice property (if set).
1996
-	 */
1997
-	public function set( $key, $value ) {
1988
+     * Magic method for setting invoice properties.
1989
+     *
1990
+     * @since 1.0.19
1991
+     * @access public
1992
+     *
1993
+     * @param string $key Discount data to retrieve
1994
+     * @param  mixed $value new value.
1995
+     * @return mixed Value of the given invoice property (if set).
1996
+     */
1997
+    public function set( $key, $value ) {
1998 1998
 
1999 1999
         $setter = "set_$key";
2000 2000
         if ( is_callable( array( $this, $setter ) ) ) {
2001 2001
             $this->{$setter}( $value );
2002 2002
         }
2003 2003
 
2004
-	}
2004
+    }
2005 2005
 
2006
-	/**
2007
-	 * Sets item status.
2008
-	 *
2009
-	 * @since 1.0.19
2010
-	 * @param string $new_status    New status.
2011
-	 * @param string $note          Optional note to add.
2012
-	 * @param bool   $manual_update Is this a manual status change?.
2013
-	 * @return array details of change.
2014
-	 */
2015
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
2016
-		$old_status = $this->get_status();
2006
+    /**
2007
+     * Sets item status.
2008
+     *
2009
+     * @since 1.0.19
2010
+     * @param string $new_status    New status.
2011
+     * @param string $note          Optional note to add.
2012
+     * @param bool   $manual_update Is this a manual status change?.
2013
+     * @return array details of change.
2014
+     */
2015
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
2016
+        $old_status = $this->get_status();
2017 2017
 
2018
-		$statuses = $this->get_all_statuses();
2018
+        $statuses = $this->get_all_statuses();
2019 2019
 
2020
-		if ( isset( $statuses[ 'draft' ] ) ) {
2021
-			unset( $statuses[ 'draft' ] );
2022
-		}
2020
+        if ( isset( $statuses[ 'draft' ] ) ) {
2021
+            unset( $statuses[ 'draft' ] );
2022
+        }
2023 2023
 
2024
-		$this->set_prop( 'status', $new_status );
2024
+        $this->set_prop( 'status', $new_status );
2025 2025
 
2026
-		// If setting the status, ensure it's set to a valid status.
2027
-		if ( true === $this->object_read ) {
2026
+        // If setting the status, ensure it's set to a valid status.
2027
+        if ( true === $this->object_read ) {
2028 2028
 
2029
-			// Only allow valid new status.
2030
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
2031
-				$new_status = $this->get_default_status();
2032
-			}
2029
+            // Only allow valid new status.
2030
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
2031
+                $new_status = $this->get_default_status();
2032
+            }
2033 2033
 
2034
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
2035
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
2036
-				$old_status = $this->get_default_status();
2037
-			}
2034
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
2035
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
2036
+                $old_status = $this->get_default_status();
2037
+            }
2038 2038
 
2039
-			// Paid - Renewal (i.e when duplicating a parent invoice )
2040
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
2041
-				$old_status = 'wpi-pending';
2042
-			}
2039
+            // Paid - Renewal (i.e when duplicating a parent invoice )
2040
+            if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
2041
+                $old_status = 'wpi-pending';
2042
+            }
2043 2043
 
2044
-			if ( $old_status !== $new_status ) {
2045
-				$this->status_transition = array(
2046
-					'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
2047
-					'to'     => $new_status,
2048
-					'note'   => $note,
2049
-					'manual' => (bool) $manual_update,
2050
-				);
2044
+            if ( $old_status !== $new_status ) {
2045
+                $this->status_transition = array(
2046
+                    'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
2047
+                    'to'     => $new_status,
2048
+                    'note'   => $note,
2049
+                    'manual' => (bool) $manual_update,
2050
+                );
2051 2051
 
2052
-				if ( $manual_update ) {
2053
-					do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
2054
-				}
2052
+                if ( $manual_update ) {
2053
+                    do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
2054
+                }
2055 2055
 
2056
-				$this->maybe_set_date_paid();
2056
+                $this->maybe_set_date_paid();
2057 2057
 
2058
-			}
2058
+            }
2059 2059
 
2060
-		}
2060
+        }
2061 2061
 
2062
-		return array(
2063
-			'from' => $old_status,
2064
-			'to'   => $new_status,
2065
-		);
2066
-	}
2062
+        return array(
2063
+            'from' => $old_status,
2064
+            'to'   => $new_status,
2065
+        );
2066
+    }
2067 2067
 
2068
-	/**
2069
-	 * Maybe set date paid.
2070
-	 *
2071
-	 * Sets the date paid variable when transitioning to the payment complete
2072
-	 * order status.
2073
-	 *
2074
-	 * @since 1.0.19
2075
-	 */
2076
-	public function maybe_set_date_paid() {
2068
+    /**
2069
+     * Maybe set date paid.
2070
+     *
2071
+     * Sets the date paid variable when transitioning to the payment complete
2072
+     * order status.
2073
+     *
2074
+     * @since 1.0.19
2075
+     */
2076
+    public function maybe_set_date_paid() {
2077 2077
 
2078
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2079
-			$this->set_date_completed( current_time( 'mysql' ) );
2080
-		}
2081
-	}
2078
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2079
+            $this->set_date_completed( current_time( 'mysql' ) );
2080
+        }
2081
+    }
2082 2082
 
2083 2083
     /**
2084
-	 * Set parent invoice ID.
2085
-	 *
2086
-	 * @since 1.0.19
2087
-	 */
2088
-	public function set_parent_id( $value ) {
2089
-		if ( $value && ( $value === $this->get_id() ) ) {
2090
-			return;
2091
-		}
2092
-		$this->set_prop( 'parent_id', absint( $value ) );
2084
+     * Set parent invoice ID.
2085
+     *
2086
+     * @since 1.0.19
2087
+     */
2088
+    public function set_parent_id( $value ) {
2089
+        if ( $value && ( $value === $this->get_id() ) ) {
2090
+            return;
2091
+        }
2092
+        $this->set_prop( 'parent_id', absint( $value ) );
2093 2093
     }
2094 2094
 
2095 2095
     /**
2096
-	 * Set plugin version when the invoice was created.
2097
-	 *
2098
-	 * @since 1.0.19
2099
-	 */
2100
-	public function set_version( $value ) {
2101
-		$this->set_prop( 'version', $value );
2096
+     * Set plugin version when the invoice was created.
2097
+     *
2098
+     * @since 1.0.19
2099
+     */
2100
+    public function set_version( $value ) {
2101
+        $this->set_prop( 'version', $value );
2102 2102
     }
2103
-
2104
-    /**
2105
-	 * Set date when the invoice was created.
2106
-	 *
2107
-	 * @since 1.0.19
2108
-	 * @param string $value Value to set.
2103
+
2104
+    /**
2105
+     * Set date when the invoice was created.
2106
+     *
2107
+     * @since 1.0.19
2108
+     * @param string $value Value to set.
2109 2109
      * @return bool Whether or not the date was set.
2110
-	 */
2111
-	public function set_date_created( $value ) {
2110
+     */
2111
+    public function set_date_created( $value ) {
2112 2112
         $date = strtotime( $value );
2113 2113
 
2114 2114
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2116,19 +2116,19 @@  discard block
 block discarded – undo
2116 2116
             return true;
2117 2117
         }
2118 2118
 
2119
-		$this->set_prop( 'date_created', '' );
2120
-		return false;
2119
+        $this->set_prop( 'date_created', '' );
2120
+        return false;
2121 2121
 
2122 2122
     }
2123 2123
 
2124 2124
     /**
2125
-	 * Set date invoice due date.
2126
-	 *
2127
-	 * @since 1.0.19
2128
-	 * @param string $value Value to set.
2125
+     * Set date invoice due date.
2126
+     *
2127
+     * @since 1.0.19
2128
+     * @param string $value Value to set.
2129 2129
      * @return bool Whether or not the date was set.
2130
-	 */
2131
-	public function set_due_date( $value ) {
2130
+     */
2131
+    public function set_due_date( $value ) {
2132 2132
         $date = strtotime( $value );
2133 2133
 
2134 2134
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2136,29 +2136,29 @@  discard block
 block discarded – undo
2136 2136
             return true;
2137 2137
         }
2138 2138
 
2139
-		$this->set_prop( 'due_date', '' );
2139
+        $this->set_prop( 'due_date', '' );
2140 2140
         return false;
2141 2141
 
2142 2142
     }
2143 2143
 
2144 2144
     /**
2145
-	 * Alias of self::set_due_date().
2146
-	 *
2147
-	 * @since 1.0.19
2148
-	 * @param  string $value New name.
2149
-	 */
2150
-	public function set_date_due( $value ) {
2151
-		$this->set_due_date( $value );
2145
+     * Alias of self::set_due_date().
2146
+     *
2147
+     * @since 1.0.19
2148
+     * @param  string $value New name.
2149
+     */
2150
+    public function set_date_due( $value ) {
2151
+        $this->set_due_date( $value );
2152 2152
     }
2153 2153
 
2154 2154
     /**
2155
-	 * Set date invoice was completed.
2156
-	 *
2157
-	 * @since 1.0.19
2158
-	 * @param string $value Value to set.
2155
+     * Set date invoice was completed.
2156
+     *
2157
+     * @since 1.0.19
2158
+     * @param string $value Value to set.
2159 2159
      * @return bool Whether or not the date was set.
2160
-	 */
2161
-	public function set_completed_date( $value ) {
2160
+     */
2161
+    public function set_completed_date( $value ) {
2162 2162
         $date = strtotime( $value );
2163 2163
 
2164 2164
         if ( $date && $value !== '0000-00-00 00:00:00'  ) {
@@ -2166,29 +2166,29 @@  discard block
 block discarded – undo
2166 2166
             return true;
2167 2167
         }
2168 2168
 
2169
-		$this->set_prop( 'completed_date', '' );
2169
+        $this->set_prop( 'completed_date', '' );
2170 2170
         return false;
2171 2171
 
2172 2172
     }
2173 2173
 
2174 2174
     /**
2175
-	 * Alias of self::set_completed_date().
2176
-	 *
2177
-	 * @since 1.0.19
2178
-	 * @param  string $value New name.
2179
-	 */
2180
-	public function set_date_completed( $value ) {
2181
-		$this->set_completed_date( $value );
2175
+     * Alias of self::set_completed_date().
2176
+     *
2177
+     * @since 1.0.19
2178
+     * @param  string $value New name.
2179
+     */
2180
+    public function set_date_completed( $value ) {
2181
+        $this->set_completed_date( $value );
2182 2182
     }
2183 2183
 
2184 2184
     /**
2185
-	 * Set date when the invoice was last modified.
2186
-	 *
2187
-	 * @since 1.0.19
2188
-	 * @param string $value Value to set.
2185
+     * Set date when the invoice was last modified.
2186
+     *
2187
+     * @since 1.0.19
2188
+     * @param string $value Value to set.
2189 2189
      * @return bool Whether or not the date was set.
2190
-	 */
2191
-	public function set_date_modified( $value ) {
2190
+     */
2191
+    public function set_date_modified( $value ) {
2192 2192
         $date = strtotime( $value );
2193 2193
 
2194 2194
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2196,813 +2196,813 @@  discard block
 block discarded – undo
2196 2196
             return true;
2197 2197
         }
2198 2198
 
2199
-		$this->set_prop( 'date_modified', '' );
2199
+        $this->set_prop( 'date_modified', '' );
2200 2200
         return false;
2201 2201
 
2202 2202
     }
2203 2203
 
2204 2204
     /**
2205
-	 * Set the invoice number.
2206
-	 *
2207
-	 * @since 1.0.19
2208
-	 * @param  string $value New number.
2209
-	 */
2210
-	public function set_number( $value ) {
2205
+     * Set the invoice number.
2206
+     *
2207
+     * @since 1.0.19
2208
+     * @param  string $value New number.
2209
+     */
2210
+    public function set_number( $value ) {
2211 2211
         $number = sanitize_text_field( $value );
2212
-		$this->set_prop( 'number', $number );
2212
+        $this->set_prop( 'number', $number );
2213 2213
     }
2214 2214
 
2215 2215
     /**
2216
-	 * Set the invoice type.
2217
-	 *
2218
-	 * @since 1.0.19
2219
-	 * @param  string $value Type.
2220
-	 */
2221
-	public function set_type( $value ) {
2216
+     * Set the invoice type.
2217
+     *
2218
+     * @since 1.0.19
2219
+     * @param  string $value Type.
2220
+     */
2221
+    public function set_type( $value ) {
2222 2222
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2223
-		$this->set_prop( 'type', $type );
2224
-	}
2223
+        $this->set_prop( 'type', $type );
2224
+    }
2225 2225
 
2226 2226
     /**
2227
-	 * Set the invoice post type.
2228
-	 *
2229
-	 * @since 1.0.19
2230
-	 * @param  string $value Post type.
2231
-	 */
2232
-	public function set_post_type( $value ) {
2227
+     * Set the invoice post type.
2228
+     *
2229
+     * @since 1.0.19
2230
+     * @param  string $value Post type.
2231
+     */
2232
+    public function set_post_type( $value ) {
2233 2233
         if ( getpaid_is_invoice_post_type( $value ) ) {
2234
-			$this->set_type( $value );
2234
+            $this->set_type( $value );
2235 2235
             $this->set_prop( 'post_type', $value );
2236 2236
         }
2237 2237
     }
2238 2238
 
2239 2239
     /**
2240
-	 * Set the invoice key.
2241
-	 *
2242
-	 * @since 1.0.19
2243
-	 * @param  string $value New key.
2244
-	 */
2245
-	public function set_key( $value ) {
2240
+     * Set the invoice key.
2241
+     *
2242
+     * @since 1.0.19
2243
+     * @param  string $value New key.
2244
+     */
2245
+    public function set_key( $value ) {
2246 2246
         $key = sanitize_text_field( $value );
2247
-		$this->set_prop( 'key', $key );
2247
+        $this->set_prop( 'key', $key );
2248 2248
     }
2249 2249
 
2250 2250
     /**
2251
-	 * Set the invoice mode.
2252
-	 *
2253
-	 * @since 1.0.19
2254
-	 * @param  string $value mode.
2255
-	 */
2256
-	public function set_mode( $value ) {
2251
+     * Set the invoice mode.
2252
+     *
2253
+     * @since 1.0.19
2254
+     * @param  string $value mode.
2255
+     */
2256
+    public function set_mode( $value ) {
2257 2257
         if ( in_array( $value, array( 'live', 'test' ) ) ) {
2258 2258
             $this->set_prop( 'mode', $value );
2259 2259
         }
2260 2260
     }
2261 2261
 
2262 2262
     /**
2263
-	 * Set the invoice path.
2264
-	 *
2265
-	 * @since 1.0.19
2266
-	 * @param  string $value path.
2267
-	 */
2268
-	public function set_path( $value ) {
2263
+     * Set the invoice path.
2264
+     *
2265
+     * @since 1.0.19
2266
+     * @param  string $value path.
2267
+     */
2268
+    public function set_path( $value ) {
2269 2269
         $this->set_prop( 'path', $value );
2270 2270
     }
2271 2271
 
2272 2272
     /**
2273
-	 * Set the invoice name.
2274
-	 *
2275
-	 * @since 1.0.19
2276
-	 * @param  string $value New name.
2277
-	 */
2278
-	public function set_name( $value ) {
2273
+     * Set the invoice name.
2274
+     *
2275
+     * @since 1.0.19
2276
+     * @param  string $value New name.
2277
+     */
2278
+    public function set_name( $value ) {
2279 2279
         $name = sanitize_text_field( $value );
2280
-		$this->set_prop( 'name', $name );
2280
+        $this->set_prop( 'name', $name );
2281 2281
     }
2282 2282
 
2283 2283
     /**
2284
-	 * Alias of self::set_name().
2285
-	 *
2286
-	 * @since 1.0.19
2287
-	 * @param  string $value New name.
2288
-	 */
2289
-	public function set_title( $value ) {
2290
-		$this->set_name( $value );
2284
+     * Alias of self::set_name().
2285
+     *
2286
+     * @since 1.0.19
2287
+     * @param  string $value New name.
2288
+     */
2289
+    public function set_title( $value ) {
2290
+        $this->set_name( $value );
2291 2291
     }
2292 2292
 
2293 2293
     /**
2294
-	 * Set the invoice description.
2295
-	 *
2296
-	 * @since 1.0.19
2297
-	 * @param  string $value New description.
2298
-	 */
2299
-	public function set_description( $value ) {
2294
+     * Set the invoice description.
2295
+     *
2296
+     * @since 1.0.19
2297
+     * @param  string $value New description.
2298
+     */
2299
+    public function set_description( $value ) {
2300 2300
         $description = wp_kses_post( $value );
2301
-		$this->set_prop( 'description', $description );
2301
+        $this->set_prop( 'description', $description );
2302
+    }
2303
+
2304
+    /**
2305
+     * Alias of self::set_description().
2306
+     *
2307
+     * @since 1.0.19
2308
+     * @param  string $value New description.
2309
+     */
2310
+    public function set_excerpt( $value ) {
2311
+        $this->set_description( $value );
2312
+    }
2313
+
2314
+    /**
2315
+     * Alias of self::set_description().
2316
+     *
2317
+     * @since 1.0.19
2318
+     * @param  string $value New description.
2319
+     */
2320
+    public function set_summary( $value ) {
2321
+        $this->set_description( $value );
2322
+    }
2323
+
2324
+    /**
2325
+     * Set the receiver of the invoice.
2326
+     *
2327
+     * @since 1.0.19
2328
+     * @param  int $value New author.
2329
+     */
2330
+    public function set_author( $value ) {
2331
+        $user = get_user_by( 'id', (int) $value );
2332
+
2333
+        if ( $user && $user->ID ) {
2334
+            $this->set_prop( 'author', $user->ID );
2335
+            $this->set_prop( 'email', $user->user_email );
2336
+        }
2337
+
2338
+    }
2339
+
2340
+    /**
2341
+     * Alias of self::set_author().
2342
+     *
2343
+     * @since 1.0.19
2344
+     * @param  int $value New user id.
2345
+     */
2346
+    public function set_user_id( $value ) {
2347
+        $this->set_author( $value );
2348
+    }
2349
+
2350
+    /**
2351
+     * Alias of self::set_author().
2352
+     *
2353
+     * @since 1.0.19
2354
+     * @param  int $value New user id.
2355
+     */
2356
+    public function set_customer_id( $value ) {
2357
+        $this->set_author( $value );
2358
+    }
2359
+
2360
+    /**
2361
+     * Set the customer's ip.
2362
+     *
2363
+     * @since 1.0.19
2364
+     * @param  string $value ip address.
2365
+     */
2366
+    public function set_ip( $value ) {
2367
+        $this->set_prop( 'ip', $value );
2368
+    }
2369
+
2370
+    /**
2371
+     * Alias of self::set_ip().
2372
+     *
2373
+     * @since 1.0.19
2374
+     * @param  string $value ip address.
2375
+     */
2376
+    public function set_user_ip( $value ) {
2377
+        $this->set_ip( $value );
2378
+    }
2379
+
2380
+    /**
2381
+     * Set the customer's first name.
2382
+     *
2383
+     * @since 1.0.19
2384
+     * @param  string $value first name.
2385
+     */
2386
+    public function set_first_name( $value ) {
2387
+        $this->set_prop( 'first_name', $value );
2388
+    }
2389
+
2390
+    /**
2391
+     * Alias of self::set_first_name().
2392
+     *
2393
+     * @since 1.0.19
2394
+     * @param  string $value first name.
2395
+     */
2396
+    public function set_user_first_name( $value ) {
2397
+        $this->set_first_name( $value );
2398
+    }
2399
+
2400
+    /**
2401
+     * Alias of self::set_first_name().
2402
+     *
2403
+     * @since 1.0.19
2404
+     * @param  string $value first name.
2405
+     */
2406
+    public function set_customer_first_name( $value ) {
2407
+        $this->set_first_name( $value );
2408
+    }
2409
+
2410
+    /**
2411
+     * Set the customer's last name.
2412
+     *
2413
+     * @since 1.0.19
2414
+     * @param  string $value last name.
2415
+     */
2416
+    public function set_last_name( $value ) {
2417
+        $this->set_prop( 'last_name', $value );
2418
+    }
2419
+
2420
+    /**
2421
+     * Alias of self::set_last_name().
2422
+     *
2423
+     * @since 1.0.19
2424
+     * @param  string $value last name.
2425
+     */
2426
+    public function set_user_last_name( $value ) {
2427
+        $this->set_last_name( $value );
2428
+    }
2429
+
2430
+    /**
2431
+     * Alias of self::set_last_name().
2432
+     *
2433
+     * @since 1.0.19
2434
+     * @param  string $value last name.
2435
+     */
2436
+    public function set_customer_last_name( $value ) {
2437
+        $this->set_last_name( $value );
2438
+    }
2439
+
2440
+    /**
2441
+     * Set the customer's phone number.
2442
+     *
2443
+     * @since 1.0.19
2444
+     * @param  string $value phone.
2445
+     */
2446
+    public function set_phone( $value ) {
2447
+        $this->set_prop( 'phone', $value );
2302 2448
     }
2303 2449
 
2304 2450
     /**
2305
-	 * Alias of self::set_description().
2306
-	 *
2307
-	 * @since 1.0.19
2308
-	 * @param  string $value New description.
2309
-	 */
2310
-	public function set_excerpt( $value ) {
2311
-		$this->set_description( $value );
2451
+     * Alias of self::set_phone().
2452
+     *
2453
+     * @since 1.0.19
2454
+     * @param  string $value phone.
2455
+     */
2456
+    public function set_user_phone( $value ) {
2457
+        $this->set_phone( $value );
2312 2458
     }
2313 2459
 
2314 2460
     /**
2315
-	 * Alias of self::set_description().
2316
-	 *
2317
-	 * @since 1.0.19
2318
-	 * @param  string $value New description.
2319
-	 */
2320
-	public function set_summary( $value ) {
2321
-		$this->set_description( $value );
2461
+     * Alias of self::set_phone().
2462
+     *
2463
+     * @since 1.0.19
2464
+     * @param  string $value phone.
2465
+     */
2466
+    public function set_customer_phone( $value ) {
2467
+        $this->set_phone( $value );
2322 2468
     }
2323 2469
 
2324 2470
     /**
2325
-	 * Set the receiver of the invoice.
2326
-	 *
2327
-	 * @since 1.0.19
2328
-	 * @param  int $value New author.
2329
-	 */
2330
-	public function set_author( $value ) {
2331
-		$user = get_user_by( 'id', (int) $value );
2471
+     * Alias of self::set_phone().
2472
+     *
2473
+     * @since 1.0.19
2474
+     * @param  string $value phone.
2475
+     */
2476
+    public function set_phone_number( $value ) {
2477
+        $this->set_phone( $value );
2478
+    }
2332 2479
 
2333
-		if ( $user && $user->ID ) {
2334
-			$this->set_prop( 'author', $user->ID );
2335
-			$this->set_prop( 'email', $user->user_email );
2336
-		}
2480
+    /**
2481
+     * Set the customer's email address.
2482
+     *
2483
+     * @since 1.0.19
2484
+     * @param  string $value email address.
2485
+     */
2486
+    public function set_email( $value ) {
2487
+        $this->set_prop( 'email', $value );
2488
+    }
2337 2489
 
2490
+    /**
2491
+     * Alias of self::set_email().
2492
+     *
2493
+     * @since 1.0.19
2494
+     * @param  string $value email address.
2495
+     */
2496
+    public function set_user_email( $value ) {
2497
+        $this->set_email( $value );
2338 2498
     }
2339 2499
 
2340 2500
     /**
2341
-	 * Alias of self::set_author().
2342
-	 *
2343
-	 * @since 1.0.19
2344
-	 * @param  int $value New user id.
2345
-	 */
2346
-	public function set_user_id( $value ) {
2347
-		$this->set_author( $value );
2501
+     * Alias of self::set_email().
2502
+     *
2503
+     * @since 1.0.19
2504
+     * @param  string $value email address.
2505
+     */
2506
+    public function set_email_address( $value ) {
2507
+        $this->set_email( $value );
2348 2508
     }
2349 2509
 
2350 2510
     /**
2351
-	 * Alias of self::set_author().
2352
-	 *
2353
-	 * @since 1.0.19
2354
-	 * @param  int $value New user id.
2355
-	 */
2356
-	public function set_customer_id( $value ) {
2357
-		$this->set_author( $value );
2511
+     * Alias of self::set_email().
2512
+     *
2513
+     * @since 1.0.19
2514
+     * @param  string $value email address.
2515
+     */
2516
+    public function set_customer_email( $value ) {
2517
+        $this->set_email( $value );
2358 2518
     }
2359 2519
 
2360 2520
     /**
2361
-	 * Set the customer's ip.
2362
-	 *
2363
-	 * @since 1.0.19
2364
-	 * @param  string $value ip address.
2365
-	 */
2366
-	public function set_ip( $value ) {
2367
-		$this->set_prop( 'ip', $value );
2521
+     * Set the customer's country.
2522
+     *
2523
+     * @since 1.0.19
2524
+     * @param  string $value country.
2525
+     */
2526
+    public function set_country( $value ) {
2527
+        $this->set_prop( 'country', $value );
2368 2528
     }
2369 2529
 
2370 2530
     /**
2371
-	 * Alias of self::set_ip().
2372
-	 *
2373
-	 * @since 1.0.19
2374
-	 * @param  string $value ip address.
2375
-	 */
2376
-	public function set_user_ip( $value ) {
2377
-		$this->set_ip( $value );
2531
+     * Alias of self::set_country().
2532
+     *
2533
+     * @since 1.0.19
2534
+     * @param  string $value country.
2535
+     */
2536
+    public function set_user_country( $value ) {
2537
+        $this->set_country( $value );
2378 2538
     }
2379 2539
 
2380 2540
     /**
2381
-	 * Set the customer's first name.
2382
-	 *
2383
-	 * @since 1.0.19
2384
-	 * @param  string $value first name.
2385
-	 */
2386
-	public function set_first_name( $value ) {
2387
-		$this->set_prop( 'first_name', $value );
2541
+     * Alias of self::set_country().
2542
+     *
2543
+     * @since 1.0.19
2544
+     * @param  string $value country.
2545
+     */
2546
+    public function set_customer_country( $value ) {
2547
+        $this->set_country( $value );
2388 2548
     }
2389 2549
 
2390 2550
     /**
2391
-	 * Alias of self::set_first_name().
2392
-	 *
2393
-	 * @since 1.0.19
2394
-	 * @param  string $value first name.
2395
-	 */
2396
-	public function set_user_first_name( $value ) {
2397
-		$this->set_first_name( $value );
2551
+     * Set the customer's state.
2552
+     *
2553
+     * @since 1.0.19
2554
+     * @param  string $value state.
2555
+     */
2556
+    public function set_state( $value ) {
2557
+        $this->set_prop( 'state', $value );
2398 2558
     }
2399 2559
 
2400 2560
     /**
2401
-	 * Alias of self::set_first_name().
2402
-	 *
2403
-	 * @since 1.0.19
2404
-	 * @param  string $value first name.
2405
-	 */
2406
-	public function set_customer_first_name( $value ) {
2407
-		$this->set_first_name( $value );
2561
+     * Alias of self::set_state().
2562
+     *
2563
+     * @since 1.0.19
2564
+     * @param  string $value state.
2565
+     */
2566
+    public function set_user_state( $value ) {
2567
+        $this->set_state( $value );
2408 2568
     }
2409 2569
 
2410 2570
     /**
2411
-	 * Set the customer's last name.
2412
-	 *
2413
-	 * @since 1.0.19
2414
-	 * @param  string $value last name.
2415
-	 */
2416
-	public function set_last_name( $value ) {
2417
-		$this->set_prop( 'last_name', $value );
2571
+     * Alias of self::set_state().
2572
+     *
2573
+     * @since 1.0.19
2574
+     * @param  string $value state.
2575
+     */
2576
+    public function set_customer_state( $value ) {
2577
+        $this->set_state( $value );
2418 2578
     }
2419 2579
 
2420 2580
     /**
2421
-	 * Alias of self::set_last_name().
2422
-	 *
2423
-	 * @since 1.0.19
2424
-	 * @param  string $value last name.
2425
-	 */
2426
-	public function set_user_last_name( $value ) {
2427
-		$this->set_last_name( $value );
2581
+     * Set the customer's city.
2582
+     *
2583
+     * @since 1.0.19
2584
+     * @param  string $value city.
2585
+     */
2586
+    public function set_city( $value ) {
2587
+        $this->set_prop( 'city', $value );
2428 2588
     }
2429 2589
 
2430 2590
     /**
2431
-	 * Alias of self::set_last_name().
2432
-	 *
2433
-	 * @since 1.0.19
2434
-	 * @param  string $value last name.
2435
-	 */
2436
-	public function set_customer_last_name( $value ) {
2437
-		$this->set_last_name( $value );
2591
+     * Alias of self::set_city().
2592
+     *
2593
+     * @since 1.0.19
2594
+     * @param  string $value city.
2595
+     */
2596
+    public function set_user_city( $value ) {
2597
+        $this->set_city( $value );
2438 2598
     }
2439 2599
 
2440 2600
     /**
2441
-	 * Set the customer's phone number.
2442
-	 *
2443
-	 * @since 1.0.19
2444
-	 * @param  string $value phone.
2445
-	 */
2446
-	public function set_phone( $value ) {
2447
-		$this->set_prop( 'phone', $value );
2601
+     * Alias of self::set_city().
2602
+     *
2603
+     * @since 1.0.19
2604
+     * @param  string $value city.
2605
+     */
2606
+    public function set_customer_city( $value ) {
2607
+        $this->set_city( $value );
2448 2608
     }
2449 2609
 
2450 2610
     /**
2451
-	 * Alias of self::set_phone().
2452
-	 *
2453
-	 * @since 1.0.19
2454
-	 * @param  string $value phone.
2455
-	 */
2456
-	public function set_user_phone( $value ) {
2457
-		$this->set_phone( $value );
2611
+     * Set the customer's zip code.
2612
+     *
2613
+     * @since 1.0.19
2614
+     * @param  string $value zip.
2615
+     */
2616
+    public function set_zip( $value ) {
2617
+        $this->set_prop( 'zip', $value );
2458 2618
     }
2459 2619
 
2460 2620
     /**
2461
-	 * Alias of self::set_phone().
2462
-	 *
2463
-	 * @since 1.0.19
2464
-	 * @param  string $value phone.
2465
-	 */
2466
-	public function set_customer_phone( $value ) {
2467
-		$this->set_phone( $value );
2621
+     * Alias of self::set_zip().
2622
+     *
2623
+     * @since 1.0.19
2624
+     * @param  string $value zip.
2625
+     */
2626
+    public function set_user_zip( $value ) {
2627
+        $this->set_zip( $value );
2468 2628
     }
2469 2629
 
2470 2630
     /**
2471
-	 * Alias of self::set_phone().
2472
-	 *
2473
-	 * @since 1.0.19
2474
-	 * @param  string $value phone.
2475
-	 */
2476
-	public function set_phone_number( $value ) {
2477
-		$this->set_phone( $value );
2631
+     * Alias of self::set_zip().
2632
+     *
2633
+     * @since 1.0.19
2634
+     * @param  string $value zip.
2635
+     */
2636
+    public function set_customer_zip( $value ) {
2637
+        $this->set_zip( $value );
2478 2638
     }
2479 2639
 
2480 2640
     /**
2481
-	 * Set the customer's email address.
2482
-	 *
2483
-	 * @since 1.0.19
2484
-	 * @param  string $value email address.
2485
-	 */
2486
-	public function set_email( $value ) {
2487
-		$this->set_prop( 'email', $value );
2641
+     * Set the customer's company.
2642
+     *
2643
+     * @since 1.0.19
2644
+     * @param  string $value company.
2645
+     */
2646
+    public function set_company( $value ) {
2647
+        $this->set_prop( 'company', $value );
2488 2648
     }
2489 2649
 
2490 2650
     /**
2491
-	 * Alias of self::set_email().
2492
-	 *
2493
-	 * @since 1.0.19
2494
-	 * @param  string $value email address.
2495
-	 */
2496
-	public function set_user_email( $value ) {
2497
-		$this->set_email( $value );
2651
+     * Alias of self::set_company().
2652
+     *
2653
+     * @since 1.0.19
2654
+     * @param  string $value company.
2655
+     */
2656
+    public function set_user_company( $value ) {
2657
+        $this->set_company( $value );
2498 2658
     }
2499 2659
 
2500 2660
     /**
2501
-	 * Alias of self::set_email().
2502
-	 *
2503
-	 * @since 1.0.19
2504
-	 * @param  string $value email address.
2505
-	 */
2506
-	public function set_email_address( $value ) {
2507
-		$this->set_email( $value );
2661
+     * Alias of self::set_company().
2662
+     *
2663
+     * @since 1.0.19
2664
+     * @param  string $value company.
2665
+     */
2666
+    public function set_customer_company( $value ) {
2667
+        $this->set_company( $value );
2508 2668
     }
2509 2669
 
2510 2670
     /**
2511
-	 * Alias of self::set_email().
2512
-	 *
2513
-	 * @since 1.0.19
2514
-	 * @param  string $value email address.
2515
-	 */
2516
-	public function set_customer_email( $value ) {
2517
-		$this->set_email( $value );
2671
+     * Set the customer's company id.
2672
+     *
2673
+     * @since 1.0.19
2674
+     * @param  string $value company id.
2675
+     */
2676
+    public function set_company_id( $value ) {
2677
+        $this->set_prop( 'company_id', $value );
2518 2678
     }
2519 2679
 
2520 2680
     /**
2521
-	 * Set the customer's country.
2522
-	 *
2523
-	 * @since 1.0.19
2524
-	 * @param  string $value country.
2525
-	 */
2526
-	public function set_country( $value ) {
2527
-		$this->set_prop( 'country', $value );
2681
+     * Set the customer's var number.
2682
+     *
2683
+     * @since 1.0.19
2684
+     * @param  string $value var number.
2685
+     */
2686
+    public function set_vat_number( $value ) {
2687
+        $this->set_prop( 'vat_number', $value );
2528 2688
     }
2529 2689
 
2530 2690
     /**
2531
-	 * Alias of self::set_country().
2532
-	 *
2533
-	 * @since 1.0.19
2534
-	 * @param  string $value country.
2535
-	 */
2536
-	public function set_user_country( $value ) {
2537
-		$this->set_country( $value );
2691
+     * Alias of self::set_vat_number().
2692
+     *
2693
+     * @since 1.0.19
2694
+     * @param  string $value var number.
2695
+     */
2696
+    public function set_user_vat_number( $value ) {
2697
+        $this->set_vat_number( $value );
2538 2698
     }
2539 2699
 
2540 2700
     /**
2541
-	 * Alias of self::set_country().
2542
-	 *
2543
-	 * @since 1.0.19
2544
-	 * @param  string $value country.
2545
-	 */
2546
-	public function set_customer_country( $value ) {
2547
-		$this->set_country( $value );
2701
+     * Alias of self::set_vat_number().
2702
+     *
2703
+     * @since 1.0.19
2704
+     * @param  string $value var number.
2705
+     */
2706
+    public function set_customer_vat_number( $value ) {
2707
+        $this->set_vat_number( $value );
2548 2708
     }
2549 2709
 
2550 2710
     /**
2551
-	 * Set the customer's state.
2552
-	 *
2553
-	 * @since 1.0.19
2554
-	 * @param  string $value state.
2555
-	 */
2556
-	public function set_state( $value ) {
2557
-		$this->set_prop( 'state', $value );
2711
+     * Set the customer's vat rate.
2712
+     *
2713
+     * @since 1.0.19
2714
+     * @param  string $value var rate.
2715
+     */
2716
+    public function set_vat_rate( $value ) {
2717
+        $this->set_prop( 'vat_rate', $value );
2558 2718
     }
2559 2719
 
2560 2720
     /**
2561
-	 * Alias of self::set_state().
2562
-	 *
2563
-	 * @since 1.0.19
2564
-	 * @param  string $value state.
2565
-	 */
2566
-	public function set_user_state( $value ) {
2567
-		$this->set_state( $value );
2721
+     * Alias of self::set_vat_rate().
2722
+     *
2723
+     * @since 1.0.19
2724
+     * @param  string $value var number.
2725
+     */
2726
+    public function set_user_vat_rate( $value ) {
2727
+        $this->set_vat_rate( $value );
2568 2728
     }
2569 2729
 
2570 2730
     /**
2571
-	 * Alias of self::set_state().
2572
-	 *
2573
-	 * @since 1.0.19
2574
-	 * @param  string $value state.
2575
-	 */
2576
-	public function set_customer_state( $value ) {
2577
-		$this->set_state( $value );
2731
+     * Alias of self::set_vat_rate().
2732
+     *
2733
+     * @since 1.0.19
2734
+     * @param  string $value var number.
2735
+     */
2736
+    public function set_customer_vat_rate( $value ) {
2737
+        $this->set_vat_rate( $value );
2578 2738
     }
2579 2739
 
2580 2740
     /**
2581
-	 * Set the customer's city.
2582
-	 *
2583
-	 * @since 1.0.19
2584
-	 * @param  string $value city.
2585
-	 */
2586
-	public function set_city( $value ) {
2587
-		$this->set_prop( 'city', $value );
2741
+     * Set the customer's address.
2742
+     *
2743
+     * @since 1.0.19
2744
+     * @param  string $value address.
2745
+     */
2746
+    public function set_address( $value ) {
2747
+        $this->set_prop( 'address', $value );
2588 2748
     }
2589 2749
 
2590 2750
     /**
2591
-	 * Alias of self::set_city().
2592
-	 *
2593
-	 * @since 1.0.19
2594
-	 * @param  string $value city.
2595
-	 */
2596
-	public function set_user_city( $value ) {
2597
-		$this->set_city( $value );
2751
+     * Alias of self::set_address().
2752
+     *
2753
+     * @since 1.0.19
2754
+     * @param  string $value address.
2755
+     */
2756
+    public function set_user_address( $value ) {
2757
+        $this->set_address( $value );
2598 2758
     }
2599 2759
 
2600 2760
     /**
2601
-	 * Alias of self::set_city().
2602
-	 *
2603
-	 * @since 1.0.19
2604
-	 * @param  string $value city.
2605
-	 */
2606
-	public function set_customer_city( $value ) {
2607
-		$this->set_city( $value );
2761
+     * Alias of self::set_address().
2762
+     *
2763
+     * @since 1.0.19
2764
+     * @param  string $value address.
2765
+     */
2766
+    public function set_customer_address( $value ) {
2767
+        $this->set_address( $value );
2608 2768
     }
2609 2769
 
2610 2770
     /**
2611
-	 * Set the customer's zip code.
2612
-	 *
2613
-	 * @since 1.0.19
2614
-	 * @param  string $value zip.
2615
-	 */
2616
-	public function set_zip( $value ) {
2617
-		$this->set_prop( 'zip', $value );
2771
+     * Set whether the customer has viewed the invoice or not.
2772
+     *
2773
+     * @since 1.0.19
2774
+     * @param  int|bool $value confirmed.
2775
+     */
2776
+    public function set_is_viewed( $value ) {
2777
+        $this->set_prop( 'is_viewed', $value );
2618 2778
     }
2619 2779
 
2620 2780
     /**
2621
-	 * Alias of self::set_zip().
2622
-	 *
2623
-	 * @since 1.0.19
2624
-	 * @param  string $value zip.
2625
-	 */
2626
-	public function set_user_zip( $value ) {
2627
-		$this->set_zip( $value );
2781
+     * Set extra email recipients.
2782
+     *
2783
+     * @since 1.0.19
2784
+     * @param  string $value email recipients.
2785
+     */
2786
+    public function set_email_cc( $value ) {
2787
+        $this->set_prop( 'email_cc', $value );
2628 2788
     }
2629 2789
 
2630 2790
     /**
2631
-	 * Alias of self::set_zip().
2632
-	 *
2633
-	 * @since 1.0.19
2634
-	 * @param  string $value zip.
2635
-	 */
2636
-	public function set_customer_zip( $value ) {
2637
-		$this->set_zip( $value );
2791
+     * Set the invoice template.
2792
+     *
2793
+     * @since 1.0.19
2794
+     * @param  string $value template.
2795
+     */
2796
+    public function set_template( $value ) {
2797
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2798
+            $this->set_prop( 'template', $value );
2799
+        }
2638 2800
     }
2639 2801
 
2640 2802
     /**
2641
-	 * Set the customer's company.
2642
-	 *
2643
-	 * @since 1.0.19
2644
-	 * @param  string $value company.
2645
-	 */
2646
-	public function set_company( $value ) {
2647
-		$this->set_prop( 'company', $value );
2803
+     * Set the invoice source.
2804
+     *
2805
+     * @since 1.0.19
2806
+     * @param  string $value source.
2807
+     * @deprecated
2808
+     */
2809
+    public function created_via( $value ) {
2810
+        $this->set_created_via( sanitize_text_field( $value ) );
2648 2811
     }
2649 2812
 
2650 2813
     /**
2651
-	 * Alias of self::set_company().
2652
-	 *
2653
-	 * @since 1.0.19
2654
-	 * @param  string $value company.
2655
-	 */
2656
-	public function set_user_company( $value ) {
2657
-		$this->set_company( $value );
2814
+     * Set the invoice source.
2815
+     *
2816
+     * @since 1.0.19
2817
+     * @param  string $value source.
2818
+     */
2819
+    public function set_created_via( $value ) {
2820
+        $this->set_prop( 'created_via', sanitize_text_field( $value ) );
2658 2821
     }
2659 2822
 
2660 2823
     /**
2661
-	 * Alias of self::set_company().
2662
-	 *
2663
-	 * @since 1.0.19
2664
-	 * @param  string $value company.
2665
-	 */
2666
-	public function set_customer_company( $value ) {
2667
-		$this->set_company( $value );
2668
-    }
2669
-
2670
-	/**
2671
-	 * Set the customer's company id.
2672
-	 *
2673
-	 * @since 1.0.19
2674
-	 * @param  string $value company id.
2675
-	 */
2676
-	public function set_company_id( $value ) {
2677
-		$this->set_prop( 'company_id', $value );
2824
+     * Set the customer's address confirmed status.
2825
+     *
2826
+     * @since 1.0.19
2827
+     * @param  int|bool $value confirmed.
2828
+     */
2829
+    public function set_address_confirmed( $value ) {
2830
+        $this->set_prop( 'address_confirmed', $value );
2678 2831
     }
2679 2832
 
2680 2833
     /**
2681
-	 * Set the customer's var number.
2682
-	 *
2683
-	 * @since 1.0.19
2684
-	 * @param  string $value var number.
2685
-	 */
2686
-	public function set_vat_number( $value ) {
2687
-		$this->set_prop( 'vat_number', $value );
2834
+     * Alias of self::set_address_confirmed().
2835
+     *
2836
+     * @since 1.0.19
2837
+     * @param  int|bool $value confirmed.
2838
+     */
2839
+    public function set_user_address_confirmed( $value ) {
2840
+        $this->set_address_confirmed( $value );
2688 2841
     }
2689 2842
 
2690 2843
     /**
2691
-	 * Alias of self::set_vat_number().
2692
-	 *
2693
-	 * @since 1.0.19
2694
-	 * @param  string $value var number.
2695
-	 */
2696
-	public function set_user_vat_number( $value ) {
2697
-		$this->set_vat_number( $value );
2844
+     * Alias of self::set_address_confirmed().
2845
+     *
2846
+     * @since 1.0.19
2847
+     * @param  int|bool $value confirmed.
2848
+     */
2849
+    public function set_customer_address_confirmed( $value ) {
2850
+        $this->set_address_confirmed( $value );
2698 2851
     }
2699 2852
 
2700 2853
     /**
2701
-	 * Alias of self::set_vat_number().
2702
-	 *
2703
-	 * @since 1.0.19
2704
-	 * @param  string $value var number.
2705
-	 */
2706
-	public function set_customer_vat_number( $value ) {
2707
-		$this->set_vat_number( $value );
2854
+     * Set the shipping fee
2855
+     *
2856
+     * @since 1.0.19
2857
+     * @param  float $value shipping amount.
2858
+     */
2859
+    public function set_shipping( $value ) {
2860
+
2861
+        if ( ! is_numeric( $value ) ) {
2862
+            return $this->set_prop( 'shipping', null );
2863
+        }
2864
+
2865
+        $this->set_prop( 'shipping', max( 0, floatval( $value ) ) );
2708 2866
     }
2709 2867
 
2710 2868
     /**
2711
-	 * Set the customer's vat rate.
2712
-	 *
2713
-	 * @since 1.0.19
2714
-	 * @param  string $value var rate.
2715
-	 */
2716
-	public function set_vat_rate( $value ) {
2717
-		$this->set_prop( 'vat_rate', $value );
2869
+     * Set the invoice sub total.
2870
+     *
2871
+     * @since 1.0.19
2872
+     * @param  float $value sub total.
2873
+     */
2874
+    public function set_subtotal( $value ) {
2875
+        $this->set_prop( 'subtotal', max( 0, $value ) );
2718 2876
     }
2719 2877
 
2720
-    /**
2721
-	 * Alias of self::set_vat_rate().
2722
-	 *
2723
-	 * @since 1.0.19
2724
-	 * @param  string $value var number.
2725
-	 */
2726
-	public function set_user_vat_rate( $value ) {
2727
-		$this->set_vat_rate( $value );
2728
-    }
2729
-
2730
-    /**
2731
-	 * Alias of self::set_vat_rate().
2732
-	 *
2733
-	 * @since 1.0.19
2734
-	 * @param  string $value var number.
2735
-	 */
2736
-	public function set_customer_vat_rate( $value ) {
2737
-		$this->set_vat_rate( $value );
2738
-    }
2739
-
2740
-    /**
2741
-	 * Set the customer's address.
2742
-	 *
2743
-	 * @since 1.0.19
2744
-	 * @param  string $value address.
2745
-	 */
2746
-	public function set_address( $value ) {
2747
-		$this->set_prop( 'address', $value );
2748
-    }
2749
-
2750
-    /**
2751
-	 * Alias of self::set_address().
2752
-	 *
2753
-	 * @since 1.0.19
2754
-	 * @param  string $value address.
2755
-	 */
2756
-	public function set_user_address( $value ) {
2757
-		$this->set_address( $value );
2758
-    }
2759
-
2760
-    /**
2761
-	 * Alias of self::set_address().
2762
-	 *
2763
-	 * @since 1.0.19
2764
-	 * @param  string $value address.
2765
-	 */
2766
-	public function set_customer_address( $value ) {
2767
-		$this->set_address( $value );
2768
-    }
2769
-
2770
-    /**
2771
-	 * Set whether the customer has viewed the invoice or not.
2772
-	 *
2773
-	 * @since 1.0.19
2774
-	 * @param  int|bool $value confirmed.
2775
-	 */
2776
-	public function set_is_viewed( $value ) {
2777
-		$this->set_prop( 'is_viewed', $value );
2778
-	}
2779
-
2780
-	/**
2781
-	 * Set extra email recipients.
2782
-	 *
2783
-	 * @since 1.0.19
2784
-	 * @param  string $value email recipients.
2785
-	 */
2786
-	public function set_email_cc( $value ) {
2787
-		$this->set_prop( 'email_cc', $value );
2788
-	}
2789
-
2790
-	/**
2791
-	 * Set the invoice template.
2792
-	 *
2793
-	 * @since 1.0.19
2794
-	 * @param  string $value template.
2795
-	 */
2796
-	public function set_template( $value ) {
2797
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2798
-			$this->set_prop( 'template', $value );
2799
-		}
2800
-	}
2801
-
2802
-	/**
2803
-	 * Set the invoice source.
2804
-	 *
2805
-	 * @since 1.0.19
2806
-	 * @param  string $value source.
2807
-	 * @deprecated
2808
-	 */
2809
-	public function created_via( $value ) {
2810
-		$this->set_created_via( sanitize_text_field( $value ) );
2811
-	}
2812
-
2813
-	/**
2814
-	 * Set the invoice source.
2815
-	 *
2816
-	 * @since 1.0.19
2817
-	 * @param  string $value source.
2818
-	 */
2819
-	public function set_created_via( $value ) {
2820
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2821
-	}
2822
-
2823
-	/**
2824
-	 * Set the customer's address confirmed status.
2825
-	 *
2826
-	 * @since 1.0.19
2827
-	 * @param  int|bool $value confirmed.
2828
-	 */
2829
-	public function set_address_confirmed( $value ) {
2830
-		$this->set_prop( 'address_confirmed', $value );
2831
-    }
2832
-
2833
-    /**
2834
-	 * Alias of self::set_address_confirmed().
2835
-	 *
2836
-	 * @since 1.0.19
2837
-	 * @param  int|bool $value confirmed.
2838
-	 */
2839
-	public function set_user_address_confirmed( $value ) {
2840
-		$this->set_address_confirmed( $value );
2841
-    }
2842
-
2843
-    /**
2844
-	 * Alias of self::set_address_confirmed().
2845
-	 *
2846
-	 * @since 1.0.19
2847
-	 * @param  int|bool $value confirmed.
2848
-	 */
2849
-	public function set_customer_address_confirmed( $value ) {
2850
-		$this->set_address_confirmed( $value );
2851
-    }
2852
-
2853
-    /**
2854
-	 * Set the shipping fee
2855
-	 *
2856
-	 * @since 1.0.19
2857
-	 * @param  float $value shipping amount.
2858
-	 */
2859
-	public function set_shipping( $value ) {
2860
-
2861
-		if ( ! is_numeric( $value ) ) {
2862
-			return $this->set_prop( 'shipping', null );
2863
-		}
2864
-
2865
-		$this->set_prop( 'shipping', max( 0, floatval( $value ) ) );
2866
-	}
2867
-
2868
-	/**
2869
-	 * Set the invoice sub total.
2870
-	 *
2871
-	 * @since 1.0.19
2872
-	 * @param  float $value sub total.
2873
-	 */
2874
-	public function set_subtotal( $value ) {
2875
-		$this->set_prop( 'subtotal', max( 0, $value ) );
2876
-	}
2877
-
2878
-	/**
2879
-	 * Set the invoice total.
2880
-	 *
2881
-	 * @since 1.0.19
2882
-	 * @param  float $value sub total.
2883
-	 */
2884
-	public function set_total( $value ) {
2885
-		$this->set_prop( 'total', max( 0, $value ) );
2878
+    /**
2879
+     * Set the invoice total.
2880
+     *
2881
+     * @since 1.0.19
2882
+     * @param  float $value sub total.
2883
+     */
2884
+    public function set_total( $value ) {
2885
+        $this->set_prop( 'total', max( 0, $value ) );
2886 2886
     }
2887 2887
 
2888 2888
     /**
2889
-	 * Set the invoice discount amount.
2890
-	 *
2891
-	 * @since 1.0.19
2892
-	 * @param  float $value discount total.
2893
-	 */
2894
-	public function set_total_discount( $value ) {
2895
-		$this->set_prop( 'total_discount', max( 0, $value ) );
2889
+     * Set the invoice discount amount.
2890
+     *
2891
+     * @since 1.0.19
2892
+     * @param  float $value discount total.
2893
+     */
2894
+    public function set_total_discount( $value ) {
2895
+        $this->set_prop( 'total_discount', max( 0, $value ) );
2896 2896
     }
2897 2897
 
2898 2898
     /**
2899
-	 * Alias of self::set_total_discount().
2900
-	 *
2901
-	 * @since 1.0.19
2902
-	 * @param  float $value discount total.
2903
-	 */
2904
-	public function set_discount( $value ) {
2905
-		$this->set_total_discount( $value );
2899
+     * Alias of self::set_total_discount().
2900
+     *
2901
+     * @since 1.0.19
2902
+     * @param  float $value discount total.
2903
+     */
2904
+    public function set_discount( $value ) {
2905
+        $this->set_total_discount( $value );
2906 2906
     }
2907 2907
 
2908 2908
     /**
2909
-	 * Set the invoice tax amount.
2910
-	 *
2911
-	 * @since 1.0.19
2912
-	 * @param  float $value tax total.
2913
-	 */
2914
-	public function set_total_tax( $value ) {
2915
-		$this->set_prop( 'total_tax', max( 0, $value ) );
2909
+     * Set the invoice tax amount.
2910
+     *
2911
+     * @since 1.0.19
2912
+     * @param  float $value tax total.
2913
+     */
2914
+    public function set_total_tax( $value ) {
2915
+        $this->set_prop( 'total_tax', max( 0, $value ) );
2916 2916
     }
2917 2917
 
2918 2918
     /**
2919
-	 * Alias of self::set_total_tax().
2920
-	 *
2921
-	 * @since 1.0.19
2922
-	 * @param  float $value tax total.
2923
-	 */
2924
-	public function set_tax_total( $value ) {
2925
-		$this->set_total_tax( $value );
2919
+     * Alias of self::set_total_tax().
2920
+     *
2921
+     * @since 1.0.19
2922
+     * @param  float $value tax total.
2923
+     */
2924
+    public function set_tax_total( $value ) {
2925
+        $this->set_total_tax( $value );
2926 2926
     }
2927 2927
 
2928 2928
     /**
2929
-	 * Set the invoice fees amount.
2930
-	 *
2931
-	 * @since 1.0.19
2932
-	 * @param  float $value fees total.
2933
-	 */
2934
-	public function set_total_fees( $value ) {
2935
-		$this->set_prop( 'total_fees', max( 0, $value ) );
2929
+     * Set the invoice fees amount.
2930
+     *
2931
+     * @since 1.0.19
2932
+     * @param  float $value fees total.
2933
+     */
2934
+    public function set_total_fees( $value ) {
2935
+        $this->set_prop( 'total_fees', max( 0, $value ) );
2936 2936
     }
2937 2937
 
2938 2938
     /**
2939
-	 * Alias of self::set_total_fees().
2940
-	 *
2941
-	 * @since 1.0.19
2942
-	 * @param  float $value fees total.
2943
-	 */
2944
-	public function set_fees_total( $value ) {
2945
-		$this->set_total_fees( $value );
2939
+     * Alias of self::set_total_fees().
2940
+     *
2941
+     * @since 1.0.19
2942
+     * @param  float $value fees total.
2943
+     */
2944
+    public function set_fees_total( $value ) {
2945
+        $this->set_total_fees( $value );
2946 2946
     }
2947 2947
 
2948 2948
     /**
2949
-	 * Set the invoice fees.
2950
-	 *
2951
-	 * @since 1.0.19
2952
-	 * @param  array $value fees.
2953
-	 */
2954
-	public function set_fees( $value ) {
2949
+     * Set the invoice fees.
2950
+     *
2951
+     * @since 1.0.19
2952
+     * @param  array $value fees.
2953
+     */
2954
+    public function set_fees( $value ) {
2955 2955
 
2956
-		if ( ! is_array( $value ) ) {
2957
-			$value = array();
2958
-		}
2956
+        if ( ! is_array( $value ) ) {
2957
+            $value = array();
2958
+        }
2959 2959
 
2960
-		$this->set_prop( 'fees', $value );
2960
+        $this->set_prop( 'fees', $value );
2961 2961
 
2962 2962
     }
2963 2963
 
2964 2964
     /**
2965
-	 * Set the invoice taxes.
2966
-	 *
2967
-	 * @since 1.0.19
2968
-	 * @param  array $value taxes.
2969
-	 */
2970
-	public function set_taxes( $value ) {
2965
+     * Set the invoice taxes.
2966
+     *
2967
+     * @since 1.0.19
2968
+     * @param  array $value taxes.
2969
+     */
2970
+    public function set_taxes( $value ) {
2971 2971
 
2972
-		if ( ! is_array( $value ) ) {
2973
-			$value = array();
2974
-		}
2972
+        if ( ! is_array( $value ) ) {
2973
+            $value = array();
2974
+        }
2975 2975
 
2976
-		$this->set_prop( 'taxes', $value );
2976
+        $this->set_prop( 'taxes', $value );
2977 2977
 
2978 2978
     }
2979 2979
 
2980 2980
     /**
2981
-	 * Set the invoice discounts.
2982
-	 *
2983
-	 * @since 1.0.19
2984
-	 * @param  array $value discounts.
2985
-	 */
2986
-	public function set_discounts( $value ) {
2981
+     * Set the invoice discounts.
2982
+     *
2983
+     * @since 1.0.19
2984
+     * @param  array $value discounts.
2985
+     */
2986
+    public function set_discounts( $value ) {
2987 2987
 
2988
-		if ( ! is_array( $value ) ) {
2989
-			$value = array();
2990
-		}
2988
+        if ( ! is_array( $value ) ) {
2989
+            $value = array();
2990
+        }
2991 2991
 
2992
-		$this->set_prop( 'discounts', $value );
2992
+        $this->set_prop( 'discounts', $value );
2993 2993
     }
2994 2994
 
2995 2995
     /**
2996
-	 * Set the invoice items.
2997
-	 *
2998
-	 * @since 1.0.19
2999
-	 * @param  GetPaid_Form_Item[] $value items.
3000
-	 */
3001
-	public function set_items( $value ) {
2996
+     * Set the invoice items.
2997
+     *
2998
+     * @since 1.0.19
2999
+     * @param  GetPaid_Form_Item[] $value items.
3000
+     */
3001
+    public function set_items( $value ) {
3002 3002
 
3003 3003
         // Remove existing items.
3004 3004
         $this->set_prop( 'items', array() );
3005
-		$this->recurring_item = null;
3005
+        $this->recurring_item = null;
3006 3006
 
3007 3007
         // Ensure that we have an array.
3008 3008
         if ( ! is_array( $value ) ) {
@@ -3016,95 +3016,95 @@  discard block
 block discarded – undo
3016 3016
     }
3017 3017
 
3018 3018
     /**
3019
-	 * Set the payment form.
3020
-	 *
3021
-	 * @since 1.0.19
3022
-	 * @param  int $value payment form.
3023
-	 */
3024
-	public function set_payment_form( $value ) {
3025
-		$this->set_prop( 'payment_form', $value );
3019
+     * Set the payment form.
3020
+     *
3021
+     * @since 1.0.19
3022
+     * @param  int $value payment form.
3023
+     */
3024
+    public function set_payment_form( $value ) {
3025
+        $this->set_prop( 'payment_form', $value );
3026 3026
     }
3027 3027
 
3028 3028
     /**
3029
-	 * Set the submission id.
3030
-	 *
3031
-	 * @since 1.0.19
3032
-	 * @param  string $value submission id.
3033
-	 */
3034
-	public function set_submission_id( $value ) {
3035
-		$this->set_prop( 'submission_id', $value );
3029
+     * Set the submission id.
3030
+     *
3031
+     * @since 1.0.19
3032
+     * @param  string $value submission id.
3033
+     */
3034
+    public function set_submission_id( $value ) {
3035
+        $this->set_prop( 'submission_id', $value );
3036 3036
     }
3037 3037
 
3038 3038
     /**
3039
-	 * Set the discount code.
3040
-	 *
3041
-	 * @since 1.0.19
3042
-	 * @param  string $value discount code.
3043
-	 */
3044
-	public function set_discount_code( $value ) {
3045
-		$this->set_prop( 'discount_code', sanitize_text_field( $value ) );
3039
+     * Set the discount code.
3040
+     *
3041
+     * @since 1.0.19
3042
+     * @param  string $value discount code.
3043
+     */
3044
+    public function set_discount_code( $value ) {
3045
+        $this->set_prop( 'discount_code', sanitize_text_field( $value ) );
3046 3046
     }
3047 3047
 
3048 3048
     /**
3049
-	 * Set the gateway.
3050
-	 *
3051
-	 * @since 1.0.19
3052
-	 * @param  string $value gateway.
3053
-	 */
3054
-	public function set_gateway( $value ) {
3055
-		$this->set_prop( 'gateway', $value );
3049
+     * Set the gateway.
3050
+     *
3051
+     * @since 1.0.19
3052
+     * @param  string $value gateway.
3053
+     */
3054
+    public function set_gateway( $value ) {
3055
+        $this->set_prop( 'gateway', $value );
3056 3056
     }
3057 3057
 
3058 3058
     /**
3059
-	 * Set the transaction id.
3060
-	 *
3061
-	 * @since 1.0.19
3062
-	 * @param  string $value transaction id.
3063
-	 */
3064
-	public function set_transaction_id( $value ) {
3065
-		if ( ! empty( $value ) ) {
3066
-			$this->set_prop( 'transaction_id', $value );
3067
-		}
3059
+     * Set the transaction id.
3060
+     *
3061
+     * @since 1.0.19
3062
+     * @param  string $value transaction id.
3063
+     */
3064
+    public function set_transaction_id( $value ) {
3065
+        if ( ! empty( $value ) ) {
3066
+            $this->set_prop( 'transaction_id', $value );
3067
+        }
3068 3068
     }
3069 3069
 
3070 3070
     /**
3071
-	 * Set the currency id.
3072
-	 *
3073
-	 * @since 1.0.19
3074
-	 * @param  string $value currency id.
3075
-	 */
3076
-	public function set_currency( $value ) {
3077
-		$this->set_prop( 'currency', $value );
3071
+     * Set the currency id.
3072
+     *
3073
+     * @since 1.0.19
3074
+     * @param  string $value currency id.
3075
+     */
3076
+    public function set_currency( $value ) {
3077
+        $this->set_prop( 'currency', $value );
3078 3078
     }
3079 3079
 
3080
-	/**
3081
-	 * Set whether to disable taxes.
3082
-	 *
3083
-	 * @since 1.0.19
3084
-	 * @param  bool $value value.
3085
-	 */
3086
-	public function set_disable_taxes( $value ) {
3087
-		$this->set_prop( 'disable_taxes', (bool) $value );
3088
-	}
3080
+    /**
3081
+     * Set whether to disable taxes.
3082
+     *
3083
+     * @since 1.0.19
3084
+     * @param  bool $value value.
3085
+     */
3086
+    public function set_disable_taxes( $value ) {
3087
+        $this->set_prop( 'disable_taxes', (bool) $value );
3088
+    }
3089 3089
 
3090 3090
     /**
3091
-	 * Set the subscription id.
3092
-	 *
3093
-	 * @since 1.0.19
3094
-	 * @param  string $value subscription id.
3095
-	 */
3096
-	public function set_subscription_id( $value ) {
3097
-		$this->set_prop( 'subscription_id', $value );
3098
-	}
3091
+     * Set the subscription id.
3092
+     *
3093
+     * @since 1.0.19
3094
+     * @param  string $value subscription id.
3095
+     */
3096
+    public function set_subscription_id( $value ) {
3097
+        $this->set_prop( 'subscription_id', $value );
3098
+    }
3099 3099
 	
3100
-	/**
3101
-	 * Set the remote subscription id.
3102
-	 *
3103
-	 * @since 1.0.19
3104
-	 * @param  string $value subscription id.
3105
-	 */
3106
-	public function set_remote_subscription_id( $value ) {
3107
-		$this->set_prop( 'remote_subscription_id', $value );
3100
+    /**
3101
+     * Set the remote subscription id.
3102
+     *
3103
+     * @since 1.0.19
3104
+     * @param  string $value subscription id.
3105
+     */
3106
+    public function set_remote_subscription_id( $value ) {
3107
+        $this->set_prop( 'remote_subscription_id', $value );
3108 3108
     }
3109 3109
 
3110 3110
     /*
@@ -3143,24 +3143,24 @@  discard block
 block discarded – undo
3143 3143
      */
3144 3144
     public function is_taxable() {
3145 3145
         return ! $this->get_disable_taxes();
3146
-	}
3146
+    }
3147 3147
 
3148
-	/**
3149
-	 * @deprecated
3150
-	 */
3151
-	public function has_vat() {
3148
+    /**
3149
+     * @deprecated
3150
+     */
3151
+    public function has_vat() {
3152 3152
         return $this->is_taxable();
3153
-	}
3153
+    }
3154 3154
 
3155
-	/**
3156
-	 * Checks to see if the invoice requires payment.
3157
-	 */
3158
-	public function is_free() {
3155
+    /**
3156
+     * Checks to see if the invoice requires payment.
3157
+     */
3158
+    public function is_free() {
3159 3159
         $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
3160 3160
 
3161
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3162
-			$is_free = false;
3163
-		}
3161
+        if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3162
+            $is_free = false;
3163
+        }
3164 3164
 
3165 3165
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
3166 3166
     }
@@ -3171,46 +3171,46 @@  discard block
 block discarded – undo
3171 3171
     public function is_paid() {
3172 3172
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
3173 3173
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
3174
-	}
3174
+    }
3175 3175
 
3176
-	/**
3176
+    /**
3177 3177
      * Checks if the invoice needs payment.
3178 3178
      */
3179
-	public function needs_payment() {
3180
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3179
+    public function needs_payment() {
3180
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3181 3181
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
3182 3182
     }
3183 3183
   
3184
-	/**
3184
+    /**
3185 3185
      * Checks if the invoice is refunded.
3186 3186
      */
3187
-	public function is_refunded() {
3187
+    public function is_refunded() {
3188 3188
         $is_refunded = $this->has_status( 'wpi-refunded' );
3189 3189
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3190
-	}
3190
+    }
3191 3191
 
3192
-	/**
3192
+    /**
3193 3193
      * Checks if the invoice is held.
3194 3194
      */
3195
-	public function is_held() {
3195
+    public function is_held() {
3196 3196
         $is_held = $this->has_status( 'wpi-onhold' );
3197 3197
         return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3198
-	}
3198
+    }
3199 3199
 
3200
-	/**
3200
+    /**
3201 3201
      * Checks if the invoice is due.
3202 3202
      */
3203
-	public function is_due() {
3204
-		$due_date = $this->get_due_date();
3205
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3206
-	}
3203
+    public function is_due() {
3204
+        $due_date = $this->get_due_date();
3205
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3206
+    }
3207 3207
 
3208
-	/**
3208
+    /**
3209 3209
      * Checks if the invoice is draft.
3210 3210
      */
3211
-	public function is_draft() {
3211
+    public function is_draft() {
3212 3212
         return $this->has_status( 'draft, auto-draft' );
3213
-	}
3213
+    }
3214 3214
 
3215 3215
     /**
3216 3216
      * Checks if the invoice has a given status.
@@ -3218,9 +3218,9 @@  discard block
 block discarded – undo
3218 3218
     public function has_status( $status ) {
3219 3219
         $status = wpinv_parse_list( $status );
3220 3220
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3221
-	}
3221
+    }
3222 3222
 
3223
-	/**
3223
+    /**
3224 3224
      * Checks if the invoice is of a given type.
3225 3225
      */
3226 3226
     public function is_type( $type ) {
@@ -3243,25 +3243,25 @@  discard block
 block discarded – undo
3243 3243
      */
3244 3244
     public function has_free_trial() {
3245 3245
         return $this->is_recurring() && 0 == $this->get_initial_total();
3246
-	}
3246
+    }
3247 3247
 
3248
-	/**
3248
+    /**
3249 3249
      * @deprecated
3250 3250
      */
3251 3251
     public function is_free_trial() {
3252 3252
         $this->has_free_trial();
3253 3253
     }
3254 3254
 
3255
-	/**
3255
+    /**
3256 3256
      * Check if the initial payment if 0.
3257 3257
      *
3258 3258
      */
3259
-	public function is_initial_free() {
3259
+    public function is_initial_free() {
3260 3260
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3261 3261
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3262 3262
     }
3263 3263
 	
3264
-	/**
3264
+    /**
3265 3265
      * Check if the recurring item has a free trial.
3266 3266
      *
3267 3267
      */
@@ -3274,21 +3274,21 @@  discard block
 block discarded – undo
3274 3274
 
3275 3275
         $item = $this->get_recurring( true );
3276 3276
         return $item->has_free_trial();
3277
-	}
3277
+    }
3278 3278
 
3279
-	/**
3279
+    /**
3280 3280
      * Check if the free trial is a result of a discount.
3281 3281
      */
3282 3282
     public function is_free_trial_from_discount() {
3283
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3284
-	}
3283
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3284
+    }
3285 3285
 	
3286
-	/**
3286
+    /**
3287 3287
      * @deprecated
3288 3288
      */
3289 3289
     public function discount_first_payment_only() {
3290 3290
 
3291
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3291
+        $discount = wpinv_get_discount_obj( $this->get_discount_code() );
3292 3292
         if ( ! $discount->exists() || ! $this->is_recurring() ) {
3293 3293
             return true;
3294 3294
         }
@@ -3313,147 +3313,147 @@  discard block
 block discarded – undo
3313 3313
      */
3314 3314
     public function add_item( $item ) {
3315 3315
 
3316
-		if ( is_array( $item ) ) {
3317
-			$item = $this->process_array_item( $item );
3318
-		}
3316
+        if ( is_array( $item ) ) {
3317
+            $item = $this->process_array_item( $item );
3318
+        }
3319 3319
 
3320
-		if ( is_numeric( $item ) ) {
3321
-			$item = new GetPaid_Form_Item( $item );
3322
-		}
3320
+        if ( is_numeric( $item ) ) {
3321
+            $item = new GetPaid_Form_Item( $item );
3322
+        }
3323 3323
 
3324 3324
         // Make sure that it is available for purchase.
3325
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3326
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3325
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3326
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3327 3327
         }
3328 3328
 
3329 3329
         // Do we have a recurring item?
3330
-		if ( $item->is_recurring() ) {
3331
-			$this->recurring_item = $item->get_id();
3330
+        if ( $item->is_recurring() ) {
3331
+            $this->recurring_item = $item->get_id();
3332 3332
         }
3333 3333
 
3334 3334
         // Invoice id.
3335 3335
         $item->invoice_id = (int) $this->get_id();
3336 3336
 
3337
-		// Remove duplicates.
3338
-		$this->remove_item( $item->get_id() );
3337
+        // Remove duplicates.
3338
+        $this->remove_item( $item->get_id() );
3339 3339
 
3340
-		if ( 0 == $item->get_quantity() ) {
3341
-			return;
3342
-		}
3340
+        if ( 0 == $item->get_quantity() ) {
3341
+            return;
3342
+        }
3343 3343
 
3344
-		// Retrieve all items.
3344
+        // Retrieve all items.
3345 3345
         $items   = $this->get_items();
3346 3346
 
3347
-		// Add new item.
3347
+        // Add new item.
3348 3348
         $items[] = $item;
3349 3349
 
3350 3350
         $this->set_prop( 'items', $items );
3351 3351
 
3352
-		return true;
3353
-	}
3352
+        return true;
3353
+    }
3354 3354
 
3355
-	/**
3356
-	 * Converts an array to an item.
3357
-	 *
3358
-	 * @since 1.0.19
3359
-	 * @return GetPaid_Form_Item
3360
-	 */
3361
-	protected function process_array_item( $array ) {
3355
+    /**
3356
+     * Converts an array to an item.
3357
+     *
3358
+     * @since 1.0.19
3359
+     * @return GetPaid_Form_Item
3360
+     */
3361
+    protected function process_array_item( $array ) {
3362 3362
 
3363
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3364
-		$item    = new GetPaid_Form_Item( $item_id );
3363
+        $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3364
+        $item    = new GetPaid_Form_Item( $item_id );
3365 3365
 
3366
-		// Set item data.
3367
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3368
-			if ( isset( $array[ "item_$key" ] ) ) {
3369
-				$method = "set_$key";
3370
-				$item->$method( $array[ "item_$key" ] );
3371
-			}
3372
-		}
3366
+        // Set item data.
3367
+        foreach ( array( 'name', 'price', 'description' ) as $key ) {
3368
+            if ( isset( $array[ "item_$key" ] ) ) {
3369
+                $method = "set_$key";
3370
+                $item->$method( $array[ "item_$key" ] );
3371
+            }
3372
+        }
3373 3373
 
3374
-		if ( isset( $array['quantity'] ) ) {
3375
-			$item->set_quantity( $array['quantity'] );
3376
-		}
3374
+        if ( isset( $array['quantity'] ) ) {
3375
+            $item->set_quantity( $array['quantity'] );
3376
+        }
3377 3377
 
3378
-		// Set item meta.
3379
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3380
-			$item->set_item_meta( $array['meta'] );
3381
-		}
3378
+        // Set item meta.
3379
+        if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3380
+            $item->set_item_meta( $array['meta'] );
3381
+        }
3382 3382
 
3383
-		return $item;
3383
+        return $item;
3384 3384
 
3385
-	}
3385
+    }
3386 3386
 
3387 3387
     /**
3388
-	 * Retrieves a specific item.
3389
-	 *
3390
-	 * @since 1.0.19
3391
-	 * @return GetPaid_Form_Item|null
3392
-	 */
3393
-	public function get_item( $item_id ) {
3388
+     * Retrieves a specific item.
3389
+     *
3390
+     * @since 1.0.19
3391
+     * @return GetPaid_Form_Item|null
3392
+     */
3393
+    public function get_item( $item_id ) {
3394 3394
 
3395
-		foreach ( $this->get_items() as $item ) {
3396
-			if ( (int) $item_id == $item->get_id() ) {
3397
-				return $item;
3398
-			}
3399
-		}
3395
+        foreach ( $this->get_items() as $item ) {
3396
+            if ( (int) $item_id == $item->get_id() ) {
3397
+                return $item;
3398
+            }
3399
+        }
3400 3400
 
3401
-		return null;
3401
+        return null;
3402 3402
     }
3403 3403
 
3404 3404
     /**
3405
-	 * Removes a specific item.
3406
-	 *
3407
-	 * @since 1.0.19
3408
-	 */
3409
-	public function remove_item( $item_id ) {
3410
-		$items   = $this->get_items();
3411
-		$item_id = (int) $item_id;
3405
+     * Removes a specific item.
3406
+     *
3407
+     * @since 1.0.19
3408
+     */
3409
+    public function remove_item( $item_id ) {
3410
+        $items   = $this->get_items();
3411
+        $item_id = (int) $item_id;
3412 3412
 
3413
-		foreach ( $items as $index => $item ) {
3414
-			if ( (int) $item_id == $item->get_id() ) {
3415
-				unset( $items[ $index ] );
3416
-				$this->set_prop( 'items', $items );
3413
+        foreach ( $items as $index => $item ) {
3414
+            if ( (int) $item_id == $item->get_id() ) {
3415
+                unset( $items[ $index ] );
3416
+                $this->set_prop( 'items', $items );
3417 3417
 
3418
-				if ( $item_id == $this->recurring_item ) {
3419
-					$this->recurring_item = null;
3420
-				}
3418
+                if ( $item_id == $this->recurring_item ) {
3419
+                    $this->recurring_item = null;
3420
+                }
3421 3421
 
3422
-			}
3423
-		}
3422
+            }
3423
+        }
3424 3424
 
3425 3425
     }
3426 3426
 
3427 3427
     /**
3428
-	 * Adds a fee to the invoice.
3429
-	 *
3430
-	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3431
-	 * @since 1.0.19
3432
-	 */
3428
+     * Adds a fee to the invoice.
3429
+     *
3430
+     * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3431
+     * @since 1.0.19
3432
+     */
3433 3433
     public function add_fee( $fee ) {
3434 3434
 
3435
-		$fees                 = $this->get_fees();
3436
-		$fees[ $fee['name'] ] = $fee;
3437
-		$this->set_prop( 'fees', $fees );
3435
+        $fees                 = $this->get_fees();
3436
+        $fees[ $fee['name'] ] = $fee;
3437
+        $this->set_prop( 'fees', $fees );
3438 3438
 
3439 3439
     }
3440 3440
 
3441 3441
     /**
3442
-	 * Retrieves a specific fee.
3443
-	 *
3444
-	 * @since 1.0.19
3445
-	 */
3446
-	public function get_fee( $fee ) {
3442
+     * Retrieves a specific fee.
3443
+     *
3444
+     * @since 1.0.19
3445
+     */
3446
+    public function get_fee( $fee ) {
3447 3447
         $fees = $this->get_fees();
3448
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3448
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3449 3449
     }
3450 3450
 
3451 3451
     /**
3452
-	 * Removes a specific fee.
3453
-	 *
3454
-	 * @since 1.0.19
3455
-	 */
3456
-	public function remove_fee( $fee ) {
3452
+     * Removes a specific fee.
3453
+     *
3454
+     * @since 1.0.19
3455
+     */
3456
+    public function remove_fee( $fee ) {
3457 3457
         $fees = $this->get_fees();
3458 3458
         if ( isset( $fees[ $fee ] ) ) {
3459 3459
             unset( $fees[ $fee ] );
@@ -3461,55 +3461,55 @@  discard block
 block discarded – undo
3461 3461
         }
3462 3462
     }
3463 3463
 
3464
-	/**
3465
-	 * Adds a discount to the invoice.
3466
-	 *
3467
-	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3468
-	 * @since 1.0.19
3469
-	 */
3470
-	public function add_discount( $discount ) {
3464
+    /**
3465
+     * Adds a discount to the invoice.
3466
+     *
3467
+     * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3468
+     * @since 1.0.19
3469
+     */
3470
+    public function add_discount( $discount ) {
3471 3471
 
3472
-		$discounts = $this->get_discounts();
3473
-		$discounts[ $discount['name'] ] = $discount;
3474
-		$this->set_prop( 'discounts', $discounts );
3472
+        $discounts = $this->get_discounts();
3473
+        $discounts[ $discount['name'] ] = $discount;
3474
+        $this->set_prop( 'discounts', $discounts );
3475 3475
 
3476
-	}
3476
+    }
3477 3477
 
3478 3478
     /**
3479
-	 * Retrieves a specific discount.
3480
-	 *
3481
-	 * @since 1.0.19
3482
-	 * @return float
3483
-	 */
3484
-	public function get_discount( $discount = false ) {
3479
+     * Retrieves a specific discount.
3480
+     *
3481
+     * @since 1.0.19
3482
+     * @return float
3483
+     */
3484
+    public function get_discount( $discount = false ) {
3485 3485
 
3486
-		// Backwards compatibilty.
3487
-		if ( empty( $discount ) ) {
3488
-			return $this->get_total_discount();
3489
-		}
3486
+        // Backwards compatibilty.
3487
+        if ( empty( $discount ) ) {
3488
+            return $this->get_total_discount();
3489
+        }
3490 3490
 
3491 3491
         $discounts = $this->get_discounts();
3492
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3492
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3493 3493
     }
3494 3494
 
3495 3495
     /**
3496
-	 * Removes a specific discount.
3497
-	 *
3498
-	 * @since 1.0.19
3499
-	 */
3500
-	public function remove_discount( $discount ) {
3496
+     * Removes a specific discount.
3497
+     *
3498
+     * @since 1.0.19
3499
+     */
3500
+    public function remove_discount( $discount ) {
3501 3501
         $discounts = $this->get_discounts();
3502 3502
         if ( isset( $discounts[ $discount ] ) ) {
3503 3503
             unset( $discounts[ $discount ] );
3504 3504
             $this->set_prop( 'discounts', $discounts );
3505 3505
         }
3506 3506
 
3507
-		if ( 'discount_code' == $discount ) {
3508
-			foreach ( $this->get_items() as $item ) {
3509
-				$item->item_discount           = 0;
3510
-				$item->recurring_item_discount = 0;
3511
-			}
3512
-		}
3507
+        if ( 'discount_code' == $discount ) {
3508
+            foreach ( $this->get_items() as $item ) {
3509
+                $item->item_discount           = 0;
3510
+                $item->recurring_item_discount = 0;
3511
+            }
3512
+        }
3513 3513
 
3514 3514
     }
3515 3515
 
@@ -3522,34 +3522,34 @@  discard block
 block discarded – undo
3522 3522
         if ( $this->is_taxable() ) {
3523 3523
 
3524 3524
             $taxes                 = $this->get_taxes();
3525
-			$taxes[ $tax['name'] ] = $tax;
3526
-			$this->set_prop( 'taxes', $tax );
3525
+            $taxes[ $tax['name'] ] = $tax;
3526
+            $this->set_prop( 'taxes', $tax );
3527 3527
 
3528 3528
         }
3529 3529
     }
3530 3530
 
3531 3531
     /**
3532
-	 * Retrieves a specific tax.
3533
-	 *
3534
-	 * @since 1.0.19
3535
-	 */
3536
-	public function get_tax( $tax = null ) {
3532
+     * Retrieves a specific tax.
3533
+     *
3534
+     * @since 1.0.19
3535
+     */
3536
+    public function get_tax( $tax = null ) {
3537 3537
 
3538
-		// Backwards compatility.
3539
-		if ( empty( $tax ) ) {
3540
-			return $this->get_total_tax();
3541
-		}
3538
+        // Backwards compatility.
3539
+        if ( empty( $tax ) ) {
3540
+            return $this->get_total_tax();
3541
+        }
3542 3542
 
3543 3543
         $taxes = $this->get_taxes();
3544
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3544
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3545 3545
     }
3546 3546
 
3547 3547
     /**
3548
-	 * Removes a specific tax.
3549
-	 *
3550
-	 * @since 1.0.19
3551
-	 */
3552
-	public function remove_tax( $tax ) {
3548
+     * Removes a specific tax.
3549
+     *
3550
+     * @since 1.0.19
3551
+     */
3552
+    public function remove_tax( $tax ) {
3553 3553
         $taxes = $this->get_taxes();
3554 3554
         if ( isset( $taxes[ $tax ] ) ) {
3555 3555
             unset( $taxes[ $tax ] );
@@ -3558,185 +3558,185 @@  discard block
 block discarded – undo
3558 3558
     }
3559 3559
 
3560 3560
     /**
3561
-	 * Recalculates the invoice subtotal.
3562
-	 *
3563
-	 * @since 1.0.19
3564
-	 * @return float The recalculated subtotal
3565
-	 */
3566
-	public function recalculate_subtotal() {
3561
+     * Recalculates the invoice subtotal.
3562
+     *
3563
+     * @since 1.0.19
3564
+     * @return float The recalculated subtotal
3565
+     */
3566
+    public function recalculate_subtotal() {
3567 3567
         $items     = $this->get_items();
3568
-		$subtotal  = 0;
3569
-		$recurring = 0;
3568
+        $subtotal  = 0;
3569
+        $recurring = 0;
3570 3570
 
3571 3571
         foreach ( $items as $item ) {
3572
-			$subtotal  += $item->get_sub_total( 'edit' );
3573
-			$recurring += $item->get_recurring_sub_total( 'edit' );
3572
+            $subtotal  += $item->get_sub_total( 'edit' );
3573
+            $recurring += $item->get_recurring_sub_total( 'edit' );
3574 3574
         }
3575 3575
 
3576
-		if ( wpinv_prices_include_tax() ) {
3577
-			$subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3578
-			$recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3579
-		}
3576
+        if ( wpinv_prices_include_tax() ) {
3577
+            $subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3578
+            $recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3579
+        }
3580 3580
 
3581
-		$current = $this->is_renewal() ? $recurring : $subtotal;
3582
-		$this->set_subtotal( $current );
3581
+        $current = $this->is_renewal() ? $recurring : $subtotal;
3582
+        $this->set_subtotal( $current );
3583 3583
 
3584
-		$this->totals['subtotal'] = array(
3585
-			'initial'   => $subtotal,
3586
-			'recurring' => $recurring,
3587
-		);
3584
+        $this->totals['subtotal'] = array(
3585
+            'initial'   => $subtotal,
3586
+            'recurring' => $recurring,
3587
+        );
3588 3588
 
3589 3589
         return $current;
3590 3590
     }
3591 3591
 
3592 3592
     /**
3593
-	 * Recalculates the invoice discount total.
3594
-	 *
3595
-	 * @since 1.0.19
3596
-	 * @return float The recalculated discount
3597
-	 */
3598
-	public function recalculate_total_discount() {
3593
+     * Recalculates the invoice discount total.
3594
+     *
3595
+     * @since 1.0.19
3596
+     * @return float The recalculated discount
3597
+     */
3598
+    public function recalculate_total_discount() {
3599 3599
         $discounts = $this->get_discounts();
3600
-		$discount  = 0;
3601
-		$recurring = 0;
3600
+        $discount  = 0;
3601
+        $recurring = 0;
3602 3602
 
3603 3603
         foreach ( $discounts as $data ) {
3604
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3605
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3606
-		}
3604
+            $discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3605
+            $recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3606
+        }
3607 3607
 
3608
-		$current = $this->is_renewal() ? $recurring : $discount;
3608
+        $current = $this->is_renewal() ? $recurring : $discount;
3609 3609
 
3610
-		$this->set_total_discount( $current );
3610
+        $this->set_total_discount( $current );
3611 3611
 
3612
-		$this->totals['discount'] = array(
3613
-			'initial'   => $discount,
3614
-			'recurring' => $recurring,
3615
-		);
3612
+        $this->totals['discount'] = array(
3613
+            'initial'   => $discount,
3614
+            'recurring' => $recurring,
3615
+        );
3616 3616
 
3617
-		return $current;
3617
+        return $current;
3618 3618
 
3619 3619
     }
3620 3620
 
3621 3621
     /**
3622
-	 * Recalculates the invoice tax total.
3623
-	 *
3624
-	 * @since 1.0.19
3625
-	 * @return float The recalculated tax
3626
-	 */
3627
-	public function recalculate_total_tax() {
3622
+     * Recalculates the invoice tax total.
3623
+     *
3624
+     * @since 1.0.19
3625
+     * @return float The recalculated tax
3626
+     */
3627
+    public function recalculate_total_tax() {
3628 3628
 
3629
-		// Maybe disable taxes.
3630
-		$vat_number = $this->get_vat_number();
3631
-		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3629
+        // Maybe disable taxes.
3630
+        $vat_number = $this->get_vat_number();
3631
+        $skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3632 3632
 
3633
-		if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3634
-			$skip_tax = false;
3635
-		}
3633
+        if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3634
+            $skip_tax = false;
3635
+        }
3636 3636
 
3637
-		if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax   ) {
3637
+        if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax   ) {
3638 3638
 
3639
-			$this->totals['tax'] = array(
3640
-				'initial'   => 0,
3641
-				'recurring' => 0,
3642
-			);
3639
+            $this->totals['tax'] = array(
3640
+                'initial'   => 0,
3641
+                'recurring' => 0,
3642
+            );
3643 3643
 
3644
-			$this->tax_rate = 0;
3644
+            $this->tax_rate = 0;
3645 3645
 
3646
-			$this->set_taxes( array() );
3647
-			$current = 0;
3648
-		} else {
3646
+            $this->set_taxes( array() );
3647
+            $current = 0;
3648
+        } else {
3649 3649
 
3650
-			$item_taxes = array();
3650
+            $item_taxes = array();
3651 3651
 
3652
-			foreach ( $this->get_items() as $item ) {
3653
-				$rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3654
-				$rates    = getpaid_filter_item_tax_rates( $item, $rates );
3655
-				$taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3656
-				$r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3657
-				foreach ( $taxes as $name => $amount ) {
3658
-					$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3659
-					$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3652
+            foreach ( $this->get_items() as $item ) {
3653
+                $rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3654
+                $rates    = getpaid_filter_item_tax_rates( $item, $rates );
3655
+                $taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3656
+                $r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3657
+                foreach ( $taxes as $name => $amount ) {
3658
+                    $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3659
+                    $tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3660 3660
 
3661
-					if ( ! isset( $item_taxes[ $name ] ) ) {
3662
-						$item_taxes[ $name ] = $tax;
3663
-						continue;
3664
-					}
3661
+                    if ( ! isset( $item_taxes[ $name ] ) ) {
3662
+                        $item_taxes[ $name ] = $tax;
3663
+                        continue;
3664
+                    }
3665 3665
 
3666
-					$item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3667
-					$item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3666
+                    $item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3667
+                    $item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3668 3668
 
3669
-				}
3669
+                }
3670 3670
 
3671
-			}
3671
+            }
3672 3672
 
3673
-			$item_taxes = array_replace( $this->get_taxes(), $item_taxes );
3674
-			$this->set_taxes( $item_taxes );
3673
+            $item_taxes = array_replace( $this->get_taxes(), $item_taxes );
3674
+            $this->set_taxes( $item_taxes );
3675 3675
 
3676
-			$initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3677
-			$recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3676
+            $initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3677
+            $recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3678 3678
 
3679
-			$current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3679
+            $current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3680 3680
 
3681
-			$this->totals['tax'] = array(
3682
-				'initial'   => $initial_tax,
3683
-				'recurring' => $recurring_tax,
3684
-			);
3681
+            $this->totals['tax'] = array(
3682
+                'initial'   => $initial_tax,
3683
+                'recurring' => $recurring_tax,
3684
+            );
3685 3685
 
3686
-		}
3686
+        }
3687 3687
 
3688
-		$this->set_total_tax( $current );
3688
+        $this->set_total_tax( $current );
3689 3689
 
3690
-		return $current;
3690
+        return $current;
3691 3691
 
3692 3692
     }
3693 3693
 
3694 3694
     /**
3695
-	 * Recalculates the invoice fees total.
3696
-	 *
3697
-	 * @since 1.0.19
3698
-	 * @return float The recalculated fee
3699
-	 */
3700
-	public function recalculate_total_fees() {
3701
-		$fees      = $this->get_fees();
3702
-		$fee       = 0;
3703
-		$recurring = 0;
3695
+     * Recalculates the invoice fees total.
3696
+     *
3697
+     * @since 1.0.19
3698
+     * @return float The recalculated fee
3699
+     */
3700
+    public function recalculate_total_fees() {
3701
+        $fees      = $this->get_fees();
3702
+        $fee       = 0;
3703
+        $recurring = 0;
3704 3704
 
3705 3705
         foreach ( $fees as $data ) {
3706
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3707
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3708
-		}
3706
+            $fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3707
+            $recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3708
+        }
3709 3709
 
3710
-		$current = $this->is_renewal() ? $recurring : $fee;
3711
-		$this->set_total_fees( $current );
3710
+        $current = $this->is_renewal() ? $recurring : $fee;
3711
+        $this->set_total_fees( $current );
3712 3712
 
3713
-		$this->totals['fee'] = array(
3714
-			'initial'   => $fee,
3715
-			'recurring' => $recurring,
3716
-		);
3713
+        $this->totals['fee'] = array(
3714
+            'initial'   => $fee,
3715
+            'recurring' => $recurring,
3716
+        );
3717 3717
 
3718 3718
         $this->set_total_fees( $fee );
3719 3719
         return $current;
3720 3720
     }
3721 3721
 
3722 3722
     /**
3723
-	 * Recalculates the invoice total.
3724
-	 *
3725
-	 * @since 1.0.19
3723
+     * Recalculates the invoice total.
3724
+     *
3725
+     * @since 1.0.19
3726 3726
      * @return float The invoice total
3727
-	 */
3728
-	public function recalculate_total() {
3727
+     */
3728
+    public function recalculate_total() {
3729 3729
         $this->recalculate_total_fees();
3730 3730
         $this->recalculate_total_discount();
3731
-		$this->recalculate_total_tax();
3732
-		$this->recalculate_subtotal();
3733
-		$this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3734
-		return $this->get_total();
3735
-	}
3736
-
3737
-	/**
3738
-	 * @deprecated
3739
-	 */
3731
+        $this->recalculate_total_tax();
3732
+        $this->recalculate_subtotal();
3733
+        $this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3734
+        return $this->get_total();
3735
+    }
3736
+
3737
+    /**
3738
+     * @deprecated
3739
+     */
3740 3740
     public function recalculate_totals() {
3741 3741
         $this->recalculate_total();
3742 3742
         $this->save( true );
@@ -3750,22 +3750,22 @@  discard block
 block discarded – undo
3750 3750
         return $this->get_data();
3751 3751
     }
3752 3752
 
3753
-	/**
3753
+    /**
3754 3754
      * Adds a system note to an invoice.
3755 3755
      *
3756 3756
      * @param string $note The note being added.
3757
-	 * @return int|false The new note's ID on success, false on failure.
3757
+     * @return int|false The new note's ID on success, false on failure.
3758 3758
      *
3759 3759
      */
3760 3760
     public function add_system_note( $note ) {
3761
-		return $this->add_note( $note, false, false, true );
3762
-	}
3761
+        return $this->add_note( $note, false, false, true );
3762
+    }
3763 3763
 
3764 3764
     /**
3765 3765
      * Adds a note to an invoice.
3766 3766
      *
3767 3767
      * @param string $note The note being added.
3768
-	 * @return int|false The new note's ID on success, false on failure.
3768
+     * @return int|false The new note's ID on success, false on failure.
3769 3769
      *
3770 3770
      */
3771 3771
     public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
@@ -3775,21 +3775,21 @@  discard block
 block discarded – undo
3775 3775
             return false;
3776 3776
         }
3777 3777
 
3778
-		$author       = 'System';
3779
-		$author_email = '[email protected]';
3778
+        $author       = 'System';
3779
+        $author_email = '[email protected]';
3780 3780
 
3781
-		// If this is an admin comment or it has been added by the user.
3782
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3783
-			$user         = get_user_by( 'id', get_current_user_id() );
3781
+        // If this is an admin comment or it has been added by the user.
3782
+        if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3783
+            $user         = get_user_by( 'id', get_current_user_id() );
3784 3784
             $author       = $user->display_name;
3785 3785
             $author_email = $user->user_email;
3786
-		}
3786
+        }
3787 3787
 
3788
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3788
+        return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3789 3789
 
3790
-	}
3790
+    }
3791 3791
 
3792
-	/**
3792
+    /**
3793 3793
      * Generates a unique key for the invoice.
3794 3794
      */
3795 3795
     public function generate_key( $string = '' ) {
@@ -3809,113 +3809,113 @@  discard block
 block discarded – undo
3809 3809
             $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3810 3810
         }
3811 3811
 
3812
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3813
-
3814
-	}
3815
-
3816
-	/**
3817
-	 * Handle the status transition.
3818
-	 */
3819
-	protected function status_transition() {
3820
-		$status_transition = $this->status_transition;
3821
-
3822
-		// Reset status transition variable.
3823
-		$this->status_transition = false;
3812
+        return wpinv_format_invoice_number( $number, $this->get_post_type() );
3824 3813
 
3825
-		if ( $status_transition ) {
3826
-			try {
3827
-
3828
-				// Fire a hook for the status change.
3829
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3830
-
3831
-				// @deprecated this is deprecated and will be removed in the future.
3832
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3833
-
3834
-				if ( ! empty( $status_transition['from'] ) ) {
3835
-
3836
-					/* translators: 1: old invoice status 2: new invoice status */
3837
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3838
-
3839
-					// Fire another hook.
3840
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3841
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3842
-
3843
-					// @deprecated this is deprecated and will be removed in the future.
3844
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3845
-
3846
-					// Note the transition occurred.
3847
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3848
-
3849
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
3850
-					if (
3851
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3852
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3853
-					) {
3854
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3855
-					}
3856
-
3857
-					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3858
-					if (
3859
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3860
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3861
-					) {
3862
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3863
-					}
3864
-				} else {
3865
-					/* translators: %s: new invoice status */
3866
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3867
-
3868
-					// Note the transition occurred.
3869
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3814
+    }
3870 3815
 
3871
-				}
3872
-			} catch ( Exception $e ) {
3873
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3874
-			}
3875
-		}
3876
-	}
3816
+    /**
3817
+     * Handle the status transition.
3818
+     */
3819
+    protected function status_transition() {
3820
+        $status_transition = $this->status_transition;
3821
+
3822
+        // Reset status transition variable.
3823
+        $this->status_transition = false;
3824
+
3825
+        if ( $status_transition ) {
3826
+            try {
3827
+
3828
+                // Fire a hook for the status change.
3829
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3830
+
3831
+                // @deprecated this is deprecated and will be removed in the future.
3832
+                do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3833
+
3834
+                if ( ! empty( $status_transition['from'] ) ) {
3835
+
3836
+                    /* translators: 1: old invoice status 2: new invoice status */
3837
+                    $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3838
+
3839
+                    // Fire another hook.
3840
+                    do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3841
+                    do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3842
+
3843
+                    // @deprecated this is deprecated and will be removed in the future.
3844
+                    do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3845
+
3846
+                    // Note the transition occurred.
3847
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3848
+
3849
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
3850
+                    if (
3851
+                        in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3852
+                        && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3853
+                    ) {
3854
+                        do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3855
+                    }
3856
+
3857
+                    // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3858
+                    if (
3859
+                        in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3860
+                        && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3861
+                    ) {
3862
+                        do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3863
+                    }
3864
+                } else {
3865
+                    /* translators: %s: new invoice status */
3866
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3867
+
3868
+                    // Note the transition occurred.
3869
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3870
+
3871
+                }
3872
+            } catch ( Exception $e ) {
3873
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3874
+            }
3875
+        }
3876
+    }
3877 3877
 
3878
-	/**
3879
-	 * Updates an invoice status.
3880
-	 */
3881
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3878
+    /**
3879
+     * Updates an invoice status.
3880
+     */
3881
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
3882 3882
 
3883
-		// Fires before updating a status.
3884
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3883
+        // Fires before updating a status.
3884
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3885 3885
 
3886
-		// Update the status.
3887
-		$this->set_status( $new_status, $note, $manual );
3886
+        // Update the status.
3887
+        $this->set_status( $new_status, $note, $manual );
3888 3888
 
3889
-		// Save the order.
3890
-		return $this->save();
3889
+        // Save the order.
3890
+        return $this->save();
3891 3891
 
3892
-	}
3892
+    }
3893 3893
 
3894
-	/**
3895
-	 * @deprecated
3896
-	 */
3897
-	public function refresh_item_ids() {
3894
+    /**
3895
+     * @deprecated
3896
+     */
3897
+    public function refresh_item_ids() {
3898 3898
         $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) );
3899 3899
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3900
-	}
3900
+    }
3901 3901
 
3902
-	/**
3903
-	 * @deprecated
3904
-	 */
3905
-	public function update_items( $temp = false ) {
3902
+    /**
3903
+     * @deprecated
3904
+     */
3905
+    public function update_items( $temp = false ) {
3906 3906
 
3907
-		$this->set_items( $this->get_items() );
3907
+        $this->set_items( $this->get_items() );
3908 3908
 
3909
-		if ( ! $temp ) {
3910
-			$this->save();
3911
-		}
3909
+        if ( ! $temp ) {
3910
+            $this->save();
3911
+        }
3912 3912
 
3913 3913
         return $this;
3914
-	}
3914
+    }
3915 3915
 
3916
-	/**
3917
-	 * @deprecated
3918
-	 */
3916
+    /**
3917
+     * @deprecated
3918
+     */
3919 3919
     public function validate_discount() {
3920 3920
 
3921 3921
         $discount_code = $this->get_discount_code();
@@ -3931,93 +3931,93 @@  discard block
 block discarded – undo
3931 3931
 
3932 3932
     }
3933 3933
 
3934
-	/**
3935
-	 * Refunds an invoice.
3936
-	 */
3934
+    /**
3935
+     * Refunds an invoice.
3936
+     */
3937 3937
     public function refund() {
3938
-		$this->set_status( 'wpi-refunded' );
3938
+        $this->set_status( 'wpi-refunded' );
3939 3939
         $this->save();
3940
-	}
3940
+    }
3941 3941
 
3942
-	/**
3943
-	 * Marks an invoice as paid.
3944
-	 * 
3945
-	 * @param string $transaction_id
3946
-	 */
3942
+    /**
3943
+     * Marks an invoice as paid.
3944
+     * 
3945
+     * @param string $transaction_id
3946
+     */
3947 3947
     public function mark_paid( $transaction_id = null, $note = '' ) {
3948 3948
 
3949
-		// Set the transaction id.
3950
-		if ( empty( $transaction_id ) ) {
3951
-			$transaction_id = $this->generate_key('trans_');
3952
-		}
3949
+        // Set the transaction id.
3950
+        if ( empty( $transaction_id ) ) {
3951
+            $transaction_id = $this->generate_key('trans_');
3952
+        }
3953 3953
 
3954
-		if ( ! $this->get_transaction_id() ) {
3955
-			$this->set_transaction_id( $transaction_id );
3956
-		}
3954
+        if ( ! $this->get_transaction_id() ) {
3955
+            $this->set_transaction_id( $transaction_id );
3956
+        }
3957 3957
 
3958
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3959
-			return $this->save();
3960
-		}
3958
+        if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3959
+            return $this->save();
3960
+        }
3961 3961
 
3962
-		// Set the completed date.
3963
-		$this->set_date_completed( current_time( 'mysql' ) );
3962
+        // Set the completed date.
3963
+        $this->set_date_completed( current_time( 'mysql' ) );
3964 3964
 
3965
-		// Set the new status.
3966
-		$gateway = sanitize_text_field( $this->get_gateway_title() );
3967
-		if ( $this->is_renewal() || ! $this->is_parent() ) {
3965
+        // Set the new status.
3966
+        $gateway = sanitize_text_field( $this->get_gateway_title() );
3967
+        if ( $this->is_renewal() || ! $this->is_parent() ) {
3968 3968
 
3969
-			$_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
3970
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3969
+            $_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
3970
+            $_note = $_note . empty( $note ) ? '' : " ($note)";
3971 3971
 
3972
-			if ( 'none' == $this->get_gateway() ) {
3973
-				$_note = $note;
3974
-			}
3972
+            if ( 'none' == $this->get_gateway() ) {
3973
+                $_note = $note;
3974
+            }
3975 3975
 
3976
-			$this->set_status( 'wpi-renewal', $_note );
3976
+            $this->set_status( 'wpi-renewal', $_note );
3977 3977
 
3978
-		} else {
3978
+        } else {
3979 3979
 
3980
-			$_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
3981
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3980
+            $_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
3981
+            $_note = $_note . empty( $note ) ? '' : " ($note)";
3982 3982
 
3983
-			if ( 'none' == $this->get_gateway() ) {
3984
-				$_note = $note;
3985
-			}
3983
+            if ( 'none' == $this->get_gateway() ) {
3984
+                $_note = $note;
3985
+            }
3986 3986
 
3987
-			$this->set_status( 'publish', $_note );
3987
+            $this->set_status( 'publish', $_note );
3988 3988
 
3989
-		}
3989
+        }
3990 3990
 
3991
-		// Set checkout mode.
3992
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3993
-		$this->set_mode( $mode );
3991
+        // Set checkout mode.
3992
+        $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3993
+        $this->set_mode( $mode );
3994 3994
 
3995
-		// Save the invoice.
3995
+        // Save the invoice.
3996 3996
         $this->save();
3997
-	}
3998
-
3999
-	/**
4000
-	 * Save data to the database.
4001
-	 *
4002
-	 * @since 1.0.19
4003
-	 * @return int invoice ID
4004
-	 */
4005
-	public function save() {
4006
-		$this->maybe_set_date_paid();
4007
-		$this->maybe_set_key();
4008
-		parent::save();
4009
-		$this->clear_cache();
4010
-		$this->status_transition();
4011
-		return $this->get_id();
4012
-	}
4013
-
4014
-	/**
3997
+    }
3998
+
3999
+    /**
4000
+     * Save data to the database.
4001
+     *
4002
+     * @since 1.0.19
4003
+     * @return int invoice ID
4004
+     */
4005
+    public function save() {
4006
+        $this->maybe_set_date_paid();
4007
+        $this->maybe_set_key();
4008
+        parent::save();
4009
+        $this->clear_cache();
4010
+        $this->status_transition();
4011
+        return $this->get_id();
4012
+    }
4013
+
4014
+    /**
4015 4015
      * Clears the subscription's cache.
4016 4016
      */
4017 4017
     public function clear_cache() {
4018
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
4019
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
4020
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
4021
-	}
4018
+        wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
4019
+        wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
4020
+        wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
4021
+    }
4022 4022
 
4023 4023
 }
Please login to merge, or discard this patch.
Spacing   +805 added lines, -805 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.
@@ -145,40 +145,40 @@  discard block
 block discarded – undo
145 145
 	 *
146 146
 	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
147 147
 	 */
148
-    public function __construct( $invoice = 0 ) {
148
+    public function __construct($invoice = 0) {
149 149
 
150
-        parent::__construct( $invoice );
150
+        parent::__construct($invoice);
151 151
 
152
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
153
-			$this->set_id( (int) $invoice );
154
-		} elseif ( $invoice instanceof self ) {
155
-			$this->set_id( $invoice->get_id() );
156
-		} elseif ( ! empty( $invoice->ID ) ) {
157
-			$this->set_id( $invoice->ID );
158
-		} elseif ( is_array( $invoice ) ) {
159
-			$this->set_props( $invoice );
152
+		if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type((int) $invoice))) {
153
+			$this->set_id((int) $invoice);
154
+		} elseif ($invoice instanceof self) {
155
+			$this->set_id($invoice->get_id());
156
+		} elseif (!empty($invoice->ID)) {
157
+			$this->set_id($invoice->ID);
158
+		} elseif (is_array($invoice)) {
159
+			$this->set_props($invoice);
160 160
 
161
-			if ( isset( $invoice['ID'] ) ) {
162
-				$this->set_id( $invoice['ID'] );
161
+			if (isset($invoice['ID'])) {
162
+				$this->set_id($invoice['ID']);
163 163
 			}
164 164
 
165
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
166
-			$this->set_id( $invoice_id );
167
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
168
-			$this->set_id( $invoice_id );
169
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
170
-			$this->set_id( $invoice_id );
165
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) {
166
+			$this->set_id($invoice_id);
167
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) {
168
+			$this->set_id($invoice_id);
169
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) {
170
+			$this->set_id($invoice_id);
171 171
 		} else {
172
-			$this->set_object_read( true );
172
+			$this->set_object_read(true);
173 173
 		}
174 174
 
175 175
         // Load the datastore.
176
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
176
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
177 177
 
178
-		if ( $this->get_id() > 0 ) {
179
-            $this->post = get_post( $this->get_id() );
178
+		if ($this->get_id() > 0) {
179
+            $this->post = get_post($this->get_id());
180 180
             $this->ID   = $this->get_id();
181
-			$this->data_store->read( $this );
181
+			$this->data_store->read($this);
182 182
         }
183 183
 
184 184
     }
@@ -193,38 +193,38 @@  discard block
 block discarded – undo
193 193
 	 * @since 1.0.15
194 194
 	 * @return int
195 195
 	 */
196
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
196
+	public static function get_invoice_id_by_field($value, $field = 'key') {
197 197
         global $wpdb;
198 198
 
199 199
 		// Trim the value.
200
-		$value = trim( $value );
200
+		$value = trim($value);
201 201
 
202
-		if ( empty( $value ) ) {
202
+		if (empty($value)) {
203 203
 			return 0;
204 204
 		}
205 205
 
206 206
         // Valid fields.
207
-        $fields = array( 'key', 'number', 'transaction_id' );
207
+        $fields = array('key', 'number', 'transaction_id');
208 208
 
209 209
 		// Ensure a field has been passed.
210
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
210
+		if (empty($field) || !in_array($field, $fields)) {
211 211
 			return 0;
212 212
 		}
213 213
 
214 214
 		// Maybe retrieve from the cache.
215
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
216
-		if ( false !== $invoice_id ) {
215
+		$invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids");
216
+		if (false !== $invoice_id) {
217 217
 			return $invoice_id;
218 218
 		}
219 219
 
220 220
         // Fetch from the db.
221 221
         $table       = $wpdb->prefix . 'getpaid_invoices';
222 222
         $invoice_id  = (int) $wpdb->get_var(
223
-            $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
223
+            $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
224 224
         );
225 225
 
226 226
 		// Update the cache with our data
227
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
227
+		wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids");
228 228
 
229 229
 		return $invoice_id;
230 230
     }
@@ -232,8 +232,8 @@  discard block
 block discarded – undo
232 232
     /**
233 233
      * Checks if an invoice key is set.
234 234
      */
235
-    public function _isset( $key ) {
236
-        return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
235
+    public function _isset($key) {
236
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
237 237
     }
238 238
 
239 239
     /*
@@ -258,8 +258,8 @@  discard block
 block discarded – undo
258 258
 	 * @param  string $context View or edit context.
259 259
 	 * @return int
260 260
 	 */
261
-	public function get_parent_id( $context = 'view' ) {
262
-		return (int) $this->get_prop( 'parent_id', $context );
261
+	public function get_parent_id($context = 'view') {
262
+		return (int) $this->get_prop('parent_id', $context);
263 263
     }
264 264
 
265 265
     /**
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 * @return WPInv_Invoice
270 270
 	 */
271 271
     public function get_parent_payment() {
272
-        return new WPInv_Invoice( $this->get_parent_id() );
272
+        return new WPInv_Invoice($this->get_parent_id());
273 273
     }
274 274
 
275 275
     /**
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 	 * @param  string $context View or edit context.
290 290
 	 * @return string
291 291
 	 */
292
-	public function get_status( $context = 'view' ) {
293
-		return $this->get_prop( 'status', $context );
292
+	public function get_status($context = 'view') {
293
+		return $this->get_prop('status', $context);
294 294
 	}
295 295
 	
296 296
 	/**
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 	 * @return array
301 301
 	 */
302 302
 	public function get_all_statuses() {
303
-		return wpinv_get_invoice_statuses( true, true, $this );
303
+		return wpinv_get_invoice_statuses(true, true, $this);
304 304
     }
305 305
 
306 306
     /**
@@ -312,9 +312,9 @@  discard block
 block discarded – undo
312 312
     public function get_status_nicename() {
313 313
 		$statuses = $this->get_all_statuses();
314 314
 
315
-        $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
315
+        $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status();
316 316
 
317
-        return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
317
+        return apply_filters('wpinv_get_invoice_status_nicename', $status, $this);
318 318
     }
319 319
 
320 320
 	/**
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 	 */
326 326
 	public function get_status_class() {
327 327
 		$statuses = getpaid_get_invoice_status_classes();
328
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
328
+		return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'badge-dark';
329 329
 	}
330 330
 
331 331
 	/**
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
      */
337 337
     public function get_status_label_html() {
338 338
 
339
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
340
-		$status       = sanitize_html_class( $this->get_status() );
341
-		$class        = esc_attr( $this->get_status_class() );
339
+		$status_label = sanitize_text_field($this->get_status_nicename());
340
+		$status       = sanitize_html_class($this->get_status());
341
+		$class        = esc_attr($this->get_status_class());
342 342
 
343 343
 		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
344 344
 	}
@@ -350,23 +350,23 @@  discard block
 block discarded – undo
350 350
 	 * @param  string $context View or edit context.
351 351
 	 * @return string
352 352
 	 */
353
-	public function get_version( $context = 'view' ) {
354
-		return $this->get_prop( 'version', $context );
353
+	public function get_version($context = 'view') {
354
+		return $this->get_prop('version', $context);
355 355
 	}
356 356
 
357 357
 	/**
358 358
 	 * @deprecated
359 359
 	 */
360
-	public function get_invoice_date( $format = true ) {
361
-		$date      = getpaid_format_date( $this->get_date_completed() );
362
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
363
-		$formatted = getpaid_format_date( $date );
360
+	public function get_invoice_date($format = true) {
361
+		$date      = getpaid_format_date($this->get_date_completed());
362
+		$date      = empty($date) ? $this->get_date_created() : $this->get_date_completed();
363
+		$formatted = getpaid_format_date($date);
364 364
 
365
-		if ( $format ) {
365
+		if ($format) {
366 366
 			return $formatted;
367 367
 		}
368 368
 
369
-		return empty( $formatted ) ? '' : $date;
369
+		return empty($formatted) ? '' : $date;
370 370
 
371 371
     }
372 372
 
@@ -377,8 +377,8 @@  discard block
 block discarded – undo
377 377
 	 * @param  string $context View or edit context.
378 378
 	 * @return string
379 379
 	 */
380
-	public function get_date_created( $context = 'view' ) {
381
-		return $this->get_prop( 'date_created', $context );
380
+	public function get_date_created($context = 'view') {
381
+		return $this->get_prop('date_created', $context);
382 382
 	}
383 383
 	
384 384
 	/**
@@ -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_created_date( $context = 'view' ) {
392
-		return $this->get_date_created( $context );
391
+	public function get_created_date($context = 'view') {
392
+		return $this->get_date_created($context);
393 393
     }
394 394
 
395 395
     /**
@@ -399,11 +399,11 @@  discard block
 block discarded – undo
399 399
 	 * @param  string $context View or edit context.
400 400
 	 * @return string
401 401
 	 */
402
-	public function get_date_created_gmt( $context = 'view' ) {
403
-        $date = $this->get_date_created( $context );
402
+	public function get_date_created_gmt($context = 'view') {
403
+        $date = $this->get_date_created($context);
404 404
 
405
-        if ( $date ) {
406
-            $date = get_gmt_from_date( $date );
405
+        if ($date) {
406
+            $date = get_gmt_from_date($date);
407 407
         }
408 408
 		return $date;
409 409
     }
@@ -415,8 +415,8 @@  discard block
 block discarded – undo
415 415
 	 * @param  string $context View or edit context.
416 416
 	 * @return string
417 417
 	 */
418
-	public function get_date_modified( $context = 'view' ) {
419
-		return $this->get_prop( 'date_modified', $context );
418
+	public function get_date_modified($context = 'view') {
419
+		return $this->get_prop('date_modified', $context);
420 420
 	}
421 421
 
422 422
 	/**
@@ -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_modified_date( $context = 'view' ) {
430
-		return $this->get_date_modified( $context );
429
+	public function get_modified_date($context = 'view') {
430
+		return $this->get_date_modified($context);
431 431
     }
432 432
 
433 433
     /**
@@ -437,11 +437,11 @@  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_modified_gmt( $context = 'view' ) {
441
-        $date = $this->get_date_modified( $context );
440
+	public function get_date_modified_gmt($context = 'view') {
441
+        $date = $this->get_date_modified($context);
442 442
 
443
-        if ( $date ) {
444
-            $date = get_gmt_from_date( $date );
443
+        if ($date) {
444
+            $date = get_gmt_from_date($date);
445 445
         }
446 446
 		return $date;
447 447
     }
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 	 * @param  string $context View or edit context.
454 454
 	 * @return string
455 455
 	 */
456
-	public function get_due_date( $context = 'view' ) {
457
-		return $this->get_prop( 'due_date', $context );
456
+	public function get_due_date($context = 'view') {
457
+		return $this->get_prop('due_date', $context);
458 458
     }
459 459
 
460 460
     /**
@@ -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_date_due( $context = 'view' ) {
468
-		return $this->get_due_date( $context );
467
+	public function get_date_due($context = 'view') {
468
+		return $this->get_due_date($context);
469 469
     }
470 470
 
471 471
     /**
@@ -475,11 +475,11 @@  discard block
 block discarded – undo
475 475
 	 * @param  string $context View or edit context.
476 476
 	 * @return string
477 477
 	 */
478
-	public function get_due_date_gmt( $context = 'view' ) {
479
-        $date = $this->get_due_date( $context );
478
+	public function get_due_date_gmt($context = 'view') {
479
+        $date = $this->get_due_date($context);
480 480
 
481
-        if ( $date ) {
482
-            $date = get_gmt_from_date( $date );
481
+        if ($date) {
482
+            $date = get_gmt_from_date($date);
483 483
         }
484 484
 		return $date;
485 485
     }
@@ -491,8 +491,8 @@  discard block
 block discarded – undo
491 491
 	 * @param  string $context View or edit context.
492 492
 	 * @return string
493 493
 	 */
494
-	public function get_gmt_date_due( $context = 'view' ) {
495
-		return $this->get_due_date_gmt( $context );
494
+	public function get_gmt_date_due($context = 'view') {
495
+		return $this->get_due_date_gmt($context);
496 496
     }
497 497
 
498 498
     /**
@@ -502,8 +502,8 @@  discard block
 block discarded – undo
502 502
 	 * @param  string $context View or edit context.
503 503
 	 * @return string
504 504
 	 */
505
-	public function get_completed_date( $context = 'view' ) {
506
-		return $this->get_prop( 'completed_date', $context );
505
+	public function get_completed_date($context = 'view') {
506
+		return $this->get_prop('completed_date', $context);
507 507
     }
508 508
 
509 509
     /**
@@ -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_date_completed( $context = 'view' ) {
517
-		return $this->get_completed_date( $context );
516
+	public function get_date_completed($context = 'view') {
517
+		return $this->get_completed_date($context);
518 518
     }
519 519
 
520 520
     /**
@@ -524,11 +524,11 @@  discard block
 block discarded – undo
524 524
 	 * @param  string $context View or edit context.
525 525
 	 * @return string
526 526
 	 */
527
-	public function get_completed_date_gmt( $context = 'view' ) {
528
-        $date = $this->get_completed_date( $context );
527
+	public function get_completed_date_gmt($context = 'view') {
528
+        $date = $this->get_completed_date($context);
529 529
 
530
-        if ( $date ) {
531
-            $date = get_gmt_from_date( $date );
530
+        if ($date) {
531
+            $date = get_gmt_from_date($date);
532 532
         }
533 533
 		return $date;
534 534
     }
@@ -540,8 +540,8 @@  discard block
 block discarded – undo
540 540
 	 * @param  string $context View or edit context.
541 541
 	 * @return string
542 542
 	 */
543
-	public function get_gmt_completed_date( $context = 'view' ) {
544
-		return $this->get_completed_date_gmt( $context );
543
+	public function get_gmt_completed_date($context = 'view') {
544
+		return $this->get_completed_date_gmt($context);
545 545
     }
546 546
 
547 547
     /**
@@ -551,12 +551,12 @@  discard block
 block discarded – undo
551 551
 	 * @param  string $context View or edit context.
552 552
 	 * @return string
553 553
 	 */
554
-	public function get_number( $context = 'view' ) {
555
-		$number = $this->get_prop( 'number', $context );
554
+	public function get_number($context = 'view') {
555
+		$number = $this->get_prop('number', $context);
556 556
 
557
-		if ( empty( $number ) ) {
557
+		if (empty($number)) {
558 558
 			$number = $this->generate_number();
559
-			$this->set_number( $this->generate_number() );
559
+			$this->set_number($this->generate_number());
560 560
 		}
561 561
 
562 562
 		return $number;
@@ -570,8 +570,8 @@  discard block
 block discarded – undo
570 570
 	public function maybe_set_number() {
571 571
         $number = $this->get_number();
572 572
 
573
-        if ( empty( $number ) || $this->get_id() == $number ) {
574
-			$this->set_number( $this->generate_number() );
573
+        if (empty($number) || $this->get_id() == $number) {
574
+			$this->set_number($this->generate_number());
575 575
         }
576 576
 
577 577
 	}
@@ -583,8 +583,8 @@  discard block
 block discarded – undo
583 583
 	 * @param  string $context View or edit context.
584 584
 	 * @return string
585 585
 	 */
586
-	public function get_key( $context = 'view' ) {
587
-        return $this->get_prop( 'key', $context );
586
+	public function get_key($context = 'view') {
587
+        return $this->get_prop('key', $context);
588 588
 	}
589 589
 
590 590
 	/**
@@ -595,9 +595,9 @@  discard block
 block discarded – undo
595 595
 	public function maybe_set_key() {
596 596
         $key = $this->get_key();
597 597
 
598
-        if ( empty( $key ) ) {
599
-            $key = $this->generate_key( $this->get_type() . '_' );
600
-            $this->set_key( $key );
598
+        if (empty($key)) {
599
+            $key = $this->generate_key($this->get_type() . '_');
600
+            $this->set_key($key);
601 601
         }
602 602
 
603 603
     }
@@ -609,8 +609,8 @@  discard block
 block discarded – undo
609 609
 	 * @param  string $context View or edit context.
610 610
 	 * @return string
611 611
 	 */
612
-	public function get_type( $context = 'view' ) {
613
-        return $this->get_prop( 'type', $context );
612
+	public function get_type($context = 'view') {
613
+        return $this->get_prop('type', $context);
614 614
 	}
615 615
 
616 616
 	/**
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 	 * @return string
621 621
 	 */
622 622
 	public function get_invoice_quote_type() {
623
-        return getpaid_get_post_type_label( $this->get_post_type(), false );
623
+        return getpaid_get_post_type_label($this->get_post_type(), false);
624 624
     }
625 625
 
626 626
     /**
@@ -630,8 +630,8 @@  discard block
 block discarded – undo
630 630
 	 * @param  string $context View or edit context.
631 631
 	 * @return string
632 632
 	 */
633
-	public function get_label( $context = 'view' ) {
634
-        return getpaid_get_post_type_label( $this->get_post_type( $context ), false );
633
+	public function get_label($context = 'view') {
634
+        return getpaid_get_post_type_label($this->get_post_type($context), false);
635 635
 	}
636 636
 
637 637
 	/**
@@ -641,8 +641,8 @@  discard block
 block discarded – undo
641 641
 	 * @param  string $context View or edit context.
642 642
 	 * @return string
643 643
 	 */
644
-	public function get_post_type( $context = 'view' ) {
645
-        return $this->get_prop( 'post_type', $context );
644
+	public function get_post_type($context = 'view') {
645
+        return $this->get_prop('post_type', $context);
646 646
     }
647 647
 
648 648
     /**
@@ -652,8 +652,8 @@  discard block
 block discarded – undo
652 652
 	 * @param  string $context View or edit context.
653 653
 	 * @return string
654 654
 	 */
655
-	public function get_mode( $context = 'view' ) {
656
-        return $this->get_prop( 'mode', $context );
655
+	public function get_mode($context = 'view') {
656
+        return $this->get_prop('mode', $context);
657 657
     }
658 658
 
659 659
     /**
@@ -663,13 +663,13 @@  discard block
 block discarded – undo
663 663
 	 * @param  string $context View or edit context.
664 664
 	 * @return string
665 665
 	 */
666
-	public function get_path( $context = 'view' ) {
667
-        $path   = $this->get_prop( 'path', $context );
666
+	public function get_path($context = 'view') {
667
+        $path = $this->get_prop('path', $context);
668 668
 		$prefix = $this->get_type();
669 669
 
670
-		if ( 0 !== strpos( $path, $prefix ) ) {
671
-			$path = sanitize_title(  $prefix . '-' . $this->get_id()  );
672
-			$this->set_path( $path );
670
+		if (0 !== strpos($path, $prefix)) {
671
+			$path = sanitize_title($prefix . '-' . $this->get_id());
672
+			$this->set_path($path);
673 673
 		}
674 674
 
675 675
 		return $path;
@@ -682,8 +682,8 @@  discard block
 block discarded – undo
682 682
 	 * @param  string $context View or edit context.
683 683
 	 * @return string
684 684
 	 */
685
-	public function get_name( $context = 'view' ) {
686
-        return $this->get_prop( 'title', $context );
685
+	public function get_name($context = 'view') {
686
+        return $this->get_prop('title', $context);
687 687
     }
688 688
 
689 689
     /**
@@ -693,8 +693,8 @@  discard block
 block discarded – undo
693 693
 	 * @param  string $context View or edit context.
694 694
 	 * @return string
695 695
 	 */
696
-	public function get_title( $context = 'view' ) {
697
-		return $this->get_name( $context );
696
+	public function get_title($context = 'view') {
697
+		return $this->get_name($context);
698 698
     }
699 699
 
700 700
     /**
@@ -704,8 +704,8 @@  discard block
 block discarded – undo
704 704
 	 * @param  string $context View or edit context.
705 705
 	 * @return string
706 706
 	 */
707
-	public function get_description( $context = 'view' ) {
708
-		return $this->get_prop( 'description', $context );
707
+	public function get_description($context = 'view') {
708
+		return $this->get_prop('description', $context);
709 709
     }
710 710
 
711 711
     /**
@@ -715,8 +715,8 @@  discard block
 block discarded – undo
715 715
 	 * @param  string $context View or edit context.
716 716
 	 * @return string
717 717
 	 */
718
-	public function get_excerpt( $context = 'view' ) {
719
-		return $this->get_description( $context );
718
+	public function get_excerpt($context = 'view') {
719
+		return $this->get_description($context);
720 720
     }
721 721
 
722 722
     /**
@@ -726,8 +726,8 @@  discard block
 block discarded – undo
726 726
 	 * @param  string $context View or edit context.
727 727
 	 * @return string
728 728
 	 */
729
-	public function get_summary( $context = 'view' ) {
730
-		return $this->get_description( $context );
729
+	public function get_summary($context = 'view') {
730
+		return $this->get_description($context);
731 731
     }
732 732
 
733 733
     /**
@@ -737,26 +737,26 @@  discard block
 block discarded – undo
737 737
      * @param  string $context View or edit context.
738 738
 	 * @return array
739 739
 	 */
740
-    public function get_user_info( $context = 'view' ) {
740
+    public function get_user_info($context = 'view') {
741 741
 
742 742
         $user_info = array(
743
-            'user_id'    => $this->get_user_id( $context ),
744
-            'email'      => $this->get_email( $context ),
745
-            'first_name' => $this->get_first_name( $context ),
746
-            'last_name'  => $this->get_last_name( $context ),
747
-            'address'    => $this->get_address( $context ),
748
-            'phone'      => $this->get_phone( $context ),
749
-            'city'       => $this->get_city( $context ),
750
-            'country'    => $this->get_country( $context ),
751
-            'state'      => $this->get_state( $context ),
752
-            'zip'        => $this->get_zip( $context ),
753
-            'company'    => $this->get_company( $context ),
754
-			'company_id' => $this->get_company_id( $context ),
755
-            'vat_number' => $this->get_vat_number( $context ),
756
-            'discount'   => $this->get_discount_code( $context ),
743
+            'user_id'    => $this->get_user_id($context),
744
+            'email'      => $this->get_email($context),
745
+            'first_name' => $this->get_first_name($context),
746
+            'last_name'  => $this->get_last_name($context),
747
+            'address'    => $this->get_address($context),
748
+            'phone'      => $this->get_phone($context),
749
+            'city'       => $this->get_city($context),
750
+            'country'    => $this->get_country($context),
751
+            'state'      => $this->get_state($context),
752
+            'zip'        => $this->get_zip($context),
753
+            'company'    => $this->get_company($context),
754
+			'company_id' => $this->get_company_id($context),
755
+            'vat_number' => $this->get_vat_number($context),
756
+            'discount'   => $this->get_discount_code($context),
757 757
 		);
758 758
 
759
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
759
+		return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this);
760 760
 
761 761
     }
762 762
 
@@ -767,8 +767,8 @@  discard block
 block discarded – undo
767 767
 	 * @param  string $context View or edit context.
768 768
 	 * @return int
769 769
 	 */
770
-	public function get_author( $context = 'view' ) {
771
-		return (int) $this->get_prop( 'author', $context );
770
+	public function get_author($context = 'view') {
771
+		return (int) $this->get_prop('author', $context);
772 772
     }
773 773
 
774 774
     /**
@@ -778,8 +778,8 @@  discard block
 block discarded – undo
778 778
 	 * @param  string $context View or edit context.
779 779
 	 * @return int
780 780
 	 */
781
-	public function get_user_id( $context = 'view' ) {
782
-		return $this->get_author( $context );
781
+	public function get_user_id($context = 'view') {
782
+		return $this->get_author($context);
783 783
     }
784 784
 
785 785
      /**
@@ -789,8 +789,8 @@  discard block
 block discarded – undo
789 789
 	 * @param  string $context View or edit context.
790 790
 	 * @return int
791 791
 	 */
792
-	public function get_customer_id( $context = 'view' ) {
793
-		return $this->get_author( $context );
792
+	public function get_customer_id($context = 'view') {
793
+		return $this->get_author($context);
794 794
     }
795 795
 
796 796
     /**
@@ -800,8 +800,8 @@  discard block
 block discarded – undo
800 800
 	 * @param  string $context View or edit context.
801 801
 	 * @return string
802 802
 	 */
803
-	public function get_ip( $context = 'view' ) {
804
-		return $this->get_prop( 'user_ip', $context );
803
+	public function get_ip($context = 'view') {
804
+		return $this->get_prop('user_ip', $context);
805 805
     }
806 806
 
807 807
     /**
@@ -811,8 +811,8 @@  discard block
 block discarded – undo
811 811
 	 * @param  string $context View or edit context.
812 812
 	 * @return string
813 813
 	 */
814
-	public function get_user_ip( $context = 'view' ) {
815
-		return $this->get_ip( $context );
814
+	public function get_user_ip($context = 'view') {
815
+		return $this->get_ip($context);
816 816
     }
817 817
 
818 818
      /**
@@ -822,8 +822,8 @@  discard block
 block discarded – undo
822 822
 	 * @param  string $context View or edit context.
823 823
 	 * @return string
824 824
 	 */
825
-	public function get_customer_ip( $context = 'view' ) {
826
-		return $this->get_ip( $context );
825
+	public function get_customer_ip($context = 'view') {
826
+		return $this->get_ip($context);
827 827
     }
828 828
 
829 829
     /**
@@ -833,8 +833,8 @@  discard block
 block discarded – undo
833 833
 	 * @param  string $context View or edit context.
834 834
 	 * @return string
835 835
 	 */
836
-	public function get_first_name( $context = 'view' ) {
837
-		return $this->get_prop( 'first_name', $context );
836
+	public function get_first_name($context = 'view') {
837
+		return $this->get_prop('first_name', $context);
838 838
     }
839 839
 
840 840
     /**
@@ -844,8 +844,8 @@  discard block
 block discarded – undo
844 844
 	 * @param  string $context View or edit context.
845 845
 	 * @return string
846 846
 	 */
847
-	public function get_user_first_name( $context = 'view' ) {
848
-		return $this->get_first_name( $context );
847
+	public function get_user_first_name($context = 'view') {
848
+		return $this->get_first_name($context);
849 849
     }
850 850
 
851 851
      /**
@@ -855,8 +855,8 @@  discard block
 block discarded – undo
855 855
 	 * @param  string $context View or edit context.
856 856
 	 * @return string
857 857
 	 */
858
-	public function get_customer_first_name( $context = 'view' ) {
859
-		return $this->get_first_name( $context );
858
+	public function get_customer_first_name($context = 'view') {
859
+		return $this->get_first_name($context);
860 860
     }
861 861
 
862 862
     /**
@@ -866,8 +866,8 @@  discard block
 block discarded – undo
866 866
 	 * @param  string $context View or edit context.
867 867
 	 * @return string
868 868
 	 */
869
-	public function get_last_name( $context = 'view' ) {
870
-		return $this->get_prop( 'last_name', $context );
869
+	public function get_last_name($context = 'view') {
870
+		return $this->get_prop('last_name', $context);
871 871
     }
872 872
 
873 873
     /**
@@ -877,8 +877,8 @@  discard block
 block discarded – undo
877 877
 	 * @param  string $context View or edit context.
878 878
 	 * @return string
879 879
 	 */
880
-	public function get_user_last_name( $context = 'view' ) {
881
-		return $this->get_last_name( $context );
880
+	public function get_user_last_name($context = 'view') {
881
+		return $this->get_last_name($context);
882 882
     }
883 883
 
884 884
     /**
@@ -888,8 +888,8 @@  discard block
 block discarded – undo
888 888
 	 * @param  string $context View or edit context.
889 889
 	 * @return string
890 890
 	 */
891
-	public function get_customer_last_name( $context = 'view' ) {
892
-		return $this->get_last_name( $context );
891
+	public function get_customer_last_name($context = 'view') {
892
+		return $this->get_last_name($context);
893 893
     }
894 894
 
895 895
     /**
@@ -899,8 +899,8 @@  discard block
 block discarded – undo
899 899
 	 * @param  string $context View or edit context.
900 900
 	 * @return string
901 901
 	 */
902
-	public function get_full_name( $context = 'view' ) {
903
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
902
+	public function get_full_name($context = 'view') {
903
+		return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context));
904 904
     }
905 905
 
906 906
     /**
@@ -910,8 +910,8 @@  discard block
 block discarded – undo
910 910
 	 * @param  string $context View or edit context.
911 911
 	 * @return string
912 912
 	 */
913
-	public function get_user_full_name( $context = 'view' ) {
914
-		return $this->get_full_name( $context );
913
+	public function get_user_full_name($context = 'view') {
914
+		return $this->get_full_name($context);
915 915
     }
916 916
 
917 917
     /**
@@ -921,8 +921,8 @@  discard block
 block discarded – undo
921 921
 	 * @param  string $context View or edit context.
922 922
 	 * @return string
923 923
 	 */
924
-	public function get_customer_full_name( $context = 'view' ) {
925
-		return $this->get_full_name( $context );
924
+	public function get_customer_full_name($context = 'view') {
925
+		return $this->get_full_name($context);
926 926
     }
927 927
 
928 928
     /**
@@ -932,8 +932,8 @@  discard block
 block discarded – undo
932 932
 	 * @param  string $context View or edit context.
933 933
 	 * @return string
934 934
 	 */
935
-	public function get_phone( $context = 'view' ) {
936
-		return $this->get_prop( 'phone', $context );
935
+	public function get_phone($context = 'view') {
936
+		return $this->get_prop('phone', $context);
937 937
     }
938 938
 
939 939
     /**
@@ -943,8 +943,8 @@  discard block
 block discarded – undo
943 943
 	 * @param  string $context View or edit context.
944 944
 	 * @return string
945 945
 	 */
946
-	public function get_phone_number( $context = 'view' ) {
947
-		return $this->get_phone( $context );
946
+	public function get_phone_number($context = 'view') {
947
+		return $this->get_phone($context);
948 948
     }
949 949
 
950 950
     /**
@@ -954,8 +954,8 @@  discard block
 block discarded – undo
954 954
 	 * @param  string $context View or edit context.
955 955
 	 * @return string
956 956
 	 */
957
-	public function get_user_phone( $context = 'view' ) {
958
-		return $this->get_phone( $context );
957
+	public function get_user_phone($context = 'view') {
958
+		return $this->get_phone($context);
959 959
     }
960 960
 
961 961
     /**
@@ -965,8 +965,8 @@  discard block
 block discarded – undo
965 965
 	 * @param  string $context View or edit context.
966 966
 	 * @return string
967 967
 	 */
968
-	public function get_customer_phone( $context = 'view' ) {
969
-		return $this->get_phone( $context );
968
+	public function get_customer_phone($context = 'view') {
969
+		return $this->get_phone($context);
970 970
     }
971 971
 
972 972
     /**
@@ -976,8 +976,8 @@  discard block
 block discarded – undo
976 976
 	 * @param  string $context View or edit context.
977 977
 	 * @return string
978 978
 	 */
979
-	public function get_email( $context = 'view' ) {
980
-		return $this->get_prop( 'email', $context );
979
+	public function get_email($context = 'view') {
980
+		return $this->get_prop('email', $context);
981 981
     }
982 982
 
983 983
     /**
@@ -987,8 +987,8 @@  discard block
 block discarded – undo
987 987
 	 * @param  string $context View or edit context.
988 988
 	 * @return string
989 989
 	 */
990
-	public function get_email_address( $context = 'view' ) {
991
-		return $this->get_email( $context );
990
+	public function get_email_address($context = 'view') {
991
+		return $this->get_email($context);
992 992
     }
993 993
 
994 994
     /**
@@ -998,8 +998,8 @@  discard block
 block discarded – undo
998 998
 	 * @param  string $context View or edit context.
999 999
 	 * @return string
1000 1000
 	 */
1001
-	public function get_user_email( $context = 'view' ) {
1002
-		return $this->get_email( $context );
1001
+	public function get_user_email($context = 'view') {
1002
+		return $this->get_email($context);
1003 1003
     }
1004 1004
 
1005 1005
     /**
@@ -1009,8 +1009,8 @@  discard block
 block discarded – undo
1009 1009
 	 * @param  string $context View or edit context.
1010 1010
 	 * @return string
1011 1011
 	 */
1012
-	public function get_customer_email( $context = 'view' ) {
1013
-		return $this->get_email( $context );
1012
+	public function get_customer_email($context = 'view') {
1013
+		return $this->get_email($context);
1014 1014
     }
1015 1015
 
1016 1016
     /**
@@ -1020,9 +1020,9 @@  discard block
 block discarded – undo
1020 1020
 	 * @param  string $context View or edit context.
1021 1021
 	 * @return string
1022 1022
 	 */
1023
-	public function get_country( $context = 'view' ) {
1024
-		$country = $this->get_prop( 'country', $context );
1025
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1023
+	public function get_country($context = 'view') {
1024
+		$country = $this->get_prop('country', $context);
1025
+		return empty($country) ? wpinv_get_default_country() : $country;
1026 1026
     }
1027 1027
 
1028 1028
     /**
@@ -1032,8 +1032,8 @@  discard block
 block discarded – undo
1032 1032
 	 * @param  string $context View or edit context.
1033 1033
 	 * @return string
1034 1034
 	 */
1035
-	public function get_user_country( $context = 'view' ) {
1036
-		return $this->get_country( $context );
1035
+	public function get_user_country($context = 'view') {
1036
+		return $this->get_country($context);
1037 1037
     }
1038 1038
 
1039 1039
     /**
@@ -1043,8 +1043,8 @@  discard block
 block discarded – undo
1043 1043
 	 * @param  string $context View or edit context.
1044 1044
 	 * @return string
1045 1045
 	 */
1046
-	public function get_customer_country( $context = 'view' ) {
1047
-		return $this->get_country( $context );
1046
+	public function get_customer_country($context = 'view') {
1047
+		return $this->get_country($context);
1048 1048
     }
1049 1049
 
1050 1050
     /**
@@ -1054,9 +1054,9 @@  discard block
 block discarded – undo
1054 1054
 	 * @param  string $context View or edit context.
1055 1055
 	 * @return string
1056 1056
 	 */
1057
-	public function get_state( $context = 'view' ) {
1058
-		$state = $this->get_prop( 'state', $context );
1059
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1057
+	public function get_state($context = 'view') {
1058
+		$state = $this->get_prop('state', $context);
1059
+		return empty($state) ? wpinv_get_default_state() : $state;
1060 1060
     }
1061 1061
 
1062 1062
     /**
@@ -1066,8 +1066,8 @@  discard block
 block discarded – undo
1066 1066
 	 * @param  string $context View or edit context.
1067 1067
 	 * @return string
1068 1068
 	 */
1069
-	public function get_user_state( $context = 'view' ) {
1070
-		return $this->get_state( $context );
1069
+	public function get_user_state($context = 'view') {
1070
+		return $this->get_state($context);
1071 1071
     }
1072 1072
 
1073 1073
     /**
@@ -1077,8 +1077,8 @@  discard block
 block discarded – undo
1077 1077
 	 * @param  string $context View or edit context.
1078 1078
 	 * @return string
1079 1079
 	 */
1080
-	public function get_customer_state( $context = 'view' ) {
1081
-		return $this->get_state( $context );
1080
+	public function get_customer_state($context = 'view') {
1081
+		return $this->get_state($context);
1082 1082
     }
1083 1083
 
1084 1084
     /**
@@ -1088,8 +1088,8 @@  discard block
 block discarded – undo
1088 1088
 	 * @param  string $context View or edit context.
1089 1089
 	 * @return string
1090 1090
 	 */
1091
-	public function get_city( $context = 'view' ) {
1092
-		return $this->get_prop( 'city', $context );
1091
+	public function get_city($context = 'view') {
1092
+		return $this->get_prop('city', $context);
1093 1093
     }
1094 1094
 
1095 1095
     /**
@@ -1099,8 +1099,8 @@  discard block
 block discarded – undo
1099 1099
 	 * @param  string $context View or edit context.
1100 1100
 	 * @return string
1101 1101
 	 */
1102
-	public function get_user_city( $context = 'view' ) {
1103
-		return $this->get_city( $context );
1102
+	public function get_user_city($context = 'view') {
1103
+		return $this->get_city($context);
1104 1104
     }
1105 1105
 
1106 1106
     /**
@@ -1110,8 +1110,8 @@  discard block
 block discarded – undo
1110 1110
 	 * @param  string $context View or edit context.
1111 1111
 	 * @return string
1112 1112
 	 */
1113
-	public function get_customer_city( $context = 'view' ) {
1114
-		return $this->get_city( $context );
1113
+	public function get_customer_city($context = 'view') {
1114
+		return $this->get_city($context);
1115 1115
     }
1116 1116
 
1117 1117
     /**
@@ -1121,8 +1121,8 @@  discard block
 block discarded – undo
1121 1121
 	 * @param  string $context View or edit context.
1122 1122
 	 * @return string
1123 1123
 	 */
1124
-	public function get_zip( $context = 'view' ) {
1125
-		return $this->get_prop( 'zip', $context );
1124
+	public function get_zip($context = 'view') {
1125
+		return $this->get_prop('zip', $context);
1126 1126
     }
1127 1127
 
1128 1128
     /**
@@ -1132,8 +1132,8 @@  discard block
 block discarded – undo
1132 1132
 	 * @param  string $context View or edit context.
1133 1133
 	 * @return string
1134 1134
 	 */
1135
-	public function get_user_zip( $context = 'view' ) {
1136
-		return $this->get_zip( $context );
1135
+	public function get_user_zip($context = 'view') {
1136
+		return $this->get_zip($context);
1137 1137
     }
1138 1138
 
1139 1139
     /**
@@ -1143,8 +1143,8 @@  discard block
 block discarded – undo
1143 1143
 	 * @param  string $context View or edit context.
1144 1144
 	 * @return string
1145 1145
 	 */
1146
-	public function get_customer_zip( $context = 'view' ) {
1147
-		return $this->get_zip( $context );
1146
+	public function get_customer_zip($context = 'view') {
1147
+		return $this->get_zip($context);
1148 1148
     }
1149 1149
 
1150 1150
     /**
@@ -1154,8 +1154,8 @@  discard block
 block discarded – undo
1154 1154
 	 * @param  string $context View or edit context.
1155 1155
 	 * @return string
1156 1156
 	 */
1157
-	public function get_company( $context = 'view' ) {
1158
-		return $this->get_prop( 'company', $context );
1157
+	public function get_company($context = 'view') {
1158
+		return $this->get_prop('company', $context);
1159 1159
     }
1160 1160
 
1161 1161
     /**
@@ -1165,8 +1165,8 @@  discard block
 block discarded – undo
1165 1165
 	 * @param  string $context View or edit context.
1166 1166
 	 * @return string
1167 1167
 	 */
1168
-	public function get_user_company( $context = 'view' ) {
1169
-		return $this->get_company( $context );
1168
+	public function get_user_company($context = 'view') {
1169
+		return $this->get_company($context);
1170 1170
     }
1171 1171
 
1172 1172
     /**
@@ -1176,8 +1176,8 @@  discard block
 block discarded – undo
1176 1176
 	 * @param  string $context View or edit context.
1177 1177
 	 * @return string
1178 1178
 	 */
1179
-	public function get_customer_company( $context = 'view' ) {
1180
-		return $this->get_company( $context );
1179
+	public function get_customer_company($context = 'view') {
1180
+		return $this->get_company($context);
1181 1181
     }
1182 1182
 
1183 1183
 	/**
@@ -1187,8 +1187,8 @@  discard block
 block discarded – undo
1187 1187
 	 * @param  string $context View or edit context.
1188 1188
 	 * @return string
1189 1189
 	 */
1190
-	public function get_company_id( $context = 'view' ) {
1191
-		return $this->get_prop( 'company_id', $context );
1190
+	public function get_company_id($context = 'view') {
1191
+		return $this->get_prop('company_id', $context);
1192 1192
     }
1193 1193
 
1194 1194
     /**
@@ -1198,8 +1198,8 @@  discard block
 block discarded – undo
1198 1198
 	 * @param  string $context View or edit context.
1199 1199
 	 * @return string
1200 1200
 	 */
1201
-	public function get_vat_number( $context = 'view' ) {
1202
-		return $this->get_prop( 'vat_number', $context );
1201
+	public function get_vat_number($context = 'view') {
1202
+		return $this->get_prop('vat_number', $context);
1203 1203
     }
1204 1204
 
1205 1205
     /**
@@ -1209,8 +1209,8 @@  discard block
 block discarded – undo
1209 1209
 	 * @param  string $context View or edit context.
1210 1210
 	 * @return string
1211 1211
 	 */
1212
-	public function get_user_vat_number( $context = 'view' ) {
1213
-		return $this->get_vat_number( $context );
1212
+	public function get_user_vat_number($context = 'view') {
1213
+		return $this->get_vat_number($context);
1214 1214
     }
1215 1215
 
1216 1216
     /**
@@ -1220,8 +1220,8 @@  discard block
 block discarded – undo
1220 1220
 	 * @param  string $context View or edit context.
1221 1221
 	 * @return string
1222 1222
 	 */
1223
-	public function get_customer_vat_number( $context = 'view' ) {
1224
-		return $this->get_vat_number( $context );
1223
+	public function get_customer_vat_number($context = 'view') {
1224
+		return $this->get_vat_number($context);
1225 1225
     }
1226 1226
 
1227 1227
     /**
@@ -1231,8 +1231,8 @@  discard block
 block discarded – undo
1231 1231
 	 * @param  string $context View or edit context.
1232 1232
 	 * @return string
1233 1233
 	 */
1234
-	public function get_vat_rate( $context = 'view' ) {
1235
-		return $this->get_prop( 'vat_rate', $context );
1234
+	public function get_vat_rate($context = 'view') {
1235
+		return $this->get_prop('vat_rate', $context);
1236 1236
     }
1237 1237
 
1238 1238
     /**
@@ -1242,8 +1242,8 @@  discard block
 block discarded – undo
1242 1242
 	 * @param  string $context View or edit context.
1243 1243
 	 * @return string
1244 1244
 	 */
1245
-	public function get_user_vat_rate( $context = 'view' ) {
1246
-		return $this->get_vat_rate( $context );
1245
+	public function get_user_vat_rate($context = 'view') {
1246
+		return $this->get_vat_rate($context);
1247 1247
     }
1248 1248
 
1249 1249
     /**
@@ -1253,8 +1253,8 @@  discard block
 block discarded – undo
1253 1253
 	 * @param  string $context View or edit context.
1254 1254
 	 * @return string
1255 1255
 	 */
1256
-	public function get_customer_vat_rate( $context = 'view' ) {
1257
-		return $this->get_vat_rate( $context );
1256
+	public function get_customer_vat_rate($context = 'view') {
1257
+		return $this->get_vat_rate($context);
1258 1258
     }
1259 1259
 
1260 1260
     /**
@@ -1264,8 +1264,8 @@  discard block
 block discarded – undo
1264 1264
 	 * @param  string $context View or edit context.
1265 1265
 	 * @return string
1266 1266
 	 */
1267
-	public function get_address( $context = 'view' ) {
1268
-		return $this->get_prop( 'address', $context );
1267
+	public function get_address($context = 'view') {
1268
+		return $this->get_prop('address', $context);
1269 1269
     }
1270 1270
 
1271 1271
     /**
@@ -1275,8 +1275,8 @@  discard block
 block discarded – undo
1275 1275
 	 * @param  string $context View or edit context.
1276 1276
 	 * @return string
1277 1277
 	 */
1278
-	public function get_user_address( $context = 'view' ) {
1279
-		return $this->get_address( $context );
1278
+	public function get_user_address($context = 'view') {
1279
+		return $this->get_address($context);
1280 1280
     }
1281 1281
 
1282 1282
     /**
@@ -1286,8 +1286,8 @@  discard block
 block discarded – undo
1286 1286
 	 * @param  string $context View or edit context.
1287 1287
 	 * @return string
1288 1288
 	 */
1289
-	public function get_customer_address( $context = 'view' ) {
1290
-		return $this->get_address( $context );
1289
+	public function get_customer_address($context = 'view') {
1290
+		return $this->get_address($context);
1291 1291
     }
1292 1292
 
1293 1293
     /**
@@ -1297,8 +1297,8 @@  discard block
 block discarded – undo
1297 1297
 	 * @param  string $context View or edit context.
1298 1298
 	 * @return bool
1299 1299
 	 */
1300
-	public function get_is_viewed( $context = 'view' ) {
1301
-		return (bool) $this->get_prop( 'is_viewed', $context );
1300
+	public function get_is_viewed($context = 'view') {
1301
+		return (bool) $this->get_prop('is_viewed', $context);
1302 1302
 	}
1303 1303
 
1304 1304
 	/**
@@ -1308,8 +1308,8 @@  discard block
 block discarded – undo
1308 1308
 	 * @param  string $context View or edit context.
1309 1309
 	 * @return bool
1310 1310
 	 */
1311
-	public function get_email_cc( $context = 'view' ) {
1312
-		return $this->get_prop( 'email_cc', $context );
1311
+	public function get_email_cc($context = 'view') {
1312
+		return $this->get_prop('email_cc', $context);
1313 1313
 	}
1314 1314
 
1315 1315
 	/**
@@ -1319,8 +1319,8 @@  discard block
 block discarded – undo
1319 1319
 	 * @param  string $context View or edit context.
1320 1320
 	 * @return bool
1321 1321
 	 */
1322
-	public function get_template( $context = 'view' ) {
1323
-		return $this->get_prop( 'template', $context );
1322
+	public function get_template($context = 'view') {
1323
+		return $this->get_prop('template', $context);
1324 1324
 	}
1325 1325
 
1326 1326
 	/**
@@ -1330,8 +1330,8 @@  discard block
 block discarded – undo
1330 1330
 	 * @param  string $context View or edit context.
1331 1331
 	 * @return bool
1332 1332
 	 */
1333
-	public function get_created_via( $context = 'view' ) {
1334
-		return $this->get_prop( 'created_via', $context );
1333
+	public function get_created_via($context = 'view') {
1334
+		return $this->get_prop('created_via', $context);
1335 1335
 	}
1336 1336
 
1337 1337
 	/**
@@ -1341,8 +1341,8 @@  discard block
 block discarded – undo
1341 1341
 	 * @param  string $context View or edit context.
1342 1342
 	 * @return bool
1343 1343
 	 */
1344
-	public function get_address_confirmed( $context = 'view' ) {
1345
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1344
+	public function get_address_confirmed($context = 'view') {
1345
+		return (bool) $this->get_prop('address_confirmed', $context);
1346 1346
     }
1347 1347
 
1348 1348
     /**
@@ -1352,8 +1352,8 @@  discard block
 block discarded – undo
1352 1352
 	 * @param  string $context View or edit context.
1353 1353
 	 * @return bool
1354 1354
 	 */
1355
-	public function get_user_address_confirmed( $context = 'view' ) {
1356
-		return $this->get_address_confirmed( $context );
1355
+	public function get_user_address_confirmed($context = 'view') {
1356
+		return $this->get_address_confirmed($context);
1357 1357
     }
1358 1358
 
1359 1359
     /**
@@ -1363,8 +1363,8 @@  discard block
 block discarded – undo
1363 1363
 	 * @param  string $context View or edit context.
1364 1364
 	 * @return bool
1365 1365
 	 */
1366
-	public function get_customer_address_confirmed( $context = 'view' ) {
1367
-		return $this->get_address_confirmed( $context );
1366
+	public function get_customer_address_confirmed($context = 'view') {
1367
+		return $this->get_address_confirmed($context);
1368 1368
     }
1369 1369
 
1370 1370
 	/**
@@ -1375,8 +1375,8 @@  discard block
 block discarded – undo
1375 1375
 	 */
1376 1376
 	public function get_shipping_address() {
1377 1377
 
1378
-		$shipping_address = get_post_meta( $this->get_id(), 'shipping_address', true );
1379
-		return is_array( $shipping_address ) ? $shipping_address : false;
1378
+		$shipping_address = get_post_meta($this->get_id(), 'shipping_address', true);
1379
+		return is_array($shipping_address) ? $shipping_address : false;
1380 1380
     }
1381 1381
 
1382 1382
 	/**
@@ -1393,17 +1393,17 @@  discard block
 block discarded – undo
1393 1393
 	 * @param  string $context View or edit context.
1394 1394
 	 * @return float
1395 1395
 	 */
1396
-	public function get_shipping( $context = 'view' ) {
1396
+	public function get_shipping($context = 'view') {
1397 1397
 
1398
-		if ( $context = 'view' ) {
1399
-			return floatval( $this->get_prop( 'shipping', $context ) );
1398
+		if ($context = 'view') {
1399
+			return floatval($this->get_prop('shipping', $context));
1400 1400
 		}
1401 1401
  
1402
-		return $this->get_prop( 'shipping', $context );
1402
+		return $this->get_prop('shipping', $context);
1403 1403
     }
1404 1404
 
1405 1405
 	public function has_shipping() {
1406
-		return defined( 'GETPAID_SHIPPING_CALCULATOR_VERSION' ) && null !== $this->get_prop( 'shipping', 'edit' );
1406
+		return defined('GETPAID_SHIPPING_CALCULATOR_VERSION') && null !== $this->get_prop('shipping', 'edit');
1407 1407
     }
1408 1408
 
1409 1409
     /**
@@ -1413,12 +1413,12 @@  discard block
 block discarded – undo
1413 1413
 	 * @param  string $context View or edit context.
1414 1414
 	 * @return float
1415 1415
 	 */
1416
-	public function get_subtotal( $context = 'view' ) {
1417
-        $subtotal = (float) $this->get_prop( 'subtotal', $context );
1416
+	public function get_subtotal($context = 'view') {
1417
+        $subtotal = (float) $this->get_prop('subtotal', $context);
1418 1418
 
1419 1419
         // Backwards compatibility.
1420
-        if ( is_bool( $context ) && $context ) {
1421
-            return wpinv_price( $subtotal, $this->get_currency() );
1420
+        if (is_bool($context) && $context) {
1421
+            return wpinv_price($subtotal, $this->get_currency());
1422 1422
         }
1423 1423
 
1424 1424
         return $subtotal;
@@ -1431,8 +1431,8 @@  discard block
 block discarded – undo
1431 1431
 	 * @param  string $context View or edit context.
1432 1432
 	 * @return float
1433 1433
 	 */
1434
-	public function get_total_discount( $context = 'view' ) {
1435
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1434
+	public function get_total_discount($context = 'view') {
1435
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_discount', $context)));
1436 1436
     }
1437 1437
 
1438 1438
     /**
@@ -1442,18 +1442,18 @@  discard block
 block discarded – undo
1442 1442
 	 * @param  string $context View or edit context.
1443 1443
 	 * @return float
1444 1444
 	 */
1445
-	public function get_total_tax( $context = 'view' ) {
1446
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1445
+	public function get_total_tax($context = 'view') {
1446
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_tax', $context)));
1447 1447
 	}
1448 1448
 
1449 1449
 	/**
1450 1450
 	 * @deprecated
1451 1451
 	 */
1452
-	public function get_final_tax( $currency = false ) {
1452
+	public function get_final_tax($currency = false) {
1453 1453
 		$tax = $this->get_total_tax();
1454 1454
 
1455
-        if ( $currency ) {
1456
-			return wpinv_price( $tax, $this->get_currency() );
1455
+        if ($currency) {
1456
+			return wpinv_price($tax, $this->get_currency());
1457 1457
         }
1458 1458
 
1459 1459
         return $tax;
@@ -1466,8 +1466,8 @@  discard block
 block discarded – undo
1466 1466
 	 * @param  string $context View or edit context.
1467 1467
 	 * @return float
1468 1468
 	 */
1469
-	public function get_total_fees( $context = 'view' ) {
1470
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1469
+	public function get_total_fees($context = 'view') {
1470
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_fees', $context)));
1471 1471
     }
1472 1472
 
1473 1473
     /**
@@ -1477,8 +1477,8 @@  discard block
 block discarded – undo
1477 1477
 	 * @param  string $context View or edit context.
1478 1478
 	 * @return float
1479 1479
 	 */
1480
-	public function get_fees_total( $context = 'view' ) {
1481
-		return $this->get_total_fees( $context );
1480
+	public function get_fees_total($context = 'view') {
1481
+		return $this->get_total_fees($context);
1482 1482
     }
1483 1483
 
1484 1484
     /**
@@ -1487,14 +1487,14 @@  discard block
 block discarded – undo
1487 1487
 	 * @since 1.0.19
1488 1488
      * @return float
1489 1489
 	 */
1490
-	public function get_total( $context = 'view' ) {
1491
-		$total = $this->get_prop( 'total', $context );
1490
+	public function get_total($context = 'view') {
1491
+		$total = $this->get_prop('total', $context);
1492 1492
 
1493
-		if ( $this->has_shipping() && $context == 'view' ) {
1494
-			$total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context );
1493
+		if ($this->has_shipping() && $context == 'view') {
1494
+			$total = $this->get_prop('total', $context) + $this->get_shipping($context);
1495 1495
 		}
1496 1496
 
1497
-		return wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1497
+		return wpinv_round_amount(wpinv_sanitize_amount($total));
1498 1498
 	}
1499 1499
 
1500 1500
 	/**
@@ -1506,20 +1506,20 @@  discard block
 block discarded – undo
1506 1506
 	public function get_non_recurring_total() {
1507 1507
 
1508 1508
 		$subtotal = 0;
1509
-		foreach ( $this->get_items() as $item ) {
1510
-			if ( ! $item->is_recurring() ) {
1509
+		foreach ($this->get_items() as $item) {
1510
+			if (!$item->is_recurring()) {
1511 1511
 				$subtotal += $item->get_sub_total();
1512 1512
 			}
1513 1513
 		}
1514 1514
 
1515
-		foreach ( $this->get_fees() as $fee ) {
1516
-			if ( empty( $fee['recurring_fee'] ) ) {
1517
-				$subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1515
+		foreach ($this->get_fees() as $fee) {
1516
+			if (empty($fee['recurring_fee'])) {
1517
+				$subtotal += wpinv_sanitize_amount($fee['initial_fee']);
1518 1518
 			}
1519 1519
 		}
1520 1520
 
1521
-		$subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1522
-        return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this );
1521
+		$subtotal = wpinv_round_amount(wpinv_sanitize_amount($subtotal));
1522
+        return apply_filters('wpinv_get_non_recurring_invoice_total', $subtotal, $this);
1523 1523
 
1524 1524
     }
1525 1525
 
@@ -1542,7 +1542,7 @@  discard block
 block discarded – undo
1542 1542
 	 */
1543 1543
     public function get_initial_total() {
1544 1544
 
1545
-		if ( empty( $this->totals ) ) {
1545
+		if (empty($this->totals)) {
1546 1546
 			$this->recalculate_total();
1547 1547
 		}
1548 1548
 
@@ -1552,12 +1552,12 @@  discard block
 block discarded – undo
1552 1552
 		$subtotal = $this->totals['subtotal']['initial'];
1553 1553
 		$total    = $tax + $fee - $discount + $subtotal;
1554 1554
 
1555
-		if ( 0 > $total ) {
1555
+		if (0 > $total) {
1556 1556
 			$total = 0;
1557 1557
 		}
1558 1558
 
1559
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1560
-        return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1559
+		$total = wpinv_round_amount(wpinv_sanitize_amount($total));
1560
+        return apply_filters('wpinv_get_initial_invoice_total', $total, $this);
1561 1561
 	}
1562 1562
 
1563 1563
 	/**
@@ -1569,7 +1569,7 @@  discard block
 block discarded – undo
1569 1569
 	 */
1570 1570
     public function get_recurring_total() {
1571 1571
 
1572
-		if ( empty( $this->totals ) ) {
1572
+		if (empty($this->totals)) {
1573 1573
 			$this->recalculate_total();
1574 1574
 		}
1575 1575
 
@@ -1579,12 +1579,12 @@  discard block
 block discarded – undo
1579 1579
 		$subtotal = $this->totals['subtotal']['recurring'];
1580 1580
 		$total    = $tax + $fee - $discount + $subtotal;
1581 1581
 
1582
-		if ( 0 > $total ) {
1582
+		if (0 > $total) {
1583 1583
 			$total = 0;
1584 1584
 		}
1585 1585
 
1586
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1587
-        return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1586
+		$total = wpinv_round_amount(wpinv_sanitize_amount($total));
1587
+        return apply_filters('wpinv_get_recurring_invoice_total', $total, $this);
1588 1588
 	}
1589 1589
 
1590 1590
 	/**
@@ -1595,10 +1595,10 @@  discard block
 block discarded – undo
1595 1595
 	 * @param string $currency Whether to include the currency.
1596 1596
      * @return float|string
1597 1597
 	 */
1598
-    public function get_recurring_details( $field = '', $currency = false ) {
1598
+    public function get_recurring_details($field = '', $currency = false) {
1599 1599
 
1600 1600
 		// Maybe recalculate totals.
1601
-		if ( empty( $this->totals ) ) {
1601
+		if (empty($this->totals)) {
1602 1602
 			$this->recalculate_total();
1603 1603
 		}
1604 1604
 
@@ -1618,8 +1618,8 @@  discard block
 block discarded – undo
1618 1618
 			$currency
1619 1619
 		);
1620 1620
 
1621
-        if ( isset( $data[$field] ) ) {
1622
-            return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
1621
+        if (isset($data[$field])) {
1622
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1623 1623
         }
1624 1624
 
1625 1625
         return $data;
@@ -1632,8 +1632,8 @@  discard block
 block discarded – undo
1632 1632
 	 * @param  string $context View or edit context.
1633 1633
 	 * @return array
1634 1634
 	 */
1635
-	public function get_fees( $context = 'view' ) {
1636
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1635
+	public function get_fees($context = 'view') {
1636
+		return wpinv_parse_list($this->get_prop('fees', $context));
1637 1637
     }
1638 1638
 
1639 1639
     /**
@@ -1643,8 +1643,8 @@  discard block
 block discarded – undo
1643 1643
 	 * @param  string $context View or edit context.
1644 1644
 	 * @return array
1645 1645
 	 */
1646
-	public function get_discounts( $context = 'view' ) {
1647
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1646
+	public function get_discounts($context = 'view') {
1647
+		return wpinv_parse_list($this->get_prop('discounts', $context));
1648 1648
     }
1649 1649
 
1650 1650
     /**
@@ -1654,8 +1654,8 @@  discard block
 block discarded – undo
1654 1654
 	 * @param  string $context View or edit context.
1655 1655
 	 * @return array
1656 1656
 	 */
1657
-	public function get_taxes( $context = 'view' ) {
1658
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1657
+	public function get_taxes($context = 'view') {
1658
+		return wpinv_parse_list($this->get_prop('taxes', $context));
1659 1659
     }
1660 1660
 
1661 1661
     /**
@@ -1665,8 +1665,8 @@  discard block
 block discarded – undo
1665 1665
 	 * @param  string $context View or edit context.
1666 1666
 	 * @return GetPaid_Form_Item[]
1667 1667
 	 */
1668
-	public function get_items( $context = 'view' ) {
1669
-        return $this->get_prop( 'items', $context );
1668
+	public function get_items($context = 'view') {
1669
+        return $this->get_prop('items', $context);
1670 1670
 	}
1671 1671
 
1672 1672
 	/**
@@ -1676,7 +1676,7 @@  discard block
 block discarded – undo
1676 1676
 	 * @return string
1677 1677
 	 */
1678 1678
 	public function get_item_ids() {
1679
-		return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1679
+		return implode(', ', wp_list_pluck($this->get_cart_details(), 'item_id'));
1680 1680
     }
1681 1681
 
1682 1682
     /**
@@ -1686,8 +1686,8 @@  discard block
 block discarded – undo
1686 1686
 	 * @param  string $context View or edit context.
1687 1687
 	 * @return int
1688 1688
 	 */
1689
-	public function get_payment_form( $context = 'view' ) {
1690
-		return intval( $this->get_prop( 'payment_form', $context ) );
1689
+	public function get_payment_form($context = 'view') {
1690
+		return intval($this->get_prop('payment_form', $context));
1691 1691
     }
1692 1692
 
1693 1693
     /**
@@ -1697,8 +1697,8 @@  discard block
 block discarded – undo
1697 1697
 	 * @param  string $context View or edit context.
1698 1698
 	 * @return string
1699 1699
 	 */
1700
-	public function get_submission_id( $context = 'view' ) {
1701
-		return $this->get_prop( 'submission_id', $context );
1700
+	public function get_submission_id($context = 'view') {
1701
+		return $this->get_prop('submission_id', $context);
1702 1702
     }
1703 1703
 
1704 1704
     /**
@@ -1708,8 +1708,8 @@  discard block
 block discarded – undo
1708 1708
 	 * @param  string $context View or edit context.
1709 1709
 	 * @return string
1710 1710
 	 */
1711
-	public function get_discount_code( $context = 'view' ) {
1712
-		return $this->get_prop( 'discount_code', $context );
1711
+	public function get_discount_code($context = 'view') {
1712
+		return $this->get_prop('discount_code', $context);
1713 1713
     }
1714 1714
 
1715 1715
     /**
@@ -1719,8 +1719,8 @@  discard block
 block discarded – undo
1719 1719
 	 * @param  string $context View or edit context.
1720 1720
 	 * @return string
1721 1721
 	 */
1722
-	public function get_gateway( $context = 'view' ) {
1723
-		return $this->get_prop( 'gateway', $context );
1722
+	public function get_gateway($context = 'view') {
1723
+		return $this->get_prop('gateway', $context);
1724 1724
     }
1725 1725
 
1726 1726
     /**
@@ -1730,8 +1730,8 @@  discard block
 block discarded – undo
1730 1730
 	 * @return string
1731 1731
 	 */
1732 1732
     public function get_gateway_title() {
1733
-        $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1734
-        return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1733
+        $title = wpinv_get_gateway_checkout_label($this->get_gateway());
1734
+        return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this);
1735 1735
     }
1736 1736
 
1737 1737
     /**
@@ -1741,8 +1741,8 @@  discard block
 block discarded – undo
1741 1741
 	 * @param  string $context View or edit context.
1742 1742
 	 * @return string
1743 1743
 	 */
1744
-	public function get_transaction_id( $context = 'view' ) {
1745
-		return $this->get_prop( 'transaction_id', $context );
1744
+	public function get_transaction_id($context = 'view') {
1745
+		return $this->get_prop('transaction_id', $context);
1746 1746
     }
1747 1747
 
1748 1748
     /**
@@ -1752,9 +1752,9 @@  discard block
 block discarded – undo
1752 1752
 	 * @param  string $context View or edit context.
1753 1753
 	 * @return string
1754 1754
 	 */
1755
-	public function get_currency( $context = 'view' ) {
1756
-        $currency = $this->get_prop( 'currency', $context );
1757
-        return empty( $currency ) ? wpinv_get_currency() : $currency;
1755
+	public function get_currency($context = 'view') {
1756
+        $currency = $this->get_prop('currency', $context);
1757
+        return empty($currency) ? wpinv_get_currency() : $currency;
1758 1758
     }
1759 1759
 
1760 1760
     /**
@@ -1764,8 +1764,8 @@  discard block
 block discarded – undo
1764 1764
 	 * @param  string $context View or edit context.
1765 1765
 	 * @return bool
1766 1766
 	 */
1767
-	public function get_disable_taxes( $context = 'view' ) {
1768
-        return (bool) $this->get_prop( 'disable_taxes', $context );
1767
+	public function get_disable_taxes($context = 'view') {
1768
+        return (bool) $this->get_prop('disable_taxes', $context);
1769 1769
     }
1770 1770
 
1771 1771
     /**
@@ -1775,8 +1775,8 @@  discard block
 block discarded – undo
1775 1775
 	 * @param  string $context View or edit context.
1776 1776
 	 * @return int
1777 1777
 	 */
1778
-    public function get_subscription_id( $context = 'view' ) {
1779
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1778
+    public function get_subscription_id($context = 'view') {
1779
+		return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context);
1780 1780
 	}
1781 1781
 
1782 1782
 	/**
@@ -1786,12 +1786,12 @@  discard block
 block discarded – undo
1786 1786
 	 * @param  string $context View or edit context.
1787 1787
 	 * @return int
1788 1788
 	 */
1789
-    public function get_remote_subscription_id( $context = 'view' ) {
1790
-        $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1789
+    public function get_remote_subscription_id($context = 'view') {
1790
+        $subscription_id = $this->get_prop('remote_subscription_id', $context);
1791 1791
 
1792
-        if ( empty( $subscription_id ) && $this->is_renewal() ) {
1792
+        if (empty($subscription_id) && $this->is_renewal()) {
1793 1793
             $parent = $this->get_parent();
1794
-            return $parent->get_remote_subscription_id( $context );
1794
+            return $parent->get_remote_subscription_id($context);
1795 1795
         }
1796 1796
 
1797 1797
         return $subscription_id;
@@ -1804,20 +1804,20 @@  discard block
 block discarded – undo
1804 1804
 	 * @param  string $context View or edit context.
1805 1805
 	 * @return array
1806 1806
 	 */
1807
-    public function get_payment_meta( $context = 'view' ) {
1807
+    public function get_payment_meta($context = 'view') {
1808 1808
 
1809 1809
         return array(
1810
-            'price'        => $this->get_total( $context ),
1811
-            'date'         => $this->get_date_created( $context ),
1812
-            'user_email'   => $this->get_email( $context ),
1813
-            'invoice_key'  => $this->get_key( $context ),
1814
-            'currency'     => $this->get_currency( $context ),
1815
-            'items'        => $this->get_items( $context ),
1816
-            'user_info'    => $this->get_user_info( $context ),
1810
+            'price'        => $this->get_total($context),
1811
+            'date'         => $this->get_date_created($context),
1812
+            'user_email'   => $this->get_email($context),
1813
+            'invoice_key'  => $this->get_key($context),
1814
+            'currency'     => $this->get_currency($context),
1815
+            'items'        => $this->get_items($context),
1816
+            'user_info'    => $this->get_user_info($context),
1817 1817
             'cart_details' => $this->get_cart_details(),
1818
-            'status'       => $this->get_status( $context ),
1819
-            'fees'         => $this->get_fees( $context ),
1820
-            'taxes'        => $this->get_taxes( $context ),
1818
+            'status'       => $this->get_status($context),
1819
+            'fees'         => $this->get_fees($context),
1820
+            'taxes'        => $this->get_taxes($context),
1821 1821
         );
1822 1822
 
1823 1823
     }
@@ -1832,9 +1832,9 @@  discard block
 block discarded – undo
1832 1832
         $items        = $this->get_items();
1833 1833
         $cart_details = array();
1834 1834
 
1835
-        foreach ( $items as $item ) {
1835
+        foreach ($items as $item) {
1836 1836
 			$item->invoice_id = $this->get_id();
1837
-            $cart_details[]   = $item->prepare_data_for_saving();
1837
+            $cart_details[] = $item->prepare_data_for_saving();
1838 1838
         }
1839 1839
 
1840 1840
         return $cart_details;
@@ -1845,11 +1845,11 @@  discard block
 block discarded – undo
1845 1845
 	 *
1846 1846
 	 * @return null|GetPaid_Form_Item|int
1847 1847
 	 */
1848
-	public function get_recurring( $object = false ) {
1848
+	public function get_recurring($object = false) {
1849 1849
 
1850 1850
 		// Are we returning an object?
1851
-        if ( $object ) {
1852
-            return $this->get_item( $this->recurring_item );
1851
+        if ($object) {
1852
+            return $this->get_item($this->recurring_item);
1853 1853
         }
1854 1854
 
1855 1855
         return $this->recurring_item;
@@ -1864,15 +1864,15 @@  discard block
 block discarded – undo
1864 1864
 	public function get_subscription_name() {
1865 1865
 
1866 1866
 		// Retrieve the recurring name
1867
-        $item = $this->get_recurring( true );
1867
+        $item = $this->get_recurring(true);
1868 1868
 
1869 1869
 		// Abort if it does not exist.
1870
-        if ( empty( $item ) ) {
1870
+        if (empty($item)) {
1871 1871
             return '';
1872 1872
         }
1873 1873
 
1874 1874
 		// Return the item name.
1875
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1875
+        return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this);
1876 1876
 	}
1877 1877
 
1878 1878
 	/**
@@ -1882,9 +1882,9 @@  discard block
 block discarded – undo
1882 1882
 	 * @return string
1883 1883
 	 */
1884 1884
 	public function get_view_url() {
1885
-        $invoice_url = get_permalink( $this->get_id() );
1886
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1887
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1885
+        $invoice_url = get_permalink($this->get_id());
1886
+		$invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
1887
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this);
1888 1888
 	}
1889 1889
 
1890 1890
 	/**
@@ -1893,25 +1893,25 @@  discard block
 block discarded – undo
1893 1893
 	 * @since 1.0.19
1894 1894
 	 * @return string
1895 1895
 	 */
1896
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1896
+	public function get_checkout_payment_url($deprecated = false, $secret = false) {
1897 1897
 
1898 1898
 		// Retrieve the checkout url.
1899 1899
         $pay_url = wpinv_get_checkout_uri();
1900 1900
 
1901 1901
 		// Maybe force ssl.
1902
-        if ( is_ssl() ) {
1903
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
1902
+        if (is_ssl()) {
1903
+            $pay_url = str_replace('http:', 'https:', $pay_url);
1904 1904
         }
1905 1905
 
1906 1906
 		// Add the invoice key.
1907
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1907
+		$pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url);
1908 1908
 
1909 1909
 		// (Maybe?) add a secret
1910
-        if ( $secret ) {
1911
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1910
+        if ($secret) {
1911
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url);
1912 1912
         }
1913 1913
 
1914
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1914
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret);
1915 1915
 	}
1916 1916
 	
1917 1917
 	/**
@@ -1926,14 +1926,14 @@  discard block
 block discarded – undo
1926 1926
         $receipt_url = wpinv_get_success_page_uri();
1927 1927
 
1928 1928
 		// Maybe force ssl.
1929
-        if ( is_ssl() ) {
1930
-            $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1929
+        if (is_ssl()) {
1930
+            $receipt_url = str_replace('http:', 'https:', $receipt_url);
1931 1931
         }
1932 1932
 
1933 1933
 		// Add the invoice key.
1934
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1934
+		$receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url);
1935 1935
 
1936
-        return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1936
+        return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this);
1937 1937
 	}
1938 1938
 
1939 1939
 	/**
@@ -1943,7 +1943,7 @@  discard block
 block discarded – undo
1943 1943
 	 * @return string
1944 1944
 	 */
1945 1945
 	public function get_transaction_url() {
1946
-		return apply_filters( 'getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this );
1946
+		return apply_filters('getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this);
1947 1947
 	}
1948 1948
 
1949 1949
 	/**
@@ -1956,7 +1956,7 @@  discard block
 block discarded – undo
1956 1956
 
1957 1957
 		$type   = $this->get_type();
1958 1958
 		$status = "wpi-$type-pending";
1959
-		return str_replace( '-invoice', '', $status );
1959
+		return str_replace('-invoice', '', $status);
1960 1960
 
1961 1961
 	}
1962 1962
 
@@ -1970,8 +1970,8 @@  discard block
 block discarded – undo
1970 1970
 	 * @param  string $context View or edit context.
1971 1971
 	 * @return mixed Value of the given invoice property (if set).
1972 1972
 	 */
1973
-	public function get( $key, $context = 'view' ) {
1974
-        return $this->get_prop( $key, $context );
1973
+	public function get($key, $context = 'view') {
1974
+        return $this->get_prop($key, $context);
1975 1975
 	}
1976 1976
 
1977 1977
     /*
@@ -1994,11 +1994,11 @@  discard block
 block discarded – undo
1994 1994
 	 * @param  mixed $value new value.
1995 1995
 	 * @return mixed Value of the given invoice property (if set).
1996 1996
 	 */
1997
-	public function set( $key, $value ) {
1997
+	public function set($key, $value) {
1998 1998
 
1999 1999
         $setter = "set_$key";
2000
-        if ( is_callable( array( $this, $setter ) ) ) {
2001
-            $this->{$setter}( $value );
2000
+        if (is_callable(array($this, $setter))) {
2001
+            $this->{$setter}($value);
2002 2002
         }
2003 2003
 
2004 2004
 	}
@@ -2012,45 +2012,45 @@  discard block
 block discarded – undo
2012 2012
 	 * @param bool   $manual_update Is this a manual status change?.
2013 2013
 	 * @return array details of change.
2014 2014
 	 */
2015
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
2015
+	public function set_status($new_status, $note = '', $manual_update = false) {
2016 2016
 		$old_status = $this->get_status();
2017 2017
 
2018 2018
 		$statuses = $this->get_all_statuses();
2019 2019
 
2020
-		if ( isset( $statuses[ 'draft' ] ) ) {
2021
-			unset( $statuses[ 'draft' ] );
2020
+		if (isset($statuses['draft'])) {
2021
+			unset($statuses['draft']);
2022 2022
 		}
2023 2023
 
2024
-		$this->set_prop( 'status', $new_status );
2024
+		$this->set_prop('status', $new_status);
2025 2025
 
2026 2026
 		// If setting the status, ensure it's set to a valid status.
2027
-		if ( true === $this->object_read ) {
2027
+		if (true === $this->object_read) {
2028 2028
 
2029 2029
 			// Only allow valid new status.
2030
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
2030
+			if (!array_key_exists($new_status, $statuses)) {
2031 2031
 				$new_status = $this->get_default_status();
2032 2032
 			}
2033 2033
 
2034 2034
 			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
2035
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
2035
+			if ($old_status && !array_key_exists($new_status, $statuses)) {
2036 2036
 				$old_status = $this->get_default_status();
2037 2037
 			}
2038 2038
 
2039 2039
 			// Paid - Renewal (i.e when duplicating a parent invoice )
2040
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
2040
+			if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) {
2041 2041
 				$old_status = 'wpi-pending';
2042 2042
 			}
2043 2043
 
2044
-			if ( $old_status !== $new_status ) {
2044
+			if ($old_status !== $new_status) {
2045 2045
 				$this->status_transition = array(
2046
-					'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
2046
+					'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
2047 2047
 					'to'     => $new_status,
2048 2048
 					'note'   => $note,
2049 2049
 					'manual' => (bool) $manual_update,
2050 2050
 				);
2051 2051
 
2052
-				if ( $manual_update ) {
2053
-					do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
2052
+				if ($manual_update) {
2053
+					do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status);
2054 2054
 				}
2055 2055
 
2056 2056
 				$this->maybe_set_date_paid();
@@ -2075,8 +2075,8 @@  discard block
 block discarded – undo
2075 2075
 	 */
2076 2076
 	public function maybe_set_date_paid() {
2077 2077
 
2078
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2079
-			$this->set_date_completed( current_time( 'mysql' ) );
2078
+		if (!$this->get_date_completed('edit') && $this->is_paid()) {
2079
+			$this->set_date_completed(current_time('mysql'));
2080 2080
 		}
2081 2081
 	}
2082 2082
 
@@ -2085,11 +2085,11 @@  discard block
 block discarded – undo
2085 2085
 	 *
2086 2086
 	 * @since 1.0.19
2087 2087
 	 */
2088
-	public function set_parent_id( $value ) {
2089
-		if ( $value && ( $value === $this->get_id() ) ) {
2088
+	public function set_parent_id($value) {
2089
+		if ($value && ($value === $this->get_id())) {
2090 2090
 			return;
2091 2091
 		}
2092
-		$this->set_prop( 'parent_id', absint( $value ) );
2092
+		$this->set_prop('parent_id', absint($value));
2093 2093
     }
2094 2094
 
2095 2095
     /**
@@ -2097,8 +2097,8 @@  discard block
 block discarded – undo
2097 2097
 	 *
2098 2098
 	 * @since 1.0.19
2099 2099
 	 */
2100
-	public function set_version( $value ) {
2101
-		$this->set_prop( 'version', $value );
2100
+	public function set_version($value) {
2101
+		$this->set_prop('version', $value);
2102 2102
     }
2103 2103
 
2104 2104
     /**
@@ -2108,15 +2108,15 @@  discard block
 block discarded – undo
2108 2108
 	 * @param string $value Value to set.
2109 2109
      * @return bool Whether or not the date was set.
2110 2110
 	 */
2111
-	public function set_date_created( $value ) {
2112
-        $date = strtotime( $value );
2111
+	public function set_date_created($value) {
2112
+        $date = strtotime($value);
2113 2113
 
2114
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2115
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
2114
+        if ($date && $value !== '0000-00-00 00:00:00') {
2115
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
2116 2116
             return true;
2117 2117
         }
2118 2118
 
2119
-		$this->set_prop( 'date_created', '' );
2119
+		$this->set_prop('date_created', '');
2120 2120
 		return false;
2121 2121
 
2122 2122
     }
@@ -2128,15 +2128,15 @@  discard block
 block discarded – undo
2128 2128
 	 * @param string $value Value to set.
2129 2129
      * @return bool Whether or not the date was set.
2130 2130
 	 */
2131
-	public function set_due_date( $value ) {
2132
-        $date = strtotime( $value );
2131
+	public function set_due_date($value) {
2132
+        $date = strtotime($value);
2133 2133
 
2134
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2135
-            $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) );
2134
+        if ($date && $value !== '0000-00-00 00:00:00') {
2135
+            $this->set_prop('due_date', date('Y-m-d H:i:s', $date));
2136 2136
             return true;
2137 2137
         }
2138 2138
 
2139
-		$this->set_prop( 'due_date', '' );
2139
+		$this->set_prop('due_date', '');
2140 2140
         return false;
2141 2141
 
2142 2142
     }
@@ -2147,8 +2147,8 @@  discard block
 block discarded – undo
2147 2147
 	 * @since 1.0.19
2148 2148
 	 * @param  string $value New name.
2149 2149
 	 */
2150
-	public function set_date_due( $value ) {
2151
-		$this->set_due_date( $value );
2150
+	public function set_date_due($value) {
2151
+		$this->set_due_date($value);
2152 2152
     }
2153 2153
 
2154 2154
     /**
@@ -2158,15 +2158,15 @@  discard block
 block discarded – undo
2158 2158
 	 * @param string $value Value to set.
2159 2159
      * @return bool Whether or not the date was set.
2160 2160
 	 */
2161
-	public function set_completed_date( $value ) {
2162
-        $date = strtotime( $value );
2161
+	public function set_completed_date($value) {
2162
+        $date = strtotime($value);
2163 2163
 
2164
-        if ( $date && $value !== '0000-00-00 00:00:00'  ) {
2165
-            $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) );
2164
+        if ($date && $value !== '0000-00-00 00:00:00') {
2165
+            $this->set_prop('completed_date', date('Y-m-d H:i:s', $date));
2166 2166
             return true;
2167 2167
         }
2168 2168
 
2169
-		$this->set_prop( 'completed_date', '' );
2169
+		$this->set_prop('completed_date', '');
2170 2170
         return false;
2171 2171
 
2172 2172
     }
@@ -2177,8 +2177,8 @@  discard block
 block discarded – undo
2177 2177
 	 * @since 1.0.19
2178 2178
 	 * @param  string $value New name.
2179 2179
 	 */
2180
-	public function set_date_completed( $value ) {
2181
-		$this->set_completed_date( $value );
2180
+	public function set_date_completed($value) {
2181
+		$this->set_completed_date($value);
2182 2182
     }
2183 2183
 
2184 2184
     /**
@@ -2188,15 +2188,15 @@  discard block
 block discarded – undo
2188 2188
 	 * @param string $value Value to set.
2189 2189
      * @return bool Whether or not the date was set.
2190 2190
 	 */
2191
-	public function set_date_modified( $value ) {
2192
-        $date = strtotime( $value );
2191
+	public function set_date_modified($value) {
2192
+        $date = strtotime($value);
2193 2193
 
2194
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2195
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
2194
+        if ($date && $value !== '0000-00-00 00:00:00') {
2195
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
2196 2196
             return true;
2197 2197
         }
2198 2198
 
2199
-		$this->set_prop( 'date_modified', '' );
2199
+		$this->set_prop('date_modified', '');
2200 2200
         return false;
2201 2201
 
2202 2202
     }
@@ -2207,9 +2207,9 @@  discard block
 block discarded – undo
2207 2207
 	 * @since 1.0.19
2208 2208
 	 * @param  string $value New number.
2209 2209
 	 */
2210
-	public function set_number( $value ) {
2211
-        $number = sanitize_text_field( $value );
2212
-		$this->set_prop( 'number', $number );
2210
+	public function set_number($value) {
2211
+        $number = sanitize_text_field($value);
2212
+		$this->set_prop('number', $number);
2213 2213
     }
2214 2214
 
2215 2215
     /**
@@ -2218,9 +2218,9 @@  discard block
 block discarded – undo
2218 2218
 	 * @since 1.0.19
2219 2219
 	 * @param  string $value Type.
2220 2220
 	 */
2221
-	public function set_type( $value ) {
2222
-        $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2223
-		$this->set_prop( 'type', $type );
2221
+	public function set_type($value) {
2222
+        $type = sanitize_text_field(str_replace('wpi_', '', $value));
2223
+		$this->set_prop('type', $type);
2224 2224
 	}
2225 2225
 
2226 2226
     /**
@@ -2229,10 +2229,10 @@  discard block
 block discarded – undo
2229 2229
 	 * @since 1.0.19
2230 2230
 	 * @param  string $value Post type.
2231 2231
 	 */
2232
-	public function set_post_type( $value ) {
2233
-        if ( getpaid_is_invoice_post_type( $value ) ) {
2234
-			$this->set_type( $value );
2235
-            $this->set_prop( 'post_type', $value );
2232
+	public function set_post_type($value) {
2233
+        if (getpaid_is_invoice_post_type($value)) {
2234
+			$this->set_type($value);
2235
+            $this->set_prop('post_type', $value);
2236 2236
         }
2237 2237
     }
2238 2238
 
@@ -2242,9 +2242,9 @@  discard block
 block discarded – undo
2242 2242
 	 * @since 1.0.19
2243 2243
 	 * @param  string $value New key.
2244 2244
 	 */
2245
-	public function set_key( $value ) {
2246
-        $key = sanitize_text_field( $value );
2247
-		$this->set_prop( 'key', $key );
2245
+	public function set_key($value) {
2246
+        $key = sanitize_text_field($value);
2247
+		$this->set_prop('key', $key);
2248 2248
     }
2249 2249
 
2250 2250
     /**
@@ -2253,9 +2253,9 @@  discard block
 block discarded – undo
2253 2253
 	 * @since 1.0.19
2254 2254
 	 * @param  string $value mode.
2255 2255
 	 */
2256
-	public function set_mode( $value ) {
2257
-        if ( in_array( $value, array( 'live', 'test' ) ) ) {
2258
-            $this->set_prop( 'mode', $value );
2256
+	public function set_mode($value) {
2257
+        if (in_array($value, array('live', 'test'))) {
2258
+            $this->set_prop('mode', $value);
2259 2259
         }
2260 2260
     }
2261 2261
 
@@ -2265,8 +2265,8 @@  discard block
 block discarded – undo
2265 2265
 	 * @since 1.0.19
2266 2266
 	 * @param  string $value path.
2267 2267
 	 */
2268
-	public function set_path( $value ) {
2269
-        $this->set_prop( 'path', $value );
2268
+	public function set_path($value) {
2269
+        $this->set_prop('path', $value);
2270 2270
     }
2271 2271
 
2272 2272
     /**
@@ -2275,9 +2275,9 @@  discard block
 block discarded – undo
2275 2275
 	 * @since 1.0.19
2276 2276
 	 * @param  string $value New name.
2277 2277
 	 */
2278
-	public function set_name( $value ) {
2279
-        $name = sanitize_text_field( $value );
2280
-		$this->set_prop( 'name', $name );
2278
+	public function set_name($value) {
2279
+        $name = sanitize_text_field($value);
2280
+		$this->set_prop('name', $name);
2281 2281
     }
2282 2282
 
2283 2283
     /**
@@ -2286,8 +2286,8 @@  discard block
 block discarded – undo
2286 2286
 	 * @since 1.0.19
2287 2287
 	 * @param  string $value New name.
2288 2288
 	 */
2289
-	public function set_title( $value ) {
2290
-		$this->set_name( $value );
2289
+	public function set_title($value) {
2290
+		$this->set_name($value);
2291 2291
     }
2292 2292
 
2293 2293
     /**
@@ -2296,9 +2296,9 @@  discard block
 block discarded – undo
2296 2296
 	 * @since 1.0.19
2297 2297
 	 * @param  string $value New description.
2298 2298
 	 */
2299
-	public function set_description( $value ) {
2300
-        $description = wp_kses_post( $value );
2301
-		$this->set_prop( 'description', $description );
2299
+	public function set_description($value) {
2300
+        $description = wp_kses_post($value);
2301
+		$this->set_prop('description', $description);
2302 2302
     }
2303 2303
 
2304 2304
     /**
@@ -2307,8 +2307,8 @@  discard block
 block discarded – undo
2307 2307
 	 * @since 1.0.19
2308 2308
 	 * @param  string $value New description.
2309 2309
 	 */
2310
-	public function set_excerpt( $value ) {
2311
-		$this->set_description( $value );
2310
+	public function set_excerpt($value) {
2311
+		$this->set_description($value);
2312 2312
     }
2313 2313
 
2314 2314
     /**
@@ -2317,8 +2317,8 @@  discard block
 block discarded – undo
2317 2317
 	 * @since 1.0.19
2318 2318
 	 * @param  string $value New description.
2319 2319
 	 */
2320
-	public function set_summary( $value ) {
2321
-		$this->set_description( $value );
2320
+	public function set_summary($value) {
2321
+		$this->set_description($value);
2322 2322
     }
2323 2323
 
2324 2324
     /**
@@ -2327,12 +2327,12 @@  discard block
 block discarded – undo
2327 2327
 	 * @since 1.0.19
2328 2328
 	 * @param  int $value New author.
2329 2329
 	 */
2330
-	public function set_author( $value ) {
2331
-		$user = get_user_by( 'id', (int) $value );
2330
+	public function set_author($value) {
2331
+		$user = get_user_by('id', (int) $value);
2332 2332
 
2333
-		if ( $user && $user->ID ) {
2334
-			$this->set_prop( 'author', $user->ID );
2335
-			$this->set_prop( 'email', $user->user_email );
2333
+		if ($user && $user->ID) {
2334
+			$this->set_prop('author', $user->ID);
2335
+			$this->set_prop('email', $user->user_email);
2336 2336
 		}
2337 2337
 
2338 2338
     }
@@ -2343,8 +2343,8 @@  discard block
 block discarded – undo
2343 2343
 	 * @since 1.0.19
2344 2344
 	 * @param  int $value New user id.
2345 2345
 	 */
2346
-	public function set_user_id( $value ) {
2347
-		$this->set_author( $value );
2346
+	public function set_user_id($value) {
2347
+		$this->set_author($value);
2348 2348
     }
2349 2349
 
2350 2350
     /**
@@ -2353,8 +2353,8 @@  discard block
 block discarded – undo
2353 2353
 	 * @since 1.0.19
2354 2354
 	 * @param  int $value New user id.
2355 2355
 	 */
2356
-	public function set_customer_id( $value ) {
2357
-		$this->set_author( $value );
2356
+	public function set_customer_id($value) {
2357
+		$this->set_author($value);
2358 2358
     }
2359 2359
 
2360 2360
     /**
@@ -2363,8 +2363,8 @@  discard block
 block discarded – undo
2363 2363
 	 * @since 1.0.19
2364 2364
 	 * @param  string $value ip address.
2365 2365
 	 */
2366
-	public function set_ip( $value ) {
2367
-		$this->set_prop( 'ip', $value );
2366
+	public function set_ip($value) {
2367
+		$this->set_prop('ip', $value);
2368 2368
     }
2369 2369
 
2370 2370
     /**
@@ -2373,8 +2373,8 @@  discard block
 block discarded – undo
2373 2373
 	 * @since 1.0.19
2374 2374
 	 * @param  string $value ip address.
2375 2375
 	 */
2376
-	public function set_user_ip( $value ) {
2377
-		$this->set_ip( $value );
2376
+	public function set_user_ip($value) {
2377
+		$this->set_ip($value);
2378 2378
     }
2379 2379
 
2380 2380
     /**
@@ -2383,8 +2383,8 @@  discard block
 block discarded – undo
2383 2383
 	 * @since 1.0.19
2384 2384
 	 * @param  string $value first name.
2385 2385
 	 */
2386
-	public function set_first_name( $value ) {
2387
-		$this->set_prop( 'first_name', $value );
2386
+	public function set_first_name($value) {
2387
+		$this->set_prop('first_name', $value);
2388 2388
     }
2389 2389
 
2390 2390
     /**
@@ -2393,8 +2393,8 @@  discard block
 block discarded – undo
2393 2393
 	 * @since 1.0.19
2394 2394
 	 * @param  string $value first name.
2395 2395
 	 */
2396
-	public function set_user_first_name( $value ) {
2397
-		$this->set_first_name( $value );
2396
+	public function set_user_first_name($value) {
2397
+		$this->set_first_name($value);
2398 2398
     }
2399 2399
 
2400 2400
     /**
@@ -2403,8 +2403,8 @@  discard block
 block discarded – undo
2403 2403
 	 * @since 1.0.19
2404 2404
 	 * @param  string $value first name.
2405 2405
 	 */
2406
-	public function set_customer_first_name( $value ) {
2407
-		$this->set_first_name( $value );
2406
+	public function set_customer_first_name($value) {
2407
+		$this->set_first_name($value);
2408 2408
     }
2409 2409
 
2410 2410
     /**
@@ -2413,8 +2413,8 @@  discard block
 block discarded – undo
2413 2413
 	 * @since 1.0.19
2414 2414
 	 * @param  string $value last name.
2415 2415
 	 */
2416
-	public function set_last_name( $value ) {
2417
-		$this->set_prop( 'last_name', $value );
2416
+	public function set_last_name($value) {
2417
+		$this->set_prop('last_name', $value);
2418 2418
     }
2419 2419
 
2420 2420
     /**
@@ -2423,8 +2423,8 @@  discard block
 block discarded – undo
2423 2423
 	 * @since 1.0.19
2424 2424
 	 * @param  string $value last name.
2425 2425
 	 */
2426
-	public function set_user_last_name( $value ) {
2427
-		$this->set_last_name( $value );
2426
+	public function set_user_last_name($value) {
2427
+		$this->set_last_name($value);
2428 2428
     }
2429 2429
 
2430 2430
     /**
@@ -2433,8 +2433,8 @@  discard block
 block discarded – undo
2433 2433
 	 * @since 1.0.19
2434 2434
 	 * @param  string $value last name.
2435 2435
 	 */
2436
-	public function set_customer_last_name( $value ) {
2437
-		$this->set_last_name( $value );
2436
+	public function set_customer_last_name($value) {
2437
+		$this->set_last_name($value);
2438 2438
     }
2439 2439
 
2440 2440
     /**
@@ -2443,8 +2443,8 @@  discard block
 block discarded – undo
2443 2443
 	 * @since 1.0.19
2444 2444
 	 * @param  string $value phone.
2445 2445
 	 */
2446
-	public function set_phone( $value ) {
2447
-		$this->set_prop( 'phone', $value );
2446
+	public function set_phone($value) {
2447
+		$this->set_prop('phone', $value);
2448 2448
     }
2449 2449
 
2450 2450
     /**
@@ -2453,8 +2453,8 @@  discard block
 block discarded – undo
2453 2453
 	 * @since 1.0.19
2454 2454
 	 * @param  string $value phone.
2455 2455
 	 */
2456
-	public function set_user_phone( $value ) {
2457
-		$this->set_phone( $value );
2456
+	public function set_user_phone($value) {
2457
+		$this->set_phone($value);
2458 2458
     }
2459 2459
 
2460 2460
     /**
@@ -2463,8 +2463,8 @@  discard block
 block discarded – undo
2463 2463
 	 * @since 1.0.19
2464 2464
 	 * @param  string $value phone.
2465 2465
 	 */
2466
-	public function set_customer_phone( $value ) {
2467
-		$this->set_phone( $value );
2466
+	public function set_customer_phone($value) {
2467
+		$this->set_phone($value);
2468 2468
     }
2469 2469
 
2470 2470
     /**
@@ -2473,8 +2473,8 @@  discard block
 block discarded – undo
2473 2473
 	 * @since 1.0.19
2474 2474
 	 * @param  string $value phone.
2475 2475
 	 */
2476
-	public function set_phone_number( $value ) {
2477
-		$this->set_phone( $value );
2476
+	public function set_phone_number($value) {
2477
+		$this->set_phone($value);
2478 2478
     }
2479 2479
 
2480 2480
     /**
@@ -2483,8 +2483,8 @@  discard block
 block discarded – undo
2483 2483
 	 * @since 1.0.19
2484 2484
 	 * @param  string $value email address.
2485 2485
 	 */
2486
-	public function set_email( $value ) {
2487
-		$this->set_prop( 'email', $value );
2486
+	public function set_email($value) {
2487
+		$this->set_prop('email', $value);
2488 2488
     }
2489 2489
 
2490 2490
     /**
@@ -2493,8 +2493,8 @@  discard block
 block discarded – undo
2493 2493
 	 * @since 1.0.19
2494 2494
 	 * @param  string $value email address.
2495 2495
 	 */
2496
-	public function set_user_email( $value ) {
2497
-		$this->set_email( $value );
2496
+	public function set_user_email($value) {
2497
+		$this->set_email($value);
2498 2498
     }
2499 2499
 
2500 2500
     /**
@@ -2503,8 +2503,8 @@  discard block
 block discarded – undo
2503 2503
 	 * @since 1.0.19
2504 2504
 	 * @param  string $value email address.
2505 2505
 	 */
2506
-	public function set_email_address( $value ) {
2507
-		$this->set_email( $value );
2506
+	public function set_email_address($value) {
2507
+		$this->set_email($value);
2508 2508
     }
2509 2509
 
2510 2510
     /**
@@ -2513,8 +2513,8 @@  discard block
 block discarded – undo
2513 2513
 	 * @since 1.0.19
2514 2514
 	 * @param  string $value email address.
2515 2515
 	 */
2516
-	public function set_customer_email( $value ) {
2517
-		$this->set_email( $value );
2516
+	public function set_customer_email($value) {
2517
+		$this->set_email($value);
2518 2518
     }
2519 2519
 
2520 2520
     /**
@@ -2523,8 +2523,8 @@  discard block
 block discarded – undo
2523 2523
 	 * @since 1.0.19
2524 2524
 	 * @param  string $value country.
2525 2525
 	 */
2526
-	public function set_country( $value ) {
2527
-		$this->set_prop( 'country', $value );
2526
+	public function set_country($value) {
2527
+		$this->set_prop('country', $value);
2528 2528
     }
2529 2529
 
2530 2530
     /**
@@ -2533,8 +2533,8 @@  discard block
 block discarded – undo
2533 2533
 	 * @since 1.0.19
2534 2534
 	 * @param  string $value country.
2535 2535
 	 */
2536
-	public function set_user_country( $value ) {
2537
-		$this->set_country( $value );
2536
+	public function set_user_country($value) {
2537
+		$this->set_country($value);
2538 2538
     }
2539 2539
 
2540 2540
     /**
@@ -2543,8 +2543,8 @@  discard block
 block discarded – undo
2543 2543
 	 * @since 1.0.19
2544 2544
 	 * @param  string $value country.
2545 2545
 	 */
2546
-	public function set_customer_country( $value ) {
2547
-		$this->set_country( $value );
2546
+	public function set_customer_country($value) {
2547
+		$this->set_country($value);
2548 2548
     }
2549 2549
 
2550 2550
     /**
@@ -2553,8 +2553,8 @@  discard block
 block discarded – undo
2553 2553
 	 * @since 1.0.19
2554 2554
 	 * @param  string $value state.
2555 2555
 	 */
2556
-	public function set_state( $value ) {
2557
-		$this->set_prop( 'state', $value );
2556
+	public function set_state($value) {
2557
+		$this->set_prop('state', $value);
2558 2558
     }
2559 2559
 
2560 2560
     /**
@@ -2563,8 +2563,8 @@  discard block
 block discarded – undo
2563 2563
 	 * @since 1.0.19
2564 2564
 	 * @param  string $value state.
2565 2565
 	 */
2566
-	public function set_user_state( $value ) {
2567
-		$this->set_state( $value );
2566
+	public function set_user_state($value) {
2567
+		$this->set_state($value);
2568 2568
     }
2569 2569
 
2570 2570
     /**
@@ -2573,8 +2573,8 @@  discard block
 block discarded – undo
2573 2573
 	 * @since 1.0.19
2574 2574
 	 * @param  string $value state.
2575 2575
 	 */
2576
-	public function set_customer_state( $value ) {
2577
-		$this->set_state( $value );
2576
+	public function set_customer_state($value) {
2577
+		$this->set_state($value);
2578 2578
     }
2579 2579
 
2580 2580
     /**
@@ -2583,8 +2583,8 @@  discard block
 block discarded – undo
2583 2583
 	 * @since 1.0.19
2584 2584
 	 * @param  string $value city.
2585 2585
 	 */
2586
-	public function set_city( $value ) {
2587
-		$this->set_prop( 'city', $value );
2586
+	public function set_city($value) {
2587
+		$this->set_prop('city', $value);
2588 2588
     }
2589 2589
 
2590 2590
     /**
@@ -2593,8 +2593,8 @@  discard block
 block discarded – undo
2593 2593
 	 * @since 1.0.19
2594 2594
 	 * @param  string $value city.
2595 2595
 	 */
2596
-	public function set_user_city( $value ) {
2597
-		$this->set_city( $value );
2596
+	public function set_user_city($value) {
2597
+		$this->set_city($value);
2598 2598
     }
2599 2599
 
2600 2600
     /**
@@ -2603,8 +2603,8 @@  discard block
 block discarded – undo
2603 2603
 	 * @since 1.0.19
2604 2604
 	 * @param  string $value city.
2605 2605
 	 */
2606
-	public function set_customer_city( $value ) {
2607
-		$this->set_city( $value );
2606
+	public function set_customer_city($value) {
2607
+		$this->set_city($value);
2608 2608
     }
2609 2609
 
2610 2610
     /**
@@ -2613,8 +2613,8 @@  discard block
 block discarded – undo
2613 2613
 	 * @since 1.0.19
2614 2614
 	 * @param  string $value zip.
2615 2615
 	 */
2616
-	public function set_zip( $value ) {
2617
-		$this->set_prop( 'zip', $value );
2616
+	public function set_zip($value) {
2617
+		$this->set_prop('zip', $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  string $value zip.
2625 2625
 	 */
2626
-	public function set_user_zip( $value ) {
2627
-		$this->set_zip( $value );
2626
+	public function set_user_zip($value) {
2627
+		$this->set_zip($value);
2628 2628
     }
2629 2629
 
2630 2630
     /**
@@ -2633,8 +2633,8 @@  discard block
 block discarded – undo
2633 2633
 	 * @since 1.0.19
2634 2634
 	 * @param  string $value zip.
2635 2635
 	 */
2636
-	public function set_customer_zip( $value ) {
2637
-		$this->set_zip( $value );
2636
+	public function set_customer_zip($value) {
2637
+		$this->set_zip($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  string $value company.
2645 2645
 	 */
2646
-	public function set_company( $value ) {
2647
-		$this->set_prop( 'company', $value );
2646
+	public function set_company($value) {
2647
+		$this->set_prop('company', $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  string $value company.
2655 2655
 	 */
2656
-	public function set_user_company( $value ) {
2657
-		$this->set_company( $value );
2656
+	public function set_user_company($value) {
2657
+		$this->set_company($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  string $value company.
2665 2665
 	 */
2666
-	public function set_customer_company( $value ) {
2667
-		$this->set_company( $value );
2666
+	public function set_customer_company($value) {
2667
+		$this->set_company($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  string $value company id.
2675 2675
 	 */
2676
-	public function set_company_id( $value ) {
2677
-		$this->set_prop( 'company_id', $value );
2676
+	public function set_company_id($value) {
2677
+		$this->set_prop('company_id', $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  string $value var number.
2685 2685
 	 */
2686
-	public function set_vat_number( $value ) {
2687
-		$this->set_prop( 'vat_number', $value );
2686
+	public function set_vat_number($value) {
2687
+		$this->set_prop('vat_number', $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  string $value var number.
2695 2695
 	 */
2696
-	public function set_user_vat_number( $value ) {
2697
-		$this->set_vat_number( $value );
2696
+	public function set_user_vat_number($value) {
2697
+		$this->set_vat_number($value);
2698 2698
     }
2699 2699
 
2700 2700
     /**
@@ -2703,8 +2703,8 @@  discard block
 block discarded – undo
2703 2703
 	 * @since 1.0.19
2704 2704
 	 * @param  string $value var number.
2705 2705
 	 */
2706
-	public function set_customer_vat_number( $value ) {
2707
-		$this->set_vat_number( $value );
2706
+	public function set_customer_vat_number($value) {
2707
+		$this->set_vat_number($value);
2708 2708
     }
2709 2709
 
2710 2710
     /**
@@ -2713,8 +2713,8 @@  discard block
 block discarded – undo
2713 2713
 	 * @since 1.0.19
2714 2714
 	 * @param  string $value var rate.
2715 2715
 	 */
2716
-	public function set_vat_rate( $value ) {
2717
-		$this->set_prop( 'vat_rate', $value );
2716
+	public function set_vat_rate($value) {
2717
+		$this->set_prop('vat_rate', $value);
2718 2718
     }
2719 2719
 
2720 2720
     /**
@@ -2723,8 +2723,8 @@  discard block
 block discarded – undo
2723 2723
 	 * @since 1.0.19
2724 2724
 	 * @param  string $value var number.
2725 2725
 	 */
2726
-	public function set_user_vat_rate( $value ) {
2727
-		$this->set_vat_rate( $value );
2726
+	public function set_user_vat_rate($value) {
2727
+		$this->set_vat_rate($value);
2728 2728
     }
2729 2729
 
2730 2730
     /**
@@ -2733,8 +2733,8 @@  discard block
 block discarded – undo
2733 2733
 	 * @since 1.0.19
2734 2734
 	 * @param  string $value var number.
2735 2735
 	 */
2736
-	public function set_customer_vat_rate( $value ) {
2737
-		$this->set_vat_rate( $value );
2736
+	public function set_customer_vat_rate($value) {
2737
+		$this->set_vat_rate($value);
2738 2738
     }
2739 2739
 
2740 2740
     /**
@@ -2743,8 +2743,8 @@  discard block
 block discarded – undo
2743 2743
 	 * @since 1.0.19
2744 2744
 	 * @param  string $value address.
2745 2745
 	 */
2746
-	public function set_address( $value ) {
2747
-		$this->set_prop( 'address', $value );
2746
+	public function set_address($value) {
2747
+		$this->set_prop('address', $value);
2748 2748
     }
2749 2749
 
2750 2750
     /**
@@ -2753,8 +2753,8 @@  discard block
 block discarded – undo
2753 2753
 	 * @since 1.0.19
2754 2754
 	 * @param  string $value address.
2755 2755
 	 */
2756
-	public function set_user_address( $value ) {
2757
-		$this->set_address( $value );
2756
+	public function set_user_address($value) {
2757
+		$this->set_address($value);
2758 2758
     }
2759 2759
 
2760 2760
     /**
@@ -2763,8 +2763,8 @@  discard block
 block discarded – undo
2763 2763
 	 * @since 1.0.19
2764 2764
 	 * @param  string $value address.
2765 2765
 	 */
2766
-	public function set_customer_address( $value ) {
2767
-		$this->set_address( $value );
2766
+	public function set_customer_address($value) {
2767
+		$this->set_address($value);
2768 2768
     }
2769 2769
 
2770 2770
     /**
@@ -2773,8 +2773,8 @@  discard block
 block discarded – undo
2773 2773
 	 * @since 1.0.19
2774 2774
 	 * @param  int|bool $value confirmed.
2775 2775
 	 */
2776
-	public function set_is_viewed( $value ) {
2777
-		$this->set_prop( 'is_viewed', $value );
2776
+	public function set_is_viewed($value) {
2777
+		$this->set_prop('is_viewed', $value);
2778 2778
 	}
2779 2779
 
2780 2780
 	/**
@@ -2783,8 +2783,8 @@  discard block
 block discarded – undo
2783 2783
 	 * @since 1.0.19
2784 2784
 	 * @param  string $value email recipients.
2785 2785
 	 */
2786
-	public function set_email_cc( $value ) {
2787
-		$this->set_prop( 'email_cc', $value );
2786
+	public function set_email_cc($value) {
2787
+		$this->set_prop('email_cc', $value);
2788 2788
 	}
2789 2789
 
2790 2790
 	/**
@@ -2793,9 +2793,9 @@  discard block
 block discarded – undo
2793 2793
 	 * @since 1.0.19
2794 2794
 	 * @param  string $value template.
2795 2795
 	 */
2796
-	public function set_template( $value ) {
2797
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2798
-			$this->set_prop( 'template', $value );
2796
+	public function set_template($value) {
2797
+		if (in_array($value, array('quantity', 'hours', 'amount'))) {
2798
+			$this->set_prop('template', $value);
2799 2799
 		}
2800 2800
 	}
2801 2801
 
@@ -2806,8 +2806,8 @@  discard block
 block discarded – undo
2806 2806
 	 * @param  string $value source.
2807 2807
 	 * @deprecated
2808 2808
 	 */
2809
-	public function created_via( $value ) {
2810
-		$this->set_created_via( sanitize_text_field( $value ) );
2809
+	public function created_via($value) {
2810
+		$this->set_created_via(sanitize_text_field($value));
2811 2811
 	}
2812 2812
 
2813 2813
 	/**
@@ -2816,8 +2816,8 @@  discard block
 block discarded – undo
2816 2816
 	 * @since 1.0.19
2817 2817
 	 * @param  string $value source.
2818 2818
 	 */
2819
-	public function set_created_via( $value ) {
2820
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2819
+	public function set_created_via($value) {
2820
+		$this->set_prop('created_via', sanitize_text_field($value));
2821 2821
 	}
2822 2822
 
2823 2823
 	/**
@@ -2826,8 +2826,8 @@  discard block
 block discarded – undo
2826 2826
 	 * @since 1.0.19
2827 2827
 	 * @param  int|bool $value confirmed.
2828 2828
 	 */
2829
-	public function set_address_confirmed( $value ) {
2830
-		$this->set_prop( 'address_confirmed', $value );
2829
+	public function set_address_confirmed($value) {
2830
+		$this->set_prop('address_confirmed', $value);
2831 2831
     }
2832 2832
 
2833 2833
     /**
@@ -2836,8 +2836,8 @@  discard block
 block discarded – undo
2836 2836
 	 * @since 1.0.19
2837 2837
 	 * @param  int|bool $value confirmed.
2838 2838
 	 */
2839
-	public function set_user_address_confirmed( $value ) {
2840
-		$this->set_address_confirmed( $value );
2839
+	public function set_user_address_confirmed($value) {
2840
+		$this->set_address_confirmed($value);
2841 2841
     }
2842 2842
 
2843 2843
     /**
@@ -2846,8 +2846,8 @@  discard block
 block discarded – undo
2846 2846
 	 * @since 1.0.19
2847 2847
 	 * @param  int|bool $value confirmed.
2848 2848
 	 */
2849
-	public function set_customer_address_confirmed( $value ) {
2850
-		$this->set_address_confirmed( $value );
2849
+	public function set_customer_address_confirmed($value) {
2850
+		$this->set_address_confirmed($value);
2851 2851
     }
2852 2852
 
2853 2853
     /**
@@ -2856,13 +2856,13 @@  discard block
 block discarded – undo
2856 2856
 	 * @since 1.0.19
2857 2857
 	 * @param  float $value shipping amount.
2858 2858
 	 */
2859
-	public function set_shipping( $value ) {
2859
+	public function set_shipping($value) {
2860 2860
 
2861
-		if ( ! is_numeric( $value ) ) {
2862
-			return $this->set_prop( 'shipping', null );
2861
+		if (!is_numeric($value)) {
2862
+			return $this->set_prop('shipping', null);
2863 2863
 		}
2864 2864
 
2865
-		$this->set_prop( 'shipping', max( 0, floatval( $value ) ) );
2865
+		$this->set_prop('shipping', max(0, floatval($value)));
2866 2866
 	}
2867 2867
 
2868 2868
 	/**
@@ -2871,8 +2871,8 @@  discard block
 block discarded – undo
2871 2871
 	 * @since 1.0.19
2872 2872
 	 * @param  float $value sub total.
2873 2873
 	 */
2874
-	public function set_subtotal( $value ) {
2875
-		$this->set_prop( 'subtotal', max( 0, $value ) );
2874
+	public function set_subtotal($value) {
2875
+		$this->set_prop('subtotal', max(0, $value));
2876 2876
 	}
2877 2877
 
2878 2878
 	/**
@@ -2881,8 +2881,8 @@  discard block
 block discarded – undo
2881 2881
 	 * @since 1.0.19
2882 2882
 	 * @param  float $value sub total.
2883 2883
 	 */
2884
-	public function set_total( $value ) {
2885
-		$this->set_prop( 'total', max( 0, $value ) );
2884
+	public function set_total($value) {
2885
+		$this->set_prop('total', max(0, $value));
2886 2886
     }
2887 2887
 
2888 2888
     /**
@@ -2891,8 +2891,8 @@  discard block
 block discarded – undo
2891 2891
 	 * @since 1.0.19
2892 2892
 	 * @param  float $value discount total.
2893 2893
 	 */
2894
-	public function set_total_discount( $value ) {
2895
-		$this->set_prop( 'total_discount', max( 0, $value ) );
2894
+	public function set_total_discount($value) {
2895
+		$this->set_prop('total_discount', max(0, $value));
2896 2896
     }
2897 2897
 
2898 2898
     /**
@@ -2901,8 +2901,8 @@  discard block
 block discarded – undo
2901 2901
 	 * @since 1.0.19
2902 2902
 	 * @param  float $value discount total.
2903 2903
 	 */
2904
-	public function set_discount( $value ) {
2905
-		$this->set_total_discount( $value );
2904
+	public function set_discount($value) {
2905
+		$this->set_total_discount($value);
2906 2906
     }
2907 2907
 
2908 2908
     /**
@@ -2911,8 +2911,8 @@  discard block
 block discarded – undo
2911 2911
 	 * @since 1.0.19
2912 2912
 	 * @param  float $value tax total.
2913 2913
 	 */
2914
-	public function set_total_tax( $value ) {
2915
-		$this->set_prop( 'total_tax', max( 0, $value ) );
2914
+	public function set_total_tax($value) {
2915
+		$this->set_prop('total_tax', max(0, $value));
2916 2916
     }
2917 2917
 
2918 2918
     /**
@@ -2921,8 +2921,8 @@  discard block
 block discarded – undo
2921 2921
 	 * @since 1.0.19
2922 2922
 	 * @param  float $value tax total.
2923 2923
 	 */
2924
-	public function set_tax_total( $value ) {
2925
-		$this->set_total_tax( $value );
2924
+	public function set_tax_total($value) {
2925
+		$this->set_total_tax($value);
2926 2926
     }
2927 2927
 
2928 2928
     /**
@@ -2931,8 +2931,8 @@  discard block
 block discarded – undo
2931 2931
 	 * @since 1.0.19
2932 2932
 	 * @param  float $value fees total.
2933 2933
 	 */
2934
-	public function set_total_fees( $value ) {
2935
-		$this->set_prop( 'total_fees', max( 0, $value ) );
2934
+	public function set_total_fees($value) {
2935
+		$this->set_prop('total_fees', max(0, $value));
2936 2936
     }
2937 2937
 
2938 2938
     /**
@@ -2941,8 +2941,8 @@  discard block
 block discarded – undo
2941 2941
 	 * @since 1.0.19
2942 2942
 	 * @param  float $value fees total.
2943 2943
 	 */
2944
-	public function set_fees_total( $value ) {
2945
-		$this->set_total_fees( $value );
2944
+	public function set_fees_total($value) {
2945
+		$this->set_total_fees($value);
2946 2946
     }
2947 2947
 
2948 2948
     /**
@@ -2951,13 +2951,13 @@  discard block
 block discarded – undo
2951 2951
 	 * @since 1.0.19
2952 2952
 	 * @param  array $value fees.
2953 2953
 	 */
2954
-	public function set_fees( $value ) {
2954
+	public function set_fees($value) {
2955 2955
 
2956
-		if ( ! is_array( $value ) ) {
2956
+		if (!is_array($value)) {
2957 2957
 			$value = array();
2958 2958
 		}
2959 2959
 
2960
-		$this->set_prop( 'fees', $value );
2960
+		$this->set_prop('fees', $value);
2961 2961
 
2962 2962
     }
2963 2963
 
@@ -2967,13 +2967,13 @@  discard block
 block discarded – undo
2967 2967
 	 * @since 1.0.19
2968 2968
 	 * @param  array $value taxes.
2969 2969
 	 */
2970
-	public function set_taxes( $value ) {
2970
+	public function set_taxes($value) {
2971 2971
 
2972
-		if ( ! is_array( $value ) ) {
2972
+		if (!is_array($value)) {
2973 2973
 			$value = array();
2974 2974
 		}
2975 2975
 
2976
-		$this->set_prop( 'taxes', $value );
2976
+		$this->set_prop('taxes', $value);
2977 2977
 
2978 2978
     }
2979 2979
 
@@ -2983,13 +2983,13 @@  discard block
 block discarded – undo
2983 2983
 	 * @since 1.0.19
2984 2984
 	 * @param  array $value discounts.
2985 2985
 	 */
2986
-	public function set_discounts( $value ) {
2986
+	public function set_discounts($value) {
2987 2987
 
2988
-		if ( ! is_array( $value ) ) {
2988
+		if (!is_array($value)) {
2989 2989
 			$value = array();
2990 2990
 		}
2991 2991
 
2992
-		$this->set_prop( 'discounts', $value );
2992
+		$this->set_prop('discounts', $value);
2993 2993
     }
2994 2994
 
2995 2995
     /**
@@ -2998,19 +2998,19 @@  discard block
 block discarded – undo
2998 2998
 	 * @since 1.0.19
2999 2999
 	 * @param  GetPaid_Form_Item[] $value items.
3000 3000
 	 */
3001
-	public function set_items( $value ) {
3001
+	public function set_items($value) {
3002 3002
 
3003 3003
         // Remove existing items.
3004
-        $this->set_prop( 'items', array() );
3004
+        $this->set_prop('items', array());
3005 3005
 		$this->recurring_item = null;
3006 3006
 
3007 3007
         // Ensure that we have an array.
3008
-        if ( ! is_array( $value ) ) {
3008
+        if (!is_array($value)) {
3009 3009
             return;
3010 3010
         }
3011 3011
 
3012
-        foreach ( $value as $item ) {
3013
-            $this->add_item( $item );
3012
+        foreach ($value as $item) {
3013
+            $this->add_item($item);
3014 3014
         }
3015 3015
 
3016 3016
     }
@@ -3021,8 +3021,8 @@  discard block
 block discarded – undo
3021 3021
 	 * @since 1.0.19
3022 3022
 	 * @param  int $value payment form.
3023 3023
 	 */
3024
-	public function set_payment_form( $value ) {
3025
-		$this->set_prop( 'payment_form', $value );
3024
+	public function set_payment_form($value) {
3025
+		$this->set_prop('payment_form', $value);
3026 3026
     }
3027 3027
 
3028 3028
     /**
@@ -3031,8 +3031,8 @@  discard block
 block discarded – undo
3031 3031
 	 * @since 1.0.19
3032 3032
 	 * @param  string $value submission id.
3033 3033
 	 */
3034
-	public function set_submission_id( $value ) {
3035
-		$this->set_prop( 'submission_id', $value );
3034
+	public function set_submission_id($value) {
3035
+		$this->set_prop('submission_id', $value);
3036 3036
     }
3037 3037
 
3038 3038
     /**
@@ -3041,8 +3041,8 @@  discard block
 block discarded – undo
3041 3041
 	 * @since 1.0.19
3042 3042
 	 * @param  string $value discount code.
3043 3043
 	 */
3044
-	public function set_discount_code( $value ) {
3045
-		$this->set_prop( 'discount_code', sanitize_text_field( $value ) );
3044
+	public function set_discount_code($value) {
3045
+		$this->set_prop('discount_code', sanitize_text_field($value));
3046 3046
     }
3047 3047
 
3048 3048
     /**
@@ -3051,8 +3051,8 @@  discard block
 block discarded – undo
3051 3051
 	 * @since 1.0.19
3052 3052
 	 * @param  string $value gateway.
3053 3053
 	 */
3054
-	public function set_gateway( $value ) {
3055
-		$this->set_prop( 'gateway', $value );
3054
+	public function set_gateway($value) {
3055
+		$this->set_prop('gateway', $value);
3056 3056
     }
3057 3057
 
3058 3058
     /**
@@ -3061,9 +3061,9 @@  discard block
 block discarded – undo
3061 3061
 	 * @since 1.0.19
3062 3062
 	 * @param  string $value transaction id.
3063 3063
 	 */
3064
-	public function set_transaction_id( $value ) {
3065
-		if ( ! empty( $value ) ) {
3066
-			$this->set_prop( 'transaction_id', $value );
3064
+	public function set_transaction_id($value) {
3065
+		if (!empty($value)) {
3066
+			$this->set_prop('transaction_id', $value);
3067 3067
 		}
3068 3068
     }
3069 3069
 
@@ -3073,8 +3073,8 @@  discard block
 block discarded – undo
3073 3073
 	 * @since 1.0.19
3074 3074
 	 * @param  string $value currency id.
3075 3075
 	 */
3076
-	public function set_currency( $value ) {
3077
-		$this->set_prop( 'currency', $value );
3076
+	public function set_currency($value) {
3077
+		$this->set_prop('currency', $value);
3078 3078
     }
3079 3079
 
3080 3080
 	/**
@@ -3083,8 +3083,8 @@  discard block
 block discarded – undo
3083 3083
 	 * @since 1.0.19
3084 3084
 	 * @param  bool $value value.
3085 3085
 	 */
3086
-	public function set_disable_taxes( $value ) {
3087
-		$this->set_prop( 'disable_taxes', (bool) $value );
3086
+	public function set_disable_taxes($value) {
3087
+		$this->set_prop('disable_taxes', (bool) $value);
3088 3088
 	}
3089 3089
 
3090 3090
     /**
@@ -3093,8 +3093,8 @@  discard block
 block discarded – undo
3093 3093
 	 * @since 1.0.19
3094 3094
 	 * @param  string $value subscription id.
3095 3095
 	 */
3096
-	public function set_subscription_id( $value ) {
3097
-		$this->set_prop( 'subscription_id', $value );
3096
+	public function set_subscription_id($value) {
3097
+		$this->set_prop('subscription_id', $value);
3098 3098
 	}
3099 3099
 	
3100 3100
 	/**
@@ -3103,8 +3103,8 @@  discard block
 block discarded – undo
3103 3103
 	 * @since 1.0.19
3104 3104
 	 * @param  string $value subscription id.
3105 3105
 	 */
3106
-	public function set_remote_subscription_id( $value ) {
3107
-		$this->set_prop( 'remote_subscription_id', $value );
3106
+	public function set_remote_subscription_id($value) {
3107
+		$this->set_prop('remote_subscription_id', $value);
3108 3108
     }
3109 3109
 
3110 3110
     /*
@@ -3121,28 +3121,28 @@  discard block
 block discarded – undo
3121 3121
      */
3122 3122
     public function is_parent() {
3123 3123
         $parent = $this->get_parent_id();
3124
-        return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this );
3124
+        return apply_filters('wpinv_invoice_is_parent', empty($parent), $this);
3125 3125
     }
3126 3126
 
3127 3127
     /**
3128 3128
      * Checks if this is a renewal invoice.
3129 3129
      */
3130 3130
     public function is_renewal() {
3131
-        return $this->is_recurring() && ! $this->is_parent();
3131
+        return $this->is_recurring() && !$this->is_parent();
3132 3132
     }
3133 3133
 
3134 3134
     /**
3135 3135
      * Checks if this is a recurring invoice.
3136 3136
      */
3137 3137
     public function is_recurring() {
3138
-        return ! empty( $this->recurring_item );
3138
+        return !empty($this->recurring_item);
3139 3139
     }
3140 3140
 
3141 3141
     /**
3142 3142
      * Checks if this is a taxable invoice.
3143 3143
      */
3144 3144
     public function is_taxable() {
3145
-        return ! $this->get_disable_taxes();
3145
+        return !$this->get_disable_taxes();
3146 3146
 	}
3147 3147
 
3148 3148
 	/**
@@ -3156,45 +3156,45 @@  discard block
 block discarded – undo
3156 3156
 	 * Checks to see if the invoice requires payment.
3157 3157
 	 */
3158 3158
 	public function is_free() {
3159
-        $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
3159
+        $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0);
3160 3160
 
3161
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3161
+		if ($this->is_recurring() && $this->get_recurring_total() > 0) {
3162 3162
 			$is_free = false;
3163 3163
 		}
3164 3164
 
3165
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
3165
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
3166 3166
     }
3167 3167
 
3168 3168
     /**
3169 3169
      * Checks if the invoice is paid.
3170 3170
      */
3171 3171
     public function is_paid() {
3172
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
3173
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
3172
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
3173
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
3174 3174
 	}
3175 3175
 
3176 3176
 	/**
3177 3177
      * Checks if the invoice needs payment.
3178 3178
      */
3179 3179
 	public function needs_payment() {
3180
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3181
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
3180
+		$needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free();
3181
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this);
3182 3182
     }
3183 3183
   
3184 3184
 	/**
3185 3185
      * Checks if the invoice is refunded.
3186 3186
      */
3187 3187
 	public function is_refunded() {
3188
-        $is_refunded = $this->has_status( 'wpi-refunded' );
3189
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3188
+        $is_refunded = $this->has_status('wpi-refunded');
3189
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
3190 3190
 	}
3191 3191
 
3192 3192
 	/**
3193 3193
      * Checks if the invoice is held.
3194 3194
      */
3195 3195
 	public function is_held() {
3196
-        $is_held = $this->has_status( 'wpi-onhold' );
3197
-        return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3196
+        $is_held = $this->has_status('wpi-onhold');
3197
+        return apply_filters('wpinv_invoice_is_held', $is_held, $this);
3198 3198
 	}
3199 3199
 
3200 3200
 	/**
@@ -3202,30 +3202,30 @@  discard block
 block discarded – undo
3202 3202
      */
3203 3203
 	public function is_due() {
3204 3204
 		$due_date = $this->get_due_date();
3205
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3205
+		return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date);
3206 3206
 	}
3207 3207
 
3208 3208
 	/**
3209 3209
      * Checks if the invoice is draft.
3210 3210
      */
3211 3211
 	public function is_draft() {
3212
-        return $this->has_status( 'draft, auto-draft' );
3212
+        return $this->has_status('draft, auto-draft');
3213 3213
 	}
3214 3214
 
3215 3215
     /**
3216 3216
      * Checks if the invoice has a given status.
3217 3217
      */
3218
-    public function has_status( $status ) {
3219
-        $status = wpinv_parse_list( $status );
3220
-        return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3218
+    public function has_status($status) {
3219
+        $status = wpinv_parse_list($status);
3220
+        return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status);
3221 3221
 	}
3222 3222
 
3223 3223
 	/**
3224 3224
      * Checks if the invoice is of a given type.
3225 3225
      */
3226
-    public function is_type( $type ) {
3227
-        $type = wpinv_parse_list( $type );
3228
-        return in_array( $this->get_type(), $type );
3226
+    public function is_type($type) {
3227
+        $type = wpinv_parse_list($type);
3228
+        return in_array($this->get_type(), $type);
3229 3229
     }
3230 3230
 
3231 3231
     /**
@@ -3257,8 +3257,8 @@  discard block
 block discarded – undo
3257 3257
      *
3258 3258
      */
3259 3259
 	public function is_initial_free() {
3260
-        $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3261
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3260
+        $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0);
3261
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this);
3262 3262
     }
3263 3263
 	
3264 3264
 	/**
@@ -3268,11 +3268,11 @@  discard block
 block discarded – undo
3268 3268
     public function item_has_free_trial() {
3269 3269
 
3270 3270
         // Ensure we have a recurring item.
3271
-        if ( ! $this->is_recurring() ) {
3271
+        if (!$this->is_recurring()) {
3272 3272
             return false;
3273 3273
         }
3274 3274
 
3275
-        $item = $this->get_recurring( true );
3275
+        $item = $this->get_recurring(true);
3276 3276
         return $item->has_free_trial();
3277 3277
 	}
3278 3278
 
@@ -3280,7 +3280,7 @@  discard block
 block discarded – undo
3280 3280
      * Check if the free trial is a result of a discount.
3281 3281
      */
3282 3282
     public function is_free_trial_from_discount() {
3283
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3283
+		return $this->has_free_trial() && !$this->item_has_free_trial();
3284 3284
 	}
3285 3285
 	
3286 3286
 	/**
@@ -3288,12 +3288,12 @@  discard block
 block discarded – undo
3288 3288
      */
3289 3289
     public function discount_first_payment_only() {
3290 3290
 
3291
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3292
-        if ( ! $discount->exists() || ! $this->is_recurring() ) {
3291
+		$discount = wpinv_get_discount_obj($this->get_discount_code());
3292
+        if (!$discount->exists() || !$this->is_recurring()) {
3293 3293
             return true;
3294 3294
         }
3295 3295
 
3296
-        return ! $discount->get_is_recurring();
3296
+        return !$discount->get_is_recurring();
3297 3297
     }
3298 3298
 
3299 3299
     /*
@@ -3311,23 +3311,23 @@  discard block
 block discarded – undo
3311 3311
      * @param GetPaid_Form_Item|array $item
3312 3312
      * @return WP_Error|Bool
3313 3313
      */
3314
-    public function add_item( $item ) {
3314
+    public function add_item($item) {
3315 3315
 
3316
-		if ( is_array( $item ) ) {
3317
-			$item = $this->process_array_item( $item );
3316
+		if (is_array($item)) {
3317
+			$item = $this->process_array_item($item);
3318 3318
 		}
3319 3319
 
3320
-		if ( is_numeric( $item ) ) {
3321
-			$item = new GetPaid_Form_Item( $item );
3320
+		if (is_numeric($item)) {
3321
+			$item = new GetPaid_Form_Item($item);
3322 3322
 		}
3323 3323
 
3324 3324
         // Make sure that it is available for purchase.
3325
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3326
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3325
+		if ($item->get_id() > 0 && !$item->can_purchase()) {
3326
+			return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing'));
3327 3327
         }
3328 3328
 
3329 3329
         // Do we have a recurring item?
3330
-		if ( $item->is_recurring() ) {
3330
+		if ($item->is_recurring()) {
3331 3331
 			$this->recurring_item = $item->get_id();
3332 3332
         }
3333 3333
 
@@ -3335,9 +3335,9 @@  discard block
 block discarded – undo
3335 3335
         $item->invoice_id = (int) $this->get_id();
3336 3336
 
3337 3337
 		// Remove duplicates.
3338
-		$this->remove_item( $item->get_id() );
3338
+		$this->remove_item($item->get_id());
3339 3339
 
3340
-		if ( 0 == $item->get_quantity() ) {
3340
+		if (0 == $item->get_quantity()) {
3341 3341
 			return;
3342 3342
 		}
3343 3343
 
@@ -3347,7 +3347,7 @@  discard block
 block discarded – undo
3347 3347
 		// Add new item.
3348 3348
         $items[] = $item;
3349 3349
 
3350
-        $this->set_prop( 'items', $items );
3350
+        $this->set_prop('items', $items);
3351 3351
 
3352 3352
 		return true;
3353 3353
 	}
@@ -3358,26 +3358,26 @@  discard block
 block discarded – undo
3358 3358
 	 * @since 1.0.19
3359 3359
 	 * @return GetPaid_Form_Item
3360 3360
 	 */
3361
-	protected function process_array_item( $array ) {
3361
+	protected function process_array_item($array) {
3362 3362
 
3363
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3364
-		$item    = new GetPaid_Form_Item( $item_id );
3363
+		$item_id = isset($array['item_id']) ? $array['item_id'] : 0;
3364
+		$item    = new GetPaid_Form_Item($item_id);
3365 3365
 
3366 3366
 		// Set item data.
3367
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3368
-			if ( isset( $array[ "item_$key" ] ) ) {
3367
+		foreach (array('name', 'price', 'description') as $key) {
3368
+			if (isset($array["item_$key"])) {
3369 3369
 				$method = "set_$key";
3370
-				$item->$method( $array[ "item_$key" ] );
3370
+				$item->$method($array["item_$key"]);
3371 3371
 			}
3372 3372
 		}
3373 3373
 
3374
-		if ( isset( $array['quantity'] ) ) {
3375
-			$item->set_quantity( $array['quantity'] );
3374
+		if (isset($array['quantity'])) {
3375
+			$item->set_quantity($array['quantity']);
3376 3376
 		}
3377 3377
 
3378 3378
 		// Set item meta.
3379
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3380
-			$item->set_item_meta( $array['meta'] );
3379
+		if (isset($array['meta']) && is_array($array['meta'])) {
3380
+			$item->set_item_meta($array['meta']);
3381 3381
 		}
3382 3382
 
3383 3383
 		return $item;
@@ -3390,10 +3390,10 @@  discard block
 block discarded – undo
3390 3390
 	 * @since 1.0.19
3391 3391
 	 * @return GetPaid_Form_Item|null
3392 3392
 	 */
3393
-	public function get_item( $item_id ) {
3393
+	public function get_item($item_id) {
3394 3394
 
3395
-		foreach ( $this->get_items() as $item ) {
3396
-			if ( (int) $item_id == $item->get_id() ) {
3395
+		foreach ($this->get_items() as $item) {
3396
+			if ((int) $item_id == $item->get_id()) {
3397 3397
 				return $item;
3398 3398
 			}
3399 3399
 		}
@@ -3406,16 +3406,16 @@  discard block
 block discarded – undo
3406 3406
 	 *
3407 3407
 	 * @since 1.0.19
3408 3408
 	 */
3409
-	public function remove_item( $item_id ) {
3409
+	public function remove_item($item_id) {
3410 3410
 		$items   = $this->get_items();
3411 3411
 		$item_id = (int) $item_id;
3412 3412
 
3413
-		foreach ( $items as $index => $item ) {
3414
-			if ( (int) $item_id == $item->get_id() ) {
3415
-				unset( $items[ $index ] );
3416
-				$this->set_prop( 'items', $items );
3413
+		foreach ($items as $index => $item) {
3414
+			if ((int) $item_id == $item->get_id()) {
3415
+				unset($items[$index]);
3416
+				$this->set_prop('items', $items);
3417 3417
 
3418
-				if ( $item_id == $this->recurring_item ) {
3418
+				if ($item_id == $this->recurring_item) {
3419 3419
 					$this->recurring_item = null;
3420 3420
 				}
3421 3421
 
@@ -3430,11 +3430,11 @@  discard block
 block discarded – undo
3430 3430
 	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3431 3431
 	 * @since 1.0.19
3432 3432
 	 */
3433
-    public function add_fee( $fee ) {
3433
+    public function add_fee($fee) {
3434 3434
 
3435 3435
 		$fees                 = $this->get_fees();
3436
-		$fees[ $fee['name'] ] = $fee;
3437
-		$this->set_prop( 'fees', $fees );
3436
+		$fees[$fee['name']] = $fee;
3437
+		$this->set_prop('fees', $fees);
3438 3438
 
3439 3439
     }
3440 3440
 
@@ -3443,9 +3443,9 @@  discard block
 block discarded – undo
3443 3443
 	 *
3444 3444
 	 * @since 1.0.19
3445 3445
 	 */
3446
-	public function get_fee( $fee ) {
3446
+	public function get_fee($fee) {
3447 3447
         $fees = $this->get_fees();
3448
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3448
+		return isset($fees[$fee]) ? $fees[$fee] : null;
3449 3449
     }
3450 3450
 
3451 3451
     /**
@@ -3453,11 +3453,11 @@  discard block
 block discarded – undo
3453 3453
 	 *
3454 3454
 	 * @since 1.0.19
3455 3455
 	 */
3456
-	public function remove_fee( $fee ) {
3456
+	public function remove_fee($fee) {
3457 3457
         $fees = $this->get_fees();
3458
-        if ( isset( $fees[ $fee ] ) ) {
3459
-            unset( $fees[ $fee ] );
3460
-            $this->set_prop( 'fees', $fees );
3458
+        if (isset($fees[$fee])) {
3459
+            unset($fees[$fee]);
3460
+            $this->set_prop('fees', $fees);
3461 3461
         }
3462 3462
     }
3463 3463
 
@@ -3467,11 +3467,11 @@  discard block
 block discarded – undo
3467 3467
 	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3468 3468
 	 * @since 1.0.19
3469 3469
 	 */
3470
-	public function add_discount( $discount ) {
3470
+	public function add_discount($discount) {
3471 3471
 
3472 3472
 		$discounts = $this->get_discounts();
3473
-		$discounts[ $discount['name'] ] = $discount;
3474
-		$this->set_prop( 'discounts', $discounts );
3473
+		$discounts[$discount['name']] = $discount;
3474
+		$this->set_prop('discounts', $discounts);
3475 3475
 
3476 3476
 	}
3477 3477
 
@@ -3481,15 +3481,15 @@  discard block
 block discarded – undo
3481 3481
 	 * @since 1.0.19
3482 3482
 	 * @return float
3483 3483
 	 */
3484
-	public function get_discount( $discount = false ) {
3484
+	public function get_discount($discount = false) {
3485 3485
 
3486 3486
 		// Backwards compatibilty.
3487
-		if ( empty( $discount ) ) {
3487
+		if (empty($discount)) {
3488 3488
 			return $this->get_total_discount();
3489 3489
 		}
3490 3490
 
3491 3491
         $discounts = $this->get_discounts();
3492
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3492
+		return isset($discounts[$discount]) ? $discounts[$discount] : null;
3493 3493
     }
3494 3494
 
3495 3495
     /**
@@ -3497,15 +3497,15 @@  discard block
 block discarded – undo
3497 3497
 	 *
3498 3498
 	 * @since 1.0.19
3499 3499
 	 */
3500
-	public function remove_discount( $discount ) {
3500
+	public function remove_discount($discount) {
3501 3501
         $discounts = $this->get_discounts();
3502
-        if ( isset( $discounts[ $discount ] ) ) {
3503
-            unset( $discounts[ $discount ] );
3504
-            $this->set_prop( 'discounts', $discounts );
3502
+        if (isset($discounts[$discount])) {
3503
+            unset($discounts[$discount]);
3504
+            $this->set_prop('discounts', $discounts);
3505 3505
         }
3506 3506
 
3507
-		if ( 'discount_code' == $discount ) {
3508
-			foreach ( $this->get_items() as $item ) {
3507
+		if ('discount_code' == $discount) {
3508
+			foreach ($this->get_items() as $item) {
3509 3509
 				$item->item_discount           = 0;
3510 3510
 				$item->recurring_item_discount = 0;
3511 3511
 			}
@@ -3518,12 +3518,12 @@  discard block
 block discarded – undo
3518 3518
      *
3519 3519
      * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
3520 3520
      */
3521
-    public function add_tax( $tax ) {
3522
-        if ( $this->is_taxable() ) {
3521
+    public function add_tax($tax) {
3522
+        if ($this->is_taxable()) {
3523 3523
 
3524
-            $taxes                 = $this->get_taxes();
3525
-			$taxes[ $tax['name'] ] = $tax;
3526
-			$this->set_prop( 'taxes', $tax );
3524
+            $taxes = $this->get_taxes();
3525
+			$taxes[$tax['name']] = $tax;
3526
+			$this->set_prop('taxes', $tax);
3527 3527
 
3528 3528
         }
3529 3529
     }
@@ -3533,15 +3533,15 @@  discard block
 block discarded – undo
3533 3533
 	 *
3534 3534
 	 * @since 1.0.19
3535 3535
 	 */
3536
-	public function get_tax( $tax = null ) {
3536
+	public function get_tax($tax = null) {
3537 3537
 
3538 3538
 		// Backwards compatility.
3539
-		if ( empty( $tax ) ) {
3539
+		if (empty($tax)) {
3540 3540
 			return $this->get_total_tax();
3541 3541
 		}
3542 3542
 
3543 3543
         $taxes = $this->get_taxes();
3544
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3544
+		return isset($taxes[$tax]) ? $taxes[$tax] : null;
3545 3545
     }
3546 3546
 
3547 3547
     /**
@@ -3549,11 +3549,11 @@  discard block
 block discarded – undo
3549 3549
 	 *
3550 3550
 	 * @since 1.0.19
3551 3551
 	 */
3552
-	public function remove_tax( $tax ) {
3552
+	public function remove_tax($tax) {
3553 3553
         $taxes = $this->get_taxes();
3554
-        if ( isset( $taxes[ $tax ] ) ) {
3555
-            unset( $taxes[ $tax ] );
3556
-            $this->set_prop( 'taxes', $taxes );
3554
+        if (isset($taxes[$tax])) {
3555
+            unset($taxes[$tax]);
3556
+            $this->set_prop('taxes', $taxes);
3557 3557
         }
3558 3558
     }
3559 3559
 
@@ -3564,22 +3564,22 @@  discard block
 block discarded – undo
3564 3564
 	 * @return float The recalculated subtotal
3565 3565
 	 */
3566 3566
 	public function recalculate_subtotal() {
3567
-        $items     = $this->get_items();
3567
+        $items = $this->get_items();
3568 3568
 		$subtotal  = 0;
3569 3569
 		$recurring = 0;
3570 3570
 
3571
-        foreach ( $items as $item ) {
3572
-			$subtotal  += $item->get_sub_total( 'edit' );
3573
-			$recurring += $item->get_recurring_sub_total( 'edit' );
3571
+        foreach ($items as $item) {
3572
+			$subtotal  += $item->get_sub_total('edit');
3573
+			$recurring += $item->get_recurring_sub_total('edit');
3574 3574
         }
3575 3575
 
3576
-		if ( wpinv_prices_include_tax() ) {
3577
-			$subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3578
-			$recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3576
+		if (wpinv_prices_include_tax()) {
3577
+			$subtotal  = max(0, $subtotal - $this->totals['tax']['initial']);
3578
+			$recurring = max(0, $recurring - $this->totals['tax']['recurring']);
3579 3579
 		}
3580 3580
 
3581 3581
 		$current = $this->is_renewal() ? $recurring : $subtotal;
3582
-		$this->set_subtotal( $current );
3582
+		$this->set_subtotal($current);
3583 3583
 
3584 3584
 		$this->totals['subtotal'] = array(
3585 3585
 			'initial'   => $subtotal,
@@ -3600,14 +3600,14 @@  discard block
 block discarded – undo
3600 3600
 		$discount  = 0;
3601 3601
 		$recurring = 0;
3602 3602
 
3603
-        foreach ( $discounts as $data ) {
3604
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3605
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3603
+        foreach ($discounts as $data) {
3604
+			$discount  += wpinv_sanitize_amount($data['initial_discount']);
3605
+			$recurring += wpinv_sanitize_amount($data['recurring_discount']);
3606 3606
 		}
3607 3607
 
3608 3608
 		$current = $this->is_renewal() ? $recurring : $discount;
3609 3609
 
3610
-		$this->set_total_discount( $current );
3610
+		$this->set_total_discount($current);
3611 3611
 
3612 3612
 		$this->totals['discount'] = array(
3613 3613
 			'initial'   => $discount,
@@ -3628,13 +3628,13 @@  discard block
 block discarded – undo
3628 3628
 
3629 3629
 		// Maybe disable taxes.
3630 3630
 		$vat_number = $this->get_vat_number();
3631
-		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3631
+		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($this->get_country()) && !empty($vat_number);
3632 3632
 
3633
-		if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3633
+		if (wpinv_is_base_country($this->get_country()) && 'vat_too' == wpinv_get_option('vat_same_country_rule', 'vat_too')) {
3634 3634
 			$skip_tax = false;
3635 3635
 		}
3636 3636
 
3637
-		if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax   ) {
3637
+		if (!wpinv_use_taxes() || $this->get_disable_taxes() || !wpinv_is_country_taxable($this->get_country()) || $skip_tax) {
3638 3638
 
3639 3639
 			$this->totals['tax'] = array(
3640 3640
 				'initial'   => 0,
@@ -3643,38 +3643,38 @@  discard block
 block discarded – undo
3643 3643
 
3644 3644
 			$this->tax_rate = 0;
3645 3645
 
3646
-			$this->set_taxes( array() );
3646
+			$this->set_taxes(array());
3647 3647
 			$current = 0;
3648 3648
 		} else {
3649 3649
 
3650 3650
 			$item_taxes = array();
3651 3651
 
3652
-			foreach ( $this->get_items() as $item ) {
3653
-				$rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3654
-				$rates    = getpaid_filter_item_tax_rates( $item, $rates );
3655
-				$taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3656
-				$r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3657
-				foreach ( $taxes as $name => $amount ) {
3658
-					$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3659
-					$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3660
-
3661
-					if ( ! isset( $item_taxes[ $name ] ) ) {
3662
-						$item_taxes[ $name ] = $tax;
3652
+			foreach ($this->get_items() as $item) {
3653
+				$rates    = getpaid_get_item_tax_rates($item, $this->get_country(), $this->get_state());
3654
+				$rates    = getpaid_filter_item_tax_rates($item, $rates);
3655
+				$taxes    = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, false), $rates);
3656
+				$r_taxes  = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, true), $rates);
3657
+				foreach ($taxes as $name => $amount) {
3658
+					$recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0;
3659
+					$tax       = getpaid_prepare_item_tax($item, $name, $amount, $recurring);
3660
+
3661
+					if (!isset($item_taxes[$name])) {
3662
+						$item_taxes[$name] = $tax;
3663 3663
 						continue;
3664 3664
 					}
3665 3665
 
3666
-					$item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3667
-					$item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3666
+					$item_taxes[$name]['initial_tax']   += $tax['initial_tax'];
3667
+					$item_taxes[$name]['recurring_tax'] += $tax['recurring_tax'];
3668 3668
 
3669 3669
 				}
3670 3670
 
3671 3671
 			}
3672 3672
 
3673
-			$item_taxes = array_replace( $this->get_taxes(), $item_taxes );
3674
-			$this->set_taxes( $item_taxes );
3673
+			$item_taxes = array_replace($this->get_taxes(), $item_taxes);
3674
+			$this->set_taxes($item_taxes);
3675 3675
 
3676
-			$initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3677
-			$recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3676
+			$initial_tax   = array_sum(wp_list_pluck($item_taxes, 'initial_tax'));
3677
+			$recurring_tax = array_sum(wp_list_pluck($item_taxes, 'recurring_tax'));
3678 3678
 
3679 3679
 			$current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3680 3680
 
@@ -3685,7 +3685,7 @@  discard block
 block discarded – undo
3685 3685
 
3686 3686
 		}
3687 3687
 
3688
-		$this->set_total_tax( $current );
3688
+		$this->set_total_tax($current);
3689 3689
 
3690 3690
 		return $current;
3691 3691
 
@@ -3702,20 +3702,20 @@  discard block
 block discarded – undo
3702 3702
 		$fee       = 0;
3703 3703
 		$recurring = 0;
3704 3704
 
3705
-        foreach ( $fees as $data ) {
3706
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3707
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3705
+        foreach ($fees as $data) {
3706
+			$fee       += wpinv_sanitize_amount($data['initial_fee']);
3707
+			$recurring += wpinv_sanitize_amount($data['recurring_fee']);
3708 3708
 		}
3709 3709
 
3710 3710
 		$current = $this->is_renewal() ? $recurring : $fee;
3711
-		$this->set_total_fees( $current );
3711
+		$this->set_total_fees($current);
3712 3712
 
3713 3713
 		$this->totals['fee'] = array(
3714 3714
 			'initial'   => $fee,
3715 3715
 			'recurring' => $recurring,
3716 3716
 		);
3717 3717
 
3718
-        $this->set_total_fees( $fee );
3718
+        $this->set_total_fees($fee);
3719 3719
         return $current;
3720 3720
     }
3721 3721
 
@@ -3730,7 +3730,7 @@  discard block
 block discarded – undo
3730 3730
         $this->recalculate_total_discount();
3731 3731
 		$this->recalculate_total_tax();
3732 3732
 		$this->recalculate_subtotal();
3733
-		$this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3733
+		$this->set_total($this->get_total_tax('edit') + $this->get_total_fees('edit') + $this->get_subtotal('edit') - $this->get_total_discount('edit'));
3734 3734
 		return $this->get_total();
3735 3735
 	}
3736 3736
 
@@ -3739,7 +3739,7 @@  discard block
 block discarded – undo
3739 3739
 	 */
3740 3740
     public function recalculate_totals() {
3741 3741
         $this->recalculate_total();
3742
-        $this->save( true );
3742
+        $this->save(true);
3743 3743
         return $this;
3744 3744
     }
3745 3745
 
@@ -3757,8 +3757,8 @@  discard block
 block discarded – undo
3757 3757
 	 * @return int|false The new note's ID on success, false on failure.
3758 3758
      *
3759 3759
      */
3760
-    public function add_system_note( $note ) {
3761
-		return $this->add_note( $note, false, false, true );
3760
+    public function add_system_note($note) {
3761
+		return $this->add_note($note, false, false, true);
3762 3762
 	}
3763 3763
 
3764 3764
     /**
@@ -3768,10 +3768,10 @@  discard block
 block discarded – undo
3768 3768
 	 * @return int|false The new note's ID on success, false on failure.
3769 3769
      *
3770 3770
      */
3771
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
3771
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
3772 3772
 
3773 3773
         // Bail if no note specified or this invoice is not yet saved.
3774
-        if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) {
3774
+        if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) {
3775 3775
             return false;
3776 3776
         }
3777 3777
 
@@ -3779,23 +3779,23 @@  discard block
 block discarded – undo
3779 3779
 		$author_email = '[email protected]';
3780 3780
 
3781 3781
 		// If this is an admin comment or it has been added by the user.
3782
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3783
-			$user         = get_user_by( 'id', get_current_user_id() );
3782
+		if (is_user_logged_in() && (!$system || $added_by_user)) {
3783
+			$user = get_user_by('id', get_current_user_id());
3784 3784
             $author       = $user->display_name;
3785 3785
             $author_email = $user->user_email;
3786 3786
 		}
3787 3787
 
3788
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3788
+		return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type);
3789 3789
 
3790 3790
 	}
3791 3791
 
3792 3792
 	/**
3793 3793
      * Generates a unique key for the invoice.
3794 3794
      */
3795
-    public function generate_key( $string = '' ) {
3796
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
3795
+    public function generate_key($string = '') {
3796
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
3797 3797
         return strtolower(
3798
-            $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) )
3798
+            $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))
3799 3799
         );
3800 3800
     }
3801 3801
 
@@ -3805,11 +3805,11 @@  discard block
 block discarded – undo
3805 3805
     public function generate_number() {
3806 3806
         $number = $this->get_id();
3807 3807
 
3808
-        if ( wpinv_sequential_number_active( $this->get_post_type() ) ) {
3809
-            $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3808
+        if (wpinv_sequential_number_active($this->get_post_type())) {
3809
+            $number = wpinv_get_next_invoice_number($this->get_post_type());
3810 3810
         }
3811 3811
 
3812
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3812
+		return wpinv_format_invoice_number($number, $this->get_post_type());
3813 3813
 
3814 3814
 	}
3815 3815
 
@@ -3822,55 +3822,55 @@  discard block
 block discarded – undo
3822 3822
 		// Reset status transition variable.
3823 3823
 		$this->status_transition = false;
3824 3824
 
3825
-		if ( $status_transition ) {
3825
+		if ($status_transition) {
3826 3826
 			try {
3827 3827
 
3828 3828
 				// Fire a hook for the status change.
3829
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3829
+				do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition);
3830 3830
 
3831 3831
 				// @deprecated this is deprecated and will be removed in the future.
3832
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3832
+				do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3833 3833
 
3834
-				if ( ! empty( $status_transition['from'] ) ) {
3834
+				if (!empty($status_transition['from'])) {
3835 3835
 
3836 3836
 					/* translators: 1: old invoice status 2: new invoice status */
3837
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3837
+					$transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from'], $this), wpinv_status_nicename($status_transition['to'], $this));
3838 3838
 
3839 3839
 					// Fire another hook.
3840
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3841
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3840
+					do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this);
3841
+					do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']);
3842 3842
 
3843 3843
 					// @deprecated this is deprecated and will be removed in the future.
3844
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3844
+					do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3845 3845
 
3846 3846
 					// Note the transition occurred.
3847
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3847
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $status_transition['manual']);
3848 3848
 
3849 3849
 					// Work out if this was for a payment, and trigger a payment_status hook instead.
3850 3850
 					if (
3851
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3852
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3851
+						in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3852
+						&& in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3853 3853
 					) {
3854
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3854
+						do_action('getpaid_invoice_payment_status_changed', $this, $status_transition);
3855 3855
 					}
3856 3856
 
3857 3857
 					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3858 3858
 					if (
3859
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3860
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3859
+						in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3860
+						&& in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3861 3861
 					) {
3862
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3862
+						do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition);
3863 3863
 					}
3864 3864
 				} else {
3865 3865
 					/* translators: %s: new invoice status */
3866
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3866
+					$transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'], $this));
3867 3867
 
3868 3868
 					// Note the transition occurred.
3869
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3869
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3870 3870
 
3871 3871
 				}
3872
-			} catch ( Exception $e ) {
3873
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3872
+			} catch (Exception $e) {
3873
+				$this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage());
3874 3874
 			}
3875 3875
 		}
3876 3876
 	}
@@ -3878,13 +3878,13 @@  discard block
 block discarded – undo
3878 3878
 	/**
3879 3879
 	 * Updates an invoice status.
3880 3880
 	 */
3881
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3881
+	public function update_status($new_status = false, $note = '', $manual = false) {
3882 3882
 
3883 3883
 		// Fires before updating a status.
3884
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3884
+		do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit'));
3885 3885
 
3886 3886
 		// Update the status.
3887
-		$this->set_status( $new_status, $note, $manual );
3887
+		$this->set_status($new_status, $note, $manual);
3888 3888
 
3889 3889
 		// Save the order.
3890 3890
 		return $this->save();
@@ -3895,18 +3895,18 @@  discard block
 block discarded – undo
3895 3895
 	 * @deprecated
3896 3896
 	 */
3897 3897
 	public function refresh_item_ids() {
3898
-        $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) );
3899
-        update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3898
+        $item_ids = implode(',', array_unique(wp_list_pluck($this->get_cart_details(), 'item_id')));
3899
+        update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids);
3900 3900
 	}
3901 3901
 
3902 3902
 	/**
3903 3903
 	 * @deprecated
3904 3904
 	 */
3905
-	public function update_items( $temp = false ) {
3905
+	public function update_items($temp = false) {
3906 3906
 
3907
-		$this->set_items( $this->get_items() );
3907
+		$this->set_items($this->get_items());
3908 3908
 
3909
-		if ( ! $temp ) {
3909
+		if (!$temp) {
3910 3910
 			$this->save();
3911 3911
 		}
3912 3912
 
@@ -3920,11 +3920,11 @@  discard block
 block discarded – undo
3920 3920
 
3921 3921
         $discount_code = $this->get_discount_code();
3922 3922
 
3923
-        if ( empty( $discount_code ) ) {
3923
+        if (empty($discount_code)) {
3924 3924
             return false;
3925 3925
         }
3926 3926
 
3927
-        $discount = wpinv_get_discount_obj( $discount_code );
3927
+        $discount = wpinv_get_discount_obj($discount_code);
3928 3928
 
3929 3929
         // Ensure it is active.
3930 3930
         return $discount->exists();
@@ -3935,7 +3935,7 @@  discard block
 block discarded – undo
3935 3935
 	 * Refunds an invoice.
3936 3936
 	 */
3937 3937
     public function refund() {
3938
-		$this->set_status( 'wpi-refunded' );
3938
+		$this->set_status('wpi-refunded');
3939 3939
         $this->save();
3940 3940
 	}
3941 3941
 
@@ -3944,53 +3944,53 @@  discard block
 block discarded – undo
3944 3944
 	 * 
3945 3945
 	 * @param string $transaction_id
3946 3946
 	 */
3947
-    public function mark_paid( $transaction_id = null, $note = '' ) {
3947
+    public function mark_paid($transaction_id = null, $note = '') {
3948 3948
 
3949 3949
 		// Set the transaction id.
3950
-		if ( empty( $transaction_id ) ) {
3950
+		if (empty($transaction_id)) {
3951 3951
 			$transaction_id = $this->generate_key('trans_');
3952 3952
 		}
3953 3953
 
3954
-		if ( ! $this->get_transaction_id() ) {
3955
-			$this->set_transaction_id( $transaction_id );
3954
+		if (!$this->get_transaction_id()) {
3955
+			$this->set_transaction_id($transaction_id);
3956 3956
 		}
3957 3957
 
3958
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3958
+		if ($this->is_paid() && 'wpi-processing' != $this->get_status()) {
3959 3959
 			return $this->save();
3960 3960
 		}
3961 3961
 
3962 3962
 		// Set the completed date.
3963
-		$this->set_date_completed( current_time( 'mysql' ) );
3963
+		$this->set_date_completed(current_time('mysql'));
3964 3964
 
3965 3965
 		// Set the new status.
3966
-		$gateway = sanitize_text_field( $this->get_gateway_title() );
3967
-		if ( $this->is_renewal() || ! $this->is_parent() ) {
3966
+		$gateway = sanitize_text_field($this->get_gateway_title());
3967
+		if ($this->is_renewal() || !$this->is_parent()) {
3968 3968
 
3969
-			$_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
3970
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3969
+			$_note = wp_sprintf(__('Renewed via %s', 'invoicing'), $gateway);
3970
+			$_note = $_note . empty($note) ? '' : " ($note)";
3971 3971
 
3972
-			if ( 'none' == $this->get_gateway() ) {
3972
+			if ('none' == $this->get_gateway()) {
3973 3973
 				$_note = $note;
3974 3974
 			}
3975 3975
 
3976
-			$this->set_status( 'wpi-renewal', $_note );
3976
+			$this->set_status('wpi-renewal', $_note);
3977 3977
 
3978 3978
 		} else {
3979 3979
 
3980
-			$_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
3981
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3980
+			$_note = wp_sprintf(__('Paid via %s', 'invoicing'), $gateway);
3981
+			$_note = $_note . empty($note) ? '' : " ($note)";
3982 3982
 
3983
-			if ( 'none' == $this->get_gateway() ) {
3983
+			if ('none' == $this->get_gateway()) {
3984 3984
 				$_note = $note;
3985 3985
 			}
3986 3986
 
3987
-			$this->set_status( 'publish', $_note );
3987
+			$this->set_status('publish', $_note);
3988 3988
 
3989 3989
 		}
3990 3990
 
3991 3991
 		// Set checkout mode.
3992
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3993
-		$this->set_mode( $mode );
3992
+		$mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live';
3993
+		$this->set_mode($mode);
3994 3994
 
3995 3995
 		// Save the invoice.
3996 3996
         $this->save();
@@ -4015,9 +4015,9 @@  discard block
 block discarded – undo
4015 4015
      * Clears the subscription's cache.
4016 4016
      */
4017 4017
     public function clear_cache() {
4018
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
4019
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
4020
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
4018
+		wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids');
4019
+		wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids');
4020
+		wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids');
4021 4021
 	}
4022 4022
 
4023 4023
 }
Please login to merge, or discard this patch.
includes/admin/class-getpaid-post-types-admin.php 2 patches
Indentation   +730 added lines, -730 removed lines patch added patch discarded remove patch
@@ -13,732 +13,732 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Post_Types_Admin {
14 14
 
15 15
     /**
16
-	 * Hook in methods.
17
-	 */
18
-	public static function init() {
19
-
20
-		// Init metaboxes.
21
-		GetPaid_Metaboxes::init();
22
-
23
-		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
-
26
-		// Filter post actions.
27
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
29
-
30
-		// Invoice table columns.
31
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
-		add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
-		add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
35
-
36
-		// Items table columns.
37
-		add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
-		add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
-		add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
-		add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
-		add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
-		add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
43
-
44
-		// Payment forms columns.
45
-		add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
-		add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
48
-
49
-		// Discount table columns.
50
-		add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
-		add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
52
-
53
-		// Deleting posts.
54
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
56
-
57
-		add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
58
-	}
59
-
60
-	/**
61
-	 * Post updated messages.
62
-	 */
63
-	public static function post_updated_messages( $messages ) {
64
-		global $post;
65
-
66
-		$messages['wpi_discount'] = array(
67
-			0   => '',
68
-			1   => __( 'Discount updated.', 'invoicing' ),
69
-			2   => __( 'Custom field updated.', 'invoicing' ),
70
-			3   => __( 'Custom field deleted.', 'invoicing' ),
71
-			4   => __( 'Discount updated.', 'invoicing' ),
72
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
-			6   => __( 'Discount updated.', 'invoicing' ),
74
-			7   => __( 'Discount saved.', 'invoicing' ),
75
-			8   => __( 'Discount submitted.', 'invoicing' ),
76
-			9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
-			10  => __( 'Discount draft updated.', 'invoicing' ),
78
-		);
79
-
80
-		$messages['wpi_payment_form'] = array(
81
-			0   => '',
82
-			1   => __( 'Payment Form updated.', 'invoicing' ),
83
-			2   => __( 'Custom field updated.', 'invoicing' ),
84
-			3   => __( 'Custom field deleted.', 'invoicing' ),
85
-			4   => __( 'Payment Form updated.', 'invoicing' ),
86
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
-			6   => __( 'Payment Form updated.', 'invoicing' ),
88
-			7   => __( 'Payment Form saved.', 'invoicing' ),
89
-			8   => __( 'Payment Form submitted.', 'invoicing' ),
90
-			9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
-			10  => __( 'Payment Form draft updated.', 'invoicing' ),
92
-		);
93
-
94
-		return $messages;
95
-
96
-	}
97
-
98
-	/**
99
-	 * Post row actions.
100
-	 */
101
-	public static function post_row_actions( $actions, $post ) {
102
-
103
-		$post = get_post( $post );
104
-
105
-		// We do not want to edit the default payment form.
106
-		if ( 'wpi_payment_form' == $post->post_type ) {
107
-
108
-			if ( $post->ID == wpinv_get_default_payment_form() ) {
109
-				unset( $actions['trash'] );
110
-				unset( $actions['inline hide-if-no-js'] );
111
-			}
112
-
113
-			$actions['duplicate'] =  sprintf(
114
-				'<a href="%1$s">%2$s</a>',
115
-				esc_url(
116
-					wp_nonce_url(
117
-						add_query_arg(
118
-							array(
119
-								'getpaid-admin-action' => 'duplicate_form',
120
-								'form_id'              => $post->ID
121
-							)
122
-						),
123
-						'getpaid-nonce',
124
-						'getpaid-nonce'
125
-					)
126
-				),
127
-				esc_html( __( 'Duplicate', 'invoicing' ) )
128
-			);
129
-
130
-		}
131
-
132
-		// Link to item payment form.
133
-		if ( 'wpi_item' == $post->post_type ) {
134
-
135
-			if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) {
136
-
137
-				$actions['buy'] =  sprintf(
138
-					'<a href="%1$s">%2$s</a>',
139
-					esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
140
-					esc_html( __( 'Buy', 'invoicing' ) )
141
-				);
142
-
143
-			}
144
-
145
-		}
146
-
147
-		return $actions;
148
-	}
149
-
150
-	/**
16
+     * Hook in methods.
17
+     */
18
+    public static function init() {
19
+
20
+        // Init metaboxes.
21
+        GetPaid_Metaboxes::init();
22
+
23
+        // Filter the post updated messages.
24
+        add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
+
26
+        // Filter post actions.
27
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
29
+
30
+        // Invoice table columns.
31
+        add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
+        add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
+        add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
+        add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
35
+
36
+        // Items table columns.
37
+        add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
+        add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
+        add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
+        add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
+        add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
+        add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
43
+
44
+        // Payment forms columns.
45
+        add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
+        add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
48
+
49
+        // Discount table columns.
50
+        add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
+        add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
52
+
53
+        // Deleting posts.
54
+        add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
56
+
57
+        add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
58
+    }
59
+
60
+    /**
61
+     * Post updated messages.
62
+     */
63
+    public static function post_updated_messages( $messages ) {
64
+        global $post;
65
+
66
+        $messages['wpi_discount'] = array(
67
+            0   => '',
68
+            1   => __( 'Discount updated.', 'invoicing' ),
69
+            2   => __( 'Custom field updated.', 'invoicing' ),
70
+            3   => __( 'Custom field deleted.', 'invoicing' ),
71
+            4   => __( 'Discount updated.', 'invoicing' ),
72
+            5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
+            6   => __( 'Discount updated.', 'invoicing' ),
74
+            7   => __( 'Discount saved.', 'invoicing' ),
75
+            8   => __( 'Discount submitted.', 'invoicing' ),
76
+            9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
+            10  => __( 'Discount draft updated.', 'invoicing' ),
78
+        );
79
+
80
+        $messages['wpi_payment_form'] = array(
81
+            0   => '',
82
+            1   => __( 'Payment Form updated.', 'invoicing' ),
83
+            2   => __( 'Custom field updated.', 'invoicing' ),
84
+            3   => __( 'Custom field deleted.', 'invoicing' ),
85
+            4   => __( 'Payment Form updated.', 'invoicing' ),
86
+            5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
+            6   => __( 'Payment Form updated.', 'invoicing' ),
88
+            7   => __( 'Payment Form saved.', 'invoicing' ),
89
+            8   => __( 'Payment Form submitted.', 'invoicing' ),
90
+            9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
+            10  => __( 'Payment Form draft updated.', 'invoicing' ),
92
+        );
93
+
94
+        return $messages;
95
+
96
+    }
97
+
98
+    /**
99
+     * Post row actions.
100
+     */
101
+    public static function post_row_actions( $actions, $post ) {
102
+
103
+        $post = get_post( $post );
104
+
105
+        // We do not want to edit the default payment form.
106
+        if ( 'wpi_payment_form' == $post->post_type ) {
107
+
108
+            if ( $post->ID == wpinv_get_default_payment_form() ) {
109
+                unset( $actions['trash'] );
110
+                unset( $actions['inline hide-if-no-js'] );
111
+            }
112
+
113
+            $actions['duplicate'] =  sprintf(
114
+                '<a href="%1$s">%2$s</a>',
115
+                esc_url(
116
+                    wp_nonce_url(
117
+                        add_query_arg(
118
+                            array(
119
+                                'getpaid-admin-action' => 'duplicate_form',
120
+                                'form_id'              => $post->ID
121
+                            )
122
+                        ),
123
+                        'getpaid-nonce',
124
+                        'getpaid-nonce'
125
+                    )
126
+                ),
127
+                esc_html( __( 'Duplicate', 'invoicing' ) )
128
+            );
129
+
130
+        }
131
+
132
+        // Link to item payment form.
133
+        if ( 'wpi_item' == $post->post_type ) {
134
+
135
+            if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) {
136
+
137
+                $actions['buy'] =  sprintf(
138
+                    '<a href="%1$s">%2$s</a>',
139
+                    esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
140
+                    esc_html( __( 'Buy', 'invoicing' ) )
141
+                );
142
+
143
+            }
144
+
145
+        }
146
+
147
+        return $actions;
148
+    }
149
+
150
+    /**
151 151
      * Remove bulk edit option from admin side quote listing
152 152
      *
153 153
      * @since    1.0.0
154 154
      * @param array $actions post actions
155
-	 * @param WP_Post $post
155
+     * @param WP_Post $post
156 156
      * @return array $actions actions without edit option
157 157
      */
158 158
     public static function filter_invoice_row_actions( $actions, $post ) {
159 159
 
160 160
         if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
161 161
 
162
-			$actions = array();
163
-			$invoice = new WPInv_Invoice( $post );
164
-
165
-			$actions['edit'] =  sprintf(
166
-				'<a href="%1$s">%2$s</a>',
167
-				esc_url( get_edit_post_link( $invoice->get_id() ) ),
168
-				esc_html( __( 'Edit', 'invoicing' ) )
169
-			);
170
-
171
-			if ( ! $invoice->is_draft() ) {
172
-
173
-				$actions['view'] =  sprintf(
174
-					'<a href="%1$s">%2$s</a>',
175
-					esc_url( $invoice->get_view_url() ),
176
-					sprintf(
177
-						esc_html( __( 'View %s', 'invoicing' ) ),
178
-						getpaid_get_post_type_label( $invoice->get_post_type(), false )
179
-					)
180
-				);
181
-
182
-				$actions['send'] =  sprintf(
183
-					'<a href="%1$s">%2$s</a>',
184
-					esc_url(
185
-						wp_nonce_url(
186
-							add_query_arg(
187
-								array(
188
-									'getpaid-admin-action' => 'send_invoice',
189
-									'invoice_id'           => $invoice->get_id()
190
-								)
191
-							),
192
-							'getpaid-nonce',
193
-							'getpaid-nonce'
194
-						)
195
-					),
196
-					esc_html( __( 'Send to Customer', 'invoicing' ) )
197
-				);
198
-
199
-			}
200
-
201
-			$actions['duplicate'] =  sprintf(
202
-				'<a href="%1$s">%2$s</a>',
203
-				esc_url(
204
-					wp_nonce_url(
205
-						add_query_arg(
206
-							array(
207
-								'getpaid-admin-action' => 'duplicate_invoice',
208
-								'invoice_id'           => $post->ID
209
-							)
210
-						),
211
-						'getpaid-nonce',
212
-						'getpaid-nonce'
213
-					)
214
-				),
215
-				esc_html( __( 'Duplicate', 'invoicing' ) )
216
-			);
162
+            $actions = array();
163
+            $invoice = new WPInv_Invoice( $post );
164
+
165
+            $actions['edit'] =  sprintf(
166
+                '<a href="%1$s">%2$s</a>',
167
+                esc_url( get_edit_post_link( $invoice->get_id() ) ),
168
+                esc_html( __( 'Edit', 'invoicing' ) )
169
+            );
170
+
171
+            if ( ! $invoice->is_draft() ) {
172
+
173
+                $actions['view'] =  sprintf(
174
+                    '<a href="%1$s">%2$s</a>',
175
+                    esc_url( $invoice->get_view_url() ),
176
+                    sprintf(
177
+                        esc_html( __( 'View %s', 'invoicing' ) ),
178
+                        getpaid_get_post_type_label( $invoice->get_post_type(), false )
179
+                    )
180
+                );
181
+
182
+                $actions['send'] =  sprintf(
183
+                    '<a href="%1$s">%2$s</a>',
184
+                    esc_url(
185
+                        wp_nonce_url(
186
+                            add_query_arg(
187
+                                array(
188
+                                    'getpaid-admin-action' => 'send_invoice',
189
+                                    'invoice_id'           => $invoice->get_id()
190
+                                )
191
+                            ),
192
+                            'getpaid-nonce',
193
+                            'getpaid-nonce'
194
+                        )
195
+                    ),
196
+                    esc_html( __( 'Send to Customer', 'invoicing' ) )
197
+                );
198
+
199
+            }
200
+
201
+            $actions['duplicate'] =  sprintf(
202
+                '<a href="%1$s">%2$s</a>',
203
+                esc_url(
204
+                    wp_nonce_url(
205
+                        add_query_arg(
206
+                            array(
207
+                                'getpaid-admin-action' => 'duplicate_invoice',
208
+                                'invoice_id'           => $post->ID
209
+                            )
210
+                        ),
211
+                        'getpaid-nonce',
212
+                        'getpaid-nonce'
213
+                    )
214
+                ),
215
+                esc_html( __( 'Duplicate', 'invoicing' ) )
216
+            );
217 217
 
218 218
         }
219 219
 
220 220
         return $actions;
221
-	}
222
-
223
-	/**
224
-	 * Returns an array of invoice table columns.
225
-	 */
226
-	public static function invoice_columns( $columns ) {
227
-
228
-		$columns = array(
229
-			'cb'                => $columns['cb'],
230
-			'number'            => __( 'Invoice', 'invoicing' ),
231
-			'customer'          => __( 'Customer', 'invoicing' ),
232
-			'invoice_date'      => __( 'Created', 'invoicing' ),
233
-			'payment_date'      => __( 'Completed', 'invoicing' ),
234
-			'amount'            => __( 'Amount', 'invoicing' ),
235
-			'recurring'         => __( 'Recurring', 'invoicing' ),
236
-			'status'            => __( 'Status', 'invoicing' ),
237
-		);
238
-
239
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
240
-	}
241
-
242
-	/**
243
-	 * Displays invoice table columns.
244
-	 */
245
-	public static function display_invoice_columns( $column_name, $post_id ) {
246
-
247
-		$invoice = new WPInv_Invoice( $post_id );
248
-
249
-		switch ( $column_name ) {
250
-
251
-			case 'invoice_date' :
252
-				$date_time = esc_attr( $invoice->get_created_date() );
253
-				$date      = getpaid_format_date_value( $date_time, "&mdash;", true );
254
-				echo "<span title='$date_time'>$date</span>";
255
-				break;
256
-
257
-			case 'payment_date' :
258
-
259
-				if ( $invoice->is_paid() ) {
260
-					$date_time = esc_attr( $invoice->get_completed_date() );
261
-					$date      = getpaid_format_date_value( $date_time, "&mdash;", true );
262
-					echo "<span title='$date_time'>$date</span>";
263
-				} else {
264
-					echo "&mdash;";
265
-				}
221
+    }
222
+
223
+    /**
224
+     * Returns an array of invoice table columns.
225
+     */
226
+    public static function invoice_columns( $columns ) {
227
+
228
+        $columns = array(
229
+            'cb'                => $columns['cb'],
230
+            'number'            => __( 'Invoice', 'invoicing' ),
231
+            'customer'          => __( 'Customer', 'invoicing' ),
232
+            'invoice_date'      => __( 'Created', 'invoicing' ),
233
+            'payment_date'      => __( 'Completed', 'invoicing' ),
234
+            'amount'            => __( 'Amount', 'invoicing' ),
235
+            'recurring'         => __( 'Recurring', 'invoicing' ),
236
+            'status'            => __( 'Status', 'invoicing' ),
237
+        );
238
+
239
+        return apply_filters( 'wpi_invoice_table_columns', $columns );
240
+    }
241
+
242
+    /**
243
+     * Displays invoice table columns.
244
+     */
245
+    public static function display_invoice_columns( $column_name, $post_id ) {
246
+
247
+        $invoice = new WPInv_Invoice( $post_id );
248
+
249
+        switch ( $column_name ) {
250
+
251
+            case 'invoice_date' :
252
+                $date_time = esc_attr( $invoice->get_created_date() );
253
+                $date      = getpaid_format_date_value( $date_time, "&mdash;", true );
254
+                echo "<span title='$date_time'>$date</span>";
255
+                break;
256
+
257
+            case 'payment_date' :
258
+
259
+                if ( $invoice->is_paid() ) {
260
+                    $date_time = esc_attr( $invoice->get_completed_date() );
261
+                    $date      = getpaid_format_date_value( $date_time, "&mdash;", true );
262
+                    echo "<span title='$date_time'>$date</span>";
263
+                } else {
264
+                    echo "&mdash;";
265
+                }
266 266
 				
267
-				break;
267
+                break;
268 268
 
269
-			case 'amount' :
269
+            case 'amount' :
270 270
 
271
-				$amount = $invoice->get_total();
272
-				$formated_amount = wpinv_price( $amount, $invoice->get_currency() );
271
+                $amount = $invoice->get_total();
272
+                $formated_amount = wpinv_price( $amount, $invoice->get_currency() );
273 273
 
274
-				if ( $invoice->is_refunded() ) {
275
-					$refunded_amount = wpinv_price( 0, $invoice->get_currency() );
276
-					echo "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>";
277
-				} else {
274
+                if ( $invoice->is_refunded() ) {
275
+                    $refunded_amount = wpinv_price( 0, $invoice->get_currency() );
276
+                    echo "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>";
277
+                } else {
278 278
 
279
-					$discount = $invoice->get_total_discount();
279
+                    $discount = $invoice->get_total_discount();
280 280
 
281
-					if ( ! empty( $discount ) ) {
282
-						$new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
283
-						echo "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>";
284
-					} else {
285
-						echo $formated_amount;
286
-					}
281
+                    if ( ! empty( $discount ) ) {
282
+                        $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
283
+                        echo "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>";
284
+                    } else {
285
+                        echo $formated_amount;
286
+                    }
287 287
 
288
-				}
288
+                }
289 289
 
290
-				break;
290
+                break;
291 291
 
292
-			case 'status' :
293
-				$status       = esc_html( $invoice->get_status() );
294
-				$status_label = esc_html( $invoice->get_status_nicename() );
292
+            case 'status' :
293
+                $status       = esc_html( $invoice->get_status() );
294
+                $status_label = esc_html( $invoice->get_status_nicename() );
295 295
 
296
-				// If it is paid, show the gateway title.
297
-				if ( $invoice->is_paid() ) {
298
-					$gateway = esc_html( $invoice->get_gateway_title() );
299
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
296
+                // If it is paid, show the gateway title.
297
+                if ( $invoice->is_paid() ) {
298
+                    $gateway = esc_html( $invoice->get_gateway_title() );
299
+                    $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
300 300
 
301
-					echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
302
-				} else {
303
-					echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>";
304
-				}
301
+                    echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
302
+                } else {
303
+                    echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>";
304
+                }
305 305
 
306
-				// If it is not paid, display the overdue and view status.
307
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
306
+                // If it is not paid, display the overdue and view status.
307
+                if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
308 308
 
309
-					// Invoice view status.
310
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
311
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
312
-					} else {
313
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
314
-					}
309
+                    // Invoice view status.
310
+                    if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
311
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
312
+                    } else {
313
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
314
+                    }
315 315
 
316
-					// Display the overview status.
317
-					if ( wpinv_get_option( 'overdue_active' ) ) {
318
-						$due_date = $invoice->get_due_date();
319
-						$fomatted = getpaid_format_date( $due_date );
316
+                    // Display the overview status.
317
+                    if ( wpinv_get_option( 'overdue_active' ) ) {
318
+                        $due_date = $invoice->get_due_date();
319
+                        $fomatted = getpaid_format_date( $due_date );
320 320
 
321
-						if ( ! empty( $fomatted ) ) {
322
-							$date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
323
-							echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";
324
-						}
325
-					}
321
+                        if ( ! empty( $fomatted ) ) {
322
+                            $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
323
+                            echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";
324
+                        }
325
+                    }
326 326
 
327
-				}
327
+                }
328 328
 
329
-				break;
329
+                break;
330 330
 
331
-			case 'recurring':
331
+            case 'recurring':
332 332
 
333
-				if ( $invoice->is_recurring() ) {
334
-					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
335
-				} else {
336
-					echo '<i class="fa fa-times" style="color:#616161;"></i>';
337
-				}
338
-				break;
333
+                if ( $invoice->is_recurring() ) {
334
+                    echo '<i class="fa fa-check" style="color:#43850a;"></i>';
335
+                } else {
336
+                    echo '<i class="fa fa-times" style="color:#616161;"></i>';
337
+                }
338
+                break;
339 339
 
340
-			case 'number' :
340
+            case 'number' :
341 341
 
342
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
343
-				$invoice_number  = esc_html( $invoice->get_number() );
344
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
342
+                $edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
343
+                $invoice_number  = esc_html( $invoice->get_number() );
344
+                $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
345 345
 
346
-				echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
346
+                echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
347 347
 
348
-				break;
348
+                break;
349 349
 
350
-			case 'customer' :
350
+            case 'customer' :
351 351
 	
352
-				$customer_name = $invoice->get_user_full_name();
352
+                $customer_name = $invoice->get_user_full_name();
353 353
 	
354
-				if ( empty( $customer_name ) ) {
355
-					$customer_name = $invoice->get_email();
356
-				}
354
+                if ( empty( $customer_name ) ) {
355
+                    $customer_name = $invoice->get_email();
356
+                }
357 357
 	
358
-				if ( ! empty( $customer_name ) ) {
359
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
360
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
361
-					echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
362
-				} else {
363
-					echo '<div>&mdash;</div>';
364
-				}
358
+                if ( ! empty( $customer_name ) ) {
359
+                    $customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
360
+                    $view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
361
+                    echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
362
+                } else {
363
+                    echo '<div>&mdash;</div>';
364
+                }
365 365
 
366
-				break;
366
+                break;
367 367
 
368
-		}
368
+        }
369 369
 
370
-	}
370
+    }
371 371
 
372
-	/**
373
-	 * Displays invoice bulk actions.
374
-	 */
375
-	public static function invoice_bulk_actions( $actions ) {
376
-		$actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
377
-		return $actions;
378
-	}
372
+    /**
373
+     * Displays invoice bulk actions.
374
+     */
375
+    public static function invoice_bulk_actions( $actions ) {
376
+        $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
377
+        return $actions;
378
+    }
379 379
 
380
-	/**
381
-	 * Processes invoice bulk actions.
382
-	 */
383
-	public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
380
+    /**
381
+     * Processes invoice bulk actions.
382
+     */
383
+    public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
384 384
 
385
-		if ( $action == 'resend-invoice' ) {
386
-			foreach ( $post_ids as $post_id ) {
387
-				getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
388
-			}
389
-		}
385
+        if ( $action == 'resend-invoice' ) {
386
+            foreach ( $post_ids as $post_id ) {
387
+                getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
388
+            }
389
+        }
390 390
 
391
-		return $redirect_url;
391
+        return $redirect_url;
392 392
 
393
-	}
393
+    }
394 394
 
395
-	/**
396
-	 * Returns an array of payment forms table columns.
397
-	 */
398
-	public static function payment_form_columns( $columns ) {
395
+    /**
396
+     * Returns an array of payment forms table columns.
397
+     */
398
+    public static function payment_form_columns( $columns ) {
399 399
 
400
-		$columns = array(
401
-			'cb'                => $columns['cb'],
402
-			'title'             => __( 'Name', 'invoicing' ),
403
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
404
-			'earnings'          => __( 'Revenue', 'invoicing' ),
405
-			'refunds'           => __( 'Refunded', 'invoicing' ),
406
-			'items'             => __( 'Items', 'invoicing' ),
407
-			'date'              => __( 'Date', 'invoicing' ),
408
-		);
400
+        $columns = array(
401
+            'cb'                => $columns['cb'],
402
+            'title'             => __( 'Name', 'invoicing' ),
403
+            'shortcode'         => __( 'Shortcode', 'invoicing' ),
404
+            'earnings'          => __( 'Revenue', 'invoicing' ),
405
+            'refunds'           => __( 'Refunded', 'invoicing' ),
406
+            'items'             => __( 'Items', 'invoicing' ),
407
+            'date'              => __( 'Date', 'invoicing' ),
408
+        );
409 409
 
410
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
410
+        return apply_filters( 'wpi_payment_form_table_columns', $columns );
411 411
 
412
-	}
412
+    }
413 413
 
414
-	/**
415
-	 * Displays payment form table columns.
416
-	 */
417
-	public static function display_payment_form_columns( $column_name, $post_id ) {
414
+    /**
415
+     * Displays payment form table columns.
416
+     */
417
+    public static function display_payment_form_columns( $column_name, $post_id ) {
418 418
 
419
-		// Retrieve the payment form.
420
-		$form = new GetPaid_Payment_Form( $post_id );
419
+        // Retrieve the payment form.
420
+        $form = new GetPaid_Payment_Form( $post_id );
421 421
 
422
-		switch ( $column_name ) {
422
+        switch ( $column_name ) {
423 423
 
424
-			case 'earnings' :
425
-				echo wpinv_price( $form->get_earned() );
426
-				break;
424
+            case 'earnings' :
425
+                echo wpinv_price( $form->get_earned() );
426
+                break;
427 427
 
428
-			case 'refunds' :
429
-				echo wpinv_price( $form->get_refunded() );
430
-				break;
428
+            case 'refunds' :
429
+                echo wpinv_price( $form->get_refunded() );
430
+                break;
431 431
 
432
-			case 'refunds' :
433
-				echo wpinv_price( $form->get_refunded() );
434
-				break;
432
+            case 'refunds' :
433
+                echo wpinv_price( $form->get_refunded() );
434
+                break;
435 435
 
436
-			case 'shortcode' :
436
+            case 'shortcode' :
437 437
 
438
-				if ( $form->is_default() ) {
439
-					echo '&mdash;';
440
-				} else {
441
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
442
-				}
438
+                if ( $form->is_default() ) {
439
+                    echo '&mdash;';
440
+                } else {
441
+                    echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
442
+                }
443 443
 
444
-				break;
444
+                break;
445 445
 
446
-			case 'items' :
446
+            case 'items' :
447 447
 
448
-				$items = $form->get_items();
448
+                $items = $form->get_items();
449 449
 
450
-				if ( $form->is_default() || empty( $items ) ) {
451
-					echo '&mdash;';
452
-					return;
453
-				}
450
+                if ( $form->is_default() || empty( $items ) ) {
451
+                    echo '&mdash;';
452
+                    return;
453
+                }
454 454
 
455
-				$_items = array();
455
+                $_items = array();
456 456
 
457
-				foreach ( $items as $item ) {
458
-					$url = $item->get_edit_url();
457
+                foreach ( $items as $item ) {
458
+                    $url = $item->get_edit_url();
459 459
 
460
-					if ( empty( $url ) ) {
461
-						$_items[] = esc_html( $item->get_name() );
462
-					} else {
463
-						$_items[] = sprintf(
464
-							'<a href="%s">%s</a>',
465
-							esc_url( $url ),
466
-							esc_html( $item->get_name() )
467
-						);
468
-					}
460
+                    if ( empty( $url ) ) {
461
+                        $_items[] = esc_html( $item->get_name() );
462
+                    } else {
463
+                        $_items[] = sprintf(
464
+                            '<a href="%s">%s</a>',
465
+                            esc_url( $url ),
466
+                            esc_html( $item->get_name() )
467
+                        );
468
+                    }
469 469
 
470
-				}
470
+                }
471 471
 
472
-				echo implode( '<br>', $_items );
472
+                echo implode( '<br>', $_items );
473 473
 
474
-				break;
474
+                break;
475 475
 
476
-		}
476
+        }
477 477
 
478
-	}
478
+    }
479 479
 
480
-	/**
481
-	 * Filters post states.
482
-	 */
483
-	public static function filter_payment_form_state( $post_states, $post ) {
480
+    /**
481
+     * Filters post states.
482
+     */
483
+    public static function filter_payment_form_state( $post_states, $post ) {
484 484
 
485
-		if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
486
-			$post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );
487
-		}
485
+        if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
486
+            $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );
487
+        }
488 488
 	
489
-		return $post_states;
490
-
491
-	}
492
-
493
-	/**
494
-	 * Returns an array of coupon table columns.
495
-	 */
496
-	public static function discount_columns( $columns ) {
497
-
498
-		$columns = array(
499
-			'cb'                => $columns['cb'],
500
-			'title'             => __( 'Name', 'invoicing' ),
501
-			'code'              => __( 'Code', 'invoicing' ),
502
-			'amount'            => __( 'Amount', 'invoicing' ),
503
-			'usage'             => __( 'Usage / Limit', 'invoicing' ),
504
-			'start_date'        => __( 'Start Date', 'invoicing' ),
505
-			'expiry_date'       => __( 'Expiry Date', 'invoicing' ),
506
-		);
507
-
508
-		return apply_filters( 'wpi_discount_table_columns', $columns );
509
-	}
510
-
511
-	/**
512
-	 * Filters post states.
513
-	 */
514
-	public static function filter_discount_state( $post_states, $post ) {
515
-
516
-		if ( 'wpi_discount' == $post->post_type ) {
517
-
518
-			$discount = new WPInv_Discount( $post );
519
-
520
-			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
521
-
522
-			if ( $status != 'publish' ) {
523
-				return array(
524
-					'discount_status' => wpinv_discount_status( $status ),
525
-				);
526
-			}
527
-
528
-			return array();
529
-
530
-		}
531
-
532
-		return $post_states;
533
-
534
-	}
535
-
536
-	/**
537
-	 * Returns an array of items table columns.
538
-	 */
539
-	public static function item_columns( $columns ) {
540
-
541
-		$columns = array(
542
-			'cb'                => $columns['cb'],
543
-			'title'             => __( 'Name', 'invoicing' ),
544
-			'price'             => __( 'Price', 'invoicing' ),
545
-			'vat_rule'          => __( 'VAT rule', 'invoicing' ),
546
-			'vat_class'         => __( 'VAT class', 'invoicing' ),
547
-			'type'              => __( 'Type', 'invoicing' ),
548
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
549
-		);
550
-
551
-		if ( ! wpinv_use_taxes() ) {
552
-			unset( $columns['vat_rule'] );
553
-			unset( $columns['vat_class'] );
554
-		}
555
-
556
-		return apply_filters( 'wpi_item_table_columns', $columns );
557
-	}
558
-
559
-	/**
560
-	 * Returns an array of sortable items table columns.
561
-	 */
562
-	public static function sortable_item_columns( $columns ) {
563
-
564
-		return array_merge(
565
-			$columns,
566
-			array(
567
-				'price'     => 'price',
568
-				'vat_rule'  => 'vat_rule',
569
-				'vat_class' => 'vat_class',
570
-				'type'      => 'type',
571
-			)
572
-		);
573
-
574
-	}
575
-
576
-	/**
577
-	 * Displays items table columns.
578
-	 */
579
-	public static function display_item_columns( $column_name, $post_id ) {
489
+        return $post_states;
490
+
491
+    }
492
+
493
+    /**
494
+     * Returns an array of coupon table columns.
495
+     */
496
+    public static function discount_columns( $columns ) {
497
+
498
+        $columns = array(
499
+            'cb'                => $columns['cb'],
500
+            'title'             => __( 'Name', 'invoicing' ),
501
+            'code'              => __( 'Code', 'invoicing' ),
502
+            'amount'            => __( 'Amount', 'invoicing' ),
503
+            'usage'             => __( 'Usage / Limit', 'invoicing' ),
504
+            'start_date'        => __( 'Start Date', 'invoicing' ),
505
+            'expiry_date'       => __( 'Expiry Date', 'invoicing' ),
506
+        );
507
+
508
+        return apply_filters( 'wpi_discount_table_columns', $columns );
509
+    }
510
+
511
+    /**
512
+     * Filters post states.
513
+     */
514
+    public static function filter_discount_state( $post_states, $post ) {
515
+
516
+        if ( 'wpi_discount' == $post->post_type ) {
517
+
518
+            $discount = new WPInv_Discount( $post );
519
+
520
+            $status = $discount->is_expired() ? 'expired' : $discount->get_status();
521
+
522
+            if ( $status != 'publish' ) {
523
+                return array(
524
+                    'discount_status' => wpinv_discount_status( $status ),
525
+                );
526
+            }
527
+
528
+            return array();
529
+
530
+        }
531
+
532
+        return $post_states;
533
+
534
+    }
535
+
536
+    /**
537
+     * Returns an array of items table columns.
538
+     */
539
+    public static function item_columns( $columns ) {
540
+
541
+        $columns = array(
542
+            'cb'                => $columns['cb'],
543
+            'title'             => __( 'Name', 'invoicing' ),
544
+            'price'             => __( 'Price', 'invoicing' ),
545
+            'vat_rule'          => __( 'VAT rule', 'invoicing' ),
546
+            'vat_class'         => __( 'VAT class', 'invoicing' ),
547
+            'type'              => __( 'Type', 'invoicing' ),
548
+            'shortcode'         => __( 'Shortcode', 'invoicing' ),
549
+        );
550
+
551
+        if ( ! wpinv_use_taxes() ) {
552
+            unset( $columns['vat_rule'] );
553
+            unset( $columns['vat_class'] );
554
+        }
555
+
556
+        return apply_filters( 'wpi_item_table_columns', $columns );
557
+    }
558
+
559
+    /**
560
+     * Returns an array of sortable items table columns.
561
+     */
562
+    public static function sortable_item_columns( $columns ) {
563
+
564
+        return array_merge(
565
+            $columns,
566
+            array(
567
+                'price'     => 'price',
568
+                'vat_rule'  => 'vat_rule',
569
+                'vat_class' => 'vat_class',
570
+                'type'      => 'type',
571
+            )
572
+        );
573
+
574
+    }
575
+
576
+    /**
577
+     * Displays items table columns.
578
+     */
579
+    public static function display_item_columns( $column_name, $post_id ) {
580 580
  
581
-		$item = new WPInv_Item( $post_id );
581
+        $item = new WPInv_Item( $post_id );
582 582
 
583
-		switch ( $column_name ) {
583
+        switch ( $column_name ) {
584 584
 
585
-			case 'price' :
585
+            case 'price' :
586 586
 
587
-				if ( ! $item->is_recurring() ) {
588
-					echo $item->get_the_price();
589
-					break;
590
-				}
587
+                if ( ! $item->is_recurring() ) {
588
+                    echo $item->get_the_price();
589
+                    break;
590
+                }
591 591
 
592
-				$price = wp_sprintf(
593
-					__( '%s / %s', 'invoicing' ),
594
-					$item->get_the_price(),
595
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
596
-				);
592
+                $price = wp_sprintf(
593
+                    __( '%s / %s', 'invoicing' ),
594
+                    $item->get_the_price(),
595
+                    getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
596
+                );
597 597
 
598
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
599
-					echo $price;
600
-					break;
601
-				}
598
+                if ( $item->get_the_price() == $item->get_the_initial_price() ) {
599
+                    echo $price;
600
+                    break;
601
+                }
602 602
 
603
-				echo $item->get_the_initial_price();
603
+                echo $item->get_the_initial_price();
604 604
 
605
-				echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
606
-				break;
605
+                echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
606
+                break;
607 607
 
608
-			case 'vat_rule' :
609
-				echo getpaid_get_tax_rule_label( $item->get_vat_rule() );
610
-				break;
608
+            case 'vat_rule' :
609
+                echo getpaid_get_tax_rule_label( $item->get_vat_rule() );
610
+                break;
611 611
 
612
-			case 'vat_class' :
613
-				echo getpaid_get_tax_class_label( $item->get_vat_class() );
614
-				break;
612
+            case 'vat_class' :
613
+                echo getpaid_get_tax_class_label( $item->get_vat_class() );
614
+                break;
615 615
 
616
-			case 'shortcode' :
616
+            case 'shortcode' :
617 617
 
618
-				if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
619
-					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
620
-				} else {
621
-					echo "&mdash;";
622
-				}
618
+                if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
619
+                    echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
620
+                } else {
621
+                    echo "&mdash;";
622
+                }
623 623
 				
624
-				break;
624
+                break;
625 625
 
626
-			case 'type' :
627
-				echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
628
-				break;
626
+            case 'type' :
627
+                echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
628
+                break;
629 629
 
630
-		}
630
+        }
631 631
 
632
-	}
632
+    }
633 633
 
634
-	/**
635
-	 * Lets users filter items using taxes.
636
-	 */
637
-	public static function add_item_filters( $post_type ) {
634
+    /**
635
+     * Lets users filter items using taxes.
636
+     */
637
+    public static function add_item_filters( $post_type ) {
638 638
 
639
-		// Abort if we're not dealing with items.
640
-		if ( $post_type != 'wpi_item' ) {
641
-			return;
642
-		}
639
+        // Abort if we're not dealing with items.
640
+        if ( $post_type != 'wpi_item' ) {
641
+            return;
642
+        }
643 643
 
644
-		// Filter by vat rules.
645
-		if ( wpinv_use_taxes() ) {
644
+        // Filter by vat rules.
645
+        if ( wpinv_use_taxes() ) {
646 646
 	
647
-			// Sanitize selected vat rule.
648
-			$vat_rule   = '';
649
-			$vat_rules  = getpaid_get_tax_rules();
650
-			if ( isset( $_GET['vat_rule'] ) ) {
651
-				$vat_rule   =  $_GET['vat_rule'];
652
-			}
653
-
654
-			// Filter by VAT rule.
655
-			echo wpinv_html_select(
656
-				array(
657
-					'options'          => array_merge(
658
-						array(
659
-							'' => __( 'All VAT rules', 'invoicing' )
660
-						),
661
-						$vat_rules
662
-					),
663
-					'name'             => 'vat_rule',
664
-					'id'               => 'vat_rule',
665
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
666
-					'show_option_all'  => false,
667
-					'show_option_none' => false,
668
-				)
669
-			);
670
-
671
-			// Filter by VAT class.
647
+            // Sanitize selected vat rule.
648
+            $vat_rule   = '';
649
+            $vat_rules  = getpaid_get_tax_rules();
650
+            if ( isset( $_GET['vat_rule'] ) ) {
651
+                $vat_rule   =  $_GET['vat_rule'];
652
+            }
653
+
654
+            // Filter by VAT rule.
655
+            echo wpinv_html_select(
656
+                array(
657
+                    'options'          => array_merge(
658
+                        array(
659
+                            '' => __( 'All VAT rules', 'invoicing' )
660
+                        ),
661
+                        $vat_rules
662
+                    ),
663
+                    'name'             => 'vat_rule',
664
+                    'id'               => 'vat_rule',
665
+                    'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
666
+                    'show_option_all'  => false,
667
+                    'show_option_none' => false,
668
+                )
669
+            );
670
+
671
+            // Filter by VAT class.
672 672
 	
673
-			// Sanitize selected vat rule.
674
-			$vat_class   = '';
675
-			$vat_classes = getpaid_get_tax_classes();
676
-			if ( isset( $_GET['vat_class'] ) ) {
677
-				$vat_class   =  $_GET['vat_class'];
678
-			}
679
-
680
-			echo wpinv_html_select(
681
-				array(
682
-					'options'          => array_merge(
683
-						array(
684
-							'' => __( 'All VAT classes', 'invoicing' )
685
-						),
686
-						$vat_classes
687
-					),
688
-					'name'             => 'vat_class',
689
-					'id'               => 'vat_class',
690
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
691
-					'show_option_all'  => false,
692
-					'show_option_none' => false,
693
-				)
694
-			);
695
-
696
-		}
697
-
698
-		// Filter by item type.
699
-		$type   = '';
700
-		if ( isset( $_GET['type'] ) ) {
701
-			$type   =  $_GET['type'];
702
-		}
703
-
704
-		echo wpinv_html_select(
705
-			array(
706
-				'options'          => array_merge(
707
-					array(
708
-						'' => __( 'All item types', 'invoicing' )
709
-					),
710
-					wpinv_get_item_types()
711
-				),
712
-				'name'             => 'type',
713
-				'id'               => 'type',
714
-				'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
715
-				'show_option_all'  => false,
716
-				'show_option_none' => false,
717
-			)
718
-		);
719
-
720
-	}
721
-
722
-	/**
723
-	 * Filters the item query.
724
-	 */
725
-	public static function filter_item_query( $query ) {
726
-
727
-		// modify the query only if it admin and main query.
728
-		if ( ! ( is_admin() && $query->is_main_query() ) ){ 
729
-			return $query;
730
-		}
731
-
732
-		// we want to modify the query for our items.
733
-		if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){
734
-			return $query;
735
-		}
736
-
737
-		if ( empty( $query->query_vars['meta_query'] ) ) {
738
-			$query->query_vars['meta_query'] = array();
739
-		}
740
-
741
-		// Filter vat rule type
673
+            // Sanitize selected vat rule.
674
+            $vat_class   = '';
675
+            $vat_classes = getpaid_get_tax_classes();
676
+            if ( isset( $_GET['vat_class'] ) ) {
677
+                $vat_class   =  $_GET['vat_class'];
678
+            }
679
+
680
+            echo wpinv_html_select(
681
+                array(
682
+                    'options'          => array_merge(
683
+                        array(
684
+                            '' => __( 'All VAT classes', 'invoicing' )
685
+                        ),
686
+                        $vat_classes
687
+                    ),
688
+                    'name'             => 'vat_class',
689
+                    'id'               => 'vat_class',
690
+                    'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
691
+                    'show_option_all'  => false,
692
+                    'show_option_none' => false,
693
+                )
694
+            );
695
+
696
+        }
697
+
698
+        // Filter by item type.
699
+        $type   = '';
700
+        if ( isset( $_GET['type'] ) ) {
701
+            $type   =  $_GET['type'];
702
+        }
703
+
704
+        echo wpinv_html_select(
705
+            array(
706
+                'options'          => array_merge(
707
+                    array(
708
+                        '' => __( 'All item types', 'invoicing' )
709
+                    ),
710
+                    wpinv_get_item_types()
711
+                ),
712
+                'name'             => 'type',
713
+                'id'               => 'type',
714
+                'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
715
+                'show_option_all'  => false,
716
+                'show_option_none' => false,
717
+            )
718
+        );
719
+
720
+    }
721
+
722
+    /**
723
+     * Filters the item query.
724
+     */
725
+    public static function filter_item_query( $query ) {
726
+
727
+        // modify the query only if it admin and main query.
728
+        if ( ! ( is_admin() && $query->is_main_query() ) ){ 
729
+            return $query;
730
+        }
731
+
732
+        // we want to modify the query for our items.
733
+        if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){
734
+            return $query;
735
+        }
736
+
737
+        if ( empty( $query->query_vars['meta_query'] ) ) {
738
+            $query->query_vars['meta_query'] = array();
739
+        }
740
+
741
+        // Filter vat rule type
742 742
         if ( ! empty( $_GET['vat_rule'] ) ) {
743 743
             $query->query_vars['meta_query'][] = array(
744 744
                 'key'     => '_wpinv_vat_rule',
@@ -763,97 +763,97 @@  discard block
 block discarded – undo
763 763
                 'value'   => sanitize_text_field( $_GET['type'] ),
764 764
                 'compare' => '='
765 765
             );
766
-		}
767
-
768
-	}
769
-
770
-	/**
771
-	 * Reorders items.
772
-	 */
773
-	public static function reorder_items( $vars ) {
774
-		global $typenow;
775
-
776
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
777
-			return $vars;
778
-		}
779
-
780
-		// By item type.
781
-		if ( 'type' == $vars['orderby'] ) {
782
-			return array_merge(
783
-				$vars,
784
-				array(
785
-					'meta_key' => '_wpinv_type',
786
-					'orderby'  => 'meta_value'
787
-				)
788
-			);
789
-		}
790
-
791
-		// By vat class.
792
-		if ( 'vat_class' == $vars['orderby'] ) {
793
-			return array_merge(
794
-				$vars,
795
-				array(
796
-					'meta_key' => '_wpinv_vat_class',
797
-					'orderby'  => 'meta_value'
798
-				)
799
-			);
800
-		}
801
-
802
-		// By vat rule.
803
-		if ( 'vat_rule' == $vars['orderby'] ) {
804
-			return array_merge(
805
-				$vars,
806
-				array(
807
-					'meta_key' => '_wpinv_vat_rule',
808
-					'orderby'  => 'meta_value'
809
-				)
810
-			);
811
-		}
812
-
813
-		// By price.
814
-		if ( 'price' == $vars['orderby'] ) {
815
-			return array_merge(
816
-				$vars,
817
-				array(
818
-					'meta_key' => '_wpinv_price',
819
-					'orderby'  => 'meta_value_num'
820
-				)
821
-			);
822
-		}
823
-
824
-		return $vars;
825
-
826
-	}
827
-
828
-	/**
829
-	 * Fired when deleting a post.
830
-	 */
831
-	public static function delete_post( $post_id ) {
832
-
833
-		switch ( get_post_type( $post_id ) ) {
834
-
835
-			case 'wpi_item' :
836
-				do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
837
-				break;
838
-
839
-			case 'wpi_payment_form' :
840
-				do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
841
-				break;
842
-
843
-			case 'wpi_discount' :
844
-				do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
845
-				break;
846
-
847
-			case 'wpi_invoice' :
848
-				$invoice = new WPInv_Invoice( $post_id );
849
-				do_action( "getpaid_before_delete_invoice", $invoice );
850
-				$invoice->get_data_store()->delete_items( $invoice );
851
-				$invoice->get_data_store()->delete_special_fields( $invoice );
852
-				break;
853
-		}
854
-	}
855
-
856
-	/**
766
+        }
767
+
768
+    }
769
+
770
+    /**
771
+     * Reorders items.
772
+     */
773
+    public static function reorder_items( $vars ) {
774
+        global $typenow;
775
+
776
+        if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
777
+            return $vars;
778
+        }
779
+
780
+        // By item type.
781
+        if ( 'type' == $vars['orderby'] ) {
782
+            return array_merge(
783
+                $vars,
784
+                array(
785
+                    'meta_key' => '_wpinv_type',
786
+                    'orderby'  => 'meta_value'
787
+                )
788
+            );
789
+        }
790
+
791
+        // By vat class.
792
+        if ( 'vat_class' == $vars['orderby'] ) {
793
+            return array_merge(
794
+                $vars,
795
+                array(
796
+                    'meta_key' => '_wpinv_vat_class',
797
+                    'orderby'  => 'meta_value'
798
+                )
799
+            );
800
+        }
801
+
802
+        // By vat rule.
803
+        if ( 'vat_rule' == $vars['orderby'] ) {
804
+            return array_merge(
805
+                $vars,
806
+                array(
807
+                    'meta_key' => '_wpinv_vat_rule',
808
+                    'orderby'  => 'meta_value'
809
+                )
810
+            );
811
+        }
812
+
813
+        // By price.
814
+        if ( 'price' == $vars['orderby'] ) {
815
+            return array_merge(
816
+                $vars,
817
+                array(
818
+                    'meta_key' => '_wpinv_price',
819
+                    'orderby'  => 'meta_value_num'
820
+                )
821
+            );
822
+        }
823
+
824
+        return $vars;
825
+
826
+    }
827
+
828
+    /**
829
+     * Fired when deleting a post.
830
+     */
831
+    public static function delete_post( $post_id ) {
832
+
833
+        switch ( get_post_type( $post_id ) ) {
834
+
835
+            case 'wpi_item' :
836
+                do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
837
+                break;
838
+
839
+            case 'wpi_payment_form' :
840
+                do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
841
+                break;
842
+
843
+            case 'wpi_discount' :
844
+                do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
845
+                break;
846
+
847
+            case 'wpi_invoice' :
848
+                $invoice = new WPInv_Invoice( $post_id );
849
+                do_action( "getpaid_before_delete_invoice", $invoice );
850
+                $invoice->get_data_store()->delete_items( $invoice );
851
+                $invoice->get_data_store()->delete_special_fields( $invoice );
852
+                break;
853
+        }
854
+    }
855
+
856
+    /**
857 857
      * Add a post display state for special GetPaid pages in the page list table.
858 858
      *
859 859
      * @param array   $post_states An array of post display states.
@@ -867,22 +867,22 @@  discard block
 block discarded – undo
867 867
             $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );
868 868
         }
869 869
 
870
-		foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
870
+        foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
871 871
 
872
-			if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
873
-				$post_states["getpaid_{$post_type}_history_page"] = sprintf(
874
-					__( 'GetPaid %s History Page', 'invoicing' ),
875
-					$label
876
-				);
877
-			}
872
+            if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
873
+                $post_states["getpaid_{$post_type}_history_page"] = sprintf(
874
+                    __( 'GetPaid %s History Page', 'invoicing' ),
875
+                    $label
876
+                );
877
+            }
878 878
 
879
-		}
879
+        }
880 880
 		
881
-		if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
881
+        if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
882 882
             $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' );
883 883
         }
884 884
 
885
-		if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
885
+        if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
886 886
             $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
887 887
         }
888 888
 
Please login to merge, or discard this patch.
Spacing   +235 added lines, -235 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,74 +21,74 @@  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 );
28
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
27
+		add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2);
28
+		add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2);
29 29
 
30 30
 		// Invoice table columns.
31
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
-		add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
-		add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
31
+		add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100);
32
+		add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2);
33
+		add_filter('bulk_actions-edit-wpi_invoice', array(__CLASS__, 'invoice_bulk_actions'));
34
+		add_filter('handle_bulk_actions-edit-wpi_invoice', array(__CLASS__, 'handle_invoice_bulk_actions'), 10, 3);
35 35
 
36 36
 		// Items table columns.
37
-		add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
-		add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
-		add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
-		add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
-		add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
-		add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
37
+		add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100);
38
+		add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20);
39
+		add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2);
40
+		add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100);
41
+		add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100);
42
+		add_action('request', array(__CLASS__, 'reorder_items'), 100);
43 43
 
44 44
 		// Payment forms columns.
45
-		add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
-		add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
45
+		add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100);
46
+		add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2);
47
+		add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2);
48 48
 
49 49
 		// Discount table columns.
50
-		add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
-		add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
50
+		add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100);
51
+		add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100);
52 52
 
53 53
 		// Deleting posts.
54
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
54
+		add_action('delete_post', array(__CLASS__, 'delete_post'));
55
+		add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2);
56 56
 
57
-		add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
57
+		add_filter('display_post_states', array(__CLASS__, 'add_display_post_states'), 10, 2);
58 58
 	}
59 59
 
60 60
 	/**
61 61
 	 * Post updated messages.
62 62
 	 */
63
-	public static function post_updated_messages( $messages ) {
63
+	public static function post_updated_messages($messages) {
64 64
 		global $post;
65 65
 
66 66
 		$messages['wpi_discount'] = array(
67 67
 			0   => '',
68
-			1   => __( 'Discount updated.', 'invoicing' ),
69
-			2   => __( 'Custom field updated.', 'invoicing' ),
70
-			3   => __( 'Custom field deleted.', 'invoicing' ),
71
-			4   => __( 'Discount updated.', 'invoicing' ),
72
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
-			6   => __( 'Discount updated.', 'invoicing' ),
74
-			7   => __( 'Discount saved.', 'invoicing' ),
75
-			8   => __( 'Discount submitted.', 'invoicing' ),
76
-			9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
-			10  => __( 'Discount draft updated.', 'invoicing' ),
68
+			1   => __('Discount updated.', 'invoicing'),
69
+			2   => __('Custom field updated.', 'invoicing'),
70
+			3   => __('Custom field deleted.', 'invoicing'),
71
+			4   => __('Discount updated.', 'invoicing'),
72
+			5   => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
73
+			6   => __('Discount updated.', 'invoicing'),
74
+			7   => __('Discount saved.', 'invoicing'),
75
+			8   => __('Discount submitted.', 'invoicing'),
76
+			9   => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
77
+			10  => __('Discount draft updated.', 'invoicing'),
78 78
 		);
79 79
 
80 80
 		$messages['wpi_payment_form'] = array(
81 81
 			0   => '',
82
-			1   => __( 'Payment Form updated.', 'invoicing' ),
83
-			2   => __( 'Custom field updated.', 'invoicing' ),
84
-			3   => __( 'Custom field deleted.', 'invoicing' ),
85
-			4   => __( 'Payment Form updated.', 'invoicing' ),
86
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
-			6   => __( 'Payment Form updated.', 'invoicing' ),
88
-			7   => __( 'Payment Form saved.', 'invoicing' ),
89
-			8   => __( 'Payment Form submitted.', 'invoicing' ),
90
-			9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
-			10  => __( 'Payment Form draft updated.', 'invoicing' ),
82
+			1   => __('Payment Form updated.', 'invoicing'),
83
+			2   => __('Custom field updated.', 'invoicing'),
84
+			3   => __('Custom field deleted.', 'invoicing'),
85
+			4   => __('Payment Form updated.', 'invoicing'),
86
+			5   => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
87
+			6   => __('Payment Form updated.', 'invoicing'),
88
+			7   => __('Payment Form saved.', 'invoicing'),
89
+			8   => __('Payment Form submitted.', 'invoicing'),
90
+			9   => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
91
+			10  => __('Payment Form draft updated.', 'invoicing'),
92 92
 		);
93 93
 
94 94
 		return $messages;
@@ -98,19 +98,19 @@  discard block
 block discarded – undo
98 98
 	/**
99 99
 	 * Post row actions.
100 100
 	 */
101
-	public static function post_row_actions( $actions, $post ) {
101
+	public static function post_row_actions($actions, $post) {
102 102
 
103
-		$post = get_post( $post );
103
+		$post = get_post($post);
104 104
 
105 105
 		// We do not want to edit the default payment form.
106
-		if ( 'wpi_payment_form' == $post->post_type ) {
106
+		if ('wpi_payment_form' == $post->post_type) {
107 107
 
108
-			if ( $post->ID == wpinv_get_default_payment_form() ) {
109
-				unset( $actions['trash'] );
110
-				unset( $actions['inline hide-if-no-js'] );
108
+			if ($post->ID == wpinv_get_default_payment_form()) {
109
+				unset($actions['trash']);
110
+				unset($actions['inline hide-if-no-js']);
111 111
 			}
112 112
 
113
-			$actions['duplicate'] =  sprintf(
113
+			$actions['duplicate'] = sprintf(
114 114
 				'<a href="%1$s">%2$s</a>',
115 115
 				esc_url(
116 116
 					wp_nonce_url(
@@ -124,20 +124,20 @@  discard block
 block discarded – undo
124 124
 						'getpaid-nonce'
125 125
 					)
126 126
 				),
127
-				esc_html( __( 'Duplicate', 'invoicing' ) )
127
+				esc_html(__('Duplicate', 'invoicing'))
128 128
 			);
129 129
 
130 130
 		}
131 131
 
132 132
 		// Link to item payment form.
133
-		if ( 'wpi_item' == $post->post_type ) {
133
+		if ('wpi_item' == $post->post_type) {
134 134
 
135
-			if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) {
135
+			if (in_array(get_post_meta($post->ID, '_wpinv_type', true), array('', 'fee', 'custom'))) {
136 136
 
137
-				$actions['buy'] =  sprintf(
137
+				$actions['buy'] = sprintf(
138 138
 					'<a href="%1$s">%2$s</a>',
139
-					esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
140
-					esc_html( __( 'Buy', 'invoicing' ) )
139
+					esc_url(getpaid_embed_url(false, $post->ID . '|0')),
140
+					esc_html(__('Buy', 'invoicing'))
141 141
 				);
142 142
 
143 143
 			}
@@ -155,31 +155,31 @@  discard block
 block discarded – undo
155 155
 	 * @param WP_Post $post
156 156
      * @return array $actions actions without edit option
157 157
      */
158
-    public static function filter_invoice_row_actions( $actions, $post ) {
158
+    public static function filter_invoice_row_actions($actions, $post) {
159 159
 
160
-        if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
160
+        if (getpaid_is_invoice_post_type($post->post_type)) {
161 161
 
162 162
 			$actions = array();
163
-			$invoice = new WPInv_Invoice( $post );
163
+			$invoice = new WPInv_Invoice($post);
164 164
 
165
-			$actions['edit'] =  sprintf(
165
+			$actions['edit'] = sprintf(
166 166
 				'<a href="%1$s">%2$s</a>',
167
-				esc_url( get_edit_post_link( $invoice->get_id() ) ),
168
-				esc_html( __( 'Edit', 'invoicing' ) )
167
+				esc_url(get_edit_post_link($invoice->get_id())),
168
+				esc_html(__('Edit', 'invoicing'))
169 169
 			);
170 170
 
171
-			if ( ! $invoice->is_draft() ) {
171
+			if (!$invoice->is_draft()) {
172 172
 
173
-				$actions['view'] =  sprintf(
173
+				$actions['view'] = sprintf(
174 174
 					'<a href="%1$s">%2$s</a>',
175
-					esc_url( $invoice->get_view_url() ),
175
+					esc_url($invoice->get_view_url()),
176 176
 					sprintf(
177
-						esc_html( __( 'View %s', 'invoicing' ) ),
178
-						getpaid_get_post_type_label( $invoice->get_post_type(), false )
177
+						esc_html(__('View %s', 'invoicing')),
178
+						getpaid_get_post_type_label($invoice->get_post_type(), false)
179 179
 					)
180 180
 				);
181 181
 
182
-				$actions['send'] =  sprintf(
182
+				$actions['send'] = sprintf(
183 183
 					'<a href="%1$s">%2$s</a>',
184 184
 					esc_url(
185 185
 						wp_nonce_url(
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
 							'getpaid-nonce'
194 194
 						)
195 195
 					),
196
-					esc_html( __( 'Send to Customer', 'invoicing' ) )
196
+					esc_html(__('Send to Customer', 'invoicing'))
197 197
 				);
198 198
 
199 199
 			}
200 200
 
201
-			$actions['duplicate'] =  sprintf(
201
+			$actions['duplicate'] = sprintf(
202 202
 				'<a href="%1$s">%2$s</a>',
203 203
 				esc_url(
204 204
 					wp_nonce_url(
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 						'getpaid-nonce'
213 213
 					)
214 214
 				),
215
-				esc_html( __( 'Duplicate', 'invoicing' ) )
215
+				esc_html(__('Duplicate', 'invoicing'))
216 216
 			);
217 217
 
218 218
         }
@@ -223,42 +223,42 @@  discard block
 block discarded – undo
223 223
 	/**
224 224
 	 * Returns an array of invoice table columns.
225 225
 	 */
226
-	public static function invoice_columns( $columns ) {
226
+	public static function invoice_columns($columns) {
227 227
 
228 228
 		$columns = array(
229 229
 			'cb'                => $columns['cb'],
230
-			'number'            => __( 'Invoice', 'invoicing' ),
231
-			'customer'          => __( 'Customer', 'invoicing' ),
232
-			'invoice_date'      => __( 'Created', 'invoicing' ),
233
-			'payment_date'      => __( 'Completed', 'invoicing' ),
234
-			'amount'            => __( 'Amount', 'invoicing' ),
235
-			'recurring'         => __( 'Recurring', 'invoicing' ),
236
-			'status'            => __( 'Status', 'invoicing' ),
230
+			'number'            => __('Invoice', 'invoicing'),
231
+			'customer'          => __('Customer', 'invoicing'),
232
+			'invoice_date'      => __('Created', 'invoicing'),
233
+			'payment_date'      => __('Completed', 'invoicing'),
234
+			'amount'            => __('Amount', 'invoicing'),
235
+			'recurring'         => __('Recurring', 'invoicing'),
236
+			'status'            => __('Status', 'invoicing'),
237 237
 		);
238 238
 
239
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
239
+		return apply_filters('wpi_invoice_table_columns', $columns);
240 240
 	}
241 241
 
242 242
 	/**
243 243
 	 * Displays invoice table columns.
244 244
 	 */
245
-	public static function display_invoice_columns( $column_name, $post_id ) {
245
+	public static function display_invoice_columns($column_name, $post_id) {
246 246
 
247
-		$invoice = new WPInv_Invoice( $post_id );
247
+		$invoice = new WPInv_Invoice($post_id);
248 248
 
249
-		switch ( $column_name ) {
249
+		switch ($column_name) {
250 250
 
251 251
 			case 'invoice_date' :
252
-				$date_time = esc_attr( $invoice->get_created_date() );
253
-				$date      = getpaid_format_date_value( $date_time, "&mdash;", true );
252
+				$date_time = esc_attr($invoice->get_created_date());
253
+				$date      = getpaid_format_date_value($date_time, "&mdash;", true);
254 254
 				echo "<span title='$date_time'>$date</span>";
255 255
 				break;
256 256
 
257 257
 			case 'payment_date' :
258 258
 
259
-				if ( $invoice->is_paid() ) {
260
-					$date_time = esc_attr( $invoice->get_completed_date() );
261
-					$date      = getpaid_format_date_value( $date_time, "&mdash;", true );
259
+				if ($invoice->is_paid()) {
260
+					$date_time = esc_attr($invoice->get_completed_date());
261
+					$date      = getpaid_format_date_value($date_time, "&mdash;", true);
262 262
 					echo "<span title='$date_time'>$date</span>";
263 263
 				} else {
264 264
 					echo "&mdash;";
@@ -269,17 +269,17 @@  discard block
 block discarded – undo
269 269
 			case 'amount' :
270 270
 
271 271
 				$amount = $invoice->get_total();
272
-				$formated_amount = wpinv_price( $amount, $invoice->get_currency() );
272
+				$formated_amount = wpinv_price($amount, $invoice->get_currency());
273 273
 
274
-				if ( $invoice->is_refunded() ) {
275
-					$refunded_amount = wpinv_price( 0, $invoice->get_currency() );
274
+				if ($invoice->is_refunded()) {
275
+					$refunded_amount = wpinv_price(0, $invoice->get_currency());
276 276
 					echo "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>";
277 277
 				} else {
278 278
 
279 279
 					$discount = $invoice->get_total_discount();
280 280
 
281
-					if ( ! empty( $discount ) ) {
282
-						$new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
281
+					if (!empty($discount)) {
282
+						$new_amount = wpinv_price($amount + $discount, $invoice->get_currency());
283 283
 						echo "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>";
284 284
 					} else {
285 285
 						echo $formated_amount;
@@ -290,13 +290,13 @@  discard block
 block discarded – undo
290 290
 				break;
291 291
 
292 292
 			case 'status' :
293
-				$status       = esc_html( $invoice->get_status() );
294
-				$status_label = esc_html( $invoice->get_status_nicename() );
293
+				$status       = esc_html($invoice->get_status());
294
+				$status_label = esc_html($invoice->get_status_nicename());
295 295
 
296 296
 				// If it is paid, show the gateway title.
297
-				if ( $invoice->is_paid() ) {
298
-					$gateway = esc_html( $invoice->get_gateway_title() );
299
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
297
+				if ($invoice->is_paid()) {
298
+					$gateway = esc_html($invoice->get_gateway_title());
299
+					$gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), $gateway);
300 300
 
301 301
 					echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
302 302
 				} else {
@@ -304,22 +304,22 @@  discard block
 block discarded – undo
304 304
 				}
305 305
 
306 306
 				// If it is not paid, display the overdue and view status.
307
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
307
+				if (!$invoice->is_paid() && !$invoice->is_refunded()) {
308 308
 
309 309
 					// Invoice view status.
310
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
311
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
310
+					if (wpinv_is_invoice_viewed($invoice->get_id())) {
311
+						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>';
312 312
 					} else {
313
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
313
+						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>';
314 314
 					}
315 315
 
316 316
 					// Display the overview status.
317
-					if ( wpinv_get_option( 'overdue_active' ) ) {
317
+					if (wpinv_get_option('overdue_active')) {
318 318
 						$due_date = $invoice->get_due_date();
319
-						$fomatted = getpaid_format_date( $due_date );
319
+						$fomatted = getpaid_format_date($due_date);
320 320
 
321
-						if ( ! empty( $fomatted ) ) {
322
-							$date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
321
+						if (!empty($fomatted)) {
322
+							$date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted);
323 323
 							echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";
324 324
 						}
325 325
 					}
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 
331 331
 			case 'recurring':
332 332
 
333
-				if ( $invoice->is_recurring() ) {
333
+				if ($invoice->is_recurring()) {
334 334
 					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
335 335
 				} else {
336 336
 					echo '<i class="fa fa-times" style="color:#616161;"></i>';
@@ -339,9 +339,9 @@  discard block
 block discarded – undo
339 339
 
340 340
 			case 'number' :
341 341
 
342
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
343
-				$invoice_number  = esc_html( $invoice->get_number() );
344
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
342
+				$edit_link       = esc_url(get_edit_post_link($invoice->get_id()));
343
+				$invoice_number  = esc_html($invoice->get_number());
344
+				$invoice_details = esc_attr__('View Invoice Details', 'invoicing');
345 345
 
346 346
 				echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
347 347
 
@@ -351,13 +351,13 @@  discard block
 block discarded – undo
351 351
 	
352 352
 				$customer_name = $invoice->get_user_full_name();
353 353
 	
354
-				if ( empty( $customer_name ) ) {
354
+				if (empty($customer_name)) {
355 355
 					$customer_name = $invoice->get_email();
356 356
 				}
357 357
 	
358
-				if ( ! empty( $customer_name ) ) {
359
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
360
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
358
+				if (!empty($customer_name)) {
359
+					$customer_details = esc_attr__('View Customer Details', 'invoicing');
360
+					$view_link        = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php')));
361 361
 					echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
362 362
 				} else {
363 363
 					echo '<div>&mdash;</div>';
@@ -372,19 +372,19 @@  discard block
 block discarded – undo
372 372
 	/**
373 373
 	 * Displays invoice bulk actions.
374 374
 	 */
375
-	public static function invoice_bulk_actions( $actions ) {
376
-		$actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
375
+	public static function invoice_bulk_actions($actions) {
376
+		$actions['resend-invoice'] = __('Send to Customer', 'invoicing');
377 377
 		return $actions;
378 378
 	}
379 379
 
380 380
 	/**
381 381
 	 * Processes invoice bulk actions.
382 382
 	 */
383
-	public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
383
+	public static function handle_invoice_bulk_actions($redirect_url, $action, $post_ids) {
384 384
 
385
-		if ( $action == 'resend-invoice' ) {
386
-			foreach ( $post_ids as $post_id ) {
387
-				getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
385
+		if ($action == 'resend-invoice') {
386
+			foreach ($post_ids as $post_id) {
387
+				getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($post_id), true);
388 388
 			}
389 389
 		}
390 390
 
@@ -395,50 +395,50 @@  discard block
 block discarded – undo
395 395
 	/**
396 396
 	 * Returns an array of payment forms table columns.
397 397
 	 */
398
-	public static function payment_form_columns( $columns ) {
398
+	public static function payment_form_columns($columns) {
399 399
 
400 400
 		$columns = array(
401 401
 			'cb'                => $columns['cb'],
402
-			'title'             => __( 'Name', 'invoicing' ),
403
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
404
-			'earnings'          => __( 'Revenue', 'invoicing' ),
405
-			'refunds'           => __( 'Refunded', 'invoicing' ),
406
-			'items'             => __( 'Items', 'invoicing' ),
407
-			'date'              => __( 'Date', 'invoicing' ),
402
+			'title'             => __('Name', 'invoicing'),
403
+			'shortcode'         => __('Shortcode', 'invoicing'),
404
+			'earnings'          => __('Revenue', 'invoicing'),
405
+			'refunds'           => __('Refunded', 'invoicing'),
406
+			'items'             => __('Items', 'invoicing'),
407
+			'date'              => __('Date', 'invoicing'),
408 408
 		);
409 409
 
410
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
410
+		return apply_filters('wpi_payment_form_table_columns', $columns);
411 411
 
412 412
 	}
413 413
 
414 414
 	/**
415 415
 	 * Displays payment form table columns.
416 416
 	 */
417
-	public static function display_payment_form_columns( $column_name, $post_id ) {
417
+	public static function display_payment_form_columns($column_name, $post_id) {
418 418
 
419 419
 		// Retrieve the payment form.
420
-		$form = new GetPaid_Payment_Form( $post_id );
420
+		$form = new GetPaid_Payment_Form($post_id);
421 421
 
422
-		switch ( $column_name ) {
422
+		switch ($column_name) {
423 423
 
424 424
 			case 'earnings' :
425
-				echo wpinv_price( $form->get_earned() );
425
+				echo wpinv_price($form->get_earned());
426 426
 				break;
427 427
 
428 428
 			case 'refunds' :
429
-				echo wpinv_price( $form->get_refunded() );
429
+				echo wpinv_price($form->get_refunded());
430 430
 				break;
431 431
 
432 432
 			case 'refunds' :
433
-				echo wpinv_price( $form->get_refunded() );
433
+				echo wpinv_price($form->get_refunded());
434 434
 				break;
435 435
 
436 436
 			case 'shortcode' :
437 437
 
438
-				if ( $form->is_default() ) {
438
+				if ($form->is_default()) {
439 439
 					echo '&mdash;';
440 440
 				} else {
441
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
441
+					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>';
442 442
 				}
443 443
 
444 444
 				break;
@@ -447,29 +447,29 @@  discard block
 block discarded – undo
447 447
 
448 448
 				$items = $form->get_items();
449 449
 
450
-				if ( $form->is_default() || empty( $items ) ) {
450
+				if ($form->is_default() || empty($items)) {
451 451
 					echo '&mdash;';
452 452
 					return;
453 453
 				}
454 454
 
455 455
 				$_items = array();
456 456
 
457
-				foreach ( $items as $item ) {
457
+				foreach ($items as $item) {
458 458
 					$url = $item->get_edit_url();
459 459
 
460
-					if ( empty( $url ) ) {
461
-						$_items[] = esc_html( $item->get_name() );
460
+					if (empty($url)) {
461
+						$_items[] = esc_html($item->get_name());
462 462
 					} else {
463 463
 						$_items[] = sprintf(
464 464
 							'<a href="%s">%s</a>',
465
-							esc_url( $url ),
466
-							esc_html( $item->get_name() )
465
+							esc_url($url),
466
+							esc_html($item->get_name())
467 467
 						);
468 468
 					}
469 469
 
470 470
 				}
471 471
 
472
-				echo implode( '<br>', $_items );
472
+				echo implode('<br>', $_items);
473 473
 
474 474
 				break;
475 475
 
@@ -480,10 +480,10 @@  discard block
 block discarded – undo
480 480
 	/**
481 481
 	 * Filters post states.
482 482
 	 */
483
-	public static function filter_payment_form_state( $post_states, $post ) {
483
+	public static function filter_payment_form_state($post_states, $post) {
484 484
 
485
-		if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
486
-			$post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );
485
+		if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) {
486
+			$post_states['default_form'] = __('Default Payment Form', 'invoicing');
487 487
 		}
488 488
 	
489 489
 		return $post_states;
@@ -493,35 +493,35 @@  discard block
 block discarded – undo
493 493
 	/**
494 494
 	 * Returns an array of coupon table columns.
495 495
 	 */
496
-	public static function discount_columns( $columns ) {
496
+	public static function discount_columns($columns) {
497 497
 
498 498
 		$columns = array(
499 499
 			'cb'                => $columns['cb'],
500
-			'title'             => __( 'Name', 'invoicing' ),
501
-			'code'              => __( 'Code', 'invoicing' ),
502
-			'amount'            => __( 'Amount', 'invoicing' ),
503
-			'usage'             => __( 'Usage / Limit', 'invoicing' ),
504
-			'start_date'        => __( 'Start Date', 'invoicing' ),
505
-			'expiry_date'       => __( 'Expiry Date', 'invoicing' ),
500
+			'title'             => __('Name', 'invoicing'),
501
+			'code'              => __('Code', 'invoicing'),
502
+			'amount'            => __('Amount', 'invoicing'),
503
+			'usage'             => __('Usage / Limit', 'invoicing'),
504
+			'start_date'        => __('Start Date', 'invoicing'),
505
+			'expiry_date'       => __('Expiry Date', 'invoicing'),
506 506
 		);
507 507
 
508
-		return apply_filters( 'wpi_discount_table_columns', $columns );
508
+		return apply_filters('wpi_discount_table_columns', $columns);
509 509
 	}
510 510
 
511 511
 	/**
512 512
 	 * Filters post states.
513 513
 	 */
514
-	public static function filter_discount_state( $post_states, $post ) {
514
+	public static function filter_discount_state($post_states, $post) {
515 515
 
516
-		if ( 'wpi_discount' == $post->post_type ) {
516
+		if ('wpi_discount' == $post->post_type) {
517 517
 
518
-			$discount = new WPInv_Discount( $post );
518
+			$discount = new WPInv_Discount($post);
519 519
 
520 520
 			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
521 521
 
522
-			if ( $status != 'publish' ) {
522
+			if ($status != 'publish') {
523 523
 				return array(
524
-					'discount_status' => wpinv_discount_status( $status ),
524
+					'discount_status' => wpinv_discount_status($status),
525 525
 				);
526 526
 			}
527 527
 
@@ -536,30 +536,30 @@  discard block
 block discarded – undo
536 536
 	/**
537 537
 	 * Returns an array of items table columns.
538 538
 	 */
539
-	public static function item_columns( $columns ) {
539
+	public static function item_columns($columns) {
540 540
 
541 541
 		$columns = array(
542 542
 			'cb'                => $columns['cb'],
543
-			'title'             => __( 'Name', 'invoicing' ),
544
-			'price'             => __( 'Price', 'invoicing' ),
545
-			'vat_rule'          => __( 'VAT rule', 'invoicing' ),
546
-			'vat_class'         => __( 'VAT class', 'invoicing' ),
547
-			'type'              => __( 'Type', 'invoicing' ),
548
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
543
+			'title'             => __('Name', 'invoicing'),
544
+			'price'             => __('Price', 'invoicing'),
545
+			'vat_rule'          => __('VAT rule', 'invoicing'),
546
+			'vat_class'         => __('VAT class', 'invoicing'),
547
+			'type'              => __('Type', 'invoicing'),
548
+			'shortcode'         => __('Shortcode', 'invoicing'),
549 549
 		);
550 550
 
551
-		if ( ! wpinv_use_taxes() ) {
552
-			unset( $columns['vat_rule'] );
553
-			unset( $columns['vat_class'] );
551
+		if (!wpinv_use_taxes()) {
552
+			unset($columns['vat_rule']);
553
+			unset($columns['vat_class']);
554 554
 		}
555 555
 
556
-		return apply_filters( 'wpi_item_table_columns', $columns );
556
+		return apply_filters('wpi_item_table_columns', $columns);
557 557
 	}
558 558
 
559 559
 	/**
560 560
 	 * Returns an array of sortable items table columns.
561 561
 	 */
562
-	public static function sortable_item_columns( $columns ) {
562
+	public static function sortable_item_columns($columns) {
563 563
 
564 564
 		return array_merge(
565 565
 			$columns,
@@ -576,47 +576,47 @@  discard block
 block discarded – undo
576 576
 	/**
577 577
 	 * Displays items table columns.
578 578
 	 */
579
-	public static function display_item_columns( $column_name, $post_id ) {
579
+	public static function display_item_columns($column_name, $post_id) {
580 580
  
581
-		$item = new WPInv_Item( $post_id );
581
+		$item = new WPInv_Item($post_id);
582 582
 
583
-		switch ( $column_name ) {
583
+		switch ($column_name) {
584 584
 
585 585
 			case 'price' :
586 586
 
587
-				if ( ! $item->is_recurring() ) {
587
+				if (!$item->is_recurring()) {
588 588
 					echo $item->get_the_price();
589 589
 					break;
590 590
 				}
591 591
 
592 592
 				$price = wp_sprintf(
593
-					__( '%s / %s', 'invoicing' ),
593
+					__('%s / %s', 'invoicing'),
594 594
 					$item->get_the_price(),
595
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
595
+					getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '')
596 596
 				);
597 597
 
598
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
598
+				if ($item->get_the_price() == $item->get_the_initial_price()) {
599 599
 					echo $price;
600 600
 					break;
601 601
 				}
602 602
 
603 603
 				echo $item->get_the_initial_price();
604 604
 
605
-				echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
605
+				echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), $price) . '</span>';
606 606
 				break;
607 607
 
608 608
 			case 'vat_rule' :
609
-				echo getpaid_get_tax_rule_label( $item->get_vat_rule() );
609
+				echo getpaid_get_tax_rule_label($item->get_vat_rule());
610 610
 				break;
611 611
 
612 612
 			case 'vat_class' :
613
-				echo getpaid_get_tax_class_label( $item->get_vat_class() );
613
+				echo getpaid_get_tax_class_label($item->get_vat_class());
614 614
 				break;
615 615
 
616 616
 			case 'shortcode' :
617 617
 
618
-				if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
619
-					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
618
+				if ($item->is_type(array('', 'fee', 'custom'))) {
619
+					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
620 620
 				} else {
621 621
 					echo "&mdash;";
622 622
 				}
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 				break;
625 625
 
626 626
 			case 'type' :
627
-				echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
627
+				echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
628 628
 				break;
629 629
 
630 630
 		}
@@ -634,21 +634,21 @@  discard block
 block discarded – undo
634 634
 	/**
635 635
 	 * Lets users filter items using taxes.
636 636
 	 */
637
-	public static function add_item_filters( $post_type ) {
637
+	public static function add_item_filters($post_type) {
638 638
 
639 639
 		// Abort if we're not dealing with items.
640
-		if ( $post_type != 'wpi_item' ) {
640
+		if ($post_type != 'wpi_item') {
641 641
 			return;
642 642
 		}
643 643
 
644 644
 		// Filter by vat rules.
645
-		if ( wpinv_use_taxes() ) {
645
+		if (wpinv_use_taxes()) {
646 646
 	
647 647
 			// Sanitize selected vat rule.
648 648
 			$vat_rule   = '';
649 649
 			$vat_rules  = getpaid_get_tax_rules();
650
-			if ( isset( $_GET['vat_rule'] ) ) {
651
-				$vat_rule   =  $_GET['vat_rule'];
650
+			if (isset($_GET['vat_rule'])) {
651
+				$vat_rule = $_GET['vat_rule'];
652 652
 			}
653 653
 
654 654
 			// Filter by VAT rule.
@@ -656,13 +656,13 @@  discard block
 block discarded – undo
656 656
 				array(
657 657
 					'options'          => array_merge(
658 658
 						array(
659
-							'' => __( 'All VAT rules', 'invoicing' )
659
+							'' => __('All VAT rules', 'invoicing')
660 660
 						),
661 661
 						$vat_rules
662 662
 					),
663 663
 					'name'             => 'vat_rule',
664 664
 					'id'               => 'vat_rule',
665
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
665
+					'selected'         => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '',
666 666
 					'show_option_all'  => false,
667 667
 					'show_option_none' => false,
668 668
 				)
@@ -673,21 +673,21 @@  discard block
 block discarded – undo
673 673
 			// Sanitize selected vat rule.
674 674
 			$vat_class   = '';
675 675
 			$vat_classes = getpaid_get_tax_classes();
676
-			if ( isset( $_GET['vat_class'] ) ) {
677
-				$vat_class   =  $_GET['vat_class'];
676
+			if (isset($_GET['vat_class'])) {
677
+				$vat_class = $_GET['vat_class'];
678 678
 			}
679 679
 
680 680
 			echo wpinv_html_select(
681 681
 				array(
682 682
 					'options'          => array_merge(
683 683
 						array(
684
-							'' => __( 'All VAT classes', 'invoicing' )
684
+							'' => __('All VAT classes', 'invoicing')
685 685
 						),
686 686
 						$vat_classes
687 687
 					),
688 688
 					'name'             => 'vat_class',
689 689
 					'id'               => 'vat_class',
690
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
690
+					'selected'         => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '',
691 691
 					'show_option_all'  => false,
692 692
 					'show_option_none' => false,
693 693
 				)
@@ -696,22 +696,22 @@  discard block
 block discarded – undo
696 696
 		}
697 697
 
698 698
 		// Filter by item type.
699
-		$type   = '';
700
-		if ( isset( $_GET['type'] ) ) {
701
-			$type   =  $_GET['type'];
699
+		$type = '';
700
+		if (isset($_GET['type'])) {
701
+			$type = $_GET['type'];
702 702
 		}
703 703
 
704 704
 		echo wpinv_html_select(
705 705
 			array(
706 706
 				'options'          => array_merge(
707 707
 					array(
708
-						'' => __( 'All item types', 'invoicing' )
708
+						'' => __('All item types', 'invoicing')
709 709
 					),
710 710
 					wpinv_get_item_types()
711 711
 				),
712 712
 				'name'             => 'type',
713 713
 				'id'               => 'type',
714
-				'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
714
+				'selected'         => in_array($type, wpinv_item_types()) ? $type : '',
715 715
 				'show_option_all'  => false,
716 716
 				'show_option_none' => false,
717 717
 			)
@@ -722,45 +722,45 @@  discard block
 block discarded – undo
722 722
 	/**
723 723
 	 * Filters the item query.
724 724
 	 */
725
-	public static function filter_item_query( $query ) {
725
+	public static function filter_item_query($query) {
726 726
 
727 727
 		// modify the query only if it admin and main query.
728
-		if ( ! ( is_admin() && $query->is_main_query() ) ){ 
728
+		if (!(is_admin() && $query->is_main_query())) { 
729 729
 			return $query;
730 730
 		}
731 731
 
732 732
 		// we want to modify the query for our items.
733
-		if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){
733
+		if (empty($query->query['post_type']) || 'wpi_item' != $query->query['post_type']) {
734 734
 			return $query;
735 735
 		}
736 736
 
737
-		if ( empty( $query->query_vars['meta_query'] ) ) {
737
+		if (empty($query->query_vars['meta_query'])) {
738 738
 			$query->query_vars['meta_query'] = array();
739 739
 		}
740 740
 
741 741
 		// Filter vat rule type
742
-        if ( ! empty( $_GET['vat_rule'] ) ) {
742
+        if (!empty($_GET['vat_rule'])) {
743 743
             $query->query_vars['meta_query'][] = array(
744 744
                 'key'     => '_wpinv_vat_rule',
745
-                'value'   => sanitize_text_field( $_GET['vat_rule'] ),
745
+                'value'   => sanitize_text_field($_GET['vat_rule']),
746 746
                 'compare' => '='
747 747
             );
748 748
         }
749 749
 
750 750
         // Filter vat class
751
-        if ( ! empty( $_GET['vat_class'] ) ) {
751
+        if (!empty($_GET['vat_class'])) {
752 752
             $query->query_vars['meta_query'][] = array(
753 753
                 'key'     => '_wpinv_vat_class',
754
-                'value'   => sanitize_text_field( $_GET['vat_class'] ),
754
+                'value'   => sanitize_text_field($_GET['vat_class']),
755 755
                 'compare' => '='
756 756
             );
757 757
         }
758 758
 
759 759
         // Filter item type
760
-        if ( ! empty( $_GET['type'] ) ) {
760
+        if (!empty($_GET['type'])) {
761 761
             $query->query_vars['meta_query'][] = array(
762 762
                 'key'     => '_wpinv_type',
763
-                'value'   => sanitize_text_field( $_GET['type'] ),
763
+                'value'   => sanitize_text_field($_GET['type']),
764 764
                 'compare' => '='
765 765
             );
766 766
 		}
@@ -770,15 +770,15 @@  discard block
 block discarded – undo
770 770
 	/**
771 771
 	 * Reorders items.
772 772
 	 */
773
-	public static function reorder_items( $vars ) {
773
+	public static function reorder_items($vars) {
774 774
 		global $typenow;
775 775
 
776
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
776
+		if ('wpi_item' !== $typenow || empty($vars['orderby'])) {
777 777
 			return $vars;
778 778
 		}
779 779
 
780 780
 		// By item type.
781
-		if ( 'type' == $vars['orderby'] ) {
781
+		if ('type' == $vars['orderby']) {
782 782
 			return array_merge(
783 783
 				$vars,
784 784
 				array(
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
 		}
790 790
 
791 791
 		// By vat class.
792
-		if ( 'vat_class' == $vars['orderby'] ) {
792
+		if ('vat_class' == $vars['orderby']) {
793 793
 			return array_merge(
794 794
 				$vars,
795 795
 				array(
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
 		}
801 801
 
802 802
 		// By vat rule.
803
-		if ( 'vat_rule' == $vars['orderby'] ) {
803
+		if ('vat_rule' == $vars['orderby']) {
804 804
 			return array_merge(
805 805
 				$vars,
806 806
 				array(
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
 		}
812 812
 
813 813
 		// By price.
814
-		if ( 'price' == $vars['orderby'] ) {
814
+		if ('price' == $vars['orderby']) {
815 815
 			return array_merge(
816 816
 				$vars,
817 817
 				array(
@@ -828,27 +828,27 @@  discard block
 block discarded – undo
828 828
 	/**
829 829
 	 * Fired when deleting a post.
830 830
 	 */
831
-	public static function delete_post( $post_id ) {
831
+	public static function delete_post($post_id) {
832 832
 
833
-		switch ( get_post_type( $post_id ) ) {
833
+		switch (get_post_type($post_id)) {
834 834
 
835 835
 			case 'wpi_item' :
836
-				do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
836
+				do_action("getpaid_before_delete_item", new WPInv_Item($post_id));
837 837
 				break;
838 838
 
839 839
 			case 'wpi_payment_form' :
840
-				do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
840
+				do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id));
841 841
 				break;
842 842
 
843 843
 			case 'wpi_discount' :
844
-				do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
844
+				do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id));
845 845
 				break;
846 846
 
847 847
 			case 'wpi_invoice' :
848
-				$invoice = new WPInv_Invoice( $post_id );
849
-				do_action( "getpaid_before_delete_invoice", $invoice );
850
-				$invoice->get_data_store()->delete_items( $invoice );
851
-				$invoice->get_data_store()->delete_special_fields( $invoice );
848
+				$invoice = new WPInv_Invoice($post_id);
849
+				do_action("getpaid_before_delete_invoice", $invoice);
850
+				$invoice->get_data_store()->delete_items($invoice);
851
+				$invoice->get_data_store()->delete_special_fields($invoice);
852 852
 				break;
853 853
 		}
854 854
 	}
@@ -861,29 +861,29 @@  discard block
 block discarded – undo
861 861
      *
862 862
      * @return mixed
863 863
      */
864
-    public static function add_display_post_states( $post_states, $post ) {
864
+    public static function add_display_post_states($post_states, $post) {
865 865
 
866
-        if ( wpinv_get_option( 'success_page', 0 ) == $post->ID ) {
867
-            $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );
866
+        if (wpinv_get_option('success_page', 0) == $post->ID) {
867
+            $post_states['getpaid_success_page'] = __('GetPaid Receipt Page', 'invoicing');
868 868
         }
869 869
 
870
-		foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
870
+		foreach (getpaid_get_invoice_post_types() as $post_type => $label) {
871 871
 
872
-			if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
872
+			if (wpinv_get_option("{$post_type}_history_page", 0) == $post->ID) {
873 873
 				$post_states["getpaid_{$post_type}_history_page"] = sprintf(
874
-					__( 'GetPaid %s History Page', 'invoicing' ),
874
+					__('GetPaid %s History Page', 'invoicing'),
875 875
 					$label
876 876
 				);
877 877
 			}
878 878
 
879 879
 		}
880 880
 		
881
-		if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
882
-            $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' );
881
+		if (wpinv_get_option('invoice_subscription_page', 0) == $post->ID) {
882
+            $post_states['getpaid_invoice_subscription_page'] = __('GetPaid Subscription Page', 'invoicing');
883 883
         }
884 884
 
885
-		if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
886
-            $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
885
+		if (wpinv_get_option('checkout_page', 0) == $post->ID) {
886
+            $post_states['getpaid_checkout_page'] = __('GetPaid Checkout Page', 'invoicing');
887 887
         }
888 888
 
889 889
         return $post_states;
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 2 patches
Indentation   +602 added lines, -602 removed lines patch added patch discarded remove patch
@@ -14,91 +14,91 @@  discard block
 block discarded – undo
14 14
 class GetPaid_Admin {
15 15
 
16 16
     /**
17
-	 * Local path to this plugins admin directory
18
-	 *
19
-	 * @var         string
20
-	 */
21
-	public $admin_path;
22
-
23
-	/**
24
-	 * Web path to this plugins admin directory
25
-	 *
26
-	 * @var         string
27
-	 */
28
-	public $admin_url;
17
+     * Local path to this plugins admin directory
18
+     *
19
+     * @var         string
20
+     */
21
+    public $admin_path;
22
+
23
+    /**
24
+     * Web path to this plugins admin directory
25
+     *
26
+     * @var         string
27
+     */
28
+    public $admin_url;
29 29
 	
30
-	/**
31
-	 * Reports components.
32
-	 *
33
-	 * @var GetPaid_Reports
34
-	 */
30
+    /**
31
+     * Reports components.
32
+     *
33
+     * @var GetPaid_Reports
34
+     */
35 35
     public $reports;
36 36
 
37 37
     /**
38
-	 * Class constructor.
39
-	 */
40
-	public function __construct(){
38
+     * Class constructor.
39
+     */
40
+    public function __construct(){
41 41
 
42 42
         $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
44
-		$this->reports     = new GetPaid_Reports();
43
+        $this->admin_url   = plugins_url( '/', __FILE__ );
44
+        $this->reports     = new GetPaid_Reports();
45 45
 
46 46
         if ( is_admin() ) {
47
-			$this->init_admin_hooks();
47
+            $this->init_admin_hooks();
48 48
         }
49 49
 
50 50
     }
51 51
 
52 52
     /**
53
-	 * Init action and filter hooks
54
-	 *
55
-	 */
56
-	private function init_admin_hooks() {
53
+     * Init action and filter hooks
54
+     *
55
+     */
56
+    private function init_admin_hooks() {
57 57
         add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ), 9 );
58 58
         add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59 59
         add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60 60
         add_action( 'admin_init', array( $this, 'activation_redirect') );
61 61
         add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) );
66
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
67
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
62
+        add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
+        add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
+        add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );
65
+        add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) );
66
+        add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
67
+        add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
68 68
         add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
70
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
71
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
72
-		add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
73
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
74
-		add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
75
-		add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
76
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
77
-		do_action( 'getpaid_init_admin_hooks', $this );
78
-
79
-		// Setup/welcome
80
-		if ( ! empty( $_GET['page'] ) ) {
81
-			switch ( $_GET['page'] ) {
82
-				case 'gp-setup' :
83
-					include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
84
-					break;
85
-			}
86
-		}
87
-
88
-    }
89
-
90
-    /**
91
-	 * Register admin scripts
92
-	 *
93
-	 */
94
-	public function enqeue_scripts() {
69
+        add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
70
+        add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
71
+        add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
72
+        add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
73
+        add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
74
+        add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
75
+        add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
76
+        add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
77
+        do_action( 'getpaid_init_admin_hooks', $this );
78
+
79
+        // Setup/welcome
80
+        if ( ! empty( $_GET['page'] ) ) {
81
+            switch ( $_GET['page'] ) {
82
+                case 'gp-setup' :
83
+                    include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
84
+                    break;
85
+            }
86
+        }
87
+
88
+    }
89
+
90
+    /**
91
+     * Register admin scripts
92
+     *
93
+     */
94
+    public function enqeue_scripts() {
95 95
         global $current_screen, $pagenow;
96 96
 
97
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
98
-		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
97
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
98
+        $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
99 99
 
100 100
         if ( ! empty( $current_screen->post_type ) ) {
101
-			$page = $current_screen->post_type;
101
+            $page = $current_screen->post_type;
102 102
         }
103 103
 
104 104
         // General styles.
@@ -119,54 +119,54 @@  discard block
 block discarded – undo
119 119
         }
120 120
 
121 121
         // Payment form scripts.
122
-		if ( 'wpi_payment_form' == $page && $editing ) {
122
+        if ( 'wpi_payment_form' == $page && $editing ) {
123 123
             $this->load_payment_form_scripts();
124 124
         }
125 125
 
126
-		if ( $page == 'wpinv-subscriptions' ) {
127
-			wp_enqueue_script( 'postbox' );
128
-		}
126
+        if ( $page == 'wpinv-subscriptions' ) {
127
+            wp_enqueue_script( 'postbox' );
128
+        }
129 129
 
130 130
     }
131 131
 
132 132
     /**
133
-	 * Returns admin js translations.
134
-	 *
135
-	 */
136
-	protected function get_admin_i18() {
133
+     * Returns admin js translations.
134
+     *
135
+     */
136
+    protected function get_admin_i18() {
137 137
         global $post;
138 138
 
139
-		$date_range = array(
140
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
141
-		);
139
+        $date_range = array(
140
+            'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
141
+        );
142 142
 
143
-		if ( $date_range['period'] == 'custom' ) {
143
+        if ( $date_range['period'] == 'custom' ) {
144 144
 			
145
-			if ( isset( $_GET['from'] ) ) {
146
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
147
-			}
145
+            if ( isset( $_GET['from'] ) ) {
146
+                $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
147
+            }
148 148
 
149
-			if ( isset( $_GET['to'] ) ) {
150
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
151
-			}
149
+            if ( isset( $_GET['to'] ) ) {
150
+                $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
151
+            }
152 152
 
153
-		}
153
+        }
154 154
 
155 155
         $i18n = array(
156 156
             'ajax_url'                  => admin_url( 'admin-ajax.php' ),
157 157
             'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
158
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
159
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
160
-			'rest_root'                 => esc_url_raw( rest_url() ),
161
-			'date_range'                => $date_range,
158
+            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
159
+            'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
160
+            'rest_root'                 => esc_url_raw( rest_url() ),
161
+            'date_range'                => $date_range,
162 162
             'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
163 163
             'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
164 164
             'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
165 165
             'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
166 166
             'tax'                       => wpinv_tax_amount(),
167 167
             'discount'                  => 0,
168
-			'currency_symbol'           => wpinv_currency_symbol(),
169
-			'currency'                  => wpinv_get_currency(),
168
+            'currency_symbol'           => wpinv_currency_symbol(),
169
+            'currency'                  => wpinv_get_currency(),
170 170
             'currency_pos'              => wpinv_currency_position(),
171 171
             'thousand_sep'              => wpinv_thousands_separator(),
172 172
             'decimal_sep'               => wpinv_decimal_separator(),
@@ -186,118 +186,118 @@  discard block
 block discarded – undo
186 186
             'item_description'          => __( 'Item Description', 'invoicing' ),
187 187
             'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
188 188
             'discount_description'      => __( 'Discount Description', 'invoicing' ),
189
-			'searching'                 => __( 'Searching', 'invoicing' ),
190
-			'loading'                   => __( 'Loading...', 'invoicing' ),
191
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
192
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
189
+            'searching'                 => __( 'Searching', 'invoicing' ),
190
+            'loading'                   => __( 'Loading...', 'invoicing' ),
191
+            'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
192
+            'search_items'              => __( 'Enter item name', 'invoicing' ),
193 193
         );
194 194
 
195
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
195
+        if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
196 196
 
197
-			$invoice              = new WPInv_Invoice( $post );
198
-			$i18n['save_invoice'] = sprintf(
199
-				__( 'Save %s', 'invoicing' ),
200
-				ucfirst( $invoice->get_invoice_quote_type() )
201
-			);
197
+            $invoice              = new WPInv_Invoice( $post );
198
+            $i18n['save_invoice'] = sprintf(
199
+                __( 'Save %s', 'invoicing' ),
200
+                ucfirst( $invoice->get_invoice_quote_type() )
201
+            );
202 202
 
203
-			$i18n['invoice_description'] = sprintf(
204
-				__( '%s Description', 'invoicing' ),
205
-				ucfirst( $invoice->get_invoice_quote_type() )
206
-			);
203
+            $i18n['invoice_description'] = sprintf(
204
+                __( '%s Description', 'invoicing' ),
205
+                ucfirst( $invoice->get_invoice_quote_type() )
206
+            );
207 207
 
208
-		}
209
-		return $i18n;
210
-	}
208
+        }
209
+        return $i18n;
210
+    }
211 211
 
212
-	/**
213
-	 * Change the admin footer text on GetPaid admin pages.
214
-	 *
215
-	 * @since  2.0.0
216
-	 * @param  string $footer_text
217
-	 * @return string
218
-	 */
219
-	public function admin_footer_text( $footer_text ) {
220
-		global $current_screen;
212
+    /**
213
+     * Change the admin footer text on GetPaid admin pages.
214
+     *
215
+     * @since  2.0.0
216
+     * @param  string $footer_text
217
+     * @return string
218
+     */
219
+    public function admin_footer_text( $footer_text ) {
220
+        global $current_screen;
221 221
 
222
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
222
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
223 223
 
224 224
         if ( ! empty( $current_screen->post_type ) ) {
225
-			$page = $current_screen->post_type;
225
+            $page = $current_screen->post_type;
226 226
         }
227 227
 
228 228
         // General styles.
229 229
         if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
230 230
 
231
-			// Change the footer text
232
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
233
-
234
-				$rating_url  = esc_url(
235
-					wp_nonce_url(
236
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
237
-						'getpaid-nonce',
238
-						'getpaid-nonce'
239
-						)
240
-				);
241
-
242
-				$footer_text = sprintf(
243
-					/* translators: %s: five stars */
244
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
245
-					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
246
-				);
247
-
248
-			} else {
249
-
250
-				$footer_text = sprintf(
251
-					/* translators: %s: GetPaid */
252
-					__( 'Thank you for using %s!', 'invoicing' ),
253
-					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
254
-				);
255
-
256
-			}
257
-
258
-		}
259
-
260
-		return $footer_text;
261
-	}
262
-
263
-	/**
264
-	 * Redirects to wp.org to rate the plugin.
265
-	 *
266
-	 * @since  2.0.0
267
-	 */
268
-	public function redirect_to_wordpress_rating_page() {
269
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
270
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
271
-		exit;
272
-	}
273
-
274
-    /**
275
-	 * Loads payment form js.
276
-	 *
277
-	 */
278
-	protected function load_payment_form_scripts() {
231
+            // Change the footer text
232
+            if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
233
+
234
+                $rating_url  = esc_url(
235
+                    wp_nonce_url(
236
+                        admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
237
+                        'getpaid-nonce',
238
+                        'getpaid-nonce'
239
+                        )
240
+                );
241
+
242
+                $footer_text = sprintf(
243
+                    /* translators: %s: five stars */
244
+                    __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
245
+                    "<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
246
+                );
247
+
248
+            } else {
249
+
250
+                $footer_text = sprintf(
251
+                    /* translators: %s: GetPaid */
252
+                    __( 'Thank you for using %s!', 'invoicing' ),
253
+                    "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
254
+                );
255
+
256
+            }
257
+
258
+        }
259
+
260
+        return $footer_text;
261
+    }
262
+
263
+    /**
264
+     * Redirects to wp.org to rate the plugin.
265
+     *
266
+     * @since  2.0.0
267
+     */
268
+    public function redirect_to_wordpress_rating_page() {
269
+        update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
270
+        wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
271
+        exit;
272
+    }
273
+
274
+    /**
275
+     * Loads payment form js.
276
+     *
277
+     */
278
+    protected function load_payment_form_scripts() {
279 279
         global $post;
280 280
 
281 281
         wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION );
282
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
283
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
282
+        wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
283
+        wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
284 284
 
285
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
286
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ),  $version );
285
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
286
+        wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ),  $version );
287 287
 
288
-		wp_localize_script(
288
+        wp_localize_script(
289 289
             'wpinv-admin-payment-form-script',
290 290
             'wpinvPaymentFormAdmin',
291 291
             array(
292
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
293
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
294
-				'currency'      => wpinv_currency_symbol(),
295
-				'position'      => wpinv_currency_position(),
296
-				'decimals'      => (int) wpinv_decimals(),
297
-				'thousands_sep' => wpinv_thousands_separator(),
298
-				'decimals_sep'  => wpinv_decimal_separator(),
299
-				'form_items'    => gepaid_get_form_items( $post->ID ),
300
-				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
292
+                'elements'      => wpinv_get_data( 'payment-form-elements' ),
293
+                'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
294
+                'currency'      => wpinv_currency_symbol(),
295
+                'position'      => wpinv_currency_position(),
296
+                'decimals'      => (int) wpinv_decimals(),
297
+                'thousands_sep' => wpinv_thousands_separator(),
298
+                'decimals_sep'  => wpinv_decimal_separator(),
299
+                'form_items'    => gepaid_get_form_items( $post->ID ),
300
+                'is_default'    => $post->ID == wpinv_get_default_payment_form(),
301 301
             )
302 302
         );
303 303
 
@@ -306,20 +306,20 @@  discard block
 block discarded – undo
306 306
     }
307 307
 
308 308
     /**
309
-	 * Add our classes to admin pages.
309
+     * Add our classes to admin pages.
310 310
      *
311 311
      * @param string $classes
312 312
      * @return string
313
-	 *
314
-	 */
313
+     *
314
+     */
315 315
     public function admin_body_class( $classes ) {
316
-		global $pagenow, $post, $current_screen;
316
+        global $pagenow, $post, $current_screen;
317 317
 
318 318
 
319 319
         $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
320 320
 
321 321
         if ( ! empty( $current_screen->post_type ) ) {
322
-			$page = $current_screen->post_type;
322
+            $page = $current_screen->post_type;
323 323
         }
324 324
 
325 325
         if ( false !== stripos( $page, 'wpi' ) ) {
@@ -328,68 +328,68 @@  discard block
 block discarded – undo
328 328
 
329 329
         if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
330 330
             $classes .= ' wpinv-cpt wpinv';
331
-		}
331
+        }
332 332
 		
333
-		if ( getpaid_is_invoice_post_type( $page ) ) {
333
+        if ( getpaid_is_invoice_post_type( $page ) ) {
334 334
             $classes .= ' getpaid-is-invoice-cpt';
335 335
         }
336 336
 
337
-		return $classes;
337
+        return $classes;
338 338
     }
339 339
 
340 340
     /**
341
-	 * Maybe show the AyeCode Connect Notice.
342
-	 */
343
-	public function init_ayecode_connect_helper(){
341
+     * Maybe show the AyeCode Connect Notice.
342
+     */
343
+    public function init_ayecode_connect_helper(){
344 344
 
345
-		// Register with the deactivation survey class.
346
-		AyeCode_Deactivation_Survey::instance(array(
347
-			'slug'		        => 'invoicing',
348
-			'version'	        => WPINV_VERSION,
349
-			'support_url'       => 'https://wpgetpaid.com/support/',
350
-			'documentation_url' => 'https://docs.wpgetpaid.com/',
351
-			'activated'         => (int) get_option( 'gepaid_installed_on' ),
352
-		));
345
+        // Register with the deactivation survey class.
346
+        AyeCode_Deactivation_Survey::instance(array(
347
+            'slug'		        => 'invoicing',
348
+            'version'	        => WPINV_VERSION,
349
+            'support_url'       => 'https://wpgetpaid.com/support/',
350
+            'documentation_url' => 'https://docs.wpgetpaid.com/',
351
+            'activated'         => (int) get_option( 'gepaid_installed_on' ),
352
+        ));
353 353
 
354 354
         new AyeCode_Connect_Helper(
355 355
             array(
356
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
357
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
358
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
359
-				'connect_button'    => __("Connect Site","invoicing"),
360
-				'connecting_button'    => __("Connecting...","invoicing"),
361
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
362
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
356
+                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
357
+                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
358
+                'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
359
+                'connect_button'    => __("Connect Site","invoicing"),
360
+                'connecting_button'    => __("Connecting...","invoicing"),
361
+                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
362
+                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
363 363
             ),
364 364
             array( 'wpi-addons' )
365 365
         );
366 366
 
367 367
     }
368 368
 
369
-	/**
370
-	 * Redirect users to settings on activation.
371
-	 *
372
-	 * @return void
373
-	 */
374
-	public function activation_redirect() {
369
+    /**
370
+     * Redirect users to settings on activation.
371
+     *
372
+     * @return void
373
+     */
374
+    public function activation_redirect() {
375 375
 
376
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
376
+        $redirected = get_option( 'wpinv_redirected_to_settings' );
377 377
 
378
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
379
-			return;
380
-		}
378
+        if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
379
+            return;
380
+        }
381 381
 
382
-		// Bail if activating from network, or bulk
383
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
384
-			return;
385
-		}
382
+        // Bail if activating from network, or bulk
383
+        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
384
+            return;
385
+        }
386 386
 
387
-	    update_option( 'wpinv_redirected_to_settings', 1 );
387
+        update_option( 'wpinv_redirected_to_settings', 1 );
388 388
 
389 389
         wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );
390 390
         exit;
391 391
 
392
-	}
392
+    }
393 393
 
394 394
     /**
395 395
      * Fires an admin action after verifying that a user can fire them.
@@ -403,532 +403,532 @@  discard block
 block discarded – undo
403 403
 
404 404
     }
405 405
 
406
-	/**
406
+    /**
407 407
      * Duplicate invoice.
408
-	 * 
409
-	 * @param array $args
408
+     * 
409
+     * @param array $args
410 410
      */
411 411
     public function duplicate_invoice( $args ) {
412 412
 
413
-		if ( empty( $args['invoice_id'] ) ) {
414
-			return;
415
-		}
413
+        if ( empty( $args['invoice_id'] ) ) {
414
+            return;
415
+        }
416 416
 
417
-		$invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
417
+        $invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
418 418
 
419
-		if ( ! $invoice->exists() ) {
420
-			return;
421
-		}
419
+        if ( ! $invoice->exists() ) {
420
+            return;
421
+        }
422 422
 
423
-		$new_invoice = getpaid_duplicate_invoice( $invoice );
424
-		$new_invoice->save();
423
+        $new_invoice = getpaid_duplicate_invoice( $invoice );
424
+        $new_invoice->save();
425 425
 
426
-		if ( $new_invoice->exists() ) {
426
+        if ( $new_invoice->exists() ) {
427 427
 
428
-			getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'newsletter-optin-box' ) );
428
+            getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'newsletter-optin-box' ) );
429 429
 
430
-			wp_safe_redirect(
431
-				add_query_arg(
432
-					array(
433
-						'action' => 'edit',
434
-						'post' => $new_invoice->get_id(),
435
-					),
436
-					admin_url( 'post.php' )
437
-				)
438
-			);
439
-			exit;
430
+            wp_safe_redirect(
431
+                add_query_arg(
432
+                    array(
433
+                        'action' => 'edit',
434
+                        'post' => $new_invoice->get_id(),
435
+                    ),
436
+                    admin_url( 'post.php' )
437
+                )
438
+            );
439
+            exit;
440 440
 
441
-		}
441
+        }
442 442
 
443
-		getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box' ) );
443
+        getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box' ) );
444 444
 
445
-	}
445
+    }
446 446
 
447
-	/**
447
+    /**
448 448
      * Sends a payment reminder to a customer.
449
-	 * 
450
-	 * @param array $args
449
+     * 
450
+     * @param array $args
451 451
      */
452 452
     public function duplicate_payment_form( $args ) {
453 453
 
454
-		if ( empty( $args['form_id'] ) ) {
455
-			return;
456
-		}
457
-
458
-		$form = new GetPaid_Payment_Form( (int) $args['form_id'] );
454
+        if ( empty( $args['form_id'] ) ) {
455
+            return;
456
+        }
459 457
 
460
-		if ( ! $form->exists() ) {
461
-			return;
462
-		}
458
+        $form = new GetPaid_Payment_Form( (int) $args['form_id'] );
463 459
 
464
-		$new_form = new GetPaid_Payment_Form();
465
-		$new_form->set_author( $form->get_author( 'edit' ) );
466
-		$new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
467
-		$new_form->set_elements( $form->get_elements( 'edit' ) );
468
-		$new_form->set_items( $form->get_items( 'edit' ) );
469
-		$new_form->save();
460
+        if ( ! $form->exists() ) {
461
+            return;
462
+        }
470 463
 
471
-		if ( $new_form->exists() ) {
472
-			$this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
473
-			$url = get_edit_post_link( $new_form->get_id(), 'edit' );
474
-		} else {
475
-			$this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
476
-			$url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
477
-		}
464
+        $new_form = new GetPaid_Payment_Form();
465
+        $new_form->set_author( $form->get_author( 'edit' ) );
466
+        $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
467
+        $new_form->set_elements( $form->get_elements( 'edit' ) );
468
+        $new_form->set_items( $form->get_items( 'edit' ) );
469
+        $new_form->save();
470
+
471
+        if ( $new_form->exists() ) {
472
+            $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
473
+            $url = get_edit_post_link( $new_form->get_id(), 'edit' );
474
+        } else {
475
+            $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
476
+            $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
477
+        }
478 478
 
479
-		wp_redirect( $url );
480
-		exit;
481
-	}
479
+        wp_redirect( $url );
480
+        exit;
481
+    }
482 482
 
483
-	/**
483
+    /**
484 484
      * Sends a payment reminder to a customer.
485
-	 * 
486
-	 * @param array $args
485
+     * 
486
+     * @param array $args
487 487
      */
488 488
     public function send_customer_invoice( $args ) {
489
-		getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
490
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
491
-		exit;
492
-	}
489
+        getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
490
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
491
+        exit;
492
+    }
493 493
 
494
-	/**
494
+    /**
495 495
      * Sends a payment reminder to a customer.
496
-	 * 
497
-	 * @param array $args
496
+     * 
497
+     * @param array $args
498 498
      */
499 499
     public function send_customer_payment_reminder( $args ) {
500
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
500
+        $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
501 501
 
502
-		if ( $sent ) {
503
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
504
-		} else {
505
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
506
-		}
502
+        if ( $sent ) {
503
+            $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
504
+        } else {
505
+            $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
506
+        }
507 507
 
508
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
509
-		exit;
510
-	}
508
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
509
+        exit;
510
+    }
511 511
 
512
-	/**
512
+    /**
513 513
      * Resets tax rates.
514
-	 * 
514
+     * 
515 515
      */
516 516
     public function admin_reset_tax_rates() {
517 517
 
518
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
519
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
520
-		exit;
518
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
519
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
520
+        exit;
521 521
 
522
-	}
522
+    }
523 523
 
524
-	/**
524
+    /**
525 525
      * Resets admin pages.
526
-	 * 
526
+     * 
527 527
      */
528 528
     public function admin_create_missing_pages() {
529
-		$installer = new GetPaid_Installer();
530
-		$installer->create_pages();
531
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
532
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
533
-		exit;
534
-	}
535
-
536
-	/**
529
+        $installer = new GetPaid_Installer();
530
+        $installer->create_pages();
531
+        $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
532
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
533
+        exit;
534
+    }
535
+
536
+    /**
537 537
      * Creates an missing admin tables.
538
-	 * 
538
+     * 
539 539
      */
540 540
     public function admin_create_missing_tables() {
541
-		global $wpdb;
542
-		$installer = new GetPaid_Installer();
541
+        global $wpdb;
542
+        $installer = new GetPaid_Installer();
543 543
 
544
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
545
-			$installer->create_subscriptions_table();
544
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
545
+            $installer->create_subscriptions_table();
546 546
 
547
-			if ( $wpdb->last_error !== '' ) {
548
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
549
-			}
550
-		}
547
+            if ( $wpdb->last_error !== '' ) {
548
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
549
+            }
550
+        }
551 551
 
552
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
553
-			$installer->create_invoices_table();
552
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
553
+            $installer->create_invoices_table();
554 554
 
555
-			if ( $wpdb->last_error !== '' ) {
556
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
557
-			}
558
-		}
555
+            if ( $wpdb->last_error !== '' ) {
556
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
557
+            }
558
+        }
559 559
 
560
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
561
-			$installer->create_invoice_items_table();
560
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
561
+            $installer->create_invoice_items_table();
562 562
 
563
-			if ( $wpdb->last_error !== '' ) {
564
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
565
-			}
566
-		}
563
+            if ( $wpdb->last_error !== '' ) {
564
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
565
+            }
566
+        }
567 567
 
568
-		if ( ! $this->has_notices() ) {
569
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
570
-		}
568
+        if ( ! $this->has_notices() ) {
569
+            $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
570
+        }
571 571
 
572
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
573
-		exit;
574
-	}
572
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
573
+        exit;
574
+    }
575 575
 
576
-	/**
576
+    /**
577 577
      * Migrates old invoices to the new database tables.
578
-	 * 
578
+     * 
579 579
      */
580 580
     public function admin_migrate_old_invoices() {
581 581
 
582
-		// Migrate the invoices.
583
-		$installer = new GetPaid_Installer();
584
-		$installer->migrate_old_invoices();
582
+        // Migrate the invoices.
583
+        $installer = new GetPaid_Installer();
584
+        $installer->migrate_old_invoices();
585 585
 
586
-		// Show an admin message.
587
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
586
+        // Show an admin message.
587
+        $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
588 588
 
589
-		// Redirect the admin.
590
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
591
-		exit;
589
+        // Redirect the admin.
590
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
591
+        exit;
592 592
 
593
-	}
593
+    }
594 594
 
595
-	/**
595
+    /**
596 596
      * Download customers.
597
-	 * 
597
+     * 
598 598
      */
599 599
     public function admin_download_customers() {
600
-		global $wpdb;
600
+        global $wpdb;
601 601
 
602
-		$output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
602
+        $output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
603 603
 
604
-		header( "Content-Type:text/csv" );
605
-		header( "Content-Disposition:attachment;filename=customers.csv" );
604
+        header( "Content-Type:text/csv" );
605
+        header( "Content-Disposition:attachment;filename=customers.csv" );
606 606
 
607
-		$post_types = '';
607
+        $post_types = '';
608 608
 
609
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
610
-			$post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
611
-		}
609
+        foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
610
+            $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
611
+        }
612 612
 
613
-		$post_types = rtrim( $post_types, ' OR' );
613
+        $post_types = rtrim( $post_types, ' OR' );
614 614
 
615
-		$customers = $wpdb->get_col(
616
-			$wpdb->prepare(
617
-				"SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types"
618
-			)
619
-		);
615
+        $customers = $wpdb->get_col(
616
+            $wpdb->prepare(
617
+                "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types"
618
+            )
619
+        );
620 620
 
621
-		$columns = array(
622
-			'name'     => __( 'Name', 'invoicing' ),
623
-			'email'    => __( 'Email', 'invoicing' ),
624
-			'country'  => __( 'Country', 'invoicing' ),
625
-			'state'    => __( 'State', 'invoicing' ),
626
-			'city'     => __( 'City', 'invoicing' ),
627
-			'zip'      => __( 'ZIP', 'invoicing' ),
628
-			'address'  => __( 'Address', 'invoicing' ),
629
-			'phone'    => __( 'Phone', 'invoicing' ),
630
-			'company'  => __( 'Company', 'invoicing' ),
631
-			'company_id'  => __( 'Company ID', 'invoicing' ),
632
-			'invoices' => __( 'Invoices', 'invoicing' ),
633
-			'total_raw' => __( 'Total Spend', 'invoicing' ),
634
-			'signup'   => __( 'Date created', 'invoicing' ),
635
-		);
621
+        $columns = array(
622
+            'name'     => __( 'Name', 'invoicing' ),
623
+            'email'    => __( 'Email', 'invoicing' ),
624
+            'country'  => __( 'Country', 'invoicing' ),
625
+            'state'    => __( 'State', 'invoicing' ),
626
+            'city'     => __( 'City', 'invoicing' ),
627
+            'zip'      => __( 'ZIP', 'invoicing' ),
628
+            'address'  => __( 'Address', 'invoicing' ),
629
+            'phone'    => __( 'Phone', 'invoicing' ),
630
+            'company'  => __( 'Company', 'invoicing' ),
631
+            'company_id'  => __( 'Company ID', 'invoicing' ),
632
+            'invoices' => __( 'Invoices', 'invoicing' ),
633
+            'total_raw' => __( 'Total Spend', 'invoicing' ),
634
+            'signup'   => __( 'Date created', 'invoicing' ),
635
+        );
636 636
 
637
-		// Output the csv column headers.
638
-		fputcsv( $output, array_values( $columns ) );
637
+        // Output the csv column headers.
638
+        fputcsv( $output, array_values( $columns ) );
639 639
 
640
-		// Loop through
641
-		$table = new WPInv_Customers_Table();
642
-		foreach ( $customers as $customer_id ) {
640
+        // Loop through
641
+        $table = new WPInv_Customers_Table();
642
+        foreach ( $customers as $customer_id ) {
643 643
 
644
-			$user = get_user_by( 'id', $customer_id );
645
-			$row  = array();
646
-			if ( empty( $user ) ) {
647
-				continue;
648
-			}
644
+            $user = get_user_by( 'id', $customer_id );
645
+            $row  = array();
646
+            if ( empty( $user ) ) {
647
+                continue;
648
+            }
649 649
 
650
-			foreach ( array_keys( $columns ) as $column ) {
650
+            foreach ( array_keys( $columns ) as $column ) {
651 651
 
652
-				$method = 'column_' . $column;
652
+                $method = 'column_' . $column;
653 653
 
654
-				if ( 'name' == $column ) {
655
-					$value = esc_html( $user->display_name );
656
-				} else if( 'email' == $column ) {
657
-					$value = sanitize_email( $user->user_email );
658
-				} else if ( is_callable( array( $table, $method ) ) ) {
659
-					$value = strip_tags( $table->$method( $user ) );
660
-				}
654
+                if ( 'name' == $column ) {
655
+                    $value = esc_html( $user->display_name );
656
+                } else if( 'email' == $column ) {
657
+                    $value = sanitize_email( $user->user_email );
658
+                } else if ( is_callable( array( $table, $method ) ) ) {
659
+                    $value = strip_tags( $table->$method( $user ) );
660
+                }
661 661
 
662
-				if ( empty( $value ) ) {
663
-					$value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
664
-				}
662
+                if ( empty( $value ) ) {
663
+                    $value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
664
+                }
665 665
 
666
-				$row[] = $value;
666
+                $row[] = $value;
667 667
 
668
-			}
668
+            }
669 669
 
670
-			fputcsv( $output, $row );
671
-		}
670
+            fputcsv( $output, $row );
671
+        }
672 672
 
673
-		fclose( $output );
674
-		exit;
673
+        fclose( $output );
674
+        exit;
675 675
 
676
-	}
676
+    }
677 677
 
678
-	/**
678
+    /**
679 679
      * Installs a plugin.
680
-	 *
681
-	 * @param array $data
680
+     *
681
+     * @param array $data
682 682
      */
683 683
     public function admin_install_plugin( $data ) {
684 684
 
685
-		if ( ! empty( $data['plugins'] ) ) {
686
-			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
687
-			wp_cache_flush();
685
+        if ( ! empty( $data['plugins'] ) ) {
686
+            include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
687
+            wp_cache_flush();
688 688
 
689
-			foreach ( $data['plugins'] as $slug => $file ) {
690
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
691
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
692
-				$installed  = $upgrader->install( $plugin_zip );
689
+            foreach ( $data['plugins'] as $slug => $file ) {
690
+                $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
691
+                $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
692
+                $installed  = $upgrader->install( $plugin_zip );
693 693
 
694
-				if ( ! is_wp_error( $installed ) && $installed ) {
695
-					activate_plugin( $file, '', false, true );
696
-				} else {
697
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
698
-				}
694
+                if ( ! is_wp_error( $installed ) && $installed ) {
695
+                    activate_plugin( $file, '', false, true );
696
+                } else {
697
+                    wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
698
+                }
699 699
 
700
-			}
700
+            }
701 701
 
702
-		}
702
+        }
703 703
 
704
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
705
-		wp_safe_redirect( $redirect );
706
-		exit;
704
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
705
+        wp_safe_redirect( $redirect );
706
+        exit;
707 707
 
708
-	}
708
+    }
709 709
 
710
-	/**
710
+    /**
711 711
      * Connects a gateway.
712
-	 *
713
-	 * @param array $data
712
+     *
713
+     * @param array $data
714 714
      */
715 715
     public function admin_connect_gateway( $data ) {
716 716
 
717
-		if ( ! empty( $data['plugin'] ) ) {
717
+        if ( ! empty( $data['plugin'] ) ) {
718 718
 
719
-			$gateway     = sanitize_key( $data['plugin'] );
720
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
719
+            $gateway     = sanitize_key( $data['plugin'] );
720
+            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
721 721
 
722
-			if ( ! empty( $connect_url ) ) {
723
-				wp_redirect( $connect_url );
724
-				exit;
725
-			}
722
+            if ( ! empty( $connect_url ) ) {
723
+                wp_redirect( $connect_url );
724
+                exit;
725
+            }
726 726
 
727
-			if ( 'stripe' == $data['plugin'] ) {
728
-				require_once ABSPATH . 'wp-admin/includes/plugin.php';
729
-				include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
730
-				wp_cache_flush();
727
+            if ( 'stripe' == $data['plugin'] ) {
728
+                require_once ABSPATH . 'wp-admin/includes/plugin.php';
729
+                include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
730
+                wp_cache_flush();
731 731
 
732
-				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
733
-					$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
734
-					$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
735
-					$upgrader->install( $plugin_zip );
736
-				}
732
+                if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
733
+                    $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
734
+                    $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
735
+                    $upgrader->install( $plugin_zip );
736
+                }
737 737
 
738
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
739
-			}
738
+                activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
739
+            }
740 740
 
741
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
742
-			if ( ! empty( $connect_url ) ) {
743
-				wp_redirect( $connect_url );
744
-				exit;
745
-			}
741
+            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
742
+            if ( ! empty( $connect_url ) ) {
743
+                wp_redirect( $connect_url );
744
+                exit;
745
+            }
746 746
 
747
-		}
747
+        }
748 748
 
749
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
750
-		wp_safe_redirect( $redirect );
751
-		exit;
749
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
750
+        wp_safe_redirect( $redirect );
751
+        exit;
752 752
 
753
-	}
753
+    }
754 754
 
755
-	/**
755
+    /**
756 756
      * Recalculates discounts.
757
-	 * 
757
+     * 
758 758
      */
759 759
     public function admin_recalculate_discounts() {
760
-		global $wpdb;
760
+        global $wpdb;
761 761
 
762
-		// Fetch all invoices that have discount codes.
763
-		$table    = $wpdb->prefix . 'getpaid_invoices';
764
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
762
+        // Fetch all invoices that have discount codes.
763
+        $table    = $wpdb->prefix . 'getpaid_invoices';
764
+        $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
765 765
 
766
-		foreach ( $invoices as $invoice ) {
766
+        foreach ( $invoices as $invoice ) {
767 767
 
768
-			$invoice = new WPInv_Invoice( $invoice );
768
+            $invoice = new WPInv_Invoice( $invoice );
769 769
 
770
-			if ( ! $invoice->exists() ) {
771
-				continue;
772
-			}
770
+            if ( ! $invoice->exists() ) {
771
+                continue;
772
+            }
773 773
 
774
-			// Abort if the discount does not exist or does not apply here.
775
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
776
-			if ( ! $discount->exists() ) {
777
-				continue;
778
-			}
774
+            // Abort if the discount does not exist or does not apply here.
775
+            $discount = new WPInv_Discount( $invoice->get_discount_code() );
776
+            if ( ! $discount->exists() ) {
777
+                continue;
778
+            }
779 779
 
780
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
781
-			$invoice->recalculate_total();
780
+            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
781
+            $invoice->recalculate_total();
782 782
 
783
-			if ( $invoice->get_total_discount() > 0 ) {
784
-				$invoice->save();
785
-			}
783
+            if ( $invoice->get_total_discount() > 0 ) {
784
+                $invoice->save();
785
+            }
786 786
 
787
-		}
787
+        }
788 788
 
789
-		// Show an admin message.
790
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
789
+        // Show an admin message.
790
+        $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
791 791
 
792
-		// Redirect the admin.
793
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
794
-		exit;
792
+        // Redirect the admin.
793
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
794
+        exit;
795 795
 
796
-	}
796
+    }
797 797
 
798 798
     /**
799
-	 * Returns an array of admin notices.
800
-	 *
801
-	 * @since       1.0.19
799
+     * Returns an array of admin notices.
800
+     *
801
+     * @since       1.0.19
802 802
      * @return array
803
-	 */
804
-	public function get_notices() {
805
-		$notices = get_option( 'wpinv_admin_notices' );
803
+     */
804
+    public function get_notices() {
805
+        $notices = get_option( 'wpinv_admin_notices' );
806 806
         return is_array( $notices ) ? $notices : array();
807
-	}
807
+    }
808 808
 
809
-	/**
810
-	 * Checks if we have any admin notices.
811
-	 *
812
-	 * @since       2.0.4
809
+    /**
810
+     * Checks if we have any admin notices.
811
+     *
812
+     * @since       2.0.4
813 813
      * @return array
814
-	 */
815
-	public function has_notices() {
816
-		return count( $this->get_notices() ) > 0;
817
-	}
818
-
819
-	/**
820
-	 * Clears all admin notices
821
-	 *
822
-	 * @access      public
823
-	 * @since       1.0.19
824
-	 */
825
-	public function clear_notices() {
826
-		delete_option( 'wpinv_admin_notices' );
827
-	}
828
-
829
-	/**
830
-	 * Saves a new admin notice
831
-	 *
832
-	 * @access      public
833
-	 * @since       1.0.19
834
-	 */
835
-	public function save_notice( $type, $message ) {
836
-		$notices = $this->get_notices();
837
-
838
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
839
-			$notices[ $type ] = array();
840
-		}
841
-
842
-		$notices[ $type ][] = $message;
843
-
844
-		update_option( 'wpinv_admin_notices', $notices );
845
-	}
846
-
847
-	/**
848
-	 * Displays a success notice
849
-	 *
850
-	 * @param       string $msg The message to qeue.
851
-	 * @access      public
852
-	 * @since       1.0.19
853
-	 */
854
-	public function show_success( $msg ) {
855
-		$this->save_notice( 'success', $msg );
856
-	}
857
-
858
-	/**
859
-	 * Displays a error notice
860
-	 *
861
-	 * @access      public
862
-	 * @param       string $msg The message to qeue.
863
-	 * @since       1.0.19
864
-	 */
865
-	public function show_error( $msg ) {
866
-		$this->save_notice( 'error', $msg );
867
-	}
868
-
869
-	/**
870
-	 * Displays a warning notice
871
-	 *
872
-	 * @access      public
873
-	 * @param       string $msg The message to qeue.
874
-	 * @since       1.0.19
875
-	 */
876
-	public function show_warning( $msg ) {
877
-		$this->save_notice( 'warning', $msg );
878
-	}
879
-
880
-	/**
881
-	 * Displays a info notice
882
-	 *
883
-	 * @access      public
884
-	 * @param       string $msg The message to qeue.
885
-	 * @since       1.0.19
886
-	 */
887
-	public function show_info( $msg ) {
888
-		$this->save_notice( 'info', $msg );
889
-	}
890
-
891
-	/**
892
-	 * Show notices
893
-	 *
894
-	 * @access      public
895
-	 * @since       1.0.19
896
-	 */
897
-	public function show_notices() {
814
+     */
815
+    public function has_notices() {
816
+        return count( $this->get_notices() ) > 0;
817
+    }
818
+
819
+    /**
820
+     * Clears all admin notices
821
+     *
822
+     * @access      public
823
+     * @since       1.0.19
824
+     */
825
+    public function clear_notices() {
826
+        delete_option( 'wpinv_admin_notices' );
827
+    }
828
+
829
+    /**
830
+     * Saves a new admin notice
831
+     *
832
+     * @access      public
833
+     * @since       1.0.19
834
+     */
835
+    public function save_notice( $type, $message ) {
836
+        $notices = $this->get_notices();
837
+
838
+        if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
839
+            $notices[ $type ] = array();
840
+        }
841
+
842
+        $notices[ $type ][] = $message;
843
+
844
+        update_option( 'wpinv_admin_notices', $notices );
845
+    }
846
+
847
+    /**
848
+     * Displays a success notice
849
+     *
850
+     * @param       string $msg The message to qeue.
851
+     * @access      public
852
+     * @since       1.0.19
853
+     */
854
+    public function show_success( $msg ) {
855
+        $this->save_notice( 'success', $msg );
856
+    }
857
+
858
+    /**
859
+     * Displays a error notice
860
+     *
861
+     * @access      public
862
+     * @param       string $msg The message to qeue.
863
+     * @since       1.0.19
864
+     */
865
+    public function show_error( $msg ) {
866
+        $this->save_notice( 'error', $msg );
867
+    }
868
+
869
+    /**
870
+     * Displays a warning notice
871
+     *
872
+     * @access      public
873
+     * @param       string $msg The message to qeue.
874
+     * @since       1.0.19
875
+     */
876
+    public function show_warning( $msg ) {
877
+        $this->save_notice( 'warning', $msg );
878
+    }
879
+
880
+    /**
881
+     * Displays a info notice
882
+     *
883
+     * @access      public
884
+     * @param       string $msg The message to qeue.
885
+     * @since       1.0.19
886
+     */
887
+    public function show_info( $msg ) {
888
+        $this->save_notice( 'info', $msg );
889
+    }
890
+
891
+    /**
892
+     * Show notices
893
+     *
894
+     * @access      public
895
+     * @since       1.0.19
896
+     */
897
+    public function show_notices() {
898 898
 
899 899
         $notices = $this->get_notices();
900 900
         $this->clear_notices();
901 901
 
902
-		foreach ( $notices as $type => $messages ) {
902
+        foreach ( $notices as $type => $messages ) {
903 903
 
904
-			if ( ! is_array( $messages ) ) {
905
-				continue;
906
-			}
904
+            if ( ! is_array( $messages ) ) {
905
+                continue;
906
+            }
907 907
 
908 908
             $type  = sanitize_key( $type );
909
-			foreach ( $messages as $message ) {
909
+            foreach ( $messages as $message ) {
910 910
                 $message = wp_kses_post( $message );
911
-				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
911
+                echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
912 912
             }
913 913
 
914 914
         }
915 915
 
916
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
917
-
918
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
919
-				$url     = wp_nonce_url(
920
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
921
-					'getpaid-nonce',
922
-					'getpaid-nonce'
923
-				);
924
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
925
-				$message2 = __( 'Generate Pages', 'invoicing' );
926
-				echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
927
-				break;
928
-			}
916
+        foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
917
+
918
+            if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
919
+                $url     = wp_nonce_url(
920
+                    add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
921
+                    'getpaid-nonce',
922
+                    'getpaid-nonce'
923
+                );
924
+                $message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
925
+                $message2 = __( 'Generate Pages', 'invoicing' );
926
+                echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
927
+                break;
928
+            }
929 929
 
930
-		}
930
+        }
931 931
 
932
-	}
932
+    }
933 933
 
934 934
 }
Please login to merge, or discard this patch.
Spacing   +277 added lines, -277 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * The main admin class.
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
     /**
38 38
 	 * Class constructor.
39 39
 	 */
40
-	public function __construct(){
40
+	public function __construct() {
41 41
 
42
-        $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
42
+        $this->admin_path = plugin_dir_path(__FILE__);
43
+		$this->admin_url   = plugins_url('/', __FILE__);
44 44
 		$this->reports     = new GetPaid_Reports();
45 45
 
46
-        if ( is_admin() ) {
46
+        if (is_admin()) {
47 47
 			$this->init_admin_hooks();
48 48
         }
49 49
 
@@ -54,33 +54,33 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 */
56 56
 	private function init_admin_hooks() {
57
-        add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ), 9 );
58
-        add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59
-        add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60
-        add_action( 'admin_init', array( $this, 'activation_redirect') );
61
-        add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) );
66
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
67
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
68
-        add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
70
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
71
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
72
-		add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
73
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
74
-		add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
75
-		add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
76
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
77
-		do_action( 'getpaid_init_admin_hooks', $this );
57
+        add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'), 9);
58
+        add_filter('admin_body_class', array($this, 'admin_body_class'));
59
+        add_action('admin_init', array($this, 'init_ayecode_connect_helper'));
60
+        add_action('admin_init', array($this, 'activation_redirect'));
61
+        add_action('admin_init', array($this, 'maybe_do_admin_action'));
62
+		add_action('admin_notices', array($this, 'show_notices'));
63
+		add_action('getpaid_authenticated_admin_action_rate_plugin', array($this, 'redirect_to_wordpress_rating_page'));
64
+		add_action('getpaid_authenticated_admin_action_duplicate_form', array($this, 'duplicate_payment_form'));
65
+		add_action('getpaid_authenticated_admin_action_duplicate_invoice', array($this, 'duplicate_invoice'));
66
+		add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice'));
67
+		add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder'));
68
+        add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates'));
69
+		add_action('getpaid_authenticated_admin_action_create_missing_pages', array($this, 'admin_create_missing_pages'));
70
+		add_action('getpaid_authenticated_admin_action_create_missing_tables', array($this, 'admin_create_missing_tables'));
71
+		add_action('getpaid_authenticated_admin_action_migrate_old_invoices', array($this, 'admin_migrate_old_invoices'));
72
+		add_action('getpaid_authenticated_admin_action_download_customers', array($this, 'admin_download_customers'));
73
+		add_action('getpaid_authenticated_admin_action_recalculate_discounts', array($this, 'admin_recalculate_discounts'));
74
+		add_action('getpaid_authenticated_admin_action_install_plugin', array($this, 'admin_install_plugin'));
75
+		add_action('getpaid_authenticated_admin_action_connect_gateway', array($this, 'admin_connect_gateway'));
76
+		add_filter('admin_footer_text', array($this, 'admin_footer_text'));
77
+		do_action('getpaid_init_admin_hooks', $this);
78 78
 
79 79
 		// Setup/welcome
80
-		if ( ! empty( $_GET['page'] ) ) {
81
-			switch ( $_GET['page'] ) {
80
+		if (!empty($_GET['page'])) {
81
+			switch ($_GET['page']) {
82 82
 				case 'gp-setup' :
83
-					include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
83
+					include_once(dirname(__FILE__) . '/class-getpaid-admin-setup-wizard.php');
84 84
 					break;
85 85
 			}
86 86
 		}
@@ -94,37 +94,37 @@  discard block
 block discarded – undo
94 94
 	public function enqeue_scripts() {
95 95
         global $current_screen, $pagenow;
96 96
 
97
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
97
+		$page    = isset($_GET['page']) ? $_GET['page'] : '';
98 98
 		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
99 99
 
100
-        if ( ! empty( $current_screen->post_type ) ) {
100
+        if (!empty($current_screen->post_type)) {
101 101
 			$page = $current_screen->post_type;
102 102
         }
103 103
 
104 104
         // General styles.
105
-        if ( false !== stripos( $page, 'wpi' ) || false !== stripos( $page, 'getpaid' ) || 'gp-setup' == $page || 'geodir-tickets' == $page ) {
105
+        if (false !== stripos($page, 'wpi') || false !== stripos($page, 'getpaid') || 'gp-setup' == $page || 'geodir-tickets' == $page) {
106 106
 
107 107
             // Styles.
108
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
109
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
110
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
108
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
109
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
110
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
111 111
 
112 112
             // Scripts.
113
-            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
113
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
114 114
 
115
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
116
-            wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-tooltip' ),  $version );
117
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
115
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
116
+            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker', 'jquery-ui-tooltip'), $version);
117
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
118 118
 
119 119
         }
120 120
 
121 121
         // Payment form scripts.
122
-		if ( 'wpi_payment_form' == $page && $editing ) {
122
+		if ('wpi_payment_form' == $page && $editing) {
123 123
             $this->load_payment_form_scripts();
124 124
         }
125 125
 
126
-		if ( $page == 'wpinv-subscriptions' ) {
127
-			wp_enqueue_script( 'postbox' );
126
+		if ($page == 'wpinv-subscriptions') {
127
+			wp_enqueue_script('postbox');
128 128
 		}
129 129
 
130 130
     }
@@ -137,32 +137,32 @@  discard block
 block discarded – undo
137 137
         global $post;
138 138
 
139 139
 		$date_range = array(
140
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
140
+			'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days'
141 141
 		);
142 142
 
143
-		if ( $date_range['period'] == 'custom' ) {
143
+		if ($date_range['period'] == 'custom') {
144 144
 			
145
-			if ( isset( $_GET['from'] ) ) {
146
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
145
+			if (isset($_GET['from'])) {
146
+				$date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS);
147 147
 			}
148 148
 
149
-			if ( isset( $_GET['to'] ) ) {
150
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
149
+			if (isset($_GET['to'])) {
150
+				$date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS);
151 151
 			}
152 152
 
153 153
 		}
154 154
 
155 155
         $i18n = array(
156
-            'ajax_url'                  => admin_url( 'admin-ajax.php' ),
157
-            'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
158
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
159
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
160
-			'rest_root'                 => esc_url_raw( rest_url() ),
156
+            'ajax_url'                  => admin_url('admin-ajax.php'),
157
+            'post_ID'                   => isset($post->ID) ? $post->ID : '',
158
+			'wpinv_nonce'               => wp_create_nonce('wpinv-nonce'),
159
+			'rest_nonce'                => wp_create_nonce('wp_rest'),
160
+			'rest_root'                 => esc_url_raw(rest_url()),
161 161
 			'date_range'                => $date_range,
162
-            'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
163
-            'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
164
-            'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
165
-            'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
162
+            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'),
163
+            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'),
164
+            'invoice_item_nonce'        => wp_create_nonce('invoice-item'),
165
+            'billing_details_nonce'     => wp_create_nonce('get-billing-details'),
166 166
             'tax'                       => wpinv_tax_amount(),
167 167
             'discount'                  => 0,
168 168
 			'currency_symbol'           => wpinv_currency_symbol(),
@@ -171,38 +171,38 @@  discard block
 block discarded – undo
171 171
             'thousand_sep'              => wpinv_thousands_separator(),
172 172
             'decimal_sep'               => wpinv_decimal_separator(),
173 173
             'decimals'                  => wpinv_decimals(),
174
-            'save_invoice'              => __( 'Save Invoice', 'invoicing' ),
175
-            'status_publish'            => wpinv_status_nicename( 'publish' ),
176
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
177
-            'delete_tax_rate'           => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),
178
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
179
-            'FillBillingDetails'        => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),
180
-            'confirmCalcTotals'         => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ),
181
-            'AreYouSure'                => __( 'Are you sure?', 'invoicing' ),
182
-            'errDeleteItem'             => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),
183
-            'delete_subscription'       => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),
184
-            'action_edit'               => __( 'Edit', 'invoicing' ),
185
-            'action_cancel'             => __( 'Cancel', 'invoicing' ),
186
-            'item_description'          => __( 'Item Description', 'invoicing' ),
187
-            'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
188
-            'discount_description'      => __( 'Discount Description', 'invoicing' ),
189
-			'searching'                 => __( 'Searching', 'invoicing' ),
190
-			'loading'                   => __( 'Loading...', 'invoicing' ),
191
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
192
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
174
+            'save_invoice'              => __('Save Invoice', 'invoicing'),
175
+            'status_publish'            => wpinv_status_nicename('publish'),
176
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
177
+            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'),
178
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
179
+            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'),
180
+            'confirmCalcTotals'         => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'),
181
+            'AreYouSure'                => __('Are you sure?', 'invoicing'),
182
+            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'),
183
+            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'),
184
+            'action_edit'               => __('Edit', 'invoicing'),
185
+            'action_cancel'             => __('Cancel', 'invoicing'),
186
+            'item_description'          => __('Item Description', 'invoicing'),
187
+            'invoice_description'       => __('Invoice Description', 'invoicing'),
188
+            'discount_description'      => __('Discount Description', 'invoicing'),
189
+			'searching'                 => __('Searching', 'invoicing'),
190
+			'loading'                   => __('Loading...', 'invoicing'),
191
+			'search_customers'          => __('Enter customer name or email', 'invoicing'),
192
+			'search_items'              => __('Enter item name', 'invoicing'),
193 193
         );
194 194
 
195
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
195
+		if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) {
196 196
 
197
-			$invoice              = new WPInv_Invoice( $post );
197
+			$invoice              = new WPInv_Invoice($post);
198 198
 			$i18n['save_invoice'] = sprintf(
199
-				__( 'Save %s', 'invoicing' ),
200
-				ucfirst( $invoice->get_invoice_quote_type() )
199
+				__('Save %s', 'invoicing'),
200
+				ucfirst($invoice->get_invoice_quote_type())
201 201
 			);
202 202
 
203 203
 			$i18n['invoice_description'] = sprintf(
204
-				__( '%s Description', 'invoicing' ),
205
-				ucfirst( $invoice->get_invoice_quote_type() )
204
+				__('%s Description', 'invoicing'),
205
+				ucfirst($invoice->get_invoice_quote_type())
206 206
 			);
207 207
 
208 208
 		}
@@ -216,24 +216,24 @@  discard block
 block discarded – undo
216 216
 	 * @param  string $footer_text
217 217
 	 * @return string
218 218
 	 */
219
-	public function admin_footer_text( $footer_text ) {
219
+	public function admin_footer_text($footer_text) {
220 220
 		global $current_screen;
221 221
 
222
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
222
+		$page = isset($_GET['page']) ? $_GET['page'] : '';
223 223
 
224
-        if ( ! empty( $current_screen->post_type ) ) {
224
+        if (!empty($current_screen->post_type)) {
225 225
 			$page = $current_screen->post_type;
226 226
         }
227 227
 
228 228
         // General styles.
229
-        if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
229
+        if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) {
230 230
 
231 231
 			// Change the footer text
232
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
232
+			if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) {
233 233
 
234
-				$rating_url  = esc_url(
234
+				$rating_url = esc_url(
235 235
 					wp_nonce_url(
236
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
236
+						admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'),
237 237
 						'getpaid-nonce',
238 238
 						'getpaid-nonce'
239 239
 						)
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 
242 242
 				$footer_text = sprintf(
243 243
 					/* translators: %s: five stars */
244
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
244
+					__('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'),
245 245
 					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
246 246
 				);
247 247
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 
250 250
 				$footer_text = sprintf(
251 251
 					/* translators: %s: GetPaid */
252
-					__( 'Thank you for using %s!', 'invoicing' ),
252
+					__('Thank you for using %s!', 'invoicing'),
253 253
 					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
254 254
 				);
255 255
 
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
 	 * @since  2.0.0
267 267
 	 */
268 268
 	public function redirect_to_wordpress_rating_page() {
269
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
270
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
269
+		update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1);
270
+		wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post');
271 271
 		exit;
272 272
 	}
273 273
 
@@ -278,30 +278,30 @@  discard block
 block discarded – undo
278 278
 	protected function load_payment_form_scripts() {
279 279
         global $post;
280 280
 
281
-        wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION );
282
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
283
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
281
+        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION);
282
+		wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
283
+		wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
284 284
 
285
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
286
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ),  $version );
285
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
286
+		wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable', 'wp-hooks'), $version);
287 287
 
288 288
 		wp_localize_script(
289 289
             'wpinv-admin-payment-form-script',
290 290
             'wpinvPaymentFormAdmin',
291 291
             array(
292
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
293
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
292
+				'elements'      => wpinv_get_data('payment-form-elements'),
293
+				'form_elements' => getpaid_get_payment_form_elements($post->ID),
294 294
 				'currency'      => wpinv_currency_symbol(),
295 295
 				'position'      => wpinv_currency_position(),
296 296
 				'decimals'      => (int) wpinv_decimals(),
297 297
 				'thousands_sep' => wpinv_thousands_separator(),
298 298
 				'decimals_sep'  => wpinv_decimal_separator(),
299
-				'form_items'    => gepaid_get_form_items( $post->ID ),
299
+				'form_items'    => gepaid_get_form_items($post->ID),
300 300
 				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
301 301
             )
302 302
         );
303 303
 
304
-        wp_enqueue_script( 'wpinv-admin-payment-form-script' );
304
+        wp_enqueue_script('wpinv-admin-payment-form-script');
305 305
 
306 306
     }
307 307
 
@@ -312,25 +312,25 @@  discard block
 block discarded – undo
312 312
      * @return string
313 313
 	 *
314 314
 	 */
315
-    public function admin_body_class( $classes ) {
315
+    public function admin_body_class($classes) {
316 316
 		global $pagenow, $post, $current_screen;
317 317
 
318 318
 
319
-        $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
319
+        $page = isset($_GET['page']) ? $_GET['page'] : '';
320 320
 
321
-        if ( ! empty( $current_screen->post_type ) ) {
321
+        if (!empty($current_screen->post_type)) {
322 322
 			$page = $current_screen->post_type;
323 323
         }
324 324
 
325
-        if ( false !== stripos( $page, 'wpi' ) ) {
326
-            $classes .= ' wpi-' . sanitize_key( $page );
325
+        if (false !== stripos($page, 'wpi')) {
326
+            $classes .= ' wpi-' . sanitize_key($page);
327 327
         }
328 328
 
329
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
329
+        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) {
330 330
             $classes .= ' wpinv-cpt wpinv';
331 331
 		}
332 332
 		
333
-		if ( getpaid_is_invoice_post_type( $page ) ) {
333
+		if (getpaid_is_invoice_post_type($page)) {
334 334
             $classes .= ' getpaid-is-invoice-cpt';
335 335
         }
336 336
 
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
     /**
341 341
 	 * Maybe show the AyeCode Connect Notice.
342 342
 	 */
343
-	public function init_ayecode_connect_helper(){
343
+	public function init_ayecode_connect_helper() {
344 344
 
345 345
 		// Register with the deactivation survey class.
346 346
 		AyeCode_Deactivation_Survey::instance(array(
@@ -348,20 +348,20 @@  discard block
 block discarded – undo
348 348
 			'version'	        => WPINV_VERSION,
349 349
 			'support_url'       => 'https://wpgetpaid.com/support/',
350 350
 			'documentation_url' => 'https://docs.wpgetpaid.com/',
351
-			'activated'         => (int) get_option( 'gepaid_installed_on' ),
351
+			'activated'         => (int) get_option('gepaid_installed_on'),
352 352
 		));
353 353
 
354 354
         new AyeCode_Connect_Helper(
355 355
             array(
356
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
357
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
358
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
359
-				'connect_button'    => __("Connect Site","invoicing"),
360
-				'connecting_button'    => __("Connecting...","invoicing"),
361
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
362
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
356
+				'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
357
+				'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
358
+				'connect'           => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"),
359
+				'connect_button'    => __("Connect Site", "invoicing"),
360
+				'connecting_button'    => __("Connecting...", "invoicing"),
361
+				'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
362
+				'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
363 363
             ),
364
-            array( 'wpi-addons' )
364
+            array('wpi-addons')
365 365
         );
366 366
 
367 367
     }
@@ -373,20 +373,20 @@  discard block
 block discarded – undo
373 373
 	 */
374 374
 	public function activation_redirect() {
375 375
 
376
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
376
+		$redirected = get_option('wpinv_redirected_to_settings');
377 377
 
378
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
378
+		if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) {
379 379
 			return;
380 380
 		}
381 381
 
382 382
 		// Bail if activating from network, or bulk
383
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
383
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
384 384
 			return;
385 385
 		}
386 386
 
387
-	    update_option( 'wpinv_redirected_to_settings', 1 );
387
+	    update_option('wpinv_redirected_to_settings', 1);
388 388
 
389
-        wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );
389
+        wp_safe_redirect(admin_url('index.php?page=gp-setup'));
390 390
         exit;
391 391
 
392 392
 	}
@@ -396,9 +396,9 @@  discard block
 block discarded – undo
396 396
      */
397 397
     public function maybe_do_admin_action() {
398 398
 
399
-        if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
400
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
401
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
399
+        if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
400
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
401
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
402 402
         }
403 403
 
404 404
     }
@@ -408,24 +408,24 @@  discard block
 block discarded – undo
408 408
 	 * 
409 409
 	 * @param array $args
410 410
      */
411
-    public function duplicate_invoice( $args ) {
411
+    public function duplicate_invoice($args) {
412 412
 
413
-		if ( empty( $args['invoice_id'] ) ) {
413
+		if (empty($args['invoice_id'])) {
414 414
 			return;
415 415
 		}
416 416
 
417
-		$invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
417
+		$invoice = new WPInv_Invoice((int) $args['invoice_id']);
418 418
 
419
-		if ( ! $invoice->exists() ) {
419
+		if (!$invoice->exists()) {
420 420
 			return;
421 421
 		}
422 422
 
423
-		$new_invoice = getpaid_duplicate_invoice( $invoice );
423
+		$new_invoice = getpaid_duplicate_invoice($invoice);
424 424
 		$new_invoice->save();
425 425
 
426
-		if ( $new_invoice->exists() ) {
426
+		if ($new_invoice->exists()) {
427 427
 
428
-			getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'newsletter-optin-box' ) );
428
+			getpaid_admin()->show_success(__('Invoice duplicated successfully.', 'newsletter-optin-box'));
429 429
 
430 430
 			wp_safe_redirect(
431 431
 				add_query_arg(
@@ -433,14 +433,14 @@  discard block
 block discarded – undo
433 433
 						'action' => 'edit',
434 434
 						'post' => $new_invoice->get_id(),
435 435
 					),
436
-					admin_url( 'post.php' )
436
+					admin_url('post.php')
437 437
 				)
438 438
 			);
439 439
 			exit;
440 440
 
441 441
 		}
442 442
 
443
-		getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box' ) );
443
+		getpaid_admin()->show_error(__('There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box'));
444 444
 
445 445
 	}
446 446
 
@@ -449,34 +449,34 @@  discard block
 block discarded – undo
449 449
 	 * 
450 450
 	 * @param array $args
451 451
      */
452
-    public function duplicate_payment_form( $args ) {
452
+    public function duplicate_payment_form($args) {
453 453
 
454
-		if ( empty( $args['form_id'] ) ) {
454
+		if (empty($args['form_id'])) {
455 455
 			return;
456 456
 		}
457 457
 
458
-		$form = new GetPaid_Payment_Form( (int) $args['form_id'] );
458
+		$form = new GetPaid_Payment_Form((int) $args['form_id']);
459 459
 
460
-		if ( ! $form->exists() ) {
460
+		if (!$form->exists()) {
461 461
 			return;
462 462
 		}
463 463
 
464 464
 		$new_form = new GetPaid_Payment_Form();
465
-		$new_form->set_author( $form->get_author( 'edit' ) );
466
-		$new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
467
-		$new_form->set_elements( $form->get_elements( 'edit' ) );
468
-		$new_form->set_items( $form->get_items( 'edit' ) );
465
+		$new_form->set_author($form->get_author('edit'));
466
+		$new_form->set_name($form->get_name('edit') . __('(copy)', 'invoicing'));
467
+		$new_form->set_elements($form->get_elements('edit'));
468
+		$new_form->set_items($form->get_items('edit'));
469 469
 		$new_form->save();
470 470
 
471
-		if ( $new_form->exists() ) {
472
-			$this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
473
-			$url = get_edit_post_link( $new_form->get_id(), 'edit' );
471
+		if ($new_form->exists()) {
472
+			$this->show_success(__('Form duplicated successfully', 'invoicing'));
473
+			$url = get_edit_post_link($new_form->get_id(), 'edit');
474 474
 		} else {
475
-			$this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
476
-			$url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
475
+			$this->show_error(__('Unable to duplicate form', 'invoicing'));
476
+			$url = remove_query_arg(array('getpaid-admin-action', 'form_id', 'getpaid-nonce'));
477 477
 		}
478 478
 
479
-		wp_redirect( $url );
479
+		wp_redirect($url);
480 480
 		exit;
481 481
 	}
482 482
 
@@ -485,9 +485,9 @@  discard block
 block discarded – undo
485 485
 	 * 
486 486
 	 * @param array $args
487 487
      */
488
-    public function send_customer_invoice( $args ) {
489
-		getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
490
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
488
+    public function send_customer_invoice($args) {
489
+		getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']), true);
490
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
491 491
 		exit;
492 492
 	}
493 493
 
@@ -496,16 +496,16 @@  discard block
 block discarded – undo
496 496
 	 * 
497 497
 	 * @param array $args
498 498
      */
499
-    public function send_customer_payment_reminder( $args ) {
500
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
499
+    public function send_customer_payment_reminder($args) {
500
+		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id']));
501 501
 
502
-		if ( $sent ) {
503
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
502
+		if ($sent) {
503
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
504 504
 		} else {
505
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
505
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
506 506
 		}
507 507
 
508
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
508
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
509 509
 		exit;
510 510
 	}
511 511
 
@@ -515,8 +515,8 @@  discard block
 block discarded – undo
515 515
      */
516 516
     public function admin_reset_tax_rates() {
517 517
 
518
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
519
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
518
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
519
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
520 520
 		exit;
521 521
 
522 522
 	}
@@ -528,8 +528,8 @@  discard block
 block discarded – undo
528 528
     public function admin_create_missing_pages() {
529 529
 		$installer = new GetPaid_Installer();
530 530
 		$installer->create_pages();
531
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
532
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
531
+		$this->show_success(__('GetPaid pages updated.', 'invoicing'));
532
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
533 533
 		exit;
534 534
 	}
535 535
 
@@ -541,35 +541,35 @@  discard block
 block discarded – undo
541 541
 		global $wpdb;
542 542
 		$installer = new GetPaid_Installer();
543 543
 
544
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
544
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'") != $wpdb->prefix . 'wpinv_subscriptions') {
545 545
 			$installer->create_subscriptions_table();
546 546
 
547
-			if ( $wpdb->last_error !== '' ) {
548
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
547
+			if ($wpdb->last_error !== '') {
548
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
549 549
 			}
550 550
 		}
551 551
 
552
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
552
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'") != $wpdb->prefix . 'getpaid_invoices') {
553 553
 			$installer->create_invoices_table();
554 554
 
555
-			if ( $wpdb->last_error !== '' ) {
556
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
555
+			if ($wpdb->last_error !== '') {
556
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
557 557
 			}
558 558
 		}
559 559
 
560
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
560
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'") != $wpdb->prefix . 'getpaid_invoice_items') {
561 561
 			$installer->create_invoice_items_table();
562 562
 
563
-			if ( $wpdb->last_error !== '' ) {
564
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
563
+			if ($wpdb->last_error !== '') {
564
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
565 565
 			}
566 566
 		}
567 567
 
568
-		if ( ! $this->has_notices() ) {
569
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
568
+		if (!$this->has_notices()) {
569
+			$this->show_success(__('Your GetPaid tables have been updated.', 'invoicing'));
570 570
 		}
571 571
 
572
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
572
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
573 573
 		exit;
574 574
 	}
575 575
 
@@ -584,10 +584,10 @@  discard block
 block discarded – undo
584 584
 		$installer->migrate_old_invoices();
585 585
 
586 586
 		// Show an admin message.
587
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
587
+		$this->show_success(__('Your invoices have been migrated.', 'invoicing'));
588 588
 
589 589
 		// Redirect the admin.
590
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
590
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
591 591
 		exit;
592 592
 
593 593
 	}
@@ -599,18 +599,18 @@  discard block
 block discarded – undo
599 599
     public function admin_download_customers() {
600 600
 		global $wpdb;
601 601
 
602
-		$output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
602
+		$output = fopen('php://output', 'w') or die(__('Unsupported server', 'invoicing'));
603 603
 
604
-		header( "Content-Type:text/csv" );
605
-		header( "Content-Disposition:attachment;filename=customers.csv" );
604
+		header("Content-Type:text/csv");
605
+		header("Content-Disposition:attachment;filename=customers.csv");
606 606
 
607 607
 		$post_types = '';
608 608
 
609
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
610
-			$post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
609
+		foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) {
610
+			$post_types .= $wpdb->prepare("post_type=%s OR ", $post_type);
611 611
 		}
612 612
 
613
-		$post_types = rtrim( $post_types, ' OR' );
613
+		$post_types = rtrim($post_types, ' OR');
614 614
 
615 615
 		$customers = $wpdb->get_col(
616 616
 			$wpdb->prepare(
@@ -619,58 +619,58 @@  discard block
 block discarded – undo
619 619
 		);
620 620
 
621 621
 		$columns = array(
622
-			'name'     => __( 'Name', 'invoicing' ),
623
-			'email'    => __( 'Email', 'invoicing' ),
624
-			'country'  => __( 'Country', 'invoicing' ),
625
-			'state'    => __( 'State', 'invoicing' ),
626
-			'city'     => __( 'City', 'invoicing' ),
627
-			'zip'      => __( 'ZIP', 'invoicing' ),
628
-			'address'  => __( 'Address', 'invoicing' ),
629
-			'phone'    => __( 'Phone', 'invoicing' ),
630
-			'company'  => __( 'Company', 'invoicing' ),
631
-			'company_id'  => __( 'Company ID', 'invoicing' ),
632
-			'invoices' => __( 'Invoices', 'invoicing' ),
633
-			'total_raw' => __( 'Total Spend', 'invoicing' ),
634
-			'signup'   => __( 'Date created', 'invoicing' ),
622
+			'name'     => __('Name', 'invoicing'),
623
+			'email'    => __('Email', 'invoicing'),
624
+			'country'  => __('Country', 'invoicing'),
625
+			'state'    => __('State', 'invoicing'),
626
+			'city'     => __('City', 'invoicing'),
627
+			'zip'      => __('ZIP', 'invoicing'),
628
+			'address'  => __('Address', 'invoicing'),
629
+			'phone'    => __('Phone', 'invoicing'),
630
+			'company'  => __('Company', 'invoicing'),
631
+			'company_id'  => __('Company ID', 'invoicing'),
632
+			'invoices' => __('Invoices', 'invoicing'),
633
+			'total_raw' => __('Total Spend', 'invoicing'),
634
+			'signup'   => __('Date created', 'invoicing'),
635 635
 		);
636 636
 
637 637
 		// Output the csv column headers.
638
-		fputcsv( $output, array_values( $columns ) );
638
+		fputcsv($output, array_values($columns));
639 639
 
640 640
 		// Loop through
641 641
 		$table = new WPInv_Customers_Table();
642
-		foreach ( $customers as $customer_id ) {
642
+		foreach ($customers as $customer_id) {
643 643
 
644
-			$user = get_user_by( 'id', $customer_id );
644
+			$user = get_user_by('id', $customer_id);
645 645
 			$row  = array();
646
-			if ( empty( $user ) ) {
646
+			if (empty($user)) {
647 647
 				continue;
648 648
 			}
649 649
 
650
-			foreach ( array_keys( $columns ) as $column ) {
650
+			foreach (array_keys($columns) as $column) {
651 651
 
652 652
 				$method = 'column_' . $column;
653 653
 
654
-				if ( 'name' == $column ) {
655
-					$value = esc_html( $user->display_name );
656
-				} else if( 'email' == $column ) {
657
-					$value = sanitize_email( $user->user_email );
658
-				} else if ( is_callable( array( $table, $method ) ) ) {
659
-					$value = strip_tags( $table->$method( $user ) );
654
+				if ('name' == $column) {
655
+					$value = esc_html($user->display_name);
656
+				} else if ('email' == $column) {
657
+					$value = sanitize_email($user->user_email);
658
+				} else if (is_callable(array($table, $method))) {
659
+					$value = strip_tags($table->$method($user));
660 660
 				}
661 661
 
662
-				if ( empty( $value ) ) {
663
-					$value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
662
+				if (empty($value)) {
663
+					$value = esc_html(get_user_meta($user->ID, '_wpinv_' . $column, true));
664 664
 				}
665 665
 
666 666
 				$row[] = $value;
667 667
 
668 668
 			}
669 669
 
670
-			fputcsv( $output, $row );
670
+			fputcsv($output, $row);
671 671
 		}
672 672
 
673
-		fclose( $output );
673
+		fclose($output);
674 674
 		exit;
675 675
 
676 676
 	}
@@ -680,29 +680,29 @@  discard block
 block discarded – undo
680 680
 	 *
681 681
 	 * @param array $data
682 682
      */
683
-    public function admin_install_plugin( $data ) {
683
+    public function admin_install_plugin($data) {
684 684
 
685
-		if ( ! empty( $data['plugins'] ) ) {
685
+		if (!empty($data['plugins'])) {
686 686
 			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
687 687
 			wp_cache_flush();
688 688
 
689
-			foreach ( $data['plugins'] as $slug => $file ) {
690
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
691
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
692
-				$installed  = $upgrader->install( $plugin_zip );
689
+			foreach ($data['plugins'] as $slug => $file) {
690
+				$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip');
691
+				$upgrader   = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
692
+				$installed  = $upgrader->install($plugin_zip);
693 693
 
694
-				if ( ! is_wp_error( $installed ) && $installed ) {
695
-					activate_plugin( $file, '', false, true );
694
+				if (!is_wp_error($installed) && $installed) {
695
+					activate_plugin($file, '', false, true);
696 696
 				} else {
697
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
697
+					wpinv_error_log($upgrader->skin->get_upgrade_messages(), false);
698 698
 				}
699 699
 
700 700
 			}
701 701
 
702 702
 		}
703 703
 
704
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
705
-		wp_safe_redirect( $redirect );
704
+		$redirect = isset($data['redirect']) ? esc_url_raw($data['redirect']) : admin_url('plugins.php');
705
+		wp_safe_redirect($redirect);
706 706
 		exit;
707 707
 
708 708
 	}
@@ -712,42 +712,42 @@  discard block
 block discarded – undo
712 712
 	 *
713 713
 	 * @param array $data
714 714
      */
715
-    public function admin_connect_gateway( $data ) {
715
+    public function admin_connect_gateway($data) {
716 716
 
717
-		if ( ! empty( $data['plugin'] ) ) {
717
+		if (!empty($data['plugin'])) {
718 718
 
719
-			$gateway     = sanitize_key( $data['plugin'] );
720
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
719
+			$gateway     = sanitize_key($data['plugin']);
720
+			$connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data);
721 721
 
722
-			if ( ! empty( $connect_url ) ) {
723
-				wp_redirect( $connect_url );
722
+			if (!empty($connect_url)) {
723
+				wp_redirect($connect_url);
724 724
 				exit;
725 725
 			}
726 726
 
727
-			if ( 'stripe' == $data['plugin'] ) {
727
+			if ('stripe' == $data['plugin']) {
728 728
 				require_once ABSPATH . 'wp-admin/includes/plugin.php';
729 729
 				include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
730 730
 				wp_cache_flush();
731 731
 
732
-				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
733
-					$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
734
-					$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
735
-					$upgrader->install( $plugin_zip );
732
+				if (!array_key_exists('getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins())) {
733
+					$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip');
734
+					$upgrader   = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
735
+					$upgrader->install($plugin_zip);
736 736
 				}
737 737
 
738
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
738
+				activate_plugin('getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true);
739 739
 			}
740 740
 
741
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
742
-			if ( ! empty( $connect_url ) ) {
743
-				wp_redirect( $connect_url );
741
+			$connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data);
742
+			if (!empty($connect_url)) {
743
+				wp_redirect($connect_url);
744 744
 				exit;
745 745
 			}
746 746
 
747 747
 		}
748 748
 
749
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
750
-		wp_safe_redirect( $redirect );
749
+		$redirect = isset($data['redirect']) ? esc_url_raw(urldecode($data['redirect'])) : admin_url('admin.php?page=wpinv-settings&tab=gateways');
750
+		wp_safe_redirect($redirect);
751 751
 		exit;
752 752
 
753 753
 	}
@@ -761,36 +761,36 @@  discard block
 block discarded – undo
761 761
 
762 762
 		// Fetch all invoices that have discount codes.
763 763
 		$table    = $wpdb->prefix . 'getpaid_invoices';
764
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
764
+		$invoices = $wpdb->get_col("SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''");
765 765
 
766
-		foreach ( $invoices as $invoice ) {
766
+		foreach ($invoices as $invoice) {
767 767
 
768
-			$invoice = new WPInv_Invoice( $invoice );
768
+			$invoice = new WPInv_Invoice($invoice);
769 769
 
770
-			if ( ! $invoice->exists() ) {
770
+			if (!$invoice->exists()) {
771 771
 				continue;
772 772
 			}
773 773
 
774 774
 			// Abort if the discount does not exist or does not apply here.
775
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
776
-			if ( ! $discount->exists() ) {
775
+			$discount = new WPInv_Discount($invoice->get_discount_code());
776
+			if (!$discount->exists()) {
777 777
 				continue;
778 778
 			}
779 779
 
780
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
780
+			$invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
781 781
 			$invoice->recalculate_total();
782 782
 
783
-			if ( $invoice->get_total_discount() > 0 ) {
783
+			if ($invoice->get_total_discount() > 0) {
784 784
 				$invoice->save();
785 785
 			}
786 786
 
787 787
 		}
788 788
 
789 789
 		// Show an admin message.
790
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
790
+		$this->show_success(__('Discounts have been recalculated.', 'invoicing'));
791 791
 
792 792
 		// Redirect the admin.
793
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
793
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
794 794
 		exit;
795 795
 
796 796
 	}
@@ -802,8 +802,8 @@  discard block
 block discarded – undo
802 802
      * @return array
803 803
 	 */
804 804
 	public function get_notices() {
805
-		$notices = get_option( 'wpinv_admin_notices' );
806
-        return is_array( $notices ) ? $notices : array();
805
+		$notices = get_option('wpinv_admin_notices');
806
+        return is_array($notices) ? $notices : array();
807 807
 	}
808 808
 
809 809
 	/**
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
      * @return array
814 814
 	 */
815 815
 	public function has_notices() {
816
-		return count( $this->get_notices() ) > 0;
816
+		return count($this->get_notices()) > 0;
817 817
 	}
818 818
 
819 819
 	/**
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
 	 * @since       1.0.19
824 824
 	 */
825 825
 	public function clear_notices() {
826
-		delete_option( 'wpinv_admin_notices' );
826
+		delete_option('wpinv_admin_notices');
827 827
 	}
828 828
 
829 829
 	/**
@@ -832,16 +832,16 @@  discard block
 block discarded – undo
832 832
 	 * @access      public
833 833
 	 * @since       1.0.19
834 834
 	 */
835
-	public function save_notice( $type, $message ) {
835
+	public function save_notice($type, $message) {
836 836
 		$notices = $this->get_notices();
837 837
 
838
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
839
-			$notices[ $type ] = array();
838
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
839
+			$notices[$type] = array();
840 840
 		}
841 841
 
842
-		$notices[ $type ][] = $message;
842
+		$notices[$type][] = $message;
843 843
 
844
-		update_option( 'wpinv_admin_notices', $notices );
844
+		update_option('wpinv_admin_notices', $notices);
845 845
 	}
846 846
 
847 847
 	/**
@@ -851,8 +851,8 @@  discard block
 block discarded – undo
851 851
 	 * @access      public
852 852
 	 * @since       1.0.19
853 853
 	 */
854
-	public function show_success( $msg ) {
855
-		$this->save_notice( 'success', $msg );
854
+	public function show_success($msg) {
855
+		$this->save_notice('success', $msg);
856 856
 	}
857 857
 
858 858
 	/**
@@ -862,8 +862,8 @@  discard block
 block discarded – undo
862 862
 	 * @param       string $msg The message to qeue.
863 863
 	 * @since       1.0.19
864 864
 	 */
865
-	public function show_error( $msg ) {
866
-		$this->save_notice( 'error', $msg );
865
+	public function show_error($msg) {
866
+		$this->save_notice('error', $msg);
867 867
 	}
868 868
 
869 869
 	/**
@@ -873,8 +873,8 @@  discard block
 block discarded – undo
873 873
 	 * @param       string $msg The message to qeue.
874 874
 	 * @since       1.0.19
875 875
 	 */
876
-	public function show_warning( $msg ) {
877
-		$this->save_notice( 'warning', $msg );
876
+	public function show_warning($msg) {
877
+		$this->save_notice('warning', $msg);
878 878
 	}
879 879
 
880 880
 	/**
@@ -884,8 +884,8 @@  discard block
 block discarded – undo
884 884
 	 * @param       string $msg The message to qeue.
885 885
 	 * @since       1.0.19
886 886
 	 */
887
-	public function show_info( $msg ) {
888
-		$this->save_notice( 'info', $msg );
887
+	public function show_info($msg) {
888
+		$this->save_notice('info', $msg);
889 889
 	}
890 890
 
891 891
 	/**
@@ -899,30 +899,30 @@  discard block
 block discarded – undo
899 899
         $notices = $this->get_notices();
900 900
         $this->clear_notices();
901 901
 
902
-		foreach ( $notices as $type => $messages ) {
902
+		foreach ($notices as $type => $messages) {
903 903
 
904
-			if ( ! is_array( $messages ) ) {
904
+			if (!is_array($messages)) {
905 905
 				continue;
906 906
 			}
907 907
 
908
-            $type  = sanitize_key( $type );
909
-			foreach ( $messages as $message ) {
910
-                $message = wp_kses_post( $message );
908
+            $type = sanitize_key($type);
909
+			foreach ($messages as $message) {
910
+                $message = wp_kses_post($message);
911 911
 				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
912 912
             }
913 913
 
914 914
         }
915 915
 
916
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
916
+		foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) {
917 917
 
918
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
919
-				$url     = wp_nonce_url(
920
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
918
+			if (!is_numeric(wpinv_get_option($page, false))) {
919
+				$url = wp_nonce_url(
920
+					add_query_arg('getpaid-admin-action', 'create_missing_pages'),
921 921
 					'getpaid-nonce',
922 922
 					'getpaid-nonce'
923 923
 				);
924
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
925
-				$message2 = __( 'Generate Pages', 'invoicing' );
924
+				$message  = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing');
925
+				$message2 = __('Generate Pages', 'invoicing');
926 926
 				echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
927 927
 				break;
928 928
 			}
Please login to merge, or discard this patch.
invoicing.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,16 +19,16 @@  discard block
 block discarded – undo
19 19
 
20 20
 // Define constants.
21 21
 if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) {
22
-	define( 'WPINV_PLUGIN_FILE', __FILE__ );
22
+    define( 'WPINV_PLUGIN_FILE', __FILE__ );
23 23
 }
24 24
 
25 25
 if ( ! defined( 'WPINV_VERSION' ) ) {
26
-	define( 'WPINV_VERSION', '2.6.0' );
26
+    define( 'WPINV_VERSION', '2.6.0' );
27 27
 }
28 28
 
29 29
 // Include the main Invoicing class.
30 30
 if ( ! class_exists( 'WPInv_Plugin', false ) ) {
31
-	require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
31
+    require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
32 32
 }
33 33
 
34 34
 /**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         $GLOBALS['invoicing'] = new WPInv_Plugin();
44 44
     }
45 45
 
46
-	return $GLOBALS['invoicing'];
46
+    return $GLOBALS['invoicing'];
47 47
 }
48 48
 
49 49
 /**
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -15,20 +15,20 @@  discard block
 block discarded – undo
15 15
  * @package GetPaid
16 16
  */
17 17
 
18
-defined( 'ABSPATH' ) || exit;
18
+defined('ABSPATH') || exit;
19 19
 
20 20
 // Define constants.
21
-if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) {
22
-	define( 'WPINV_PLUGIN_FILE', __FILE__ );
21
+if (!defined('WPINV_PLUGIN_FILE')) {
22
+	define('WPINV_PLUGIN_FILE', __FILE__);
23 23
 }
24 24
 
25
-if ( ! defined( 'WPINV_VERSION' ) ) {
26
-	define( 'WPINV_VERSION', '2.6.0' );
25
+if (!defined('WPINV_VERSION')) {
26
+	define('WPINV_VERSION', '2.6.0');
27 27
 }
28 28
 
29 29
 // Include the main Invoicing class.
30
-if ( ! class_exists( 'WPInv_Plugin', false ) ) {
31
-	require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
30
+if (!class_exists('WPInv_Plugin', false)) {
31
+	require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/class-wpinv.php';
32 32
 }
33 33
 
34 34
 /**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  */
40 40
 function getpaid() {
41 41
 
42
-    if ( empty( $GLOBALS['invoicing'] ) ) {
42
+    if (empty($GLOBALS['invoicing'])) {
43 43
         $GLOBALS['invoicing'] = new WPInv_Plugin();
44 44
     }
45 45
 
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
  * @since  2.0.8
53 53
  */
54 54
 function getpaid_deactivation_hook() {
55
-    update_option( 'wpinv_flush_permalinks', 1 );
55
+    update_option('wpinv_flush_permalinks', 1);
56 56
 }
57
-register_deactivation_hook( __FILE__, 'getpaid_deactivation_hook' );
57
+register_deactivation_hook(__FILE__, 'getpaid_deactivation_hook');
58 58
 
59 59
 /**
60 60
  * @deprecated
@@ -64,4 +64,4 @@  discard block
 block discarded – undo
64 64
 }
65 65
 
66 66
 // Kickstart the plugin.
67
-add_action( 'plugins_loaded', 'getpaid', -100 );
67
+add_action('plugins_loaded', 'getpaid', -100);
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,40 +7,40 @@
 block discarded – undo
7 7
  * Bail if we are not in WP.
8 8
  */
9 9
 if ( ! defined( 'ABSPATH' ) ) {
10
-	exit;
10
+    exit;
11 11
 }
12 12
 
13 13
 /**
14 14
  * Set the version only if its the current newest while loading.
15 15
  */
16 16
 add_action('after_setup_theme', function () {
17
-	global $ayecode_ui_version,$ayecode_ui_file_key;
18
-	$this_version = "0.1.65";
19
-	if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){
20
-		$ayecode_ui_version = $this_version ;
21
-		$ayecode_ui_file_key = wp_hash( __FILE__ );
22
-	}
17
+    global $ayecode_ui_version,$ayecode_ui_file_key;
18
+    $this_version = "0.1.65";
19
+    if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){
20
+        $ayecode_ui_version = $this_version ;
21
+        $ayecode_ui_file_key = wp_hash( __FILE__ );
22
+    }
23 23
 },0);
24 24
 
25 25
 /**
26 26
  * Load this version of WP Bootstrap Settings only if the file hash is the current one.
27 27
  */
28 28
 add_action('after_setup_theme', function () {
29
-	global $ayecode_ui_file_key;
30
-	if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
-		include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
-		include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
33
-	}
29
+    global $ayecode_ui_file_key;
30
+    if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
+        include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
+        include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
33
+    }
34 34
 },1);
35 35
 
36 36
 /**
37 37
  * Add the function that calls the class.
38 38
  */
39 39
 if(!function_exists('aui')){
40
-	function aui(){
41
-		if(!class_exists("AUI",false)){
42
-			return false;
43
-		}
44
-		return AUI::instance();
45
-	}
40
+    function aui(){
41
+        if(!class_exists("AUI",false)){
42
+            return false;
43
+        }
44
+        return AUI::instance();
45
+    }
46 46
 }
47 47
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -6,39 +6,39 @@
 block discarded – undo
6 6
 /**
7 7
  * Bail if we are not in WP.
8 8
  */
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if (!defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
13 13
 /**
14 14
  * Set the version only if its the current newest while loading.
15 15
  */
16
-add_action('after_setup_theme', function () {
17
-	global $ayecode_ui_version,$ayecode_ui_file_key;
16
+add_action('after_setup_theme', function() {
17
+	global $ayecode_ui_version, $ayecode_ui_file_key;
18 18
 	$this_version = "0.1.65";
19
-	if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){
20
-		$ayecode_ui_version = $this_version ;
21
-		$ayecode_ui_file_key = wp_hash( __FILE__ );
19
+	if (empty($ayecode_ui_version) || version_compare($this_version, $ayecode_ui_version, '>')) {
20
+		$ayecode_ui_version = $this_version;
21
+		$ayecode_ui_file_key = wp_hash(__FILE__);
22 22
 	}
23 23
 },0);
24 24
 
25 25
 /**
26 26
  * Load this version of WP Bootstrap Settings only if the file hash is the current one.
27 27
  */
28
-add_action('after_setup_theme', function () {
28
+add_action('after_setup_theme', function() {
29 29
 	global $ayecode_ui_file_key;
30
-	if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
-		include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
-		include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
30
+	if ($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash(__FILE__)) {
31
+		include_once(dirname(__FILE__) . '/includes/class-aui.php');
32
+		include_once(dirname(__FILE__) . '/includes/ayecode-ui-settings.php');
33 33
 	}
34 34
 },1);
35 35
 
36 36
 /**
37 37
  * Add the function that calls the class.
38 38
  */
39
-if(!function_exists('aui')){
40
-	function aui(){
41
-		if(!class_exists("AUI",false)){
39
+if (!function_exists('aui')) {
40
+	function aui() {
41
+		if (!class_exists("AUI", false)) {
42 42
 			return false;
43 43
 		}
44 44
 		return AUI::instance();
Please login to merge, or discard this patch.