Passed
Push — master ( 3d88bf...f3309e )
by Brian
05:31
created
includes/class-getpaid-invoice-notification-emails.php 2 patches
Indentation   +389 added lines, -389 removed lines patch added patch discarded remove patch
@@ -12,443 +12,443 @@
 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
-		return 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}'       => wpinv_price( wpinv_format_amount( $invoice->get_total() ) ),
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( $invoice->get_type() ),
144
-			'{invoice_label}'       => sanitize_text_field( ucfirst( $invoice->get_type() ) ),
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
-	}
151
-
152
-	/**
153
-	 * Helper function to send an email.
154
-	 *
155
-	 * @param WPInv_Invoice $invoice
156
-	 * @param GetPaid_Notification_Email $email
157
-	 * @param string $type
158
-	 * @param string|array $recipients
159
-	 * @param array $extra_args Extra template args.
160
-	 */
161
-	public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) {
162
-
163
-		do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email );
164
-
165
-		$mailer     = new GetPaid_Notification_Email_Sender();
166
-		$merge_tags = $email->get_merge_tags();
167
-
168
-		$result = $mailer->send(
169
-			apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ),
170
-			$email->add_merge_tags( $email->get_subject(), $merge_tags ),
171
-			$email->get_content( $merge_tags, $extra_args ),
172
-			$email->get_attachments()
173
-		);
174
-
175
-		// Maybe send a copy to the admin.
176
-		if ( $email->include_admin_bcc() ) {
177
-			$mailer->send(
178
-				wpinv_get_admin_email(),
179
-				$email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ),
180
-				$email->get_content( $merge_tags ),
181
-				$email->get_attachments()
182
-			);
183
-		}
184
-
185
-		if ( ! $result ) {
186
-			$invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true );
187
-		}
188
-
189
-		do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email );
190
-
191
-		return $result;
192
-	}
193
-
194
-	/**
195
-	 * Also send emails to any cc users.
196
-	 *
197
-	 * @param array $recipients
198
-	 * @param GetPaid_Notification_Email $email
199
-	 */
200
-	public function filter_email_recipients( $recipients, $email ) {
201
-
202
-		if ( ! $email->is_admin_email() ) {
203
-			$cc = $email->object->get_email_cc();
204
-
205
-			if ( ! empty( $cc ) ) {
206
-				$cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
207
-				$recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
208
-			}
209
-
210
-		}
211
-
212
-		return $recipients;
213
-
214
-	}
215
-
216
-	/**
217
-	 * Sends a new invoice notification.
218
-	 *
219
-	 * @param WPInv_Invoice $invoice
220
-	 */
221
-	public function new_invoice( $invoice ) {
222
-
223
-		// Only send this email for invoices created via the admin page.
224
-		if ( ! $invoice->is_type( 'invoice' ) || $this->is_payment_form_invoice( $invoice->get_id() ) ) {
225
-			return;
226
-		}
227
-
228
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
229
-		$recipient = wpinv_get_admin_email();
230
-
231
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
232
-
233
-	}
234
-
235
-	/**
236
-	 * Sends a cancelled invoice notification.
237
-	 *
238
-	 * @param WPInv_Invoice $invoice
239
-	 */
240
-	public function cancelled_invoice( $invoice ) {
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
+        return 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}'       => wpinv_price( wpinv_format_amount( $invoice->get_total() ) ),
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( $invoice->get_type() ),
144
+            '{invoice_label}'       => sanitize_text_field( ucfirst( $invoice->get_type() ) ),
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
+    }
151
+
152
+    /**
153
+     * Helper function to send an email.
154
+     *
155
+     * @param WPInv_Invoice $invoice
156
+     * @param GetPaid_Notification_Email $email
157
+     * @param string $type
158
+     * @param string|array $recipients
159
+     * @param array $extra_args Extra template args.
160
+     */
161
+    public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) {
162
+
163
+        do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email );
164
+
165
+        $mailer     = new GetPaid_Notification_Email_Sender();
166
+        $merge_tags = $email->get_merge_tags();
167
+
168
+        $result = $mailer->send(
169
+            apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ),
170
+            $email->add_merge_tags( $email->get_subject(), $merge_tags ),
171
+            $email->get_content( $merge_tags, $extra_args ),
172
+            $email->get_attachments()
173
+        );
174
+
175
+        // Maybe send a copy to the admin.
176
+        if ( $email->include_admin_bcc() ) {
177
+            $mailer->send(
178
+                wpinv_get_admin_email(),
179
+                $email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ),
180
+                $email->get_content( $merge_tags ),
181
+                $email->get_attachments()
182
+            );
183
+        }
184
+
185
+        if ( ! $result ) {
186
+            $invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true );
187
+        }
188
+
189
+        do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email );
190
+
191
+        return $result;
192
+    }
193
+
194
+    /**
195
+     * Also send emails to any cc users.
196
+     *
197
+     * @param array $recipients
198
+     * @param GetPaid_Notification_Email $email
199
+     */
200
+    public function filter_email_recipients( $recipients, $email ) {
201
+
202
+        if ( ! $email->is_admin_email() ) {
203
+            $cc = $email->object->get_email_cc();
204
+
205
+            if ( ! empty( $cc ) ) {
206
+                $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
207
+                $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
208
+            }
209
+
210
+        }
211
+
212
+        return $recipients;
213
+
214
+    }
215
+
216
+    /**
217
+     * Sends a new invoice notification.
218
+     *
219
+     * @param WPInv_Invoice $invoice
220
+     */
221
+    public function new_invoice( $invoice ) {
222
+
223
+        // Only send this email for invoices created via the admin page.
224
+        if ( ! $invoice->is_type( 'invoice' ) || $this->is_payment_form_invoice( $invoice->get_id() ) ) {
225
+            return;
226
+        }
227
+
228
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
229
+        $recipient = wpinv_get_admin_email();
230
+
231
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
232
+
233
+    }
234
+
235
+    /**
236
+     * Sends a cancelled invoice notification.
237
+     *
238
+     * @param WPInv_Invoice $invoice
239
+     */
240
+    public function cancelled_invoice( $invoice ) {
241 241
 
242
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
243
-		$recipient = wpinv_get_admin_email();
242
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
243
+        $recipient = wpinv_get_admin_email();
244 244
 
245
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
245
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
246 246
 
247
-	}
247
+    }
248 248
 
249
-	/**
250
-	 * Sends a failed invoice notification.
251
-	 *
252
-	 * @param WPInv_Invoice $invoice
253
-	 */
254
-	public function failed_invoice( $invoice ) {
249
+    /**
250
+     * Sends a failed invoice notification.
251
+     *
252
+     * @param WPInv_Invoice $invoice
253
+     */
254
+    public function failed_invoice( $invoice ) {
255 255
 
256
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
257
-		$recipient = wpinv_get_admin_email();
256
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
257
+        $recipient = wpinv_get_admin_email();
258 258
 
259
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
259
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
260 260
 
261
-	}
261
+    }
262 262
 
263
-	/**
264
-	 * Sends a notification whenever an invoice is put on hold.
265
-	 *
266
-	 * @param WPInv_Invoice $invoice
267
-	 */
268
-	public function onhold_invoice( $invoice ) {
263
+    /**
264
+     * Sends a notification whenever an invoice is put on hold.
265
+     *
266
+     * @param WPInv_Invoice $invoice
267
+     */
268
+    public function onhold_invoice( $invoice ) {
269 269
 
270
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
271
-		$recipient = $invoice->get_email();
270
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
271
+        $recipient = $invoice->get_email();
272 272
 
273
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
273
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
274 274
 
275
-	}
275
+    }
276 276
 
277
-	/**
278
-	 * Sends a notification whenever an invoice is marked as processing payment.
279
-	 *
280
-	 * @param WPInv_Invoice $invoice
281
-	 */
282
-	public function processing_invoice( $invoice ) {
277
+    /**
278
+     * Sends a notification whenever an invoice is marked as processing payment.
279
+     *
280
+     * @param WPInv_Invoice $invoice
281
+     */
282
+    public function processing_invoice( $invoice ) {
283 283
 
284
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
285
-		$recipient = $invoice->get_email();
284
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
285
+        $recipient = $invoice->get_email();
286 286
 
287
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
287
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
288 288
 
289
-	}
289
+    }
290 290
 
291
-	/**
292
-	 * Sends a notification whenever an invoice is paid.
293
-	 *
294
-	 * @param WPInv_Invoice $invoice
295
-	 */
296
-	public function completed_invoice( $invoice ) {
291
+    /**
292
+     * Sends a notification whenever an invoice is paid.
293
+     *
294
+     * @param WPInv_Invoice $invoice
295
+     */
296
+    public function completed_invoice( $invoice ) {
297 297
 
298
-		// (Maybe) abort if it is a renewal invoice.
299
-		if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) {
300
-			return;
301
-		}
298
+        // (Maybe) abort if it is a renewal invoice.
299
+        if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) {
300
+            return;
301
+        }
302 302
 
303
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
304
-		$recipient = $invoice->get_email();
303
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
304
+        $recipient = $invoice->get_email();
305 305
 
306
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
306
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
307 307
 
308
-	}
308
+    }
309 309
 
310
-	/**
311
-	 * Sends a notification whenever an invoice is refunded.
312
-	 *
313
-	 * @param WPInv_Invoice $invoice
314
-	 */
315
-	public function refunded_invoice( $invoice ) {
310
+    /**
311
+     * Sends a notification whenever an invoice is refunded.
312
+     *
313
+     * @param WPInv_Invoice $invoice
314
+     */
315
+    public function refunded_invoice( $invoice ) {
316 316
 
317
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
318
-		$recipient = $invoice->get_email();
317
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
318
+        $recipient = $invoice->get_email();
319 319
 
320
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
320
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
321 321
 
322
-	}
322
+    }
323 323
 
324
-	/**
325
-	 * Notifies a user about new invoices
326
-	 *
327
-	 * @param WPInv_Invoice $invoice
328
-	 */
329
-	public function user_invoice( $invoice ) {
324
+    /**
325
+     * Notifies a user about new invoices
326
+     *
327
+     * @param WPInv_Invoice $invoice
328
+     */
329
+    public function user_invoice( $invoice ) {
330 330
 
331
-		// Only send this email for invoices created via the admin page.
332
-		if ( ! $invoice->is_type( 'invoice' ) || $this->is_payment_form_invoice( $invoice->get_id() ) ) {
333
-			return;
334
-		}
331
+        // Only send this email for invoices created via the admin page.
332
+        if ( ! $invoice->is_type( 'invoice' ) || $this->is_payment_form_invoice( $invoice->get_id() ) ) {
333
+            return;
334
+        }
335 335
 
336
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
337
-		$recipient = $invoice->get_email();
336
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
337
+        $recipient = $invoice->get_email();
338 338
 
339
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
339
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
340 340
 
341
-	}
341
+    }
342 342
 
343
-	/**
344
-	 * Checks if an invoice is a payment form invoice.
345
-	 *
346
-	 * @param int $invoice
347
-	 * @return bool
348
-	 */
349
-	public function is_payment_form_invoice( $invoice ) {
350
-		return empty( $_GET['getpaid-admin-action'] ) && 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true );
351
-	}
343
+    /**
344
+     * Checks if an invoice is a payment form invoice.
345
+     *
346
+     * @param int $invoice
347
+     * @return bool
348
+     */
349
+    public function is_payment_form_invoice( $invoice ) {
350
+        return empty( $_GET['getpaid-admin-action'] ) && 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true );
351
+    }
352 352
 
353
-	/**
354
-	 * Notifies admin about new invoice notes
355
-	 *
356
-	 * @param WPInv_Invoice $invoice
357
-	 * @param string $note
358
-	 */
359
-	public function user_note( $invoice, $note ) {
353
+    /**
354
+     * Notifies admin about new invoice notes
355
+     *
356
+     * @param WPInv_Invoice $invoice
357
+     * @param string $note
358
+     */
359
+    public function user_note( $invoice, $note ) {
360 360
 
361
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
362
-		$recipient = $invoice->get_email();
363
-
364
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) );
365
-
366
-	}
361
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
362
+        $recipient = $invoice->get_email();
363
+
364
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) );
365
+
366
+    }
367 367
 
368
-	/**
369
-	 * (Force) Sends overdue notices.
370
-	 *
371
-	 * @param WPInv_Invoice $invoice
372
-	 */
373
-	public function force_send_overdue_notice( $invoice ) {
374
-		$email = new GetPaid_Notification_Email( 'overdue', $invoice );
375
-		return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() );
376
-	}
377
-
378
-	/**
379
-	 * Sends overdue notices.
380
-	 *
381
-	 * @TODO: Create an invoices query class.
382
-	 */
383
-	public function overdue() {
384
-		global $wpdb;
385
-
386
-		$email = new GetPaid_Notification_Email( __FUNCTION__ );
387
-
388
-		// Fetch reminder days.
389
-		$reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
390
-
391
-		// Abort if non is set.
392
-		if ( empty( $reminder_days ) ) {
393
-			return;
394
-		}
395
-
396
-		// Retrieve date query.
397
-		$date_query = $this->get_date_query( $reminder_days );
398
-
399
-		// Invoices table.
400
-		$table = $wpdb->prefix . 'getpaid_invoices';
401
-
402
-		// Fetch invoices.
403
-		$invoices  = $wpdb->get_col(
404
-			"SELECT posts.ID FROM $wpdb->posts as posts
368
+    /**
369
+     * (Force) Sends overdue notices.
370
+     *
371
+     * @param WPInv_Invoice $invoice
372
+     */
373
+    public function force_send_overdue_notice( $invoice ) {
374
+        $email = new GetPaid_Notification_Email( 'overdue', $invoice );
375
+        return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() );
376
+    }
377
+
378
+    /**
379
+     * Sends overdue notices.
380
+     *
381
+     * @TODO: Create an invoices query class.
382
+     */
383
+    public function overdue() {
384
+        global $wpdb;
385
+
386
+        $email = new GetPaid_Notification_Email( __FUNCTION__ );
387
+
388
+        // Fetch reminder days.
389
+        $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
390
+
391
+        // Abort if non is set.
392
+        if ( empty( $reminder_days ) ) {
393
+            return;
394
+        }
395
+
396
+        // Retrieve date query.
397
+        $date_query = $this->get_date_query( $reminder_days );
398
+
399
+        // Invoices table.
400
+        $table = $wpdb->prefix . 'getpaid_invoices';
401
+
402
+        // Fetch invoices.
403
+        $invoices  = $wpdb->get_col(
404
+            "SELECT posts.ID FROM $wpdb->posts as posts
405 405
 			LEFT JOIN $table as invoices ON invoices.post_id = posts.ID
406 406
 			WHERE posts.post_type = 'wpi_invoice' AND posts.post_status = 'wpi-pending' $date_query");
407 407
 
408
-		foreach ( $invoices as $invoice ) {
408
+        foreach ( $invoices as $invoice ) {
409 409
 
410
-			// Only send this email for invoices created via the admin page.
411
-			if ( ! $this->is_payment_form_invoice( $invoice ) ) {
412
-				$invoice       = new WPInv_Invoice( $invoice );
413
-				$email->object = $invoice;
410
+            // Only send this email for invoices created via the admin page.
411
+            if ( ! $this->is_payment_form_invoice( $invoice ) ) {
412
+                $invoice       = new WPInv_Invoice( $invoice );
413
+                $email->object = $invoice;
414 414
 
415
-				if ( $invoice->needs_payment() ) {
416
-					$this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() );
417
-				}
415
+                if ( $invoice->needs_payment() ) {
416
+                    $this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() );
417
+                }
418 418
 
419
-			}
419
+            }
420 420
 
421
-		}
421
+        }
422 422
 
423
-	}
423
+    }
424 424
 
425
-	/**
426
-	 * Calculates the date query for an invoices query
427
-	 *
428
-	 * @param array $reminder_days
429
-	 * @return string
430
-	 */
431
-	public function get_date_query( $reminder_days ) {
425
+    /**
426
+     * Calculates the date query for an invoices query
427
+     *
428
+     * @param array $reminder_days
429
+     * @return string
430
+     */
431
+    public function get_date_query( $reminder_days ) {
432 432
 
433
-		$date_query = array(
434
-			'relation'  => 'OR'
435
-		);
433
+        $date_query = array(
434
+            'relation'  => 'OR'
435
+        );
436 436
 
437
-		foreach ( $reminder_days as $days ) {
438
-			$date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) );
437
+        foreach ( $reminder_days as $days ) {
438
+            $date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) );
439 439
 
440
-			$date_query[] = array(
441
-				'year'  => $date['year'],
442
-				'month' => $date['month'],
443
-				'day'   => $date['day'],
444
-			);
440
+            $date_query[] = array(
441
+                'year'  => $date['year'],
442
+                'month' => $date['month'],
443
+                'day'   => $date['day'],
444
+            );
445 445
 
446
-		}
446
+        }
447 447
 
448
-		$date_query = new WP_Date_Query( $date_query, 'invoices.due_date' );
448
+        $date_query = new WP_Date_Query( $date_query, 'invoices.due_date' );
449 449
 
450
-		return $date_query->get_sql();
450
+        return $date_query->get_sql();
451 451
 
452
-	}
452
+    }
453 453
 
454 454
 }
Please login to merge, or discard this patch.
Spacing   +104 added lines, -104 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,32 +119,32 @@  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
 		return 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}'       => wpinv_price( wpinv_format_amount( $invoice->get_total() ) ),
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( $invoice->get_type() ),
144
-			'{invoice_label}'       => sanitize_text_field( ucfirst( $invoice->get_type() ) ),
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}'       => wpinv_price(wpinv_format_amount($invoice->get_total())),
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($invoice->get_type()),
144
+			'{invoice_label}'       => sanitize_text_field(ucfirst($invoice->get_type())),
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 150
 	}
@@ -158,35 +158,35 @@  discard block
 block discarded – undo
158 158
 	 * @param string|array $recipients
159 159
 	 * @param array $extra_args Extra template args.
160 160
 	 */
161
-	public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) {
161
+	public function send_email($invoice, $email, $type, $recipients, $extra_args = array()) {
162 162
 
163
-		do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email );
163
+		do_action('getpaid_before_send_invoice_notification', $type, $invoice, $email);
164 164
 
165 165
 		$mailer     = new GetPaid_Notification_Email_Sender();
166 166
 		$merge_tags = $email->get_merge_tags();
167 167
 
168 168
 		$result = $mailer->send(
169
-			apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ),
170
-			$email->add_merge_tags( $email->get_subject(), $merge_tags ),
171
-			$email->get_content( $merge_tags, $extra_args ),
169
+			apply_filters('getpaid_invoice_email_recipients', wpinv_parse_list($recipients), $email),
170
+			$email->add_merge_tags($email->get_subject(), $merge_tags),
171
+			$email->get_content($merge_tags, $extra_args),
172 172
 			$email->get_attachments()
173 173
 		);
174 174
 
175 175
 		// Maybe send a copy to the admin.
176
-		if ( $email->include_admin_bcc() ) {
176
+		if ($email->include_admin_bcc()) {
177 177
 			$mailer->send(
178 178
 				wpinv_get_admin_email(),
179
-				$email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ),
180
-				$email->get_content( $merge_tags ),
179
+				$email->add_merge_tags($email->get_subject() . __(' - ADMIN BCC COPY', 'invoicing'), $merge_tags),
180
+				$email->get_content($merge_tags),
181 181
 				$email->get_attachments()
182 182
 			);
183 183
 		}
184 184
 
185
-		if ( ! $result ) {
186
-			$invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true );
185
+		if (!$result) {
186
+			$invoice->add_note(sprintf(__('Failed sending %s notification email.', 'invoicing'), sanitize_key($type)), false, false, true);
187 187
 		}
188 188
 
189
-		do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email );
189
+		do_action('getpaid_after_send_invoice_notification', $type, $invoice, $email);
190 190
 
191 191
 		return $result;
192 192
 	}
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
 	 * @param array $recipients
198 198
 	 * @param GetPaid_Notification_Email $email
199 199
 	 */
200
-	public function filter_email_recipients( $recipients, $email ) {
200
+	public function filter_email_recipients($recipients, $email) {
201 201
 
202
-		if ( ! $email->is_admin_email() ) {
202
+		if (!$email->is_admin_email()) {
203 203
 			$cc = $email->object->get_email_cc();
204 204
 
205
-			if ( ! empty( $cc ) ) {
206
-				$cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
207
-				$recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
205
+			if (!empty($cc)) {
206
+				$cc = array_map('sanitize_email', wpinv_parse_list($cc));
207
+				$recipients = array_filter(array_unique(array_merge($recipients, $cc)));
208 208
 			}
209 209
 
210 210
 		}
@@ -218,17 +218,17 @@  discard block
 block discarded – undo
218 218
 	 *
219 219
 	 * @param WPInv_Invoice $invoice
220 220
 	 */
221
-	public function new_invoice( $invoice ) {
221
+	public function new_invoice($invoice) {
222 222
 
223 223
 		// Only send this email for invoices created via the admin page.
224
-		if ( ! $invoice->is_type( 'invoice' ) || $this->is_payment_form_invoice( $invoice->get_id() ) ) {
224
+		if (!$invoice->is_type('invoice') || $this->is_payment_form_invoice($invoice->get_id())) {
225 225
 			return;
226 226
 		}
227 227
 
228
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
228
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
229 229
 		$recipient = wpinv_get_admin_email();
230 230
 
231
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
231
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
232 232
 
233 233
 	}
234 234
 
@@ -237,12 +237,12 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 * @param WPInv_Invoice $invoice
239 239
 	 */
240
-	public function cancelled_invoice( $invoice ) {
240
+	public function cancelled_invoice($invoice) {
241 241
 
242
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
242
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
243 243
 		$recipient = wpinv_get_admin_email();
244 244
 
245
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
245
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
246 246
 
247 247
 	}
248 248
 
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
 	 *
252 252
 	 * @param WPInv_Invoice $invoice
253 253
 	 */
254
-	public function failed_invoice( $invoice ) {
254
+	public function failed_invoice($invoice) {
255 255
 
256
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
256
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
257 257
 		$recipient = wpinv_get_admin_email();
258 258
 
259
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
259
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
260 260
 
261 261
 	}
262 262
 
@@ -265,12 +265,12 @@  discard block
 block discarded – undo
265 265
 	 *
266 266
 	 * @param WPInv_Invoice $invoice
267 267
 	 */
268
-	public function onhold_invoice( $invoice ) {
268
+	public function onhold_invoice($invoice) {
269 269
 
270
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
270
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
271 271
 		$recipient = $invoice->get_email();
272 272
 
273
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
273
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
274 274
 
275 275
 	}
276 276
 
@@ -279,12 +279,12 @@  discard block
 block discarded – undo
279 279
 	 *
280 280
 	 * @param WPInv_Invoice $invoice
281 281
 	 */
282
-	public function processing_invoice( $invoice ) {
282
+	public function processing_invoice($invoice) {
283 283
 
284
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
284
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
285 285
 		$recipient = $invoice->get_email();
286 286
 
287
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
287
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
288 288
 
289 289
 	}
290 290
 
@@ -293,17 +293,17 @@  discard block
 block discarded – undo
293 293
 	 *
294 294
 	 * @param WPInv_Invoice $invoice
295 295
 	 */
296
-	public function completed_invoice( $invoice ) {
296
+	public function completed_invoice($invoice) {
297 297
 
298 298
 		// (Maybe) abort if it is a renewal invoice.
299
-		if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) {
299
+		if ($invoice->is_renewal() && !wpinv_get_option('email_completed_invoice_renewal_active', false)) {
300 300
 			return;
301 301
 		}
302 302
 
303
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
303
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
304 304
 		$recipient = $invoice->get_email();
305 305
 
306
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
306
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
307 307
 
308 308
 	}
309 309
 
@@ -312,12 +312,12 @@  discard block
 block discarded – undo
312 312
 	 *
313 313
 	 * @param WPInv_Invoice $invoice
314 314
 	 */
315
-	public function refunded_invoice( $invoice ) {
315
+	public function refunded_invoice($invoice) {
316 316
 
317
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
317
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
318 318
 		$recipient = $invoice->get_email();
319 319
 
320
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
320
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
321 321
 
322 322
 	}
323 323
 
@@ -326,17 +326,17 @@  discard block
 block discarded – undo
326 326
 	 *
327 327
 	 * @param WPInv_Invoice $invoice
328 328
 	 */
329
-	public function user_invoice( $invoice ) {
329
+	public function user_invoice($invoice) {
330 330
 
331 331
 		// Only send this email for invoices created via the admin page.
332
-		if ( ! $invoice->is_type( 'invoice' ) || $this->is_payment_form_invoice( $invoice->get_id() ) ) {
332
+		if (!$invoice->is_type('invoice') || $this->is_payment_form_invoice($invoice->get_id())) {
333 333
 			return;
334 334
 		}
335 335
 
336
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
336
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
337 337
 		$recipient = $invoice->get_email();
338 338
 
339
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
339
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
340 340
 
341 341
 	}
342 342
 
@@ -346,8 +346,8 @@  discard block
 block discarded – undo
346 346
 	 * @param int $invoice
347 347
 	 * @return bool
348 348
 	 */
349
-	public function is_payment_form_invoice( $invoice ) {
350
-		return empty( $_GET['getpaid-admin-action'] ) && 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true );
349
+	public function is_payment_form_invoice($invoice) {
350
+		return empty($_GET['getpaid-admin-action']) && 'payment_form' == get_post_meta($invoice, 'wpinv_created_via', true);
351 351
 	}
352 352
 
353 353
 	/**
@@ -356,12 +356,12 @@  discard block
 block discarded – undo
356 356
 	 * @param WPInv_Invoice $invoice
357 357
 	 * @param string $note
358 358
 	 */
359
-	public function user_note( $invoice, $note ) {
359
+	public function user_note($invoice, $note) {
360 360
 
361
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
361
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
362 362
 		$recipient = $invoice->get_email();
363 363
 
364
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) );
364
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient, array('customer_note' => $note));
365 365
 
366 366
 	}
367 367
 
@@ -370,9 +370,9 @@  discard block
 block discarded – undo
370 370
 	 *
371 371
 	 * @param WPInv_Invoice $invoice
372 372
 	 */
373
-	public function force_send_overdue_notice( $invoice ) {
374
-		$email = new GetPaid_Notification_Email( 'overdue', $invoice );
375
-		return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() );
373
+	public function force_send_overdue_notice($invoice) {
374
+		$email = new GetPaid_Notification_Email('overdue', $invoice);
375
+		return $this->send_email($invoice, $email, 'overdue', $invoice->get_email());
376 376
 	}
377 377
 
378 378
 	/**
@@ -383,37 +383,37 @@  discard block
 block discarded – undo
383 383
 	public function overdue() {
384 384
 		global $wpdb;
385 385
 
386
-		$email = new GetPaid_Notification_Email( __FUNCTION__ );
386
+		$email = new GetPaid_Notification_Email(__FUNCTION__);
387 387
 
388 388
 		// Fetch reminder days.
389
-		$reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
389
+		$reminder_days = array_unique(wp_parse_id_list($email->get_option('days')));
390 390
 
391 391
 		// Abort if non is set.
392
-		if ( empty( $reminder_days ) ) {
392
+		if (empty($reminder_days)) {
393 393
 			return;
394 394
 		}
395 395
 
396 396
 		// Retrieve date query.
397
-		$date_query = $this->get_date_query( $reminder_days );
397
+		$date_query = $this->get_date_query($reminder_days);
398 398
 
399 399
 		// Invoices table.
400 400
 		$table = $wpdb->prefix . 'getpaid_invoices';
401 401
 
402 402
 		// Fetch invoices.
403
-		$invoices  = $wpdb->get_col(
403
+		$invoices = $wpdb->get_col(
404 404
 			"SELECT posts.ID FROM $wpdb->posts as posts
405 405
 			LEFT JOIN $table as invoices ON invoices.post_id = posts.ID
406 406
 			WHERE posts.post_type = 'wpi_invoice' AND posts.post_status = 'wpi-pending' $date_query");
407 407
 
408
-		foreach ( $invoices as $invoice ) {
408
+		foreach ($invoices as $invoice) {
409 409
 
410 410
 			// Only send this email for invoices created via the admin page.
411
-			if ( ! $this->is_payment_form_invoice( $invoice ) ) {
412
-				$invoice       = new WPInv_Invoice( $invoice );
411
+			if (!$this->is_payment_form_invoice($invoice)) {
412
+				$invoice       = new WPInv_Invoice($invoice);
413 413
 				$email->object = $invoice;
414 414
 
415
-				if ( $invoice->needs_payment() ) {
416
-					$this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() );
415
+				if ($invoice->needs_payment()) {
416
+					$this->send_email($invoice, $email, __FUNCTION__, $invoice->get_email());
417 417
 				}
418 418
 
419 419
 			}
@@ -428,14 +428,14 @@  discard block
 block discarded – undo
428 428
 	 * @param array $reminder_days
429 429
 	 * @return string
430 430
 	 */
431
-	public function get_date_query( $reminder_days ) {
431
+	public function get_date_query($reminder_days) {
432 432
 
433 433
 		$date_query = array(
434 434
 			'relation'  => 'OR'
435 435
 		);
436 436
 
437
-		foreach ( $reminder_days as $days ) {
438
-			$date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) );
437
+		foreach ($reminder_days as $days) {
438
+			$date = date_parse(date('Y-m-d', strtotime("-$days days", current_time('timestamp'))));
439 439
 
440 440
 			$date_query[] = array(
441 441
 				'year'  => $date['year'],
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 
446 446
 		}
447 447
 
448
-		$date_query = new WP_Date_Query( $date_query, 'invoices.due_date' );
448
+		$date_query = new WP_Date_Query($date_query, 'invoices.due_date');
449 449
 
450 450
 		return $date_query->get_sql();
451 451
 
Please login to merge, or discard this patch.
includes/admin/wpinv-upgrade-functions.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -11,55 +11,55 @@  discard block
 block discarded – undo
11 11
  * @since 1.0.0
12 12
 */
13 13
 function wpinv_automatic_upgrade() {
14
-    $wpi_version = get_option( 'wpinv_version' );
14
+    $wpi_version = get_option('wpinv_version');
15 15
 
16 16
     // Update tables.
17
-    if ( ! get_option( 'getpaid_created_invoice_tables' ) ) {
17
+    if (!get_option('getpaid_created_invoice_tables')) {
18 18
         wpinv_v119_upgrades();
19
-        update_option( 'getpaid_created_invoice_tables', true );
19
+        update_option('getpaid_created_invoice_tables', true);
20 20
     }
21 21
 
22
-    if ( $wpi_version == WPINV_VERSION ) {
22
+    if ($wpi_version == WPINV_VERSION) {
23 23
         return;
24 24
     }
25 25
 
26
-    if ( version_compare( $wpi_version, '0.0.5', '<' ) ) {
26
+    if (version_compare($wpi_version, '0.0.5', '<')) {
27 27
         wpinv_v005_upgrades();
28 28
     }
29 29
 
30
-    if ( version_compare( $wpi_version, '1.0.3', '<' ) ) {
30
+    if (version_compare($wpi_version, '1.0.3', '<')) {
31 31
         wpinv_v110_upgrades();
32 32
     }
33 33
 
34
-    update_option( 'wpinv_version', WPINV_VERSION );
34
+    update_option('wpinv_version', WPINV_VERSION);
35 35
 }
36
-add_action( 'admin_init', 'wpinv_automatic_upgrade' );
36
+add_action('admin_init', 'wpinv_automatic_upgrade');
37 37
 
38 38
 function wpinv_v005_upgrades() {
39 39
     global $wpdb;
40 40
 
41 41
     // Invoices status
42
-    $results = $wpdb->get_results( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
43
-    if ( !empty( $results ) ) {
44
-        $wpdb->query( "UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
42
+    $results = $wpdb->get_results("SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
43
+    if (!empty($results)) {
44
+        $wpdb->query("UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
45 45
 
46 46
         // Clean post cache
47
-        foreach ( $results as $row ) {
48
-            clean_post_cache( $row->ID );
47
+        foreach ($results as $row) {
48
+            clean_post_cache($row->ID);
49 49
         }
50 50
     }
51 51
 
52 52
     // Item meta key changes
53 53
     $query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
54
-    $results = $wpdb->get_results( $query );
54
+    $results = $wpdb->get_results($query);
55 55
 
56
-    if ( !empty( $results ) ) {
57
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
58
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
59
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
56
+    if (!empty($results)) {
57
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )");
58
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'");
59
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'");
60 60
         
61
-        foreach ( $results as $row ) {
62
-            clean_post_cache( $row->post_id );
61
+        foreach ($results as $row) {
62
+            clean_post_cache($row->post_id);
63 63
         }
64 64
     }
65 65
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 function wpinv_create_invoices_table() {
89 89
     global $wpdb;
90 90
 
91
-    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
91
+    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
92 92
 
93 93
     // Create invoices table.
94 94
     $table = $wpdb->prefix . 'getpaid_invoices';
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
             KEY `key` ( `key` )
133 133
             ) CHARACTER SET utf8 COLLATE utf8_general_ci;";
134 134
 
135
-    dbDelta( $sql );
135
+    dbDelta($sql);
136 136
 
137 137
     // Create invoice items table.
138 138
     $table = $wpdb->prefix . 'getpaid_invoice_items';
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
             KEY post_id ( post_id )
161 161
             ) CHARACTER SET utf8 COLLATE utf8_general_ci;";
162 162
 
163
-    dbDelta( $sql );
163
+    dbDelta($sql);
164 164
 }
165 165
 
166 166
 /**
@@ -172,10 +172,10 @@  discard block
 block discarded – undo
172 172
     $invoices = array_unique(
173 173
         get_posts(
174 174
             array(
175
-                'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
175
+                'post_type'      => array('wpi_invoice', 'wpi_quote'),
176 176
                 'posts_per_page' => -1,
177 177
                 'fields'         => 'ids',
178
-                'post_status'    => array_keys( get_post_stati() ),
178
+                'post_status'    => array_keys(get_post_stati()),
179 179
             )
180 180
         )
181 181
     );
@@ -183,19 +183,19 @@  discard block
 block discarded – undo
183 183
     $invoices_table = $wpdb->prefix . 'getpaid_invoices';
184 184
     $invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
185 185
 
186
-    if ( ! class_exists( 'WPInv_Legacy_Invoice' ) ) {
187
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php' );
186
+    if (!class_exists('WPInv_Legacy_Invoice')) {
187
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php');
188 188
     }
189 189
 
190 190
     $invoice_rows = array();
191
-    foreach ( $invoices as $invoice ) {
191
+    foreach ($invoices as $invoice) {
192 192
 
193
-        $invoice = new WPInv_Legacy_Invoice( $invoice );
194
-        $fields = array (
193
+        $invoice = new WPInv_Legacy_Invoice($invoice);
194
+        $fields = array(
195 195
             'post_id'        => $invoice->ID,
196 196
             'number'         => $invoice->get_number(),
197 197
             'key'            => $invoice->get_key(),
198
-            'type'           => str_replace( 'wpi_', '', $invoice->post_type ),
198
+            'type'           => str_replace('wpi_', '', $invoice->post_type),
199 199
             'mode'           => $invoice->mode,
200 200
             'user_ip'        => $invoice->get_ip(),
201 201
             'first_name'     => $invoice->get_first_name(),
@@ -224,27 +224,27 @@  discard block
 block discarded – undo
224 224
             'custom_meta'    => $invoice->payment_meta
225 225
         );
226 226
 
227
-        foreach ( $fields as $key => $val ) {
228
-            if ( is_null( $val ) ) {
227
+        foreach ($fields as $key => $val) {
228
+            if (is_null($val)) {
229 229
                 $val = '';
230 230
             }
231
-            $val = maybe_serialize( $val );
232
-            $fields[ $key ] = $wpdb->prepare( '%s', $val );
231
+            $val = maybe_serialize($val);
232
+            $fields[$key] = $wpdb->prepare('%s', $val);
233 233
         }
234 234
 
235
-        $fields = implode( ', ', $fields );
235
+        $fields = implode(', ', $fields);
236 236
         $invoice_rows[] = "($fields)";
237 237
 
238 238
         $item_rows    = array();
239 239
         $item_columns = array();
240
-        foreach ( $invoice->get_cart_details() as $details ) {
240
+        foreach ($invoice->get_cart_details() as $details) {
241 241
             $fields = array(
242 242
                 'post_id'          => $invoice->ID,
243 243
                 'item_id'          => $details['id'],
244 244
                 'item_name'        => $details['name'],
245
-                'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
245
+                'item_description' => empty($details['meta']['description']) ? '' : $details['meta']['description'],
246 246
                 'vat_rate'         => $details['vat_rate'],
247
-                'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
247
+                'vat_class'        => empty($details['vat_class']) ? '_standard' : $details['vat_class'],
248 248
                 'tax'              => $details['tax'],
249 249
                 'item_price'       => $details['item_price'],
250 250
                 'custom_price'     => $details['custom_price'],
@@ -256,26 +256,26 @@  discard block
 block discarded – undo
256 256
                 'fees'             => $details['fees'],
257 257
             );
258 258
 
259
-            $item_columns = array_keys ( $fields );
259
+            $item_columns = array_keys($fields);
260 260
 
261
-            foreach ( $fields as $key => $val ) {
262
-                if ( is_null( $val ) ) {
261
+            foreach ($fields as $key => $val) {
262
+                if (is_null($val)) {
263 263
                     $val = '';
264 264
                 }
265
-                $val = maybe_serialize( $val );
266
-                $fields[ $key ] = $wpdb->prepare( '%s', $val );
265
+                $val = maybe_serialize($val);
266
+                $fields[$key] = $wpdb->prepare('%s', $val);
267 267
             }
268 268
 
269
-            $fields = implode( ', ', $fields );
269
+            $fields = implode(', ', $fields);
270 270
             $item_rows[] = "($fields)";
271 271
         }
272 272
 
273
-        $item_rows    = implode( ', ', $item_rows );
274
-        $item_columns = implode( ', ', $item_columns );
275
-        $wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
273
+        $item_rows    = implode(', ', $item_rows);
274
+        $item_columns = implode(', ', $item_columns);
275
+        $wpdb->query("INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows");
276 276
     }
277 277
 
278
-    $invoice_rows = implode( ', ', $invoice_rows );
279
-    $wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
278
+    $invoice_rows = implode(', ', $invoice_rows);
279
+    $wpdb->query("INSERT INTO $invoices_table VALUES $invoice_rows");
280 280
 
281 281
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-payment-meta.php 1 patch
Spacing   +24 added lines, -24 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,10 +21,10 @@  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 );
27
+        $invoice = new WPInv_Invoice($post);
28 28
 
29 29
         ?>
30 30
 
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
                                 'id'          => 'wpinv_key',
48 48
                                 'name'        => 'wpinv_key',
49 49
                                 'label'       => sprintf(
50
-                                    __( '%s Key:', 'invoicing' ),
51
-                                    ucfirst( $invoice->get_type() )
50
+                                    __('%s Key:', 'invoicing'),
51
+                                    ucfirst($invoice->get_type())
52 52
                                 ),
53 53
                                 'label_type'  => 'vertical',
54 54
                                 'class'       => 'form-control-sm',
55
-                                'value'       => $invoice->get_key( 'edit' ),
55
+                                'value'       => $invoice->get_key('edit'),
56 56
                                 'extra_attributes' => array(
57 57
                                     'onclick'  => 'this.select();',
58 58
                                     'readonly' => 'true',
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
                                 'id'          => 'wpinv_view_url',
68 68
                                 'name'        => 'wpinv_view_url',
69 69
                                 'label'       => sprintf(
70
-                                    __( '%s URL:', 'invoicing' ),
71
-                                    ucfirst( $invoice->get_type() )
70
+                                    __('%s URL:', 'invoicing'),
71
+                                    ucfirst($invoice->get_type())
72 72
                                 ),
73 73
                                 'label_type'  => 'vertical',
74 74
                                 'class'       => 'form-control-sm',
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
                         );
82 82
 
83 83
                         // If the invoice is paid...
84
-                        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
84
+                        if ($invoice->is_paid() || $invoice->is_refunded()) {
85 85
 
86 86
                             // Payment date.
87 87
                             echo aui()->input(
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
                                     'type'        => 'datepicker',
90 90
                                     'id'          => 'wpinv_date_completed',
91 91
                                     'name'        => 'date_completed',
92
-                                    'label'       => __( 'Payment Date:', 'invoicing' ),
92
+                                    'label'       => __('Payment Date:', 'invoicing'),
93 93
                                     'label_type'  => 'vertical',
94 94
                                     'placeholder' => 'YYYY-MM-DD 00:00',
95 95
                                     'class'       => 'form-control-sm',
96
-                                    'value'       => $invoice->get_date_completed( 'edit' ),
96
+                                    'value'       => $invoice->get_date_completed('edit'),
97 97
                                     'extra_attributes' => array(
98 98
                                         'data-enable-time' => 'true',
99 99
                                         'data-time_24hr'   => 'true',
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
                                     'type'        => 'text',
109 109
                                     'id'          => 'wpinv_gateway',
110 110
                                     'name'        => 'wpinv_gateway',
111
-                                    'label'       => __( 'Gateway:', 'invoicing' ),
111
+                                    'label'       => __('Gateway:', 'invoicing'),
112 112
                                     'label_type'  => 'vertical',
113 113
                                     'class'       => 'form-control-sm',
114
-                                    'value'       => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ),
114
+                                    'value'       => wpinv_get_gateway_admin_label($invoice->get_gateway('edit')),
115 115
                                     'extra_attributes' => array(
116 116
                                         'onclick'  => 'this.select();',
117 117
                                         'readonly' => 'true',
@@ -125,11 +125,11 @@  discard block
 block discarded – undo
125 125
                                     'type'        => 'text',
126 126
                                     'id'          => 'wpinv_transaction_id',
127 127
                                     'name'        => 'wpinv_transaction_id',
128
-                                    'label'       => __( 'Transaction ID:', 'invoicing' ),
128
+                                    'label'       => __('Transaction ID:', 'invoicing'),
129 129
                                     'label_type'  => 'vertical',
130 130
                                     'class'       => 'form-control-sm',
131
-                                    'value'       => $invoice->get_transaction_id( 'edit' ),
132
-                                    'help_text'   => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), '', $invoice->get_transaction_id(), $invoice ),
131
+                                    'value'       => $invoice->get_transaction_id('edit'),
132
+                                    'help_text'   => apply_filters('wpinv_invoice_transaction_link_' . $invoice->get_gateway('edit'), '', $invoice->get_transaction_id(), $invoice),
133 133
                                     'extra_attributes' => array(
134 134
                                         'onclick'  => 'this.select();',
135 135
                                         'readonly' => 'true',
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
                                     'type'        => 'text',
144 144
                                     'id'          => 'wpinv_currency',
145 145
                                     'name'        => 'wpinv_currency',
146
-                                    'label'       => __( 'Currency:', 'invoicing' ),
146
+                                    'label'       => __('Currency:', 'invoicing'),
147 147
                                     'label_type'  => 'vertical',
148 148
                                     'class'       => 'form-control-sm',
149
-                                    'value'       => $invoice->get_currency( 'edit' ),
149
+                                    'value'       => $invoice->get_currency('edit'),
150 150
                                     'extra_attributes' => array(
151 151
                                         'onclick'  => 'this.select();',
152 152
                                         'readonly' => 'true',
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
                         } else {
158 158
 
159
-                            if ( 'wpi_invoice' == $invoice->get_post_type() ) {
159
+                            if ('wpi_invoice' == $invoice->get_post_type()) {
160 160
 
161 161
                                 // Payment URL.
162 162
                                 echo aui()->input(
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
                                         'type'        => 'text',
165 165
                                         'id'          => 'wpinv_payment_url',
166 166
                                         'name'        => 'wpinv_payment_url',
167
-                                        'label'       => __( 'Payment URL:', 'invoicing' ),
167
+                                        'label'       => __('Payment URL:', 'invoicing'),
168 168
                                         'label_type'  => 'vertical',
169 169
                                         'class'       => 'form-control-sm',
170 170
                                         'value'       => $invoice->get_checkout_payment_url(),
@@ -180,13 +180,13 @@  discard block
 block discarded – undo
180 180
                                     array(
181 181
                                         'id'               => 'wpinv_gateway',
182 182
                                         'name'             => 'wpinv_gateway',
183
-                                        'label'            => __( 'Gateway:', 'invoicing' ),
183
+                                        'label'            => __('Gateway:', 'invoicing'),
184 184
                                         'label_type'       => 'vertical',
185
-                                        'placeholder'      => __( 'Select Gateway', 'invoicing' ),
186
-                                        'value'            => $invoice->get_gateway( 'edit' ),
185
+                                        'placeholder'      => __('Select Gateway', 'invoicing'),
186
+                                        'value'            => $invoice->get_gateway('edit'),
187 187
                                         'select2'          => true,
188 188
                                         'data-allow-clear' => 'false',
189
-                                        'options'          => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ),
189
+                                        'options'          => wp_list_pluck(wpinv_get_enabled_payment_gateways(true), 'admin_label'),
190 190
                                     )
191 191
                                 );
192 192
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-details.php 1 patch
Spacing   +42 added lines, -42 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,13 +21,13 @@  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 );
27
+        $invoice = new WPInv_Invoice($post);
28 28
 
29 29
         // Nonce field.
30
-        wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ;
30
+        wp_nonce_field('wpinv_details', 'wpinv_details_nonce');
31 31
 
32 32
 
33 33
         ?>
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
 
47 47
                 <div class="bsui" style="margin-top: 1.5rem" id="gdmbx2-metabox-wpinv_details">
48 48
 
49
-                    <?php if ( ! $invoice->is_draft() ) : ?>
49
+                    <?php if (!$invoice->is_draft()) : ?>
50 50
                         <div class="form-group">
51
-                            <strong><?php _e( 'Viewed by Customer:', 'invoicing' );?></strong>
52
-                            <?php ( $invoice->get_is_viewed() ) ? _e( 'Yes', 'invoicing' ) : _e( 'No', 'invoicing' ); ?>
51
+                            <strong><?php _e('Viewed by Customer:', 'invoicing'); ?></strong>
52
+                            <?php ($invoice->get_is_viewed()) ? _e('Yes', 'invoicing') : _e('No', 'invoicing'); ?>
53 53
                         </div>
54 54
                     <?php endif; ?>
55 55
 
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
 
58 58
                         // Date created.
59 59
                         $label = sprintf(
60
-                            __( '%s Date:', 'invoicing' ),
61
-                            ucfirst( $invoice->get_type() )
60
+                            __('%s Date:', 'invoicing'),
61
+                            ucfirst($invoice->get_type())
62 62
                         );
63 63
 
64
-                        $info  = sprintf(
65
-                            __( 'The date this %s was created.', 'invoicing' ),
66
-                            strtolower( $invoice->get_type() )
64
+                        $info = sprintf(
65
+                            __('The date this %s was created.', 'invoicing'),
66
+                            strtolower($invoice->get_type())
67 67
                         );
68 68
 
69 69
                         echo aui()->input(
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
                                 'type'        => 'datepicker',
72 72
                                 'id'          => 'wpinv_date_created',
73 73
                                 'name'        => 'date_created',
74
-                                'label'       => $label . getpaid_get_help_tip( $info ),
74
+                                'label'       => $label . getpaid_get_help_tip($info),
75 75
                                 'label_type'  => 'vertical',
76 76
                                 'placeholder' => 'YYYY-MM-DD 00:00',
77 77
                                 'class'       => 'form-control-sm',
78
-                                'value'       => $invoice->get_date_created( 'edit' ),
78
+                                'value'       => $invoice->get_date_created('edit'),
79 79
                                 'extra_attributes' => array(
80 80
                                     'data-enable-time' => 'true',
81 81
                                     'data-time_24hr'   => 'true',
@@ -86,30 +86,30 @@  discard block
 block discarded – undo
86 86
                         );
87 87
 
88 88
                         // Due date.
89
-                        if ( $invoice->is_type( 'invoice' ) && wpinv_get_option( 'overdue_active' ) && ( $invoice->needs_payment() || $invoice->is_draft() ) ) {
89
+                        if ($invoice->is_type('invoice') && wpinv_get_option('overdue_active') && ($invoice->needs_payment() || $invoice->is_draft())) {
90 90
 
91 91
                             echo aui()->input(
92 92
                                 array(
93 93
                                     'type'        => 'text',
94 94
                                     'id'          => 'wpinv_due_date',
95 95
                                     'name'        => 'wpinv_due_date',
96
-                                    'label'       => __( 'Due Date:', 'invoicing' ) . getpaid_get_help_tip( __( 'Leave blank to disable automated reminder emails for this invoice.', 'invoicing' ) ),
96
+                                    'label'       => __('Due Date:', 'invoicing') . getpaid_get_help_tip(__('Leave blank to disable automated reminder emails for this invoice.', 'invoicing')),
97 97
                                     'label_type'  => 'vertical',
98
-                                    'placeholder' => __( 'No due date', 'invoicing' ),
98
+                                    'placeholder' => __('No due date', 'invoicing'),
99 99
                                     'class'       => 'form-control-sm',
100
-                                    'value'       => $invoice->get_due_date( 'edit' ),
100
+                                    'value'       => $invoice->get_due_date('edit'),
101 101
                                 )
102 102
                             );
103 103
 
104 104
                         }
105 105
 
106
-                        do_action( 'wpinv_meta_box_details_after_due_date', $invoice->get_id() );
107
-                        do_action( 'getpaid_metabox_after_due_date', $invoice );
106
+                        do_action('wpinv_meta_box_details_after_due_date', $invoice->get_id());
107
+                        do_action('getpaid_metabox_after_due_date', $invoice);
108 108
 
109 109
                         // Status.
110 110
                         $label = sprintf(
111
-                            __( '%s Status:', 'invoicing' ),
112
-                            ucfirst( $invoice->get_type() )
111
+                            __('%s Status:', 'invoicing'),
112
+                            ucfirst($invoice->get_type())
113 113
                         );
114 114
 
115 115
                         echo aui()->select(
@@ -118,23 +118,23 @@  discard block
 block discarded – undo
118 118
                                 'name'             => 'wpinv_status',
119 119
                                 'label'            => $label,
120 120
                                 'label_type'       => 'vertical',
121
-                                'placeholder'      => __( 'Select Status', 'invoicing' ),
122
-                                'value'            => $invoice->get_status( 'edit' ),
121
+                                'placeholder'      => __('Select Status', 'invoicing'),
122
+                                'value'            => $invoice->get_status('edit'),
123 123
                                 'select2'          => true,
124 124
                                 'data-allow-clear' => 'false',
125
-                                'options'          => wpinv_get_invoice_statuses( true, false, $invoice )
125
+                                'options'          => wpinv_get_invoice_statuses(true, false, $invoice)
126 126
                             )
127 127
                         );
128 128
 
129 129
                         // Invoice number.
130 130
                         $label = sprintf(
131
-                            __( '%s Number:', 'invoicing' ),
132
-                            ucfirst( $invoice->get_type() )
131
+                            __('%s Number:', 'invoicing'),
132
+                            ucfirst($invoice->get_type())
133 133
                         );
134 134
 
135
-                        $info  = sprintf(
136
-                            __( 'Each %s number must be unique.', 'invoicing' ),
137
-                            strtolower( $invoice->get_type() )
135
+                        $info = sprintf(
136
+                            __('Each %s number must be unique.', 'invoicing'),
137
+                            strtolower($invoice->get_type())
138 138
                         );
139 139
 
140 140
                         echo aui()->input(
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
                                 'type'        => 'text',
143 143
                                 'id'          => 'wpinv_number',
144 144
                                 'name'        => 'wpinv_number',
145
-                                'label'       => $label . getpaid_get_help_tip( $info ),
145
+                                'label'       => $label . getpaid_get_help_tip($info),
146 146
                                 'label_type'  => 'vertical',
147
-                                'placeholder' => __( 'Autogenerate', 'invoicing' ),
147
+                                'placeholder' => __('Autogenerate', 'invoicing'),
148 148
                                 'class'       => 'form-control-sm',
149
-                                'value'       => $invoice->get_number( 'edit' ),
149
+                                'value'       => $invoice->get_number('edit'),
150 150
                             )
151 151
                         );
152 152
 
@@ -156,25 +156,25 @@  discard block
 block discarded – undo
156 156
                                 'type'        => 'text',
157 157
                                 'id'          => 'wpinv_cc',
158 158
                                 'name'        => 'wpinv_cc',
159
-                                'label'       => __( 'Email CC:', 'invoicing' ) . getpaid_get_help_tip( __( 'Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing' ) ),
159
+                                'label'       => __('Email CC:', 'invoicing') . getpaid_get_help_tip(__('Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing')),
160 160
                                 'label_type'  => 'vertical',
161
-                                'placeholder' => __( '[email protected], [email protected]', 'invoicing' ),
161
+                                'placeholder' => __('[email protected], [email protected]', 'invoicing'),
162 162
                                 'class'       => 'form-control-sm',
163
-                                'value'       => $invoice->get_email_cc( 'edit' ),
163
+                                'value'       => $invoice->get_email_cc('edit'),
164 164
                             )
165 165
                         );
166 166
 
167
-                        do_action( 'wpinv_meta_box_details_inner', $invoice->get_id() );
167
+                        do_action('wpinv_meta_box_details_inner', $invoice->get_id());
168 168
 
169 169
                         // Disable taxes.
170
-                        if ( wpinv_use_taxes() && ! ( $invoice->is_paid() || $invoice->is_refunded() ) ) {
170
+                        if (wpinv_use_taxes() && !($invoice->is_paid() || $invoice->is_refunded())) {
171 171
 
172 172
                             echo aui()->input(
173 173
                                 array(
174 174
                                     'id'          => 'wpinv_taxable',
175 175
                                     'name'        => 'disable_taxes',
176 176
                                     'type'        => 'checkbox',
177
-                                    'label'       => __( 'Disable taxes', 'invoicing' ),
177
+                                    'label'       => __('Disable taxes', 'invoicing'),
178 178
                                     'value'       => '1',
179 179
                                     'checked'     => (bool) $invoice->get_disable_taxes(),
180 180
                                 )
@@ -183,17 +183,17 @@  discard block
 block discarded – undo
183 183
                         }
184 184
 
185 185
                         // Apply a discount.
186
-                        if ( $invoice->get_discount_code( 'edit' ) ) {
186
+                        if ($invoice->get_discount_code('edit')) {
187 187
 
188 188
                             echo aui()->input(
189 189
                                 array(
190 190
                                     'type'        => 'text',
191 191
                                     'id'          => 'wpinv_discount_code',
192 192
                                     'name'        => 'wpinv_discount_code',
193
-                                    'label'       => __( 'Discount Code:', 'invoicing' ),
193
+                                    'label'       => __('Discount Code:', 'invoicing'),
194 194
                                     'label_type'  => 'vertical',
195 195
                                     'class'       => 'form-control-sm',
196
-                                    'value'       => $invoice->get_discount_code( 'edit' ),
196
+                                    'value'       => $invoice->get_discount_code('edit'),
197 197
                                     'extra_attributes' => array(
198 198
                                         'onclick'  => 'this.select();',
199 199
                                         'readonly' => 'true',
Please login to merge, or discard this patch.
includes/admin/admin-pages.php 1 patch
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' );
8
-function wpinv_discount_custom_column( $column ) {
7
+add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column');
8
+function wpinv_discount_custom_column($column) {
9 9
     global $post;
10 10
 
11
-    $discount = new WPInv_Discount( $post );
11
+    $discount = new WPInv_Discount($post);
12 12
 
13
-    switch ( $column ) {
13
+    switch ($column) {
14 14
         case 'code' :
15 15
             echo $discount->get_code();
16 16
         break;
@@ -21,38 +21,38 @@  discard block
 block discarded – undo
21 21
             echo $discount->get_usage();
22 22
         break;
23 23
         case 'start_date' :
24
-            echo getpaid_format_date_value( $discount->get_start_date() );
24
+            echo getpaid_format_date_value($discount->get_start_date());
25 25
         break;
26 26
         case 'expiry_date' :
27
-            echo getpaid_format_date_value( $discount->get_expiration_date(), __( 'Never', 'invoicing' ) );
27
+            echo getpaid_format_date_value($discount->get_expiration_date(), __('Never', 'invoicing'));
28 28
         break;
29 29
     }
30 30
 }
31 31
 
32
-add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 );
33
-function wpinv_post_row_actions( $actions, $post ) {
34
-    $post_type = !empty( $post->post_type ) ? $post->post_type : '';
32
+add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2);
33
+function wpinv_post_row_actions($actions, $post) {
34
+    $post_type = !empty($post->post_type) ? $post->post_type : '';
35 35
 
36
-    if ( $post_type == 'wpi_invoice' ) {
36
+    if ($post_type == 'wpi_invoice') {
37 37
         $actions = array();
38 38
     }
39 39
 
40
-    if ( $post_type == 'wpi_discount' ) {
41
-        $actions = wpinv_discount_row_actions( $post, $actions );
40
+    if ($post_type == 'wpi_discount') {
41
+        $actions = wpinv_discount_row_actions($post, $actions);
42 42
     }
43 43
 
44 44
     return $actions;
45 45
 }
46 46
 
47
-function wpinv_discount_row_actions( $discount, $row_actions ) {
48
-    $row_actions  = array();
49
-    $edit_link = get_edit_post_link( $discount->ID );
50
-    $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>';
47
+function wpinv_discount_row_actions($discount, $row_actions) {
48
+    $row_actions = array();
49
+    $edit_link = get_edit_post_link($discount->ID);
50
+    $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>';
51 51
 
52
-    if( in_array( strtolower( $discount->post_status ),  array(  'publish' ) ) ) {
53
-        $row_actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'deactivate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Deactivate', 'invoicing' ) . '</a>';
54
-    } elseif( in_array( strtolower( $discount->post_status ),  array( 'pending', 'draft' ) ) ) {
55
-        $row_actions['activate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'activate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Activate', 'invoicing' ) . '</a>';
52
+    if (in_array(strtolower($discount->post_status), array('publish'))) {
53
+        $row_actions['deactivate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'deactivate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Deactivate', 'invoicing') . '</a>';
54
+    } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) {
55
+        $row_actions['activate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'activate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Activate', 'invoicing') . '</a>';
56 56
     }
57 57
 
58 58
     $delete_url = esc_url(
@@ -66,110 +66,110 @@  discard block
 block discarded – undo
66 66
             'wpinv_discount_nonce'
67 67
         )
68 68
     );
69
-    $row_actions['delete'] = '<a href="' . $delete_url . '">' . __( 'Delete', 'invoicing' ) . '</a>';
69
+    $row_actions['delete'] = '<a href="' . $delete_url . '">' . __('Delete', 'invoicing') . '</a>';
70 70
 
71
-    $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount );
71
+    $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount);
72 72
 
73 73
     return $row_actions;
74 74
 }
75 75
 
76
-add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 );
77
-function wpinv_table_primary_column( $default, $screen_id ) {
78
-    if ( 'edit-wpi_invoice' === $screen_id ) {
76
+add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2);
77
+function wpinv_table_primary_column($default, $screen_id) {
78
+    if ('edit-wpi_invoice' === $screen_id) {
79 79
         return 'name';
80 80
     }
81 81
 
82 82
     return $default;
83 83
 }
84 84
 
85
-function wpinv_discount_bulk_actions( $actions, $display = false ) {
86
-    if ( !$display ) {
85
+function wpinv_discount_bulk_actions($actions, $display = false) {
86
+    if (!$display) {
87 87
         return array();
88 88
     }
89 89
 
90 90
     $actions = array(
91
-        'activate'   => __( 'Activate', 'invoicing' ),
92
-        'deactivate' => __( 'Deactivate', 'invoicing' ),
93
-        'delete'     => __( 'Delete', 'invoicing' ),
91
+        'activate'   => __('Activate', 'invoicing'),
92
+        'deactivate' => __('Deactivate', 'invoicing'),
93
+        'delete'     => __('Delete', 'invoicing'),
94 94
     );
95 95
     $two = '';
96 96
     $which = 'top';
97 97
     echo '</div><div class="alignleft actions bulkactions">';
98
-    echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
99
-    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">";
100
-    echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>";
98
+    echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>';
99
+    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">";
100
+    echo '<option value="-1">' . __('Bulk Actions') . "</option>";
101 101
 
102
-    foreach ( $actions as $name => $title ) {
102
+    foreach ($actions as $name => $title) {
103 103
         $class = 'edit' === $name ? ' class="hide-if-no-js"' : '';
104 104
 
105 105
         echo "" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>";
106 106
     }
107 107
     echo "</select>";
108 108
 
109
-    submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) );
109
+    submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two"));
110 110
 
111 111
     echo '</div><div class="alignleft actions">';
112 112
 }
113
-add_filter( 'bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10 );
113
+add_filter('bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10);
114 114
 
115
-function wpinv_disable_months_dropdown( $disable, $post_type ) {
116
-    if ( $post_type == 'wpi_discount' ) {
115
+function wpinv_disable_months_dropdown($disable, $post_type) {
116
+    if ($post_type == 'wpi_discount') {
117 117
         $disable = true;
118 118
     }
119 119
 
120 120
     return $disable;
121 121
 }
122
-add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 );
122
+add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2);
123 123
 
124 124
 function wpinv_restrict_manage_posts() {
125 125
     global $typenow;
126 126
 
127
-    if( 'wpi_discount' == $typenow ) {
127
+    if ('wpi_discount' == $typenow) {
128 128
         wpinv_discount_filters();
129 129
     }
130 130
 }
131
-add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 );
131
+add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10);
132 132
 
133 133
 function wpinv_discount_filters() {
134
-    wpinv_discount_bulk_actions( array(), true );
134
+    wpinv_discount_bulk_actions(array(), true);
135 135
 
136 136
     ?>
137 137
     <select name="discount_type" id="dropdown_wpinv_discount_type">
138
-        <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option>
138
+        <option value=""><?php _e('Show all types', 'invoicing'); ?></option>
139 139
         <?php
140 140
             $types = wpinv_get_discount_types();
141 141
 
142
-            foreach ( $types as $name => $type ) {
143
-                echo '<option value="' . esc_attr( $name ) . '"';
142
+            foreach ($types as $name => $type) {
143
+                echo '<option value="' . esc_attr($name) . '"';
144 144
 
145
-                if ( isset( $_GET['discount_type'] ) )
146
-                    selected( $name, $_GET['discount_type'] );
145
+                if (isset($_GET['discount_type']))
146
+                    selected($name, $_GET['discount_type']);
147 147
 
148
-                echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
148
+                echo '>' . esc_html__($type, 'invoicing') . '</option>';
149 149
             }
150 150
         ?>
151 151
     </select>
152 152
     <?php
153 153
 }
154 154
 
155
-function wpinv_request( $vars ) {
155
+function wpinv_request($vars) {
156 156
     global $typenow, $wp_query, $wp_post_statuses;
157 157
 
158
-    if ( getpaid_is_invoice_post_type( $typenow ) ) {
159
-        if ( !isset( $vars['post_status'] ) ) {
160
-            $post_statuses = wpinv_get_invoice_statuses( false, false, $typenow );
158
+    if (getpaid_is_invoice_post_type($typenow)) {
159
+        if (!isset($vars['post_status'])) {
160
+            $post_statuses = wpinv_get_invoice_statuses(false, false, $typenow);
161 161
 
162
-            foreach ( $post_statuses as $status => $value ) {
163
-                if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) {
164
-                    unset( $post_statuses[ $status ] );
162
+            foreach ($post_statuses as $status => $value) {
163
+                if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) {
164
+                    unset($post_statuses[$status]);
165 165
                 }
166 166
             }
167 167
 
168
-            $vars['post_status'] = array_keys( $post_statuses );
168
+            $vars['post_status'] = array_keys($post_statuses);
169 169
         }
170 170
 
171
-        if ( isset( $vars['orderby'] ) ) {
172
-            if ( 'amount' == $vars['orderby'] ) {
171
+        if (isset($vars['orderby'])) {
172
+            if ('amount' == $vars['orderby']) {
173 173
                 $vars = array_merge(
174 174
                     $vars,
175 175
                     array(
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
                         'orderby'  => 'meta_value_num'
178 178
                     )
179 179
                 );
180
-            } else if ( 'customer' == $vars['orderby'] ) {
180
+            } else if ('customer' == $vars['orderby']) {
181 181
                 $vars = array_merge(
182 182
                     $vars,
183 183
                     array(
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
                         'orderby'  => 'meta_value'
186 186
                     )
187 187
                 );
188
-            } else if ( 'number' == $vars['orderby'] ) {
188
+            } else if ('number' == $vars['orderby']) {
189 189
                 $vars = array_merge(
190 190
                     $vars,
191 191
                     array(
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
                         'orderby'  => 'meta_value'
194 194
                     )
195 195
                 );
196
-            } else if ( 'payment_date' == $vars['orderby'] ) {
196
+            } else if ('payment_date' == $vars['orderby']) {
197 197
                 $vars = array_merge(
198 198
                     $vars,
199 199
                     array(
@@ -203,73 +203,73 @@  discard block
 block discarded – undo
203 203
                 );
204 204
             }
205 205
         }
206
-    } else if ( 'wpi_discount' == $typenow ) {
207
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
206
+    } else if ('wpi_discount' == $typenow) {
207
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
208 208
         // Filter vat rule type
209
-        if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) {
209
+        if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') {
210 210
             $meta_query[] = array(
211 211
                     'key'   => '_wpi_discount_type',
212
-                    'value' => sanitize_text_field( $_GET['discount_type'] ),
212
+                    'value' => sanitize_text_field($_GET['discount_type']),
213 213
                     'compare' => '='
214 214
                 );
215 215
         }
216 216
 
217
-        if ( !empty( $meta_query ) ) {
217
+        if (!empty($meta_query)) {
218 218
             $vars['meta_query'] = $meta_query;
219 219
         }
220 220
     }
221 221
 
222 222
     return $vars;
223 223
 }
224
-add_filter( 'request', 'wpinv_request' );
224
+add_filter('request', 'wpinv_request');
225 225
 
226
-function wpinv_item_type_class( $classes, $class, $post_id ) {
226
+function wpinv_item_type_class($classes, $class, $post_id) {
227 227
     global $pagenow, $typenow;
228 228
 
229
-    if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow ) {
230
-        if ( $type = get_post_meta( $post_id, '_wpinv_type', true ) ) {
231
-            $classes[] = 'wpi-type-' . sanitize_html_class( $type );
229
+    if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow) {
230
+        if ($type = get_post_meta($post_id, '_wpinv_type', true)) {
231
+            $classes[] = 'wpi-type-' . sanitize_html_class($type);
232 232
         }
233 233
 
234
-        if ( !wpinv_item_is_editable( $post_id ) ) {
234
+        if (!wpinv_item_is_editable($post_id)) {
235 235
             $classes[] = 'wpi-editable-n';
236 236
         }
237 237
     }
238 238
     return $classes;
239 239
 }
240
-add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 );
240
+add_filter('post_class', 'wpinv_item_type_class', 10, 3);
241 241
 
242 242
 function wpinv_check_quick_edit() {
243 243
     global $pagenow, $current_screen, $wpinv_item_screen;
244 244
 
245
-    if ( $pagenow == 'edit.php' && !empty( $current_screen->post_type ) ) {
246
-        if ( empty( $wpinv_item_screen ) ) {
247
-            if ( $current_screen->post_type == 'wpi_item' ) {
245
+    if ($pagenow == 'edit.php' && !empty($current_screen->post_type)) {
246
+        if (empty($wpinv_item_screen)) {
247
+            if ($current_screen->post_type == 'wpi_item') {
248 248
                 $wpinv_item_screen = 'y';
249 249
             } else {
250 250
                 $wpinv_item_screen = 'n';
251 251
             }
252 252
         }
253 253
 
254
-        if ( $wpinv_item_screen == 'y' && $pagenow == 'edit.php' ) {
255
-            add_filter( 'post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
256
-            add_filter( 'page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
254
+        if ($wpinv_item_screen == 'y' && $pagenow == 'edit.php') {
255
+            add_filter('post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
256
+            add_filter('page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
257 257
         }
258 258
     }
259 259
 }
260
-add_action( 'admin_head', 'wpinv_check_quick_edit', 10 );
260
+add_action('admin_head', 'wpinv_check_quick_edit', 10);
261 261
 
262
-function wpinv_item_disable_quick_edit( $actions = array(), $row = null ) {
263
-    if ( isset( $actions['inline hide-if-no-js'] ) ) {
264
-        unset( $actions['inline hide-if-no-js'] );
262
+function wpinv_item_disable_quick_edit($actions = array(), $row = null) {
263
+    if (isset($actions['inline hide-if-no-js'])) {
264
+        unset($actions['inline hide-if-no-js']);
265 265
     }
266 266
 
267
-    if ( !empty( $row->post_type ) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable( $row ) ) {
268
-        if ( isset( $actions['trash'] ) ) {
269
-            unset( $actions['trash'] );
267
+    if (!empty($row->post_type) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable($row)) {
268
+        if (isset($actions['trash'])) {
269
+            unset($actions['trash']);
270 270
         }
271
-        if ( isset( $actions['delete'] ) ) {
272
-            unset( $actions['delete'] );
271
+        if (isset($actions['delete'])) {
272
+            unset($actions['delete']);
273 273
         }
274 274
     }
275 275
 
@@ -286,19 +286,19 @@  discard block
 block discarded – undo
286 286
  * @param int $post_parent (default: 0) Parent for the new page
287 287
  * @return int page ID
288 288
  */
289
-function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
289
+function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) {
290 290
     global $wpdb;
291 291
 
292
-    $option_value = wpinv_get_option( $option );
292
+    $option_value = wpinv_get_option($option);
293 293
 
294
-    if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) {
295
-        if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) {
294
+    if ($option_value > 0 && ($page_object = get_post($option_value))) {
295
+        if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) {
296 296
             // Valid page is already in place
297 297
             return $page_object->ID;
298 298
         }
299 299
     }
300 300
 
301
-    if(!empty($post_parent)){
301
+    if (!empty($post_parent)) {
302 302
         $page = get_page_by_path($post_parent);
303 303
         if ($page) {
304 304
             $post_parent = $page->ID;
@@ -307,40 +307,40 @@  discard block
 block discarded – undo
307 307
         }
308 308
     }
309 309
 
310
-    if ( strlen( $page_content ) > 0 ) {
310
+    if (strlen($page_content) > 0) {
311 311
         // Search for an existing page with the specified page content (typically a shortcode)
312
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
312
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
313 313
     } else {
314 314
         // Search for an existing page with the specified page slug
315
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug ) );
315
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug));
316 316
     }
317 317
 
318
-    $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content );
318
+    $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content);
319 319
 
320
-    if ( $valid_page_found ) {
321
-        if ( $option ) {
322
-            wpinv_update_option( $option, $valid_page_found );
320
+    if ($valid_page_found) {
321
+        if ($option) {
322
+            wpinv_update_option($option, $valid_page_found);
323 323
         }
324 324
         return $valid_page_found;
325 325
     }
326 326
 
327 327
     // Search for a matching valid trashed page
328
-    if ( strlen( $page_content ) > 0 ) {
328
+    if (strlen($page_content) > 0) {
329 329
         // Search for an existing page with the specified page content (typically a shortcode)
330
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
330
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
331 331
     } else {
332 332
         // Search for an existing page with the specified page slug
333
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) );
333
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug));
334 334
     }
335 335
 
336
-    if ( $trashed_page_found ) {
336
+    if ($trashed_page_found) {
337 337
         $page_id   = $trashed_page_found;
338 338
         $page_data = array(
339 339
             'ID'             => $page_id,
340 340
             'post_status'    => 'publish',
341 341
             'post_parent'    => $post_parent,
342 342
         );
343
-        wp_update_post( $page_data );
343
+        wp_update_post($page_data);
344 344
     } else {
345 345
         $page_data = array(
346 346
             'post_status'    => 'publish',
@@ -352,11 +352,11 @@  discard block
 block discarded – undo
352 352
             'post_parent'    => $post_parent,
353 353
             'comment_status' => 'closed',
354 354
         );
355
-        $page_id = wp_insert_post( $page_data );
355
+        $page_id = wp_insert_post($page_data);
356 356
     }
357 357
 
358
-    if ( $option ) {
359
-        wpinv_update_option( $option, (int)$page_id );
358
+    if ($option) {
359
+        wpinv_update_option($option, (int) $page_id);
360 360
     }
361 361
 
362 362
     return $page_id;
Please login to merge, or discard this patch.
includes/admin/class-getpaid-metaboxes.php 2 patches
Indentation   +218 added lines, -218 removed lines patch added patch discarded remove patch
@@ -12,234 +12,234 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Metaboxes {
14 14
 
15
-	/**
16
-	 * Only save metaboxes once.
17
-	 *
18
-	 * @var boolean
19
-	 */
20
-	private static $saved_meta_boxes = false;
15
+    /**
16
+     * Only save metaboxes once.
17
+     *
18
+     * @var boolean
19
+     */
20
+    private static $saved_meta_boxes = false;
21 21
 
22 22
     /**
23
-	 * Hook in methods.
24
-	 */
25
-	public static function init() {
26
-
27
-		// Register metaboxes.
28
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 );
29
-
30
-		// Remove metaboxes.
31
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 );
32
-
33
-		// Rename metaboxes.
34
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 );
35
-
36
-		// Save metaboxes.
37
-		add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 );
38
-	}
39
-
40
-	/**
41
-	 * Register core metaboxes.
42
-	 */
43
-	public static function add_meta_boxes( $post_type, $post ) {
44
-		global $wpinv_euvat;
45
-
46
-		// For invoices...
47
-		if ( getpaid_is_invoice_post_type( $post_type ) ) {
48
-			$invoice = new WPInv_Invoice( $post );
49
-
50
-			// Resend invoice.
51
-			if ( ! $invoice->is_draft() && ! $invoice->is_paid() ) {
52
-
53
-				add_meta_box(
54
-					'wpinv-mb-resend-invoice',
55
-					sprintf(
56
-						__( 'Resend %s', 'invoicing' ),
57
-						ucfirst( $invoice->get_type() )
58
-					),
59
-					'GetPaid_Meta_Box_Resend_Invoice::output',
60
-					$post_type,
61
-					'side',
62
-					'low'
63
-				);
64
-
65
-			}
66
-
67
-			// Subscriptions.
68
-			$subscription = getpaid_get_invoice_subscription( $invoice );
69
-			if ( ! empty( $subscription ) ) {
70
-				add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' );
71
-				add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' );
72
-			}
73
-
74
-			// Invoice details.
75
-			add_meta_box(
76
-				'wpinv-details',
77
-				sprintf(
78
-					__( '%s Details', 'invoicing' ),
79
-					ucfirst( $invoice->get_type() )
80
-				),
81
-				'GetPaid_Meta_Box_Invoice_Details::output',
82
-				$post_type,
83
-				'side'
84
-			);
85
-
86
-			// Payment details.
87
-			if ( ! $invoice->is_draft() ) {
88
-				add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' );
89
-			}
90
-
91
-			// Billing details.
92
-			add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' );
23
+     * Hook in methods.
24
+     */
25
+    public static function init() {
26
+
27
+        // Register metaboxes.
28
+        add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 );
29
+
30
+        // Remove metaboxes.
31
+        add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 );
32
+
33
+        // Rename metaboxes.
34
+        add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 );
35
+
36
+        // Save metaboxes.
37
+        add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 );
38
+    }
39
+
40
+    /**
41
+     * Register core metaboxes.
42
+     */
43
+    public static function add_meta_boxes( $post_type, $post ) {
44
+        global $wpinv_euvat;
45
+
46
+        // For invoices...
47
+        if ( getpaid_is_invoice_post_type( $post_type ) ) {
48
+            $invoice = new WPInv_Invoice( $post );
49
+
50
+            // Resend invoice.
51
+            if ( ! $invoice->is_draft() && ! $invoice->is_paid() ) {
52
+
53
+                add_meta_box(
54
+                    'wpinv-mb-resend-invoice',
55
+                    sprintf(
56
+                        __( 'Resend %s', 'invoicing' ),
57
+                        ucfirst( $invoice->get_type() )
58
+                    ),
59
+                    'GetPaid_Meta_Box_Resend_Invoice::output',
60
+                    $post_type,
61
+                    'side',
62
+                    'low'
63
+                );
64
+
65
+            }
66
+
67
+            // Subscriptions.
68
+            $subscription = getpaid_get_invoice_subscription( $invoice );
69
+            if ( ! empty( $subscription ) ) {
70
+                add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' );
71
+                add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' );
72
+            }
73
+
74
+            // Invoice details.
75
+            add_meta_box(
76
+                'wpinv-details',
77
+                sprintf(
78
+                    __( '%s Details', 'invoicing' ),
79
+                    ucfirst( $invoice->get_type() )
80
+                ),
81
+                'GetPaid_Meta_Box_Invoice_Details::output',
82
+                $post_type,
83
+                'side'
84
+            );
85
+
86
+            // Payment details.
87
+            if ( ! $invoice->is_draft() ) {
88
+                add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' );
89
+            }
90
+
91
+            // Billing details.
92
+            add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' );
93 93
 			
94
-			// Invoice items.
95
-			add_meta_box(
96
-				'wpinv-items',
97
-				sprintf(
98
-					__( '%s Items', 'invoicing' ),
99
-					ucfirst( $invoice->get_type() )
100
-				),
101
-				'GetPaid_Meta_Box_Invoice_Items::output',
102
-				$post_type,
103
-				'normal',
104
-				'high'
105
-			);
94
+            // Invoice items.
95
+            add_meta_box(
96
+                'wpinv-items',
97
+                sprintf(
98
+                    __( '%s Items', 'invoicing' ),
99
+                    ucfirst( $invoice->get_type() )
100
+                ),
101
+                'GetPaid_Meta_Box_Invoice_Items::output',
102
+                $post_type,
103
+                'normal',
104
+                'high'
105
+            );
106 106
 			
107
-			// Invoice notes.
108
-			add_meta_box(
109
-				'wpinv-notes',
110
-				sprintf(
111
-					__( '%s Notes', 'invoicing' ),
112
-					ucfirst( $invoice->get_type() )
113
-				),
114
-				'WPInv_Meta_Box_Notes::output',
115
-				$post_type,
116
-				'side',
117
-				'low'
118
-			);
119
-
120
-			// Payment form information.
121
-			if ( ! empty( $post->ID ) && get_post_meta( $post->ID, 'payment_form_data', true ) ) {
122
-				add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' );
123
-			}
124
-		}
125
-
126
-		// For payment forms.
127
-		if ( $post_type == 'wpi_payment_form' ) {
128
-
129
-			// Design payment form.
130
-			add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
131
-
132
-			// Payment form information.
133
-			add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' );
134
-
135
-		}
136
-
137
-		// For invoice items.
138
-		if ( $post_type == 'wpi_item' ) {
139
-
140
-			// Item details.
141
-			add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' );
142
-
143
-			// If taxes are enabled, register the tax metabox.
144
-			if ( $wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes() ) {
145
-				add_meta_box( 'wpinv_item_vat', __( 'VAT / Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' );
146
-			}
147
-
148
-			// Item info.
149
-			add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' );
150
-
151
-		}
152
-
153
-		// For invoice discounts.
154
-		if ( $post_type == 'wpi_discount' ) {
155
-			add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' );
156
-		}
107
+            // Invoice notes.
108
+            add_meta_box(
109
+                'wpinv-notes',
110
+                sprintf(
111
+                    __( '%s Notes', 'invoicing' ),
112
+                    ucfirst( $invoice->get_type() )
113
+                ),
114
+                'WPInv_Meta_Box_Notes::output',
115
+                $post_type,
116
+                'side',
117
+                'low'
118
+            );
119
+
120
+            // Payment form information.
121
+            if ( ! empty( $post->ID ) && get_post_meta( $post->ID, 'payment_form_data', true ) ) {
122
+                add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' );
123
+            }
124
+        }
125
+
126
+        // For payment forms.
127
+        if ( $post_type == 'wpi_payment_form' ) {
128
+
129
+            // Design payment form.
130
+            add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
131
+
132
+            // Payment form information.
133
+            add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' );
134
+
135
+        }
136
+
137
+        // For invoice items.
138
+        if ( $post_type == 'wpi_item' ) {
139
+
140
+            // Item details.
141
+            add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' );
142
+
143
+            // If taxes are enabled, register the tax metabox.
144
+            if ( $wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes() ) {
145
+                add_meta_box( 'wpinv_item_vat', __( 'VAT / Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' );
146
+            }
147
+
148
+            // Item info.
149
+            add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' );
150
+
151
+        }
152
+
153
+        // For invoice discounts.
154
+        if ( $post_type == 'wpi_discount' ) {
155
+            add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' );
156
+        }
157 157
 		
158 158
 
159
-	}
159
+    }
160 160
 
161
-	/**
162
-	 * Remove some metaboxes.
163
-	 */
164
-	public static function remove_meta_boxes() {
165
-		remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' );
166
-	}
161
+    /**
162
+     * Remove some metaboxes.
163
+     */
164
+    public static function remove_meta_boxes() {
165
+        remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' );
166
+    }
167 167
 
168
-	/**
169
-	 * Rename other metaboxes.
170
-	 */
171
-	public static function rename_meta_boxes() {
168
+    /**
169
+     * Rename other metaboxes.
170
+     */
171
+    public static function rename_meta_boxes() {
172 172
 		
173
-	}
174
-
175
-	/**
176
-	 * Check if we're saving, then trigger an action based on the post type.
177
-	 *
178
-	 * @param  int    $post_id Post ID.
179
-	 * @param  object $post Post object.
180
-	 */
181
-	public static function save_meta_boxes( $post_id, $post ) {
182
-		$post_id = absint( $post_id );
183
-		$data    = wp_unslash( $_POST );
184
-
185
-		// Do not save for ajax requests.
186
-		if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
187
-			return;
188
-		}
189
-
190
-		// $post_id and $post are required
191
-		if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) {
192
-			return;
193
-		}
194
-
195
-		// Dont' save meta boxes for revisions or autosaves.
196
-		if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
197
-			return;
198
-		}
199
-
200
-		// Check the nonce.
201
-		if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) {
202
-			return;
203
-		}
204
-
205
-		// Check the post being saved == the $post_id to prevent triggering this call for other save_post events.
206
-		if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) {
207
-			return;
208
-		}
209
-
210
-		// Check user has permission to edit.
211
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
212
-			return;
213
-		}
214
-
215
-		if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
216
-
217
-			// We need this save event to run once to avoid potential endless loops.
218
-			self::$saved_meta_boxes = true;
219
-
220
-			return GetPaid_Meta_Box_Invoice_Address::save( $post_id );
221
-
222
-		}
223
-
224
-		// Ensure this is our post type.
225
-		$post_types_map = array(
226
-			'wpi_item'         => 'GetPaid_Meta_Box_Item_Details',
227
-			'wpi_payment_form' => 'GetPaid_Meta_Box_Payment_Form',
228
-			'wpi_discount'     => 'GetPaid_Meta_Box_Discount_Details',
229
-		);
230
-
231
-		// Is this our post type?
232
-		if ( ! isset( $post_types_map[ $post->post_type ] ) ) {
233
-			return;
234
-		}
235
-
236
-		// We need this save event to run once to avoid potential endless loops.
237
-		self::$saved_meta_boxes = true;
173
+    }
174
+
175
+    /**
176
+     * Check if we're saving, then trigger an action based on the post type.
177
+     *
178
+     * @param  int    $post_id Post ID.
179
+     * @param  object $post Post object.
180
+     */
181
+    public static function save_meta_boxes( $post_id, $post ) {
182
+        $post_id = absint( $post_id );
183
+        $data    = wp_unslash( $_POST );
184
+
185
+        // Do not save for ajax requests.
186
+        if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
187
+            return;
188
+        }
189
+
190
+        // $post_id and $post are required
191
+        if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) {
192
+            return;
193
+        }
194
+
195
+        // Dont' save meta boxes for revisions or autosaves.
196
+        if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
197
+            return;
198
+        }
199
+
200
+        // Check the nonce.
201
+        if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) {
202
+            return;
203
+        }
204
+
205
+        // Check the post being saved == the $post_id to prevent triggering this call for other save_post events.
206
+        if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) {
207
+            return;
208
+        }
209
+
210
+        // Check user has permission to edit.
211
+        if ( ! current_user_can( 'edit_post', $post_id ) ) {
212
+            return;
213
+        }
214
+
215
+        if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
216
+
217
+            // We need this save event to run once to avoid potential endless loops.
218
+            self::$saved_meta_boxes = true;
219
+
220
+            return GetPaid_Meta_Box_Invoice_Address::save( $post_id );
221
+
222
+        }
223
+
224
+        // Ensure this is our post type.
225
+        $post_types_map = array(
226
+            'wpi_item'         => 'GetPaid_Meta_Box_Item_Details',
227
+            'wpi_payment_form' => 'GetPaid_Meta_Box_Payment_Form',
228
+            'wpi_discount'     => 'GetPaid_Meta_Box_Discount_Details',
229
+        );
230
+
231
+        // Is this our post type?
232
+        if ( ! isset( $post_types_map[ $post->post_type ] ) ) {
233
+            return;
234
+        }
235
+
236
+        // We need this save event to run once to avoid potential endless loops.
237
+        self::$saved_meta_boxes = true;
238 238
 		
239
-		// Save the post.
240
-		$class = $post_types_map[ $post->post_type ];
241
-		$class::save( $post_id, $_POST, $post );
239
+        // Save the post.
240
+        $class = $post_types_map[ $post->post_type ];
241
+        $class::save( $post_id, $_POST, $post );
242 242
 
243
-	}
243
+    }
244 244
 
245 245
 }
Please login to merge, or discard this patch.
Spacing   +51 added lines, -51 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
  * Metaboxes Admin Class
@@ -25,36 +25,36 @@  discard block
 block discarded – undo
25 25
 	public static function init() {
26 26
 
27 27
 		// Register metaboxes.
28
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 );
28
+		add_action('add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2);
29 29
 
30 30
 		// Remove metaboxes.
31
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 );
31
+		add_action('add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30);
32 32
 
33 33
 		// Rename metaboxes.
34
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 );
34
+		add_action('add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45);
35 35
 
36 36
 		// Save metaboxes.
37
-		add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 );
37
+		add_action('save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2);
38 38
 	}
39 39
 
40 40
 	/**
41 41
 	 * Register core metaboxes.
42 42
 	 */
43
-	public static function add_meta_boxes( $post_type, $post ) {
43
+	public static function add_meta_boxes($post_type, $post) {
44 44
 		global $wpinv_euvat;
45 45
 
46 46
 		// For invoices...
47
-		if ( getpaid_is_invoice_post_type( $post_type ) ) {
48
-			$invoice = new WPInv_Invoice( $post );
47
+		if (getpaid_is_invoice_post_type($post_type)) {
48
+			$invoice = new WPInv_Invoice($post);
49 49
 
50 50
 			// Resend invoice.
51
-			if ( ! $invoice->is_draft() && ! $invoice->is_paid() ) {
51
+			if (!$invoice->is_draft() && !$invoice->is_paid()) {
52 52
 
53 53
 				add_meta_box(
54 54
 					'wpinv-mb-resend-invoice',
55 55
 					sprintf(
56
-						__( 'Resend %s', 'invoicing' ),
57
-						ucfirst( $invoice->get_type() )
56
+						__('Resend %s', 'invoicing'),
57
+						ucfirst($invoice->get_type())
58 58
 					),
59 59
 					'GetPaid_Meta_Box_Resend_Invoice::output',
60 60
 					$post_type,
@@ -65,18 +65,18 @@  discard block
 block discarded – undo
65 65
 			}
66 66
 
67 67
 			// Subscriptions.
68
-			$subscription = getpaid_get_invoice_subscription( $invoice );
69
-			if ( ! empty( $subscription ) ) {
70
-				add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' );
71
-				add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' );
68
+			$subscription = getpaid_get_invoice_subscription($invoice);
69
+			if (!empty($subscription)) {
70
+				add_meta_box('wpinv-mb-subscriptions', __('Subscription Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced');
71
+				add_meta_box('wpinv-mb-subscription-invoices', __('Related Payments', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced');
72 72
 			}
73 73
 
74 74
 			// Invoice details.
75 75
 			add_meta_box(
76 76
 				'wpinv-details',
77 77
 				sprintf(
78
-					__( '%s Details', 'invoicing' ),
79
-					ucfirst( $invoice->get_type() )
78
+					__('%s Details', 'invoicing'),
79
+					ucfirst($invoice->get_type())
80 80
 				),
81 81
 				'GetPaid_Meta_Box_Invoice_Details::output',
82 82
 				$post_type,
@@ -84,19 +84,19 @@  discard block
 block discarded – undo
84 84
 			);
85 85
 
86 86
 			// Payment details.
87
-			if ( ! $invoice->is_draft() ) {
88
-				add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' );
87
+			if (!$invoice->is_draft()) {
88
+				add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default');
89 89
 			}
90 90
 
91 91
 			// Billing details.
92
-			add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' );
92
+			add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high');
93 93
 			
94 94
 			// Invoice items.
95 95
 			add_meta_box(
96 96
 				'wpinv-items',
97 97
 				sprintf(
98
-					__( '%s Items', 'invoicing' ),
99
-					ucfirst( $invoice->get_type() )
98
+					__('%s Items', 'invoicing'),
99
+					ucfirst($invoice->get_type())
100 100
 				),
101 101
 				'GetPaid_Meta_Box_Invoice_Items::output',
102 102
 				$post_type,
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 			add_meta_box(
109 109
 				'wpinv-notes',
110 110
 				sprintf(
111
-					__( '%s Notes', 'invoicing' ),
112
-					ucfirst( $invoice->get_type() )
111
+					__('%s Notes', 'invoicing'),
112
+					ucfirst($invoice->get_type())
113 113
 				),
114 114
 				'WPInv_Meta_Box_Notes::output',
115 115
 				$post_type,
@@ -118,41 +118,41 @@  discard block
 block discarded – undo
118 118
 			);
119 119
 
120 120
 			// Payment form information.
121
-			if ( ! empty( $post->ID ) && get_post_meta( $post->ID, 'payment_form_data', true ) ) {
122
-				add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' );
121
+			if (!empty($post->ID) && get_post_meta($post->ID, 'payment_form_data', true)) {
122
+				add_meta_box('wpinv-invoice-payment-form-details', __('Payment Form Details', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high');
123 123
 			}
124 124
 		}
125 125
 
126 126
 		// For payment forms.
127
-		if ( $post_type == 'wpi_payment_form' ) {
127
+		if ($post_type == 'wpi_payment_form') {
128 128
 
129 129
 			// Design payment form.
130
-			add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
130
+			add_meta_box('wpinv-payment-form-design', __('Payment Form', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal');
131 131
 
132 132
 			// Payment form information.
133
-			add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' );
133
+			add_meta_box('wpinv-payment-form-info', __('Details', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side');
134 134
 
135 135
 		}
136 136
 
137 137
 		// For invoice items.
138
-		if ( $post_type == 'wpi_item' ) {
138
+		if ($post_type == 'wpi_item') {
139 139
 
140 140
 			// Item details.
141
-			add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' );
141
+			add_meta_box('wpinv_item_details', __('Item Details', 'invoicing'), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high');
142 142
 
143 143
 			// If taxes are enabled, register the tax metabox.
144
-			if ( $wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes() ) {
145
-				add_meta_box( 'wpinv_item_vat', __( 'VAT / Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' );
144
+			if ($wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes()) {
145
+				add_meta_box('wpinv_item_vat', __('VAT / Tax', 'invoicing'), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high');
146 146
 			}
147 147
 
148 148
 			// Item info.
149
-			add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' );
149
+			add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core');
150 150
 
151 151
 		}
152 152
 
153 153
 		// For invoice discounts.
154
-		if ( $post_type == 'wpi_discount' ) {
155
-			add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' );
154
+		if ($post_type == 'wpi_discount') {
155
+			add_meta_box('wpinv_discount_details', __('Discount Details', 'invoicing'), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high');
156 156
 		}
157 157
 		
158 158
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	 * Remove some metaboxes.
163 163
 	 */
164 164
 	public static function remove_meta_boxes() {
165
-		remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' );
165
+		remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal');
166 166
 	}
167 167
 
168 168
 	/**
@@ -178,46 +178,46 @@  discard block
 block discarded – undo
178 178
 	 * @param  int    $post_id Post ID.
179 179
 	 * @param  object $post Post object.
180 180
 	 */
181
-	public static function save_meta_boxes( $post_id, $post ) {
182
-		$post_id = absint( $post_id );
183
-		$data    = wp_unslash( $_POST );
181
+	public static function save_meta_boxes($post_id, $post) {
182
+		$post_id = absint($post_id);
183
+		$data    = wp_unslash($_POST);
184 184
 
185 185
 		// Do not save for ajax requests.
186
-		if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
186
+		if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
187 187
 			return;
188 188
 		}
189 189
 
190 190
 		// $post_id and $post are required
191
-		if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) {
191
+		if (empty($post_id) || empty($post) || self::$saved_meta_boxes) {
192 192
 			return;
193 193
 		}
194 194
 
195 195
 		// Dont' save meta boxes for revisions or autosaves.
196
-		if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
196
+		if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
197 197
 			return;
198 198
 		}
199 199
 
200 200
 		// Check the nonce.
201
-		if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) {
201
+		if (empty($data['getpaid_meta_nonce']) || !wp_verify_nonce($data['getpaid_meta_nonce'], 'getpaid_meta_nonce')) {
202 202
 			return;
203 203
 		}
204 204
 
205 205
 		// Check the post being saved == the $post_id to prevent triggering this call for other save_post events.
206
-		if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) {
206
+		if (empty($data['post_ID']) || absint($data['post_ID']) !== $post_id) {
207 207
 			return;
208 208
 		}
209 209
 
210 210
 		// Check user has permission to edit.
211
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
211
+		if (!current_user_can('edit_post', $post_id)) {
212 212
 			return;
213 213
 		}
214 214
 
215
-		if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
215
+		if (getpaid_is_invoice_post_type($post->post_type)) {
216 216
 
217 217
 			// We need this save event to run once to avoid potential endless loops.
218 218
 			self::$saved_meta_boxes = true;
219 219
 
220
-			return GetPaid_Meta_Box_Invoice_Address::save( $post_id );
220
+			return GetPaid_Meta_Box_Invoice_Address::save($post_id);
221 221
 
222 222
 		}
223 223
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 		);
230 230
 
231 231
 		// Is this our post type?
232
-		if ( ! isset( $post_types_map[ $post->post_type ] ) ) {
232
+		if (!isset($post_types_map[$post->post_type])) {
233 233
 			return;
234 234
 		}
235 235
 
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
 		self::$saved_meta_boxes = true;
238 238
 		
239 239
 		// Save the post.
240
-		$class = $post_types_map[ $post->post_type ];
241
-		$class::save( $post_id, $_POST, $post );
240
+		$class = $post_types_map[$post->post_type];
241
+		$class::save($post_id, $_POST, $post);
242 242
 
243 243
 	}
244 244
 
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 2 patches
Indentation   +225 added lines, -225 removed lines patch added patch discarded remove patch
@@ -14,62 +14,62 @@  discard block
 block discarded – undo
14 14
 class GetPaid_Admin {
15 15
 
16 16
     /**
17
-	 * Local path to this plugins admin directory
18
-	 *
19
-	 * @var         string
20
-	 */
21
-	public $admin_path;
22
-
23
-	/**
24
-	 * Web path to this plugins admin directory
25
-	 *
26
-	 * @var         string
27
-	 */
17
+     * Local path to this plugins admin directory
18
+     *
19
+     * @var         string
20
+     */
21
+    public $admin_path;
22
+
23
+    /**
24
+     * Web path to this plugins admin directory
25
+     *
26
+     * @var         string
27
+     */
28 28
     public $admin_url;
29 29
 
30 30
     /**
31
-	 * Class constructor.
32
-	 */
33
-	public function __construct(){
31
+     * Class constructor.
32
+     */
33
+    public function __construct(){
34 34
 
35 35
         $this->admin_path  = plugin_dir_path( __FILE__ );
36 36
         $this->admin_url   = plugins_url( '/', __FILE__ );
37 37
 
38 38
         if ( is_admin() ) {
39
-			$this->init_admin_hooks();
39
+            $this->init_admin_hooks();
40 40
         }
41 41
 
42 42
     }
43 43
 
44 44
     /**
45
-	 * Init action and filter hooks
46
-	 *
47
-	 */
48
-	private function init_admin_hooks() {
45
+     * Init action and filter hooks
46
+     *
47
+     */
48
+    private function init_admin_hooks() {
49 49
         add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
50 50
         add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
51 51
         add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
52 52
         add_action( 'admin_init', array( $this, 'activation_redirect') );
53 53
         add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
54
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
55
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
56
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
57
-		do_action( 'getpaid_init_admin_hooks', $this );
54
+        add_action( 'admin_notices', array( $this, 'show_notices' ) );
55
+        add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
56
+        add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
57
+        do_action( 'getpaid_init_admin_hooks', $this );
58 58
 
59 59
     }
60 60
 
61 61
     /**
62
-	 * Register admin scripts
63
-	 *
64
-	 */
65
-	public function enqeue_scripts() {
62
+     * Register admin scripts
63
+     *
64
+     */
65
+    public function enqeue_scripts() {
66 66
         global $current_screen, $pagenow;
67 67
 
68
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
69
-		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
68
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
69
+        $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
70 70
 
71 71
         if ( ! empty( $current_screen->post_type ) ) {
72
-			$page = $current_screen->post_type;
72
+            $page = $current_screen->post_type;
73 73
         }
74 74
 
75 75
         // General styles.
@@ -93,30 +93,30 @@  discard block
 block discarded – undo
93 93
         }
94 94
 
95 95
         // Payment form scripts.
96
-		if ( 'wpi_payment_form' == $page && $editing ) {
96
+        if ( 'wpi_payment_form' == $page && $editing ) {
97 97
             $this->load_payment_form_scripts();
98 98
         }
99 99
 
100 100
         if ( $page == 'wpinv-subscriptions' ) {
101
-			wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
102
-			wp_enqueue_script( 'wpinv-sub-admin-script' );
103
-		}
101
+            wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
102
+            wp_enqueue_script( 'wpinv-sub-admin-script' );
103
+        }
104 104
 
105
-		if ( $page == 'wpinv-reports' ) {
106
-			wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' );
107
-		}
105
+        if ( $page == 'wpinv-reports' ) {
106
+            wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' );
107
+        }
108 108
 
109
-		if ( $page == 'wpinv-subscriptions' ) {
110
-			wp_enqueue_script( 'postbox' );
111
-		}
109
+        if ( $page == 'wpinv-subscriptions' ) {
110
+            wp_enqueue_script( 'postbox' );
111
+        }
112 112
 
113 113
     }
114 114
 
115 115
     /**
116
-	 * Returns admin js translations.
117
-	 *
118
-	 */
119
-	protected function get_admin_i18() {
116
+     * Returns admin js translations.
117
+     *
118
+     */
119
+    protected function get_admin_i18() {
120 120
         global $post;
121 121
 
122 122
         $i18n = array(
@@ -152,50 +152,50 @@  discard block
 block discarded – undo
152 152
             'searching'                 => __( 'Searching', 'invoicing' ),
153 153
         );
154 154
 
155
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
155
+        if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
156 156
 
157
-			$invoice              = new WPInv_Invoice( $post );
158
-			$i18n['save_invoice'] = sprintf(
159
-				__( 'Save %s', 'invoicing' ),
160
-				ucfirst( $invoice->get_type() )
161
-			);
157
+            $invoice              = new WPInv_Invoice( $post );
158
+            $i18n['save_invoice'] = sprintf(
159
+                __( 'Save %s', 'invoicing' ),
160
+                ucfirst( $invoice->get_type() )
161
+            );
162 162
 
163
-			$i18n['invoice_description'] = sprintf(
164
-				__( '%s Description', 'invoicing' ),
165
-				ucfirst( $invoice->get_type() )
166
-			);
163
+            $i18n['invoice_description'] = sprintf(
164
+                __( '%s Description', 'invoicing' ),
165
+                ucfirst( $invoice->get_type() )
166
+            );
167 167
 
168
-		}
169
-		return $i18n;
168
+        }
169
+        return $i18n;
170 170
     }
171 171
 
172 172
     /**
173
-	 * Loads payment form js.
174
-	 *
175
-	 */
176
-	protected function load_payment_form_scripts() {
173
+     * Loads payment form js.
174
+     *
175
+     */
176
+    protected function load_payment_form_scripts() {
177 177
         global $post;
178 178
 
179 179
         wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
180
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
181
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
180
+        wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
181
+        wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
182 182
 
183
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
184
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
183
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
184
+        wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
185 185
 
186
-		wp_localize_script(
186
+        wp_localize_script(
187 187
             'wpinv-admin-payment-form-script',
188 188
             'wpinvPaymentFormAdmin',
189 189
             array(
190
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
191
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
192
-				'currency'      => wpinv_currency_symbol(),
193
-				'position'      => wpinv_currency_position(),
194
-				'decimals'      => (int) wpinv_decimals(),
195
-				'thousands_sep' => wpinv_thousands_separator(),
196
-				'decimals_sep'  => wpinv_decimal_separator(),
197
-				'form_items'    => gepaid_get_form_items( $post->ID ),
198
-				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
190
+                'elements'      => wpinv_get_data( 'payment-form-elements' ),
191
+                'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
192
+                'currency'      => wpinv_currency_symbol(),
193
+                'position'      => wpinv_currency_position(),
194
+                'decimals'      => (int) wpinv_decimals(),
195
+                'thousands_sep' => wpinv_thousands_separator(),
196
+                'decimals_sep'  => wpinv_decimal_separator(),
197
+                'form_items'    => gepaid_get_form_items( $post->ID ),
198
+                'is_default'    => $post->ID == wpinv_get_default_payment_form(),
199 199
             )
200 200
         );
201 201
 
@@ -204,20 +204,20 @@  discard block
 block discarded – undo
204 204
     }
205 205
 
206 206
     /**
207
-	 * Add our classes to admin pages.
207
+     * Add our classes to admin pages.
208 208
      *
209 209
      * @param string $classes
210 210
      * @return string
211
-	 *
212
-	 */
211
+     *
212
+     */
213 213
     public function admin_body_class( $classes ) {
214
-		global $pagenow, $post, $current_screen;
214
+        global $pagenow, $post, $current_screen;
215 215
 
216 216
 
217 217
         $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
218 218
 
219 219
         if ( ! empty( $current_screen->post_type ) ) {
220
-			$page = $current_screen->post_type;
220
+            $page = $current_screen->post_type;
221 221
         }
222 222
 
223 223
         if ( false !== stripos( $page, 'wpi' ) ) {
@@ -226,33 +226,33 @@  discard block
 block discarded – undo
226 226
 
227 227
         if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
228 228
             $classes .= ' wpinv-cpt wpinv';
229
-		}
229
+        }
230 230
 		
231
-		if ( getpaid_is_invoice_post_type( $page ) ) {
231
+        if ( getpaid_is_invoice_post_type( $page ) ) {
232 232
             $classes .= ' getpaid-is-invoice-cpt';
233 233
         }
234 234
 
235
-		if ( $pagenow == 'post.php' && $page == 'wpi_item' && ! empty( $post ) && ! wpinv_item_is_editable( $post ) ) {
236
-			$classes .= ' wpi-editable-n';
237
-		}
235
+        if ( $pagenow == 'post.php' && $page == 'wpi_item' && ! empty( $post ) && ! wpinv_item_is_editable( $post ) ) {
236
+            $classes .= ' wpi-editable-n';
237
+        }
238 238
 
239
-		return $classes;
239
+        return $classes;
240 240
     }
241 241
 
242 242
     /**
243
-	 * Maybe show the AyeCode Connect Notice.
244
-	 */
245
-	public function init_ayecode_connect_helper(){
243
+     * Maybe show the AyeCode Connect Notice.
244
+     */
245
+    public function init_ayecode_connect_helper(){
246 246
 
247 247
         new AyeCode_Connect_Helper(
248 248
             array(
249
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
250
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
251
-				'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>" ),
252
-				'connect_button'    => __("Connect Site","invoicing"),
253
-				'connecting_button'    => __("Connecting...","invoicing"),
254
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
255
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
249
+                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
250
+                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
251
+                '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>" ),
252
+                'connect_button'    => __("Connect Site","invoicing"),
253
+                'connecting_button'    => __("Connecting...","invoicing"),
254
+                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
255
+                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
256 256
             ),
257 257
             array( 'wpi-addons' )
258 258
         );
@@ -264,21 +264,21 @@  discard block
 block discarded – undo
264 264
      */
265 265
     public function activation_redirect() {
266 266
 
267
-		// Bail if no activation redirect.
268
-		if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) {
269
-			return;
270
-		}
267
+        // Bail if no activation redirect.
268
+        if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) {
269
+            return;
270
+        }
271 271
 
272
-		// Delete the redirect transient.
273
-		delete_transient( '_wpinv_activation_redirect' );
272
+        // Delete the redirect transient.
273
+        delete_transient( '_wpinv_activation_redirect' );
274 274
 
275
-		// Bail if activating from network, or bulk
276
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
277
-			return;
278
-		}
275
+        // Bail if activating from network, or bulk
276
+        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
277
+            return;
278
+        }
279 279
 
280
-		wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
281
-		exit;
280
+        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
281
+        exit;
282 282
     }
283 283
 
284 284
     /**
@@ -293,150 +293,150 @@  discard block
 block discarded – undo
293 293
 
294 294
     }
295 295
 
296
-	/**
296
+    /**
297 297
      * Sends a payment reminder to a customer.
298
-	 * 
299
-	 * @param array $args
298
+     * 
299
+     * @param array $args
300 300
      */
301 301
     public function send_customer_invoice( $args ) {
302
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
302
+        $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
303 303
 
304
-		if ( $sent ) {
305
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
306
-		} else {
307
-			$this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
308
-		}
304
+        if ( $sent ) {
305
+            $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
306
+        } else {
307
+            $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
308
+        }
309 309
 
310
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
311
-		exit;
312
-	}
310
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
311
+        exit;
312
+    }
313 313
 
314
-	/**
314
+    /**
315 315
      * Sends a payment reminder to a customer.
316
-	 * 
317
-	 * @param array $args
316
+     * 
317
+     * @param array $args
318 318
      */
319 319
     public function send_customer_payment_reminder( $args ) {
320
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
320
+        $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
321 321
 
322
-		if ( $sent ) {
323
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
324
-		} else {
325
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
326
-		}
322
+        if ( $sent ) {
323
+            $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
324
+        } else {
325
+            $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
326
+        }
327 327
 
328
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
329
-		exit;
330
-	}
328
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
329
+        exit;
330
+    }
331 331
 
332 332
     /**
333
-	 * Returns an array of admin notices.
334
-	 *
335
-	 * @since       1.0.19
333
+     * Returns an array of admin notices.
334
+     *
335
+     * @since       1.0.19
336 336
      * @return array
337
-	 */
338
-	public function get_notices() {
339
-		$notices = get_option( 'wpinv_admin_notices' );
337
+     */
338
+    public function get_notices() {
339
+        $notices = get_option( 'wpinv_admin_notices' );
340 340
         return is_array( $notices ) ? $notices : array();
341
-	}
342
-
343
-	/**
344
-	 * Clears all admin notices
345
-	 *
346
-	 * @access      public
347
-	 * @since       1.0.19
348
-	 */
349
-	public function clear_notices() {
350
-		delete_option( 'wpinv_admin_notices' );
351
-	}
352
-
353
-	/**
354
-	 * Saves a new admin notice
355
-	 *
356
-	 * @access      public
357
-	 * @since       1.0.19
358
-	 */
359
-	public function save_notice( $type, $message ) {
360
-		$notices = $this->get_notices();
361
-
362
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
363
-			$notices[ $type ] = array();
364
-		}
365
-
366
-		$notices[ $type ][] = $message;
367
-
368
-		update_option( 'wpinv_admin_notices', $notices );
369
-	}
370
-
371
-	/**
372
-	 * Displays a success notice
373
-	 *
374
-	 * @param       string $msg The message to qeue.
375
-	 * @access      public
376
-	 * @since       1.0.19
377
-	 */
378
-	public function show_success( $msg ) {
379
-		$this->save_notice( 'success', $msg );
380
-	}
381
-
382
-	/**
383
-	 * Displays a error notice
384
-	 *
385
-	 * @access      public
386
-	 * @param       string $msg The message to qeue.
387
-	 * @since       1.0.19
388
-	 */
389
-	public function show_error( $msg ) {
390
-		$this->save_notice( 'error', $msg );
391
-	}
392
-
393
-	/**
394
-	 * Displays a warning notice
395
-	 *
396
-	 * @access      public
397
-	 * @param       string $msg The message to qeue.
398
-	 * @since       1.0.19
399
-	 */
400
-	public function show_warning( $msg ) {
401
-		$this->save_notice( 'warning', $msg );
402
-	}
403
-
404
-	/**
405
-	 * Displays a info notice
406
-	 *
407
-	 * @access      public
408
-	 * @param       string $msg The message to qeue.
409
-	 * @since       1.0.19
410
-	 */
411
-	public function show_info( $msg ) {
412
-		$this->save_notice( 'info', $msg );
413
-	}
414
-
415
-	/**
416
-	 * Show notices
417
-	 *
418
-	 * @access      public
419
-	 * @since       1.0.19
420
-	 */
421
-	public function show_notices() {
341
+    }
342
+
343
+    /**
344
+     * Clears all admin notices
345
+     *
346
+     * @access      public
347
+     * @since       1.0.19
348
+     */
349
+    public function clear_notices() {
350
+        delete_option( 'wpinv_admin_notices' );
351
+    }
352
+
353
+    /**
354
+     * Saves a new admin notice
355
+     *
356
+     * @access      public
357
+     * @since       1.0.19
358
+     */
359
+    public function save_notice( $type, $message ) {
360
+        $notices = $this->get_notices();
361
+
362
+        if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
363
+            $notices[ $type ] = array();
364
+        }
365
+
366
+        $notices[ $type ][] = $message;
367
+
368
+        update_option( 'wpinv_admin_notices', $notices );
369
+    }
370
+
371
+    /**
372
+     * Displays a success notice
373
+     *
374
+     * @param       string $msg The message to qeue.
375
+     * @access      public
376
+     * @since       1.0.19
377
+     */
378
+    public function show_success( $msg ) {
379
+        $this->save_notice( 'success', $msg );
380
+    }
381
+
382
+    /**
383
+     * Displays a error notice
384
+     *
385
+     * @access      public
386
+     * @param       string $msg The message to qeue.
387
+     * @since       1.0.19
388
+     */
389
+    public function show_error( $msg ) {
390
+        $this->save_notice( 'error', $msg );
391
+    }
392
+
393
+    /**
394
+     * Displays a warning notice
395
+     *
396
+     * @access      public
397
+     * @param       string $msg The message to qeue.
398
+     * @since       1.0.19
399
+     */
400
+    public function show_warning( $msg ) {
401
+        $this->save_notice( 'warning', $msg );
402
+    }
403
+
404
+    /**
405
+     * Displays a info notice
406
+     *
407
+     * @access      public
408
+     * @param       string $msg The message to qeue.
409
+     * @since       1.0.19
410
+     */
411
+    public function show_info( $msg ) {
412
+        $this->save_notice( 'info', $msg );
413
+    }
414
+
415
+    /**
416
+     * Show notices
417
+     *
418
+     * @access      public
419
+     * @since       1.0.19
420
+     */
421
+    public function show_notices() {
422 422
 
423 423
         $notices = $this->get_notices();
424 424
         $this->clear_notices();
425 425
 
426
-		foreach ( $notices as $type => $messages ) {
426
+        foreach ( $notices as $type => $messages ) {
427 427
 
428
-			if ( ! is_array( $messages ) ) {
429
-				continue;
430
-			}
428
+            if ( ! is_array( $messages ) ) {
429
+                continue;
430
+            }
431 431
 
432 432
             $type  = sanitize_key( $type );
433
-			foreach ( $messages as $message ) {
433
+            foreach ( $messages as $message ) {
434 434
                 $message = wp_kses_post( $message );
435
-				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
435
+                echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
436 436
             }
437 437
 
438 438
         }
439 439
 
440
-	}
440
+    }
441 441
 
442 442
 }
Please login to merge, or discard this patch.
Spacing   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * The main admin class.
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
     /**
31 31
 	 * Class constructor.
32 32
 	 */
33
-	public function __construct(){
33
+	public function __construct() {
34 34
 
35
-        $this->admin_path  = plugin_dir_path( __FILE__ );
36
-        $this->admin_url   = plugins_url( '/', __FILE__ );
35
+        $this->admin_path  = plugin_dir_path(__FILE__);
36
+        $this->admin_url   = plugins_url('/', __FILE__);
37 37
 
38
-        if ( is_admin() ) {
38
+        if (is_admin()) {
39 39
 			$this->init_admin_hooks();
40 40
         }
41 41
 
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
 	 *
47 47
 	 */
48 48
 	private function init_admin_hooks() {
49
-        add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
50
-        add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
51
-        add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
52
-        add_action( 'admin_init', array( $this, 'activation_redirect') );
53
-        add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
54
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
55
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
56
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
57
-		do_action( 'getpaid_init_admin_hooks', $this );
49
+        add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'));
50
+        add_filter('admin_body_class', array($this, 'admin_body_class'));
51
+        add_action('admin_init', array($this, 'init_ayecode_connect_helper'));
52
+        add_action('admin_init', array($this, 'activation_redirect'));
53
+        add_action('admin_init', array($this, 'maybe_do_admin_action'));
54
+		add_action('admin_notices', array($this, 'show_notices'));
55
+		add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice'));
56
+		add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder'));
57
+		do_action('getpaid_init_admin_hooks', $this);
58 58
 
59 59
     }
60 60
 
@@ -65,49 +65,49 @@  discard block
 block discarded – undo
65 65
 	public function enqeue_scripts() {
66 66
         global $current_screen, $pagenow;
67 67
 
68
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
68
+		$page    = isset($_GET['page']) ? $_GET['page'] : '';
69 69
 		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
70 70
 
71
-        if ( ! empty( $current_screen->post_type ) ) {
71
+        if (!empty($current_screen->post_type)) {
72 72
 			$page = $current_screen->post_type;
73 73
         }
74 74
 
75 75
         // General styles.
76
-        if ( false !== stripos( $page, 'wpi' ) ) {
76
+        if (false !== stripos($page, 'wpi')) {
77 77
 
78 78
             // Styles.
79
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
80
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
81
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
82
-            wp_enqueue_style( 'wp_enqueue_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
83
-            wp_enqueue_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16' );
79
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
80
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
81
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
82
+            wp_enqueue_style('wp_enqueue_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
83
+            wp_enqueue_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16');
84 84
 
85 85
             // Scripts.
86
-            wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '4.0.13', true );
87
-            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
86
+            wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '4.0.13', true);
87
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
88 88
 
89
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
90
-            wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker' ),  $version );
91
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
89
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
90
+            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker'), $version);
91
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
92 92
 
93 93
         }
94 94
 
95 95
         // Payment form scripts.
96
-		if ( 'wpi_payment_form' == $page && $editing ) {
96
+		if ('wpi_payment_form' == $page && $editing) {
97 97
             $this->load_payment_form_scripts();
98 98
         }
99 99
 
100
-        if ( $page == 'wpinv-subscriptions' ) {
101
-			wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
102
-			wp_enqueue_script( 'wpinv-sub-admin-script' );
100
+        if ($page == 'wpinv-subscriptions') {
101
+			wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION);
102
+			wp_enqueue_script('wpinv-sub-admin-script');
103 103
 		}
104 104
 
105
-		if ( $page == 'wpinv-reports' ) {
106
-			wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' );
105
+		if ($page == 'wpinv-reports') {
106
+			wp_enqueue_script('jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array('jquery'), '0.7');
107 107
 		}
108 108
 
109
-		if ( $page == 'wpinv-subscriptions' ) {
110
-			wp_enqueue_script( 'postbox' );
109
+		if ($page == 'wpinv-subscriptions') {
110
+			wp_enqueue_script('postbox');
111 111
 		}
112 112
 
113 113
     }
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
         global $post;
121 121
 
122 122
         $i18n = array(
123
-            'ajax_url'                  => admin_url( 'admin-ajax.php' ),
124
-            'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
125
-            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
126
-            'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
127
-            'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
128
-            'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
129
-            'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
123
+            'ajax_url'                  => admin_url('admin-ajax.php'),
124
+            'post_ID'                   => isset($post->ID) ? $post->ID : '',
125
+            'wpinv_nonce'               => wp_create_nonce('wpinv-nonce'),
126
+            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'),
127
+            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'),
128
+            'invoice_item_nonce'        => wp_create_nonce('invoice-item'),
129
+            'billing_details_nonce'     => wp_create_nonce('get-billing-details'),
130 130
             'tax'                       => wpinv_tax_amount(),
131 131
             'discount'                  => wpinv_discount_amount(),
132 132
             'currency_symbol'           => wpinv_currency_symbol(),
@@ -134,35 +134,35 @@  discard block
 block discarded – undo
134 134
             'thousand_sep'              => wpinv_thousands_separator(),
135 135
             'decimal_sep'               => wpinv_decimal_separator(),
136 136
             'decimals'                  => wpinv_decimals(),
137
-            'save_invoice'              => __( 'Save Invoice', 'invoicing' ),
138
-            'status_publish'            => wpinv_status_nicename( 'publish' ),
139
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
140
-            'delete_tax_rate'           => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),
141
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
142
-            'FillBillingDetails'        => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),
143
-            'confirmCalcTotals'         => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ),
144
-            'AreYouSure'                => __( 'Are you sure?', 'invoicing' ),
145
-            'errDeleteItem'             => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),
146
-            'delete_subscription'       => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),
147
-            'action_edit'               => __( 'Edit', 'invoicing' ),
148
-            'action_cancel'             => __( 'Cancel', 'invoicing' ),
149
-            'item_description'          => __( 'Item Description', 'invoicing' ),
150
-            'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
151
-            'discount_description'      => __( 'Discount Description', 'invoicing' ),
152
-            'searching'                 => __( 'Searching', 'invoicing' ),
137
+            'save_invoice'              => __('Save Invoice', 'invoicing'),
138
+            'status_publish'            => wpinv_status_nicename('publish'),
139
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
140
+            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'),
141
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
142
+            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'),
143
+            'confirmCalcTotals'         => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'),
144
+            'AreYouSure'                => __('Are you sure?', 'invoicing'),
145
+            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'),
146
+            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'),
147
+            'action_edit'               => __('Edit', 'invoicing'),
148
+            'action_cancel'             => __('Cancel', 'invoicing'),
149
+            'item_description'          => __('Item Description', 'invoicing'),
150
+            'invoice_description'       => __('Invoice Description', 'invoicing'),
151
+            'discount_description'      => __('Discount Description', 'invoicing'),
152
+            'searching'                 => __('Searching', 'invoicing'),
153 153
         );
154 154
 
155
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
155
+		if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) {
156 156
 
157
-			$invoice              = new WPInv_Invoice( $post );
157
+			$invoice              = new WPInv_Invoice($post);
158 158
 			$i18n['save_invoice'] = sprintf(
159
-				__( 'Save %s', 'invoicing' ),
160
-				ucfirst( $invoice->get_type() )
159
+				__('Save %s', 'invoicing'),
160
+				ucfirst($invoice->get_type())
161 161
 			);
162 162
 
163 163
 			$i18n['invoice_description'] = sprintf(
164
-				__( '%s Description', 'invoicing' ),
165
-				ucfirst( $invoice->get_type() )
164
+				__('%s Description', 'invoicing'),
165
+				ucfirst($invoice->get_type())
166 166
 			);
167 167
 
168 168
 		}
@@ -176,30 +176,30 @@  discard block
 block discarded – undo
176 176
 	protected function load_payment_form_scripts() {
177 177
         global $post;
178 178
 
179
-        wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
180
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
181
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
179
+        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION);
180
+		wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
181
+		wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
182 182
 
183
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
184
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
183
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
184
+		wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
185 185
 
186 186
 		wp_localize_script(
187 187
             'wpinv-admin-payment-form-script',
188 188
             'wpinvPaymentFormAdmin',
189 189
             array(
190
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
191
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
190
+				'elements'      => wpinv_get_data('payment-form-elements'),
191
+				'form_elements' => getpaid_get_payment_form_elements($post->ID),
192 192
 				'currency'      => wpinv_currency_symbol(),
193 193
 				'position'      => wpinv_currency_position(),
194 194
 				'decimals'      => (int) wpinv_decimals(),
195 195
 				'thousands_sep' => wpinv_thousands_separator(),
196 196
 				'decimals_sep'  => wpinv_decimal_separator(),
197
-				'form_items'    => gepaid_get_form_items( $post->ID ),
197
+				'form_items'    => gepaid_get_form_items($post->ID),
198 198
 				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
199 199
             )
200 200
         );
201 201
 
202
-        wp_enqueue_script( 'wpinv-admin-payment-form-script' );
202
+        wp_enqueue_script('wpinv-admin-payment-form-script');
203 203
 
204 204
     }
205 205
 
@@ -210,29 +210,29 @@  discard block
 block discarded – undo
210 210
      * @return string
211 211
 	 *
212 212
 	 */
213
-    public function admin_body_class( $classes ) {
213
+    public function admin_body_class($classes) {
214 214
 		global $pagenow, $post, $current_screen;
215 215
 
216 216
 
217
-        $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
217
+        $page = isset($_GET['page']) ? $_GET['page'] : '';
218 218
 
219
-        if ( ! empty( $current_screen->post_type ) ) {
219
+        if (!empty($current_screen->post_type)) {
220 220
 			$page = $current_screen->post_type;
221 221
         }
222 222
 
223
-        if ( false !== stripos( $page, 'wpi' ) ) {
224
-            $classes .= ' wpi-' . sanitize_key( $page );
223
+        if (false !== stripos($page, 'wpi')) {
224
+            $classes .= ' wpi-' . sanitize_key($page);
225 225
         }
226 226
 
227
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
227
+        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) {
228 228
             $classes .= ' wpinv-cpt wpinv';
229 229
 		}
230 230
 		
231
-		if ( getpaid_is_invoice_post_type( $page ) ) {
231
+		if (getpaid_is_invoice_post_type($page)) {
232 232
             $classes .= ' getpaid-is-invoice-cpt';
233 233
         }
234 234
 
235
-		if ( $pagenow == 'post.php' && $page == 'wpi_item' && ! empty( $post ) && ! wpinv_item_is_editable( $post ) ) {
235
+		if ($pagenow == 'post.php' && $page == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
236 236
 			$classes .= ' wpi-editable-n';
237 237
 		}
238 238
 
@@ -242,19 +242,19 @@  discard block
 block discarded – undo
242 242
     /**
243 243
 	 * Maybe show the AyeCode Connect Notice.
244 244
 	 */
245
-	public function init_ayecode_connect_helper(){
245
+	public function init_ayecode_connect_helper() {
246 246
 
247 247
         new AyeCode_Connect_Helper(
248 248
             array(
249
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
250
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
251
-				'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>" ),
252
-				'connect_button'    => __("Connect Site","invoicing"),
253
-				'connecting_button'    => __("Connecting...","invoicing"),
254
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
255
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
249
+				'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
250
+				'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
251
+				'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>"),
252
+				'connect_button'    => __("Connect Site", "invoicing"),
253
+				'connecting_button'    => __("Connecting...", "invoicing"),
254
+				'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
255
+				'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
256 256
             ),
257
-            array( 'wpi-addons' )
257
+            array('wpi-addons')
258 258
         );
259 259
 
260 260
     }
@@ -265,19 +265,19 @@  discard block
 block discarded – undo
265 265
     public function activation_redirect() {
266 266
 
267 267
 		// Bail if no activation redirect.
268
-		if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) {
268
+		if (!get_transient('_wpinv_activation_redirect') || wp_doing_ajax()) {
269 269
 			return;
270 270
 		}
271 271
 
272 272
 		// Delete the redirect transient.
273
-		delete_transient( '_wpinv_activation_redirect' );
273
+		delete_transient('_wpinv_activation_redirect');
274 274
 
275 275
 		// Bail if activating from network, or bulk
276
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
276
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
277 277
 			return;
278 278
 		}
279 279
 
280
-		wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
280
+		wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
281 281
 		exit;
282 282
     }
283 283
 
@@ -286,9 +286,9 @@  discard block
 block discarded – undo
286 286
      */
287 287
     public function maybe_do_admin_action() {
288 288
 
289
-        if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
290
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
291
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
289
+        if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
290
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
291
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
292 292
         }
293 293
 
294 294
     }
@@ -298,16 +298,16 @@  discard block
 block discarded – undo
298 298
 	 * 
299 299
 	 * @param array $args
300 300
      */
301
-    public function send_customer_invoice( $args ) {
302
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
301
+    public function send_customer_invoice($args) {
302
+		$sent = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']));
303 303
 
304
-		if ( $sent ) {
305
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
304
+		if ($sent) {
305
+			$this->show_success(__('Invoice was successfully sent to the customer', 'invoicing'));
306 306
 		} else {
307
-			$this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
307
+			$this->show_error(__('Could not sent the invoice to the customer', 'invoicing'));
308 308
 		}
309 309
 
310
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
310
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
311 311
 		exit;
312 312
 	}
313 313
 
@@ -316,16 +316,16 @@  discard block
 block discarded – undo
316 316
 	 * 
317 317
 	 * @param array $args
318 318
      */
319
-    public function send_customer_payment_reminder( $args ) {
320
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
319
+    public function send_customer_payment_reminder($args) {
320
+		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id']));
321 321
 
322
-		if ( $sent ) {
323
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
322
+		if ($sent) {
323
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
324 324
 		} else {
325
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
325
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
326 326
 		}
327 327
 
328
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
328
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
329 329
 		exit;
330 330
 	}
331 331
 
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
      * @return array
337 337
 	 */
338 338
 	public function get_notices() {
339
-		$notices = get_option( 'wpinv_admin_notices' );
340
-        return is_array( $notices ) ? $notices : array();
339
+		$notices = get_option('wpinv_admin_notices');
340
+        return is_array($notices) ? $notices : array();
341 341
 	}
342 342
 
343 343
 	/**
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 	 * @since       1.0.19
348 348
 	 */
349 349
 	public function clear_notices() {
350
-		delete_option( 'wpinv_admin_notices' );
350
+		delete_option('wpinv_admin_notices');
351 351
 	}
352 352
 
353 353
 	/**
@@ -356,16 +356,16 @@  discard block
 block discarded – undo
356 356
 	 * @access      public
357 357
 	 * @since       1.0.19
358 358
 	 */
359
-	public function save_notice( $type, $message ) {
359
+	public function save_notice($type, $message) {
360 360
 		$notices = $this->get_notices();
361 361
 
362
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
363
-			$notices[ $type ] = array();
362
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
363
+			$notices[$type] = array();
364 364
 		}
365 365
 
366
-		$notices[ $type ][] = $message;
366
+		$notices[$type][] = $message;
367 367
 
368
-		update_option( 'wpinv_admin_notices', $notices );
368
+		update_option('wpinv_admin_notices', $notices);
369 369
 	}
370 370
 
371 371
 	/**
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
 	 * @access      public
376 376
 	 * @since       1.0.19
377 377
 	 */
378
-	public function show_success( $msg ) {
379
-		$this->save_notice( 'success', $msg );
378
+	public function show_success($msg) {
379
+		$this->save_notice('success', $msg);
380 380
 	}
381 381
 
382 382
 	/**
@@ -386,8 +386,8 @@  discard block
 block discarded – undo
386 386
 	 * @param       string $msg The message to qeue.
387 387
 	 * @since       1.0.19
388 388
 	 */
389
-	public function show_error( $msg ) {
390
-		$this->save_notice( 'error', $msg );
389
+	public function show_error($msg) {
390
+		$this->save_notice('error', $msg);
391 391
 	}
392 392
 
393 393
 	/**
@@ -397,8 +397,8 @@  discard block
 block discarded – undo
397 397
 	 * @param       string $msg The message to qeue.
398 398
 	 * @since       1.0.19
399 399
 	 */
400
-	public function show_warning( $msg ) {
401
-		$this->save_notice( 'warning', $msg );
400
+	public function show_warning($msg) {
401
+		$this->save_notice('warning', $msg);
402 402
 	}
403 403
 
404 404
 	/**
@@ -408,8 +408,8 @@  discard block
 block discarded – undo
408 408
 	 * @param       string $msg The message to qeue.
409 409
 	 * @since       1.0.19
410 410
 	 */
411
-	public function show_info( $msg ) {
412
-		$this->save_notice( 'info', $msg );
411
+	public function show_info($msg) {
412
+		$this->save_notice('info', $msg);
413 413
 	}
414 414
 
415 415
 	/**
@@ -423,15 +423,15 @@  discard block
 block discarded – undo
423 423
         $notices = $this->get_notices();
424 424
         $this->clear_notices();
425 425
 
426
-		foreach ( $notices as $type => $messages ) {
426
+		foreach ($notices as $type => $messages) {
427 427
 
428
-			if ( ! is_array( $messages ) ) {
428
+			if (!is_array($messages)) {
429 429
 				continue;
430 430
 			}
431 431
 
432
-            $type  = sanitize_key( $type );
433
-			foreach ( $messages as $message ) {
434
-                $message = wp_kses_post( $message );
432
+            $type = sanitize_key($type);
433
+			foreach ($messages as $message) {
434
+                $message = wp_kses_post($message);
435 435
 				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
436 436
             }
437 437
 
Please login to merge, or discard this patch.
includes/admin/class-wpinv-admin-menus.php 1 patch
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Setup menus in WP admin.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WC_Admin_Menus Class.
@@ -13,25 +13,25 @@  discard block
 block discarded – undo
13 13
      * Hook in tabs.
14 14
      */
15 15
     public function __construct() {
16
-        add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 );
17
-        add_action( 'admin_menu', array( $this, 'add_customers_menu' ), 18 );
18
-        add_action( 'admin_menu', array( $this, 'add_subscriptions_menu' ), 40 );
19
-        add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 100 );
20
-        add_action( 'admin_menu', array( $this, 'add_settings_menu' ), 60 );
21
-        add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 );
22
-        add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) );
16
+        add_action('admin_menu', array($this, 'admin_menu'), 10);
17
+        add_action('admin_menu', array($this, 'add_customers_menu'), 18);
18
+        add_action('admin_menu', array($this, 'add_subscriptions_menu'), 40);
19
+        add_action('admin_menu', array($this, 'add_addons_menu'), 100);
20
+        add_action('admin_menu', array($this, 'add_settings_menu'), 60);
21
+        add_action('admin_menu', array($this, 'remove_admin_submenus'), 10);
22
+        add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes'));
23 23
     }
24 24
 
25 25
     public function admin_menu() {
26 26
 
27
-        $capability = apply_filters( 'invoicing_capability', wpinv_get_capability() );
27
+        $capability = apply_filters('invoicing_capability', wpinv_get_capability());
28 28
         add_menu_page(
29
-            __( 'GetPaid', 'invoicing' ),
30
-            __( 'GetPaid', 'invoicing' ),
29
+            __('GetPaid', 'invoicing'),
30
+            __('GetPaid', 'invoicing'),
31 31
             $capability,
32 32
             'wpinv',
33 33
             null,
34
-            'data:image/svg+xml;base64,' . base64_encode( file_get_contents( WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg' ) ),
34
+            'data:image/svg+xml;base64,' . base64_encode(file_get_contents(WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg')),
35 35
             '54.123460'
36 36
         );
37 37
 
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
     public function add_customers_menu() {
44 44
         add_submenu_page(
45 45
             'wpinv',
46
-            __( 'Customers', 'invoicing' ),
47
-            __( 'Customers', 'invoicing' ),
46
+            __('Customers', 'invoicing'),
47
+            __('Customers', 'invoicing'),
48 48
             wpinv_get_capability(),
49 49
             'wpinv-customers',
50
-            array( $this, 'customers_page' )
50
+            array($this, 'customers_page')
51 51
         );
52 52
     }
53 53
 
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
     public function add_subscriptions_menu() {
58 58
         add_submenu_page(
59 59
             'wpinv',
60
-            __( 'Subscriptions', 'invoicing' ),
61
-            __( 'Subscriptions', 'invoicing' ),
60
+            __('Subscriptions', 'invoicing'),
61
+            __('Subscriptions', 'invoicing'),
62 62
             wpinv_get_capability(),
63 63
             'wpinv-subscriptions',
64 64
             'wpinv_subscriptions_page'
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      * Displays the customers page.
70 70
      */
71 71
     public function customers_page() {
72
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php' );
72
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php');
73 73
         ?>
74 74
         <div class="wrap wpi-customers-wrap">
75 75
             <style>
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
                     width: 30%;
78 78
                 }
79 79
             </style>
80
-            <h1><?php echo esc_html( __( 'Customers', 'invoicing' ) ); ?></h1>
80
+            <h1><?php echo esc_html(__('Customers', 'invoicing')); ?></h1>
81 81
             <?php
82 82
                 $table = new WPInv_Customers_Table();
83 83
                 $table->prepare_items();
@@ -93,16 +93,16 @@  discard block
 block discarded – undo
93 93
     public function add_settings_menu() {
94 94
         add_submenu_page(
95 95
             'wpinv',
96
-            __( 'Invoice Settings', 'invoicing' ),
97
-            __( 'Settings', 'invoicing' ),
98
-            apply_filters( 'invoicing_capability', wpinv_get_capability() ),
96
+            __('Invoice Settings', 'invoicing'),
97
+            __('Settings', 'invoicing'),
98
+            apply_filters('invoicing_capability', wpinv_get_capability()),
99 99
             'wpinv-settings',
100
-            array( $this, 'options_page' )
100
+            array($this, 'options_page')
101 101
         );
102 102
     }
103 103
 
104
-    public function add_addons_menu(){
105
-        if ( !apply_filters( 'wpi_show_addons_page', true ) ) {
104
+    public function add_addons_menu() {
105
+        if (!apply_filters('wpi_show_addons_page', true)) {
106 106
             return;
107 107
         }
108 108
 
@@ -112,78 +112,78 @@  discard block
 block discarded – undo
112 112
             __('Extensions', 'invoicing'),
113 113
             'manage_options',
114 114
             'wpi-addons',
115
-            array( $this, 'addons_page' )
115
+            array($this, 'addons_page')
116 116
         );
117 117
     }
118 118
 
119
-    public function addons_page(){
119
+    public function addons_page() {
120 120
         $addon_obj = new WPInv_Admin_Addons();
121 121
         $addon_obj->output();
122 122
     }
123 123
 
124 124
     function options_page() {
125
-        $page       = isset( $_GET['page'] )                ? strtolower( $_GET['page'] )               : false;
125
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
126 126
 
127
-        if ( $page !== 'wpinv-settings' ) {
127
+        if ($page !== 'wpinv-settings') {
128 128
             return;
129 129
         }
130 130
 
131 131
         $settings_tabs = wpinv_get_settings_tabs();
132 132
         $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs;
133
-        $active_tab    = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
134
-        $sections      = wpinv_get_settings_tab_sections( $active_tab );
133
+        $active_tab    = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general';
134
+        $sections      = wpinv_get_settings_tab_sections($active_tab);
135 135
         $key           = 'main';
136 136
 
137
-        if ( is_array( $sections ) ) {
138
-            $key = key( $sections );
137
+        if (is_array($sections)) {
138
+            $key = key($sections);
139 139
         }
140 140
 
141
-        $registered_sections = wpinv_get_settings_tab_sections( $active_tab );
142
-        $section             = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key;
141
+        $registered_sections = wpinv_get_settings_tab_sections($active_tab);
142
+        $section             = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key;
143 143
         ob_start();
144 144
         ?>
145 145
         <div class="wrap">
146 146
             <h1 class="nav-tab-wrapper">
147 147
                 <?php
148
-                foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) {
149
-                    $tab_url = add_query_arg( array(
148
+                foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) {
149
+                    $tab_url = add_query_arg(array(
150 150
                         'settings-updated' => false,
151 151
                         'tab' => $tab_id,
152
-                    ) );
152
+                    ));
153 153
 
154 154
                     // Remove the section from the tabs so we always end up at the main section
155
-                    $tab_url = remove_query_arg( 'section', $tab_url );
156
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
155
+                    $tab_url = remove_query_arg('section', $tab_url);
156
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
157 157
 
158 158
                     $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
159 159
 
160
-                    echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
161
-                    echo esc_html( $tab_name );
160
+                    echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">';
161
+                    echo esc_html($tab_name);
162 162
                     echo '</a>';
163 163
                 }
164 164
                 ?>
165 165
             </h1>
166 166
             <?php
167
-            $number_of_sections = count( $sections );
167
+            $number_of_sections = count($sections);
168 168
             $number = 0;
169
-            if ( $number_of_sections > 1 ) {
169
+            if ($number_of_sections > 1) {
170 170
                 echo '<div><ul class="subsubsub">';
171
-                foreach( $sections as $section_id => $section_name ) {
171
+                foreach ($sections as $section_id => $section_name) {
172 172
                     echo '<li>';
173 173
                     $number++;
174
-                    $tab_url = add_query_arg( array(
174
+                    $tab_url = add_query_arg(array(
175 175
                         'settings-updated' => false,
176 176
                         'tab' => $active_tab,
177 177
                         'section' => $section_id
178
-                    ) );
179
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
178
+                    ));
179
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
180 180
                     $class = '';
181
-                    if ( $section == $section_id ) {
181
+                    if ($section == $section_id) {
182 182
                         $class = 'current';
183 183
                     }
184
-                    echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>';
184
+                    echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>';
185 185
 
186
-                    if ( $number != $number_of_sections ) {
186
+                    if ($number != $number_of_sections) {
187 187
                         echo ' | ';
188 188
                     }
189 189
                     echo '</li>';
@@ -195,20 +195,20 @@  discard block
 block discarded – undo
195 195
                 <form method="post" action="options.php">
196 196
                     <table class="form-table">
197 197
                         <?php
198
-                        settings_fields( 'wpinv_settings' );
198
+                        settings_fields('wpinv_settings');
199 199
 
200
-                        if ( 'main' === $section ) {
201
-                            do_action( 'wpinv_settings_tab_top', $active_tab );
200
+                        if ('main' === $section) {
201
+                            do_action('wpinv_settings_tab_top', $active_tab);
202 202
                         }
203 203
 
204
-                        do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section );
205
-                        do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section );
206
-                        do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section );
207
-                        do_action( 'getpaid_settings_tab_bottom', $active_tab, $section );
204
+                        do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section);
205
+                        do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section);
206
+                        do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section);
207
+                        do_action('getpaid_settings_tab_bottom', $active_tab, $section);
208 208
 
209 209
                         // For backwards compatibility
210
-                        if ( 'main' === $section ) {
211
-                            do_action( 'wpinv_settings_tab_bottom', $active_tab );
210
+                        if ('main' === $section) {
211
+                            do_action('wpinv_settings_tab_bottom', $active_tab);
212 212
                         }
213 213
                         ?>
214 214
                     </table>
@@ -222,18 +222,18 @@  discard block
 block discarded – undo
222 222
     }
223 223
 
224 224
     public function remove_admin_submenus() {
225
-        remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' );
225
+        remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice');
226 226
     }
227 227
 
228
-    public function add_nav_menu_meta_boxes(){
229
-        add_meta_box( 'wpinv_endpoints_nav_link', __( 'Invoicing Pages', 'invoicing' ), array( $this, 'nav_menu_links' ), 'nav-menus', 'side', 'low' );
228
+    public function add_nav_menu_meta_boxes() {
229
+        add_meta_box('wpinv_endpoints_nav_link', __('Invoicing Pages', 'invoicing'), array($this, 'nav_menu_links'), 'nav-menus', 'side', 'low');
230 230
     }
231 231
 
232
-    public function nav_menu_links(){
232
+    public function nav_menu_links() {
233 233
         $endpoints = $this->get_menu_items();
234 234
         ?>
235 235
         <div id="invoicing-endpoints" class="posttypediv">
236
-        <?php if(!empty($endpoints['pages'])){ ?>
236
+        <?php if (!empty($endpoints['pages'])) { ?>
237 237
             <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active">
238 238
                 <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear">
239 239
                     <?php
@@ -245,29 +245,29 @@  discard block
 block discarded – undo
245 245
         <?php } ?>
246 246
         <p class="button-controls">
247 247
         <span class="list-controls">
248
-            <a href="<?php echo admin_url( 'nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints' ); ?>" class="select-all"><?php _e( 'Select all', 'invoicing' ); ?></a>
248
+            <a href="<?php echo admin_url('nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints'); ?>" class="select-all"><?php _e('Select all', 'invoicing'); ?></a>
249 249
         </span>
250 250
             <span class="add-to-menu">
251
-            <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints">
251
+            <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints">
252 252
             <span class="spinner"></span>
253 253
         </span>
254 254
         </p>
255 255
         <?php
256 256
     }
257 257
 
258
-    public function get_menu_items(){
258
+    public function get_menu_items() {
259 259
         $items = array();
260 260
 
261
-        $wpinv_history_page_id = (int)wpinv_get_option( 'invoice_history_page' );
262
-        if($wpinv_history_page_id > 0){
261
+        $wpinv_history_page_id = (int) wpinv_get_option('invoice_history_page');
262
+        if ($wpinv_history_page_id > 0) {
263 263
             $item = new stdClass();
264 264
             $item->object_id = $wpinv_history_page_id;
265 265
             $item->db_id = 0;
266
-            $item->object =  'page';
266
+            $item->object = 'page';
267 267
             $item->menu_item_parent = 0;
268 268
             $item->type = 'post_type';
269
-            $item->title = __('Invoice History Page','invoicing');
270
-            $item->url = get_permalink( $wpinv_history_page_id );
269
+            $item->title = __('Invoice History Page', 'invoicing');
270
+            $item->url = get_permalink($wpinv_history_page_id);
271 271
             $item->target = '';
272 272
             $item->attr_title = '';
273 273
             $item->classes = array('wpinv-menu-item');
@@ -276,16 +276,16 @@  discard block
 block discarded – undo
276 276
             $items['pages'][] = $item;
277 277
         }
278 278
 
279
-        $wpinv_sub_history_page_id = (int)wpinv_get_option( 'invoice_subscription_page' );
280
-        if($wpinv_sub_history_page_id > 0){
279
+        $wpinv_sub_history_page_id = (int) wpinv_get_option('invoice_subscription_page');
280
+        if ($wpinv_sub_history_page_id > 0) {
281 281
             $item = new stdClass();
282 282
             $item->object_id = $wpinv_sub_history_page_id;
283 283
             $item->db_id = 0;
284
-            $item->object =  'page';
284
+            $item->object = 'page';
285 285
             $item->menu_item_parent = 0;
286 286
             $item->type = 'post_type';
287
-            $item->title = __('Invoice Subscriptions Page','invoicing');
288
-            $item->url = get_permalink( $wpinv_sub_history_page_id );
287
+            $item->title = __('Invoice Subscriptions Page', 'invoicing');
288
+            $item->url = get_permalink($wpinv_sub_history_page_id);
289 289
             $item->target = '';
290 290
             $item->attr_title = '';
291 291
             $item->classes = array('wpinv-menu-item');
@@ -294,16 +294,16 @@  discard block
 block discarded – undo
294 294
             $items['pages'][] = $item;
295 295
         }
296 296
 
297
-        $wpinv_checkout_page_id = (int)wpinv_get_option( 'checkout_page' );
298
-        if($wpinv_checkout_page_id > 0){
297
+        $wpinv_checkout_page_id = (int) wpinv_get_option('checkout_page');
298
+        if ($wpinv_checkout_page_id > 0) {
299 299
             $item = new stdClass();
300 300
             $item->object_id = $wpinv_checkout_page_id;
301 301
             $item->db_id = 0;
302
-            $item->object =  'page';
302
+            $item->object = 'page';
303 303
             $item->menu_item_parent = 0;
304 304
             $item->type = 'post_type';
305
-            $item->title = __('Checkout Page','invoicing');
306
-            $item->url = get_permalink( $wpinv_checkout_page_id );
305
+            $item->title = __('Checkout Page', 'invoicing');
306
+            $item->url = get_permalink($wpinv_checkout_page_id);
307 307
             $item->target = '';
308 308
             $item->attr_title = '';
309 309
             $item->classes = array('wpinv-menu-item');
@@ -312,16 +312,16 @@  discard block
 block discarded – undo
312 312
             $items['pages'][] = $item;
313 313
         }
314 314
 
315
-        $wpinv_tandc_page_id = (int)wpinv_get_option( 'tandc_page' );
316
-        if($wpinv_tandc_page_id > 0){
315
+        $wpinv_tandc_page_id = (int) wpinv_get_option('tandc_page');
316
+        if ($wpinv_tandc_page_id > 0) {
317 317
             $item = new stdClass();
318 318
             $item->object_id = $wpinv_tandc_page_id;
319 319
             $item->db_id = 0;
320
-            $item->object =  'page';
320
+            $item->object = 'page';
321 321
             $item->menu_item_parent = 0;
322 322
             $item->type = 'post_type';
323
-            $item->title = __('Terms & Conditions','invoicing');
324
-            $item->url = get_permalink( $wpinv_tandc_page_id );
323
+            $item->title = __('Terms & Conditions', 'invoicing');
324
+            $item->url = get_permalink($wpinv_tandc_page_id);
325 325
             $item->target = '';
326 326
             $item->attr_title = '';
327 327
             $item->classes = array('wpinv-menu-item');
@@ -330,16 +330,16 @@  discard block
 block discarded – undo
330 330
             $items['pages'][] = $item;
331 331
         }
332 332
 
333
-        $wpinv_success_page_id = (int)wpinv_get_option( 'success_page' );
334
-        if($wpinv_success_page_id > 0){
333
+        $wpinv_success_page_id = (int) wpinv_get_option('success_page');
334
+        if ($wpinv_success_page_id > 0) {
335 335
             $item = new stdClass();
336 336
             $item->object_id = $wpinv_success_page_id;
337 337
             $item->db_id = 0;
338
-            $item->object =  'page';
338
+            $item->object = 'page';
339 339
             $item->menu_item_parent = 0;
340 340
             $item->type = 'post_type';
341
-            $item->title = __('Success Page','invoicing');
342
-            $item->url = get_permalink( $wpinv_success_page_id );
341
+            $item->title = __('Success Page', 'invoicing');
342
+            $item->url = get_permalink($wpinv_success_page_id);
343 343
             $item->target = '';
344 344
             $item->attr_title = '';
345 345
             $item->classes = array('wpinv-menu-item');
@@ -348,16 +348,16 @@  discard block
 block discarded – undo
348 348
             $items['pages'][] = $item;
349 349
         }
350 350
 
351
-        $wpinv_failure_page_id = (int)wpinv_get_option( 'failure_page' );
352
-        if($wpinv_failure_page_id > 0){
351
+        $wpinv_failure_page_id = (int) wpinv_get_option('failure_page');
352
+        if ($wpinv_failure_page_id > 0) {
353 353
             $item = new stdClass();
354 354
             $item->object_id = $wpinv_failure_page_id;
355 355
             $item->db_id = 0;
356
-            $item->object =  'page';
356
+            $item->object = 'page';
357 357
             $item->menu_item_parent = 0;
358 358
             $item->type = 'post_type';
359
-            $item->title = __('Failed Transaction Page','invoicing');
360
-            $item->url = get_permalink( $wpinv_failure_page_id );
359
+            $item->title = __('Failed Transaction Page', 'invoicing');
360
+            $item->url = get_permalink($wpinv_failure_page_id);
361 361
             $item->target = '';
362 362
             $item->attr_title = '';
363 363
             $item->classes = array('wpinv-menu-item');
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
             $items['pages'][] = $item;
367 367
         }
368 368
 
369
-        return apply_filters( 'wpinv_menu_items', $items );
369
+        return apply_filters('wpinv_menu_items', $items);
370 370
     }
371 371
 
372 372
 }
Please login to merge, or discard this patch.
templates/invoice/invoice.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
@@ -18,16 +18,16 @@  discard block
 block discarded – undo
18 18
         <?php
19 19
 
20 20
             // Fires when printing the header.
21
-            do_action( 'getpaid_invoice_header', $invoice );
21
+            do_action('getpaid_invoice_header', $invoice);
22 22
 
23 23
             // Print the opening wrapper.
24 24
             echo '<div class="container bg-white border mt-4 mb-4 p-4 position-relative flex-grow-1">';
25 25
 
26 26
             // Fires when printing the invoice details.
27
-            do_action( 'getpaid_invoice_details', $invoice );
27
+            do_action('getpaid_invoice_details', $invoice);
28 28
 
29 29
             // Fires when printing the invoice line items.
30
-            do_action( 'getpaid_invoice_line_items', $invoice );
30
+            do_action('getpaid_invoice_line_items', $invoice);
31 31
 
32 32
             // Print notifications.
33 33
             wpinv_print_errors();
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
             echo '</div>';
37 37
 
38 38
             // Fires when printing the invoice footer.
39
-            do_action( 'getpaid_invoice_footer', $invoice );
39
+            do_action('getpaid_invoice_footer', $invoice);
40 40
 
41 41
         ?>
42 42
 
Please login to merge, or discard this patch.