@@ -8,24 +8,24 @@ discard block |
||
8 | 8 | * @version 1.0.19 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | // Prepare the due date reminder options. |
14 | 14 | $overdue_days_options = array(); |
15 | -$overdue_days_options['0'] = __( 'On the Due Date', 'invoicing' ); |
|
16 | -$overdue_days_options['1'] = __( '1 day after Due Date', 'invoicing' ); |
|
15 | +$overdue_days_options['0'] = __('On the Due Date', 'invoicing'); |
|
16 | +$overdue_days_options['1'] = __('1 day after Due Date', 'invoicing'); |
|
17 | 17 | |
18 | -for ( $i = 2; $i <= 10; $i++ ) { |
|
19 | - $overdue_days_options["$i"] = wp_sprintf( __( '%d days after Due Date', 'invoicing' ), $i ); |
|
18 | +for ($i = 2; $i <= 10; $i++) { |
|
19 | + $overdue_days_options["$i"] = wp_sprintf(__('%d days after Due Date', 'invoicing'), $i); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | // Prepare up coming renewal reminder options. |
23 | 23 | $renewal_days_options = array(); |
24 | -$renewal_days_options['0'] = __( 'On the renewal date', 'invoicing' ); |
|
25 | -$renewal_days_options['1'] = __( '1 day before the renewal date', 'invoicing' ); |
|
24 | +$renewal_days_options['0'] = __('On the renewal date', 'invoicing'); |
|
25 | +$renewal_days_options['1'] = __('1 day before the renewal date', 'invoicing'); |
|
26 | 26 | |
27 | -for ( $i = 2; $i <= 10; $i++ ) { |
|
28 | - $renewal_days_options["$i"] = wp_sprintf( __( '%d days before the renewal date', 'invoicing' ), $i ); |
|
27 | +for ($i = 2; $i <= 10; $i++) { |
|
28 | + $renewal_days_options["$i"] = wp_sprintf(__('%d days before the renewal date', 'invoicing'), $i); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | // Default, built-in gateways |
@@ -34,45 +34,45 @@ discard block |
||
34 | 34 | |
35 | 35 | 'email_new_invoice_header' => array( |
36 | 36 | 'id' => 'email_new_invoice_header', |
37 | - 'name' => '<h3>' . __( 'New Invoice', 'invoicing' ) . '</h3>', |
|
38 | - 'desc' => __( 'These emails are sent to the site admin whenever there is a new invoice.', 'invoicing' ), |
|
37 | + 'name' => '<h3>' . __('New Invoice', 'invoicing') . '</h3>', |
|
38 | + 'desc' => __('These emails are sent to the site admin whenever there is a new invoice.', 'invoicing'), |
|
39 | 39 | 'type' => 'header', |
40 | 40 | ), |
41 | 41 | |
42 | 42 | 'email_new_invoice_active' => array( |
43 | 43 | 'id' => 'email_new_invoice_active', |
44 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
45 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
44 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
45 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
46 | 46 | 'type' => 'checkbox', |
47 | 47 | 'std' => 1 |
48 | 48 | ), |
49 | 49 | |
50 | 50 | 'email_new_invoice_subject' => array( |
51 | 51 | 'id' => 'email_new_invoice_subject', |
52 | - 'name' => __( 'Subject', 'invoicing' ), |
|
53 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
52 | + 'name' => __('Subject', 'invoicing'), |
|
53 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
54 | 54 | 'help-tip' => true, |
55 | 55 | 'type' => 'text', |
56 | - 'std' => __( '[{site_title}] New invoice ({invoice_number}) for {invoice_total} {invoice_currency}', 'invoicing' ), |
|
56 | + 'std' => __('[{site_title}] New invoice ({invoice_number}) for {invoice_total} {invoice_currency}', 'invoicing'), |
|
57 | 57 | 'size' => 'large' |
58 | 58 | ), |
59 | 59 | |
60 | 60 | 'email_new_invoice_heading' => array( |
61 | 61 | 'id' => 'email_new_invoice_heading', |
62 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
63 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
62 | + 'name' => __('Email Heading', 'invoicing'), |
|
63 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
64 | 64 | 'help-tip' => true, |
65 | 65 | 'type' => 'text', |
66 | - 'std' => __( 'New invoice', 'invoicing' ), |
|
66 | + 'std' => __('New invoice', 'invoicing'), |
|
67 | 67 | 'size' => 'large' |
68 | 68 | ), |
69 | 69 | |
70 | 70 | 'email_new_invoice_body' => array( |
71 | 71 | 'id' => 'email_new_invoice_body', |
72 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
72 | + 'name' => __('Email Content', 'invoicing'), |
|
73 | 73 | 'desc' => wpinv_get_merge_tags_help_text(), |
74 | 74 | 'type' => 'rich_editor', |
75 | - 'std' => __( '<p>A new invoice <a href="{invoice_link}">({invoice_number})</a> to {name} for {invoice_total} {invoice_currency} has been created on your site. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing' ), |
|
75 | + 'std' => __('<p>A new invoice <a href="{invoice_link}">({invoice_number})</a> to {name} for {invoice_total} {invoice_currency} has been created on your site. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing'), |
|
76 | 76 | 'class' => 'large', |
77 | 77 | 'size' => '10' |
78 | 78 | ), |
@@ -82,45 +82,45 @@ discard block |
||
82 | 82 | |
83 | 83 | 'email_cancelled_invoice_header' => array( |
84 | 84 | 'id' => 'email_cancelled_invoice_header', |
85 | - 'name' => '<h3>' . __( 'Cancelled Invoice', 'invoicing' ) . '</h3>', |
|
86 | - 'desc' => __( 'These emails are sent to the site admin whenever invoices are cancelled.', 'invoicing' ), |
|
85 | + 'name' => '<h3>' . __('Cancelled Invoice', 'invoicing') . '</h3>', |
|
86 | + 'desc' => __('These emails are sent to the site admin whenever invoices are cancelled.', 'invoicing'), |
|
87 | 87 | 'type' => 'header', |
88 | 88 | ), |
89 | 89 | |
90 | 90 | 'email_cancelled_invoice_active' => array( |
91 | 91 | 'id' => 'email_cancelled_invoice_active', |
92 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
93 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
92 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
93 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
94 | 94 | 'type' => 'checkbox', |
95 | 95 | 'std' => 1 |
96 | 96 | ), |
97 | 97 | |
98 | 98 | 'email_cancelled_invoice_subject' => array( |
99 | 99 | 'id' => 'email_cancelled_invoice_subject', |
100 | - 'name' => __( 'Subject', 'invoicing' ), |
|
101 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
100 | + 'name' => __('Subject', 'invoicing'), |
|
101 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
102 | 102 | 'help-tip' => true, |
103 | 103 | 'type' => 'text', |
104 | - 'std' => __( '[{site_title}] Invoice ({invoice_number}) Cancelled', 'invoicing' ), |
|
104 | + 'std' => __('[{site_title}] Invoice ({invoice_number}) Cancelled', 'invoicing'), |
|
105 | 105 | 'size' => 'large' |
106 | 106 | ), |
107 | 107 | |
108 | 108 | 'email_cancelled_invoice_heading' => array( |
109 | 109 | 'id' => 'email_cancelled_invoice_heading', |
110 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
111 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
110 | + 'name' => __('Email Heading', 'invoicing'), |
|
111 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
112 | 112 | 'help-tip' => true, |
113 | 113 | 'type' => 'text', |
114 | - 'std' => __( 'Invoice Cancelled', 'invoicing' ), |
|
114 | + 'std' => __('Invoice Cancelled', 'invoicing'), |
|
115 | 115 | 'size' => 'large' |
116 | 116 | ), |
117 | 117 | |
118 | 118 | 'email_cancelled_invoice_body' => array( |
119 | 119 | 'id' => 'email_cancelled_invoice_body', |
120 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
120 | + 'name' => __('Email Content', 'invoicing'), |
|
121 | 121 | 'desc' => wpinv_get_merge_tags_help_text(), |
122 | 122 | 'type' => 'rich_editor', |
123 | - 'std' => __( '<p>The invoice <a href="{invoice_link}">#{invoice_number}</a> created for {name} on {site_title} has been cancelled. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing' ), |
|
123 | + 'std' => __('<p>The invoice <a href="{invoice_link}">#{invoice_number}</a> created for {name} on {site_title} has been cancelled. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing'), |
|
124 | 124 | 'class' => 'large', |
125 | 125 | 'size' => '10' |
126 | 126 | ), |
@@ -131,45 +131,45 @@ discard block |
||
131 | 131 | |
132 | 132 | 'email_failed_invoice_header' => array( |
133 | 133 | 'id' => 'email_failed_invoice_header', |
134 | - 'name' => '<h3>' . __( 'Failed Invoice', 'invoicing' ) . '</h3>', |
|
135 | - 'desc' => __( 'Failed invoice emails are sent to the site admin when invoice payments fail.', 'invoicing' ), |
|
134 | + 'name' => '<h3>' . __('Failed Invoice', 'invoicing') . '</h3>', |
|
135 | + 'desc' => __('Failed invoice emails are sent to the site admin when invoice payments fail.', 'invoicing'), |
|
136 | 136 | 'type' => 'header', |
137 | 137 | ), |
138 | 138 | |
139 | 139 | 'email_failed_invoice_active' => array( |
140 | 140 | 'id' => 'email_failed_invoice_active', |
141 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
142 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
141 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
142 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
143 | 143 | 'type' => 'checkbox', |
144 | 144 | 'std' => 1 |
145 | 145 | ), |
146 | 146 | |
147 | 147 | 'email_failed_invoice_subject' => array( |
148 | 148 | 'id' => 'email_failed_invoice_subject', |
149 | - 'name' => __( 'Subject', 'invoicing' ), |
|
150 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
149 | + 'name' => __('Subject', 'invoicing'), |
|
150 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
151 | 151 | 'help-tip' => true, |
152 | 152 | 'type' => 'text', |
153 | - 'std' => __( '[{site_title}] Invoice ({invoice_number}) Payment Failed', 'invoicing' ), |
|
153 | + 'std' => __('[{site_title}] Invoice ({invoice_number}) Payment Failed', 'invoicing'), |
|
154 | 154 | 'size' => 'large' |
155 | 155 | ), |
156 | 156 | |
157 | 157 | 'email_failed_invoice_heading' => array( |
158 | 158 | 'id' => 'email_failed_invoice_heading', |
159 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
160 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
159 | + 'name' => __('Email Heading', 'invoicing'), |
|
160 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
161 | 161 | 'help-tip' => true, |
162 | 162 | 'type' => 'text', |
163 | - 'std' => __( 'Invoice Payment Failed', 'invoicing' ), |
|
163 | + 'std' => __('Invoice Payment Failed', 'invoicing'), |
|
164 | 164 | 'size' => 'large' |
165 | 165 | ), |
166 | 166 | |
167 | 167 | 'email_failed_invoice_body' => array( |
168 | 168 | 'id' => 'email_failed_invoice_body', |
169 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
169 | + 'name' => __('Email Content', 'invoicing'), |
|
170 | 170 | 'desc' => wpinv_get_merge_tags_help_text(), |
171 | 171 | 'type' => 'rich_editor', |
172 | - 'std' => __( '<p>Payment for the invoice <a href="{invoice_link}">#{invoice_number}</a> on {site_title} has failed to go through. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing' ), |
|
172 | + 'std' => __('<p>Payment for the invoice <a href="{invoice_link}">#{invoice_number}</a> on {site_title} has failed to go through. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing'), |
|
173 | 173 | 'class' => 'large', |
174 | 174 | 'size' => '10' |
175 | 175 | ), |
@@ -179,53 +179,53 @@ discard block |
||
179 | 179 | |
180 | 180 | 'email_onhold_invoice_header' => array( |
181 | 181 | 'id' => 'email_onhold_invoice_header', |
182 | - 'name' => '<h3>' . __( 'On Hold Invoice', 'invoicing' ) . '</h3>', |
|
183 | - 'desc' => __( 'These emails are sent to customers whenever their invoices are held.', 'invoicing' ), |
|
182 | + 'name' => '<h3>' . __('On Hold Invoice', 'invoicing') . '</h3>', |
|
183 | + 'desc' => __('These emails are sent to customers whenever their invoices are held.', 'invoicing'), |
|
184 | 184 | 'type' => 'header', |
185 | 185 | ), |
186 | 186 | |
187 | 187 | 'email_onhold_invoice_active' => array( |
188 | 188 | 'id' => 'email_onhold_invoice_active', |
189 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
190 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
189 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
190 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
191 | 191 | 'type' => 'checkbox', |
192 | 192 | 'std' => 1 |
193 | 193 | ), |
194 | 194 | |
195 | 195 | 'email_onhold_invoice_admin_bcc' => array( |
196 | 196 | 'id' => 'email_onhold_invoice_admin_bcc', |
197 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
198 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
197 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
198 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
199 | 199 | 'type' => 'checkbox', |
200 | 200 | 'std' => 1 |
201 | 201 | ), |
202 | 202 | |
203 | 203 | 'email_onhold_invoice_subject' => array( |
204 | 204 | 'id' => 'email_onhold_invoice_subject', |
205 | - 'name' => __( 'Subject', 'invoicing' ), |
|
206 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
205 | + 'name' => __('Subject', 'invoicing'), |
|
206 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
207 | 207 | 'help-tip' => true, |
208 | 208 | 'type' => 'text', |
209 | - 'std' => __( '[{site_title}] Your invoice is on hold', 'invoicing' ), |
|
209 | + 'std' => __('[{site_title}] Your invoice is on hold', 'invoicing'), |
|
210 | 210 | 'size' => 'large' |
211 | 211 | ), |
212 | 212 | |
213 | 213 | 'email_onhold_invoice_heading' => array( |
214 | 214 | 'id' => 'email_onhold_invoice_heading', |
215 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
216 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
215 | + 'name' => __('Email Heading', 'invoicing'), |
|
216 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
217 | 217 | 'help-tip' => true, |
218 | 218 | 'type' => 'text', |
219 | - 'std' => __( 'Your invoice is on hold', 'invoicing' ), |
|
219 | + 'std' => __('Your invoice is on hold', 'invoicing'), |
|
220 | 220 | 'size' => 'large' |
221 | 221 | ), |
222 | 222 | |
223 | 223 | 'email_onhold_invoice_body' => array( |
224 | 224 | 'id' => 'email_onhold_invoice_body', |
225 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
225 | + 'name' => __('Email Content', 'invoicing'), |
|
226 | 226 | 'desc' => wpinv_get_merge_tags_help_text(), |
227 | 227 | 'type' => 'rich_editor', |
228 | - 'std' => __( '<p>Hi {name},</p><p>Your invoice is on-hold and will be processed when we receive your payment. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing' ), |
|
228 | + 'std' => __('<p>Hi {name},</p><p>Your invoice is on-hold and will be processed when we receive your payment. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing'), |
|
229 | 229 | 'class' => 'large', |
230 | 230 | 'size' => '10' |
231 | 231 | ), |
@@ -236,53 +236,53 @@ discard block |
||
236 | 236 | |
237 | 237 | 'email_processing_invoice_header' => array( |
238 | 238 | 'id' => 'email_processing_invoice_header', |
239 | - 'name' => '<h3>' . __( 'Processing Invoice', 'invoicing' ) . '</h3>', |
|
240 | - 'desc' => __( 'These emails are sent to users whenever payments for their invoices are processing.', 'invoicing' ), |
|
239 | + 'name' => '<h3>' . __('Processing Invoice', 'invoicing') . '</h3>', |
|
240 | + 'desc' => __('These emails are sent to users whenever payments for their invoices are processing.', 'invoicing'), |
|
241 | 241 | 'type' => 'header', |
242 | 242 | ), |
243 | 243 | |
244 | 244 | 'email_processing_invoice_active' => array( |
245 | 245 | 'id' => 'email_processing_invoice_active', |
246 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
247 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
246 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
247 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
248 | 248 | 'type' => 'checkbox', |
249 | 249 | 'std' => 1 |
250 | 250 | ), |
251 | 251 | |
252 | 252 | 'email_processing_invoice_admin_bcc' => array( |
253 | 253 | 'id' => 'email_processing_invoice_admin_bcc', |
254 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
255 | - 'desc' => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ), |
|
254 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
255 | + 'desc' => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'), |
|
256 | 256 | 'type' => 'checkbox', |
257 | 257 | 'std' => 1 |
258 | 258 | ), |
259 | 259 | |
260 | 260 | 'email_processing_invoice_subject' => array( |
261 | 261 | 'id' => 'email_processing_invoice_subject', |
262 | - 'name' => __( 'Subject', 'invoicing' ), |
|
263 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
262 | + 'name' => __('Subject', 'invoicing'), |
|
263 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
264 | 264 | 'help-tip' => true, |
265 | 265 | 'type' => 'text', |
266 | - 'std' => __( '[{site_title}] Your payment is being processed', 'invoicing' ), |
|
266 | + 'std' => __('[{site_title}] Your payment is being processed', 'invoicing'), |
|
267 | 267 | 'size' => 'large' |
268 | 268 | ), |
269 | 269 | |
270 | 270 | 'email_processing_invoice_heading' => array( |
271 | 271 | 'id' => 'email_processing_invoice_heading', |
272 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
273 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
272 | + 'name' => __('Email Heading', 'invoicing'), |
|
273 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
274 | 274 | 'help-tip' => true, |
275 | 275 | 'type' => 'text', |
276 | - 'std' => __( 'Your payment is being processed', 'invoicing' ), |
|
276 | + 'std' => __('Your payment is being processed', 'invoicing'), |
|
277 | 277 | 'size' => 'large' |
278 | 278 | ), |
279 | 279 | |
280 | 280 | 'email_processing_invoice_body' => array( |
281 | 281 | 'id' => 'email_processing_invoice_body', |
282 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
282 | + 'name' => __('Email Content', 'invoicing'), |
|
283 | 283 | 'desc' => wpinv_get_merge_tags_help_text(), |
284 | 284 | 'type' => 'rich_editor', |
285 | - 'std' => __( '<p>Hi {name},</p><p>I would like to let you know that we have received and are currently processing your payment for the invoice <a href="{invoice_link}">#{invoice_number}</a> on {site_title}. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing' ), |
|
285 | + 'std' => __('<p>Hi {name},</p><p>I would like to let you know that we have received and are currently processing your payment for the invoice <a href="{invoice_link}">#{invoice_number}</a> on {site_title}. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing'), |
|
286 | 286 | 'class' => 'large', |
287 | 287 | 'size' => '10' |
288 | 288 | ), |
@@ -293,61 +293,61 @@ discard block |
||
293 | 293 | |
294 | 294 | 'email_completed_invoice_header' => array( |
295 | 295 | 'id' => 'email_completed_invoice_header', |
296 | - 'name' => '<h3>' . __( 'Paid Invoice', 'invoicing' ) . '</h3>', |
|
297 | - 'desc' => __( 'These emails are sent to customers when their invoices are marked as paid.', 'invoicing' ), |
|
296 | + 'name' => '<h3>' . __('Paid Invoice', 'invoicing') . '</h3>', |
|
297 | + 'desc' => __('These emails are sent to customers when their invoices are marked as paid.', 'invoicing'), |
|
298 | 298 | 'type' => 'header', |
299 | 299 | ), |
300 | 300 | |
301 | 301 | 'email_completed_invoice_active' => array( |
302 | 302 | 'id' => 'email_completed_invoice_active', |
303 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
304 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
303 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
304 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
305 | 305 | 'type' => 'checkbox', |
306 | 306 | 'std' => 1 |
307 | 307 | ), |
308 | 308 | |
309 | 309 | 'email_completed_invoice_renewal_active' => array( |
310 | 310 | 'id' => 'email_completed_invoice_renewal_active', |
311 | - 'name' => __( 'Enable renewal notification', 'invoicing' ), |
|
312 | - 'desc' => __( 'Should this email be sent for renewals too?', 'invoicing' ), |
|
311 | + 'name' => __('Enable renewal notification', 'invoicing'), |
|
312 | + 'desc' => __('Should this email be sent for renewals too?', 'invoicing'), |
|
313 | 313 | 'type' => 'checkbox', |
314 | 314 | 'std' => 1 |
315 | 315 | ), |
316 | 316 | |
317 | 317 | 'email_completed_invoice_admin_bcc' => array( |
318 | 318 | 'id' => 'email_completed_invoice_admin_bcc', |
319 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
320 | - 'desc' => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ), |
|
319 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
320 | + 'desc' => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'), |
|
321 | 321 | 'type' => 'checkbox', |
322 | 322 | 'std' => 1, |
323 | 323 | ), |
324 | 324 | |
325 | 325 | 'email_completed_invoice_subject' => array( |
326 | 326 | 'id' => 'email_completed_invoice_subject', |
327 | - 'name' => __( 'Subject', 'invoicing' ), |
|
328 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
327 | + 'name' => __('Subject', 'invoicing'), |
|
328 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
329 | 329 | 'help-tip' => true, |
330 | 330 | 'type' => 'text', |
331 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing' ), |
|
331 | + 'std' => __('[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing'), |
|
332 | 332 | 'size' => 'large' |
333 | 333 | ), |
334 | 334 | |
335 | 335 | 'email_completed_invoice_heading' => array( |
336 | 336 | 'id' => 'email_completed_invoice_heading', |
337 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
338 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
337 | + 'name' => __('Email Heading', 'invoicing'), |
|
338 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
339 | 339 | 'help-tip' => true, |
340 | 340 | 'type' => 'text', |
341 | - 'std' => __( 'Your invoice has been paid', 'invoicing' ), |
|
341 | + 'std' => __('Your invoice has been paid', 'invoicing'), |
|
342 | 342 | 'size' => 'large' |
343 | 343 | ), |
344 | 344 | |
345 | 345 | 'email_completed_invoice_body' => array( |
346 | 346 | 'id' => 'email_completed_invoice_body', |
347 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
347 | + 'name' => __('Email Content', 'invoicing'), |
|
348 | 348 | 'desc' => wpinv_get_merge_tags_help_text(), |
349 | 349 | 'type' => 'rich_editor', |
350 | - 'std' => __( '<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing' ), |
|
350 | + 'std' => __('<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing'), |
|
351 | 351 | 'class' => 'large', |
352 | 352 | 'size' => '10' |
353 | 353 | ), |
@@ -358,53 +358,53 @@ discard block |
||
358 | 358 | |
359 | 359 | 'email_refunded_invoice_header' => array( |
360 | 360 | 'id' => 'email_refunded_invoice_header', |
361 | - 'name' => '<h3>' . __( 'Refunded Invoice', 'invoicing' ) . '</h3>', |
|
362 | - 'desc' => __( 'These emails are sent to users when their invoices are marked as refunded.', 'invoicing' ), |
|
361 | + 'name' => '<h3>' . __('Refunded Invoice', 'invoicing') . '</h3>', |
|
362 | + 'desc' => __('These emails are sent to users when their invoices are marked as refunded.', 'invoicing'), |
|
363 | 363 | 'type' => 'header', |
364 | 364 | ), |
365 | 365 | |
366 | 366 | 'email_refunded_invoice_active' => array( |
367 | 367 | 'id' => 'email_refunded_invoice_active', |
368 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
369 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
368 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
369 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
370 | 370 | 'type' => 'checkbox', |
371 | 371 | 'std' => 1 |
372 | 372 | ), |
373 | 373 | |
374 | 374 | 'email_refunded_invoice_admin_bcc' => array( |
375 | 375 | 'id' => 'email_refunded_invoice_admin_bcc', |
376 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
377 | - 'desc' => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ), |
|
376 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
377 | + 'desc' => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'), |
|
378 | 378 | 'type' => 'checkbox', |
379 | 379 | 'std' => 1 |
380 | 380 | ), |
381 | 381 | |
382 | 382 | 'email_refunded_invoice_subject' => array( |
383 | 383 | 'id' => 'email_refunded_invoice_subject', |
384 | - 'name' => __( 'Subject', 'invoicing' ), |
|
385 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
384 | + 'name' => __('Subject', 'invoicing'), |
|
385 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
386 | 386 | 'help-tip' => true, |
387 | 387 | 'type' => 'text', |
388 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing' ), |
|
388 | + 'std' => __('[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing'), |
|
389 | 389 | 'size' => 'large' |
390 | 390 | ), |
391 | 391 | |
392 | 392 | 'email_refunded_invoice_heading' => array( |
393 | 393 | 'id' => 'email_refunded_invoice_heading', |
394 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
395 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
394 | + 'name' => __('Email Heading', 'invoicing'), |
|
395 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
396 | 396 | 'help-tip' => true, |
397 | 397 | 'type' => 'text', |
398 | - 'std' => __( 'Your invoice has been refunded', 'invoicing' ), |
|
398 | + 'std' => __('Your invoice has been refunded', 'invoicing'), |
|
399 | 399 | 'size' => 'large' |
400 | 400 | ), |
401 | 401 | |
402 | 402 | 'email_refunded_invoice_body' => array( |
403 | 403 | 'id' => 'email_refunded_invoice_body', |
404 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
404 | + 'name' => __('Email Content', 'invoicing'), |
|
405 | 405 | 'desc' => wpinv_get_merge_tags_help_text(), |
406 | 406 | 'type' => 'rich_editor', |
407 | - 'std' => __( '<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing' ), |
|
407 | + 'std' => __('<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded. <a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a></p>', 'invoicing'), |
|
408 | 408 | 'class' => 'large', |
409 | 409 | 'size' => '10' |
410 | 410 | ), |
@@ -415,53 +415,53 @@ discard block |
||
415 | 415 | |
416 | 416 | 'email_user_invoice_header' => array( |
417 | 417 | 'id' => 'email_user_invoice_header', |
418 | - 'name' => '<h3>' . __( 'Customer Invoice', 'invoicing' ) . '</h3>', |
|
419 | - 'desc' => __( 'These emails are sent to customers containing their invoice information and payment links.', 'invoicing' ), |
|
418 | + 'name' => '<h3>' . __('Customer Invoice', 'invoicing') . '</h3>', |
|
419 | + 'desc' => __('These emails are sent to customers containing their invoice information and payment links.', 'invoicing'), |
|
420 | 420 | 'type' => 'header', |
421 | 421 | ), |
422 | 422 | |
423 | 423 | 'email_user_invoice_active' => array( |
424 | 424 | 'id' => 'email_user_invoice_active', |
425 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
426 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
425 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
426 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
427 | 427 | 'type' => 'checkbox', |
428 | 428 | 'std' => 1 |
429 | 429 | ), |
430 | 430 | |
431 | 431 | 'email_user_invoice_admin_bcc' => array( |
432 | 432 | 'id' => 'email_user_invoice_admin_bcc', |
433 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
434 | - 'desc' => __( 'Check if you want to send a copy of this notification email to to the site admin.', 'invoicing' ), |
|
433 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
434 | + 'desc' => __('Check if you want to send a copy of this notification email to to the site admin.', 'invoicing'), |
|
435 | 435 | 'type' => 'checkbox', |
436 | 436 | 'std' => 0 |
437 | 437 | ), |
438 | 438 | |
439 | 439 | 'email_user_invoice_subject' => array( |
440 | 440 | 'id' => 'email_user_invoice_subject', |
441 | - 'name' => __( 'Subject', 'invoicing' ), |
|
442 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
441 | + 'name' => __('Subject', 'invoicing'), |
|
442 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
443 | 443 | 'help-tip' => true, |
444 | 444 | 'type' => 'text', |
445 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date}', 'invoicing' ), |
|
445 | + 'std' => __('[{site_title}] Your invoice from {invoice_date}', 'invoicing'), |
|
446 | 446 | 'size' => 'large' |
447 | 447 | ), |
448 | 448 | |
449 | 449 | 'email_user_invoice_heading' => array( |
450 | 450 | 'id' => 'email_user_invoice_heading', |
451 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
452 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
451 | + 'name' => __('Email Heading', 'invoicing'), |
|
452 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
453 | 453 | 'help-tip' => true, |
454 | 454 | 'type' => 'text', |
455 | - 'std' => __( 'Your invoice {invoice_number} details', 'invoicing' ), |
|
455 | + 'std' => __('Your invoice {invoice_number} details', 'invoicing'), |
|
456 | 456 | 'size' => 'large' |
457 | 457 | ), |
458 | 458 | |
459 | 459 | 'email_user_invoice_body' => array( |
460 | 460 | 'id' => 'email_user_invoice_body', |
461 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
461 | + 'name' => __('Email Content', 'invoicing'), |
|
462 | 462 | 'desc' => wpinv_get_merge_tags_help_text(), |
463 | 463 | 'type' => 'rich_editor', |
464 | - 'std' => __( '<p>Hi {name},</p><p>An invoice of {invoice_total} has been created for you on {site_title}. You can <a href="{invoice_link}">view</a> or <a href="{invoice_pay_link}">pay</a> the invoice. Please reply to this email if you have any questions about the invoice.', 'invoicing' ), |
|
464 | + 'std' => __('<p>Hi {name},</p><p>An invoice of {invoice_total} has been created for you on {site_title}. You can <a href="{invoice_link}">view</a> or <a href="{invoice_pay_link}">pay</a> the invoice. Please reply to this email if you have any questions about the invoice.', 'invoicing'), |
|
465 | 465 | 'class' => 'large', |
466 | 466 | 'size' => '10' |
467 | 467 | ), |
@@ -471,53 +471,53 @@ discard block |
||
471 | 471 | |
472 | 472 | 'email_user_note_header' => array( |
473 | 473 | 'id' => 'email_user_note_header', |
474 | - 'name' => '<h3>' . __( 'Customer Note', 'invoicing' ) . '</h3>', |
|
475 | - 'desc' => __( 'These emails are sent when you add a customer note to an invoice/quote.', 'invoicing' ), |
|
474 | + 'name' => '<h3>' . __('Customer Note', 'invoicing') . '</h3>', |
|
475 | + 'desc' => __('These emails are sent when you add a customer note to an invoice/quote.', 'invoicing'), |
|
476 | 476 | 'type' => 'header', |
477 | 477 | ), |
478 | 478 | |
479 | 479 | 'email_user_note_active' => array( |
480 | 480 | 'id' => 'email_user_note_active', |
481 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
482 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
481 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
482 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
483 | 483 | 'type' => 'checkbox', |
484 | 484 | 'std' => 1 |
485 | 485 | ), |
486 | 486 | |
487 | 487 | 'email_user_note_admin_bcc' => array( |
488 | 488 | 'id' => 'email_user_note_admin_bcc', |
489 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
490 | - 'desc' => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ), |
|
489 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
490 | + 'desc' => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'), |
|
491 | 491 | 'type' => 'checkbox', |
492 | 492 | 'std' => 0 |
493 | 493 | ), |
494 | 494 | |
495 | 495 | 'email_user_note_subject' => array( |
496 | 496 | 'id' => 'email_user_note_subject', |
497 | - 'name' => __( 'Subject', 'invoicing' ), |
|
498 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
497 | + 'name' => __('Subject', 'invoicing'), |
|
498 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
499 | 499 | 'help-tip' => true, |
500 | 500 | 'type' => 'text', |
501 | - 'std' => __( '[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing' ), |
|
501 | + 'std' => __('[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing'), |
|
502 | 502 | 'size' => 'large' |
503 | 503 | ), |
504 | 504 | |
505 | 505 | 'email_user_note_heading' => array( |
506 | 506 | 'id' => 'email_user_note_heading', |
507 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
508 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
507 | + 'name' => __('Email Heading', 'invoicing'), |
|
508 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
509 | 509 | 'help-tip' => true, |
510 | 510 | 'type' => 'text', |
511 | - 'std' => __( 'A note has been added to your {invoice_label}', 'invoicing' ), |
|
511 | + 'std' => __('A note has been added to your {invoice_label}', 'invoicing'), |
|
512 | 512 | 'size' => 'large' |
513 | 513 | ), |
514 | 514 | |
515 | 515 | 'email_user_note_body' => array( |
516 | 516 | 'id' => 'email_user_note_body', |
517 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
517 | + 'name' => __('Email Content', 'invoicing'), |
|
518 | 518 | 'desc' => wpinv_get_merge_tags_help_text(), |
519 | 519 | 'type' => 'rich_editor', |
520 | - 'std' => __( '<p>Hi {name},</p><p>The following note has been added to your {invoice_label} <a href="{invoice_link}">#{invoice_number}</a>:</p><blockquote class="wpinv-note">{customer_note}</blockquote><a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a>', 'invoicing' ), |
|
520 | + 'std' => __('<p>Hi {name},</p><p>The following note has been added to your {invoice_label} <a href="{invoice_link}">#{invoice_number}</a>:</p><blockquote class="wpinv-note">{customer_note}</blockquote><a class="btn btn-success" href="{invoice_link}">View / Print Invoice</a>', 'invoicing'), |
|
521 | 521 | 'class' => 'large', |
522 | 522 | 'size' => '10' |
523 | 523 | ), |
@@ -527,63 +527,63 @@ discard block |
||
527 | 527 | |
528 | 528 | 'email_overdue_header' => array( |
529 | 529 | 'id' => 'email_overdue_header', |
530 | - 'name' => '<h3>' . __( 'Payment Reminder', 'invoicing' ) . '</h3>', |
|
531 | - 'desc' => __( 'Payment reminder emails are sent to customers whenever their invoices are due.', 'invoicing' ), |
|
530 | + 'name' => '<h3>' . __('Payment Reminder', 'invoicing') . '</h3>', |
|
531 | + 'desc' => __('Payment reminder emails are sent to customers whenever their invoices are due.', 'invoicing'), |
|
532 | 532 | 'type' => 'header', |
533 | 533 | ), |
534 | 534 | |
535 | 535 | 'email_overdue_active' => array( |
536 | 536 | 'id' => 'email_overdue_active', |
537 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
538 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
537 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
538 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
539 | 539 | 'type' => 'checkbox', |
540 | 540 | 'std' => 1 |
541 | 541 | ), |
542 | 542 | |
543 | 543 | 'email_overdue_admin_bcc' => array( |
544 | 544 | 'id' => 'email_overdue_admin_bcc', |
545 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
546 | - 'desc' => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ), |
|
545 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
546 | + 'desc' => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'), |
|
547 | 547 | 'type' => 'checkbox', |
548 | 548 | 'std' => 0 |
549 | 549 | ), |
550 | 550 | |
551 | 551 | 'email_overdue_days' => array( |
552 | 552 | 'id' => 'email_overdue_days', |
553 | - 'name' => __( 'When to Send', 'invoicing' ), |
|
554 | - 'desc' => __( 'Check when you would like payment reminders sent out.', 'invoicing' ), |
|
553 | + 'name' => __('When to Send', 'invoicing'), |
|
554 | + 'desc' => __('Check when you would like payment reminders sent out.', 'invoicing'), |
|
555 | 555 | 'help-tip' => true, |
556 | - 'std' => array( '1' ), |
|
556 | + 'std' => array('1'), |
|
557 | 557 | 'type' => 'multicheck', |
558 | 558 | 'options' => $overdue_days_options, |
559 | 559 | ), |
560 | 560 | |
561 | 561 | 'email_overdue_subject' => array( |
562 | 562 | 'id' => 'email_overdue_subject', |
563 | - 'name' => __( 'Subject', 'invoicing' ), |
|
564 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
563 | + 'name' => __('Subject', 'invoicing'), |
|
564 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
565 | 565 | 'help-tip' => true, |
566 | 566 | 'type' => 'text', |
567 | - 'std' => __( '[{site_title}] Payment Reminder', 'invoicing' ), |
|
567 | + 'std' => __('[{site_title}] Payment Reminder', 'invoicing'), |
|
568 | 568 | 'size' => 'large' |
569 | 569 | ), |
570 | 570 | |
571 | 571 | 'email_overdue_heading' => array( |
572 | 572 | 'id' => 'email_overdue_heading', |
573 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
574 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
573 | + 'name' => __('Email Heading', 'invoicing'), |
|
574 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
575 | 575 | 'help-tip' => true, |
576 | 576 | 'type' => 'text', |
577 | - 'std' => __( 'Payment reminder for your invoice', 'invoicing' ), |
|
577 | + 'std' => __('Payment reminder for your invoice', 'invoicing'), |
|
578 | 578 | 'size' => 'large' |
579 | 579 | ), |
580 | 580 | |
581 | 581 | 'email_overdue_body' => array( |
582 | 582 | 'id' => 'email_overdue_body', |
583 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
583 | + 'name' => __('Email Content', 'invoicing'), |
|
584 | 584 | 'desc' => wpinv_get_merge_tags_help_text(), |
585 | 585 | 'type' => 'rich_editor', |
586 | - 'std' => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ), |
|
586 | + 'std' => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'), |
|
587 | 587 | 'class' => 'large', |
588 | 588 | 'size' => 10, |
589 | 589 | ), |
@@ -594,63 +594,63 @@ discard block |
||
594 | 594 | |
595 | 595 | 'email_renewal_reminder_header' => array( |
596 | 596 | 'id' => 'email_renewal_reminder_header', |
597 | - 'name' => '<h3>' . __( 'Renewal Reminder', 'invoicing' ) . '</h3>', |
|
598 | - 'desc' => __( 'These emails are sent to customers whenever their subscription is about to renew.', 'invoicing' ), |
|
597 | + 'name' => '<h3>' . __('Renewal Reminder', 'invoicing') . '</h3>', |
|
598 | + 'desc' => __('These emails are sent to customers whenever their subscription is about to renew.', 'invoicing'), |
|
599 | 599 | 'type' => 'header', |
600 | 600 | ), |
601 | 601 | |
602 | 602 | 'email_renewal_reminder_active' => array( |
603 | 603 | 'id' => 'email_renewal_reminder_active', |
604 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
605 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
604 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
605 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
606 | 606 | 'type' => 'checkbox', |
607 | 607 | 'std' => 0 |
608 | 608 | ), |
609 | 609 | |
610 | 610 | 'email_renewal_reminder_admin_bcc' => array( |
611 | 611 | 'id' => 'email_renewal_reminder_admin_bcc', |
612 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
613 | - 'desc' => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ), |
|
612 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
613 | + 'desc' => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'), |
|
614 | 614 | 'type' => 'checkbox', |
615 | 615 | 'std' => 0 |
616 | 616 | ), |
617 | 617 | |
618 | 618 | 'email_renewal_reminder_days' => array( |
619 | 619 | 'id' => 'email_renewal_reminder_days', |
620 | - 'name' => __( 'When to Send', 'invoicing' ), |
|
621 | - 'desc' => __( 'Check when you would like renewal reminders sent out.', 'invoicing' ), |
|
620 | + 'name' => __('When to Send', 'invoicing'), |
|
621 | + 'desc' => __('Check when you would like renewal reminders sent out.', 'invoicing'), |
|
622 | 622 | 'help-tip' => true, |
623 | - 'std' => array( '1', '5', '10' ), |
|
623 | + 'std' => array('1', '5', '10'), |
|
624 | 624 | 'type' => 'multicheck', |
625 | 625 | 'options' => $renewal_days_options, |
626 | 626 | ), |
627 | 627 | |
628 | 628 | 'email_renewal_reminder_subject' => array( |
629 | 629 | 'id' => 'email_renewal_reminder_subject', |
630 | - 'name' => __( 'Subject', 'invoicing' ), |
|
631 | - 'desc' => __( 'Enter the subject line for the email.', 'invoicing' ), |
|
630 | + 'name' => __('Subject', 'invoicing'), |
|
631 | + 'desc' => __('Enter the subject line for the email.', 'invoicing'), |
|
632 | 632 | 'help-tip' => true, |
633 | 633 | 'type' => 'text', |
634 | - 'std' => __( '[{site_title}] Renewal Reminder', 'invoicing' ), |
|
634 | + 'std' => __('[{site_title}] Renewal Reminder', 'invoicing'), |
|
635 | 635 | 'size' => 'large' |
636 | 636 | ), |
637 | 637 | |
638 | 638 | 'email_renewal_reminder_heading' => array( |
639 | 639 | 'id' => 'email_renewal_reminder_heading', |
640 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
641 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
640 | + 'name' => __('Email Heading', 'invoicing'), |
|
641 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
642 | 642 | 'help-tip' => true, |
643 | 643 | 'type' => 'text', |
644 | - 'std' => __( 'Upcoming renewal reminder', 'invoicing' ), |
|
644 | + 'std' => __('Upcoming renewal reminder', 'invoicing'), |
|
645 | 645 | 'size' => 'large' |
646 | 646 | ), |
647 | 647 | |
648 | 648 | 'email_renewal_reminder_body' => array( |
649 | 649 | 'id' => 'email_renewal_reminder_body', |
650 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
651 | - 'desc' => wpinv_get_merge_tags_help_text( true ), |
|
650 | + 'name' => __('Email Content', 'invoicing'), |
|
651 | + 'desc' => wpinv_get_merge_tags_help_text(true), |
|
652 | 652 | 'type' => 'rich_editor', |
653 | - 'std' => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that your subscription for invoice <a href="{invoice_link}">#{invoice_number}</a> will renew on {subscription_renewal_date}.</p>', 'invoicing' ), |
|
653 | + 'std' => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that your subscription for invoice <a href="{invoice_link}">#{invoice_number}</a> will renew on {subscription_renewal_date}.</p>', 'invoicing'), |
|
654 | 654 | 'class' => 'large', |
655 | 655 | 'size' => 10, |
656 | 656 | ), |
@@ -661,53 +661,53 @@ discard block |
||
661 | 661 | |
662 | 662 | 'email_subscription_trial_header' => array( |
663 | 663 | 'id' => 'email_subscription_trial_header', |
664 | - 'name' => '<h3>' . __( 'Trial Started', 'invoicing' ) . '</h3>', |
|
665 | - 'desc' => __( 'These emails are sent when a customer starts a subscription trial.', 'invoicing' ), |
|
664 | + 'name' => '<h3>' . __('Trial Started', 'invoicing') . '</h3>', |
|
665 | + 'desc' => __('These emails are sent when a customer starts a subscription trial.', 'invoicing'), |
|
666 | 666 | 'type' => 'header', |
667 | 667 | ), |
668 | 668 | |
669 | 669 | 'email_subscription_trial_active' => array( |
670 | 670 | 'id' => 'email_subscription_trial_active', |
671 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
672 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
671 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
672 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
673 | 673 | 'type' => 'checkbox', |
674 | 674 | 'std' => 0 |
675 | 675 | ), |
676 | 676 | |
677 | 677 | 'email_subscription_trial_admin_bcc' => array( |
678 | 678 | 'id' => 'email_subscription_trial_admin_bcc', |
679 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
680 | - 'desc' => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ), |
|
679 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
680 | + 'desc' => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'), |
|
681 | 681 | 'type' => 'checkbox', |
682 | 682 | 'std' => 0 |
683 | 683 | ), |
684 | 684 | |
685 | 685 | 'email_subscription_trial_subject' => array( |
686 | 686 | 'id' => 'email_subscription_trial_subject', |
687 | - 'name' => __( 'Subject', 'invoicing' ), |
|
688 | - 'desc' => __( 'Enter the subject line for the subscription trial email.', 'invoicing' ), |
|
687 | + 'name' => __('Subject', 'invoicing'), |
|
688 | + 'desc' => __('Enter the subject line for the subscription trial email.', 'invoicing'), |
|
689 | 689 | 'help-tip' => true, |
690 | 690 | 'type' => 'text', |
691 | - 'std' => __( '[{site_title}] Trial Started', 'invoicing' ), |
|
691 | + 'std' => __('[{site_title}] Trial Started', 'invoicing'), |
|
692 | 692 | 'size' => 'large' |
693 | 693 | ), |
694 | 694 | |
695 | 695 | 'email_subscription_trial_heading' => array( |
696 | 696 | 'id' => 'email_subscription_trial_heading', |
697 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
698 | - 'desc' => __( 'Enter the main heading of this email.', 'invoicing' ), |
|
697 | + 'name' => __('Email Heading', 'invoicing'), |
|
698 | + 'desc' => __('Enter the main heading of this email.', 'invoicing'), |
|
699 | 699 | 'help-tip' => true, |
700 | 700 | 'type' => 'text', |
701 | - 'std' => __( 'Trial Started', 'invoicing' ), |
|
701 | + 'std' => __('Trial Started', 'invoicing'), |
|
702 | 702 | 'size' => 'large' |
703 | 703 | ), |
704 | 704 | |
705 | 705 | 'email_subscription_trial_body' => array( |
706 | 706 | 'id' => 'email_subscription_trial_body', |
707 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
708 | - 'desc' => wpinv_get_merge_tags_help_text( true ), |
|
707 | + 'name' => __('Email Content', 'invoicing'), |
|
708 | + 'desc' => wpinv_get_merge_tags_help_text(true), |
|
709 | 709 | 'type' => 'rich_editor', |
710 | - 'std' => __( '<p>Hi {first_name},</p><p>Your trial for {subscription_name} is now active and will renew on {subscription_renewal_date}.</p>', 'invoicing' ), |
|
710 | + 'std' => __('<p>Hi {first_name},</p><p>Your trial for {subscription_name} is now active and will renew on {subscription_renewal_date}.</p>', 'invoicing'), |
|
711 | 711 | 'class' => 'large', |
712 | 712 | 'size' => 10, |
713 | 713 | ), |
@@ -717,53 +717,53 @@ discard block |
||
717 | 717 | |
718 | 718 | 'email_subscription_cancelled_header' => array( |
719 | 719 | 'id' => 'email_subscription_cancelled_header', |
720 | - 'name' => '<h3>' . __( 'Subscription Cancelled', 'invoicing' ) . '</h3>', |
|
721 | - 'desc' => __( 'These emails are sent when a customer cancels their subscription.', 'invoicing' ), |
|
720 | + 'name' => '<h3>' . __('Subscription Cancelled', 'invoicing') . '</h3>', |
|
721 | + 'desc' => __('These emails are sent when a customer cancels their subscription.', 'invoicing'), |
|
722 | 722 | 'type' => 'header', |
723 | 723 | ), |
724 | 724 | |
725 | 725 | 'email_subscription_cancelled_active' => array( |
726 | 726 | 'id' => 'email_subscription_cancelled_active', |
727 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
728 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
727 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
728 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
729 | 729 | 'type' => 'checkbox', |
730 | 730 | 'std' => 1 |
731 | 731 | ), |
732 | 732 | |
733 | 733 | 'email_subscription_cancelled_admin_bcc' => array( |
734 | 734 | 'id' => 'email_subscription_cancelled_admin_bcc', |
735 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
736 | - 'desc' => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ), |
|
735 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
736 | + 'desc' => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'), |
|
737 | 737 | 'type' => 'checkbox', |
738 | 738 | 'std' => 1 |
739 | 739 | ), |
740 | 740 | |
741 | 741 | 'email_subscription_cancelled_subject' => array( |
742 | 742 | 'id' => 'email_subscription_cancelled_subject', |
743 | - 'name' => __( 'Subject', 'invoicing' ), |
|
744 | - 'desc' => __( 'Enter the subject line for the subscription cancelled email.', 'invoicing' ), |
|
743 | + 'name' => __('Subject', 'invoicing'), |
|
744 | + 'desc' => __('Enter the subject line for the subscription cancelled email.', 'invoicing'), |
|
745 | 745 | 'help-tip' => true, |
746 | 746 | 'type' => 'text', |
747 | - 'std' => __( '[{site_title}] Subscription Cancelled', 'invoicing' ), |
|
747 | + 'std' => __('[{site_title}] Subscription Cancelled', 'invoicing'), |
|
748 | 748 | 'size' => 'large' |
749 | 749 | ), |
750 | 750 | |
751 | 751 | 'email_subscription_cancelled_heading' => array( |
752 | 752 | 'id' => 'email_subscription_cancelled_heading', |
753 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
754 | - 'desc' => __( 'Enter the main heading of this email.', 'invoicing' ), |
|
753 | + 'name' => __('Email Heading', 'invoicing'), |
|
754 | + 'desc' => __('Enter the main heading of this email.', 'invoicing'), |
|
755 | 755 | 'help-tip' => true, |
756 | 756 | 'type' => 'text', |
757 | - 'std' => __( 'Subscription Cancelled', 'invoicing' ), |
|
757 | + 'std' => __('Subscription Cancelled', 'invoicing'), |
|
758 | 758 | 'size' => 'large' |
759 | 759 | ), |
760 | 760 | |
761 | 761 | 'email_subscription_cancelled_body' => array( |
762 | 762 | 'id' => 'email_subscription_cancelled_body', |
763 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
764 | - 'desc' => wpinv_get_merge_tags_help_text( true ), |
|
763 | + 'name' => __('Email Content', 'invoicing'), |
|
764 | + 'desc' => wpinv_get_merge_tags_help_text(true), |
|
765 | 765 | 'type' => 'rich_editor', |
766 | - 'std' => __( '<p>Hi {first_name},</p><p>Your subscription for {subscription_name} has been cancelled and will no longer renew.</p>', 'invoicing' ), |
|
766 | + 'std' => __('<p>Hi {first_name},</p><p>Your subscription for {subscription_name} has been cancelled and will no longer renew.</p>', 'invoicing'), |
|
767 | 767 | 'class' => 'large', |
768 | 768 | 'size' => 10, |
769 | 769 | ), |
@@ -773,53 +773,53 @@ discard block |
||
773 | 773 | |
774 | 774 | 'email_subscription_expired_header' => array( |
775 | 775 | 'id' => 'email_subscription_expired_header', |
776 | - 'name' => '<h3>' . __( 'Subscription Expired', 'invoicing' ) . '</h3>', |
|
777 | - 'desc' => __( "These emails are sent when a customer's subscription expires and automatic renewal fails.", 'invoicing' ), |
|
776 | + 'name' => '<h3>' . __('Subscription Expired', 'invoicing') . '</h3>', |
|
777 | + 'desc' => __("These emails are sent when a customer's subscription expires and automatic renewal fails.", 'invoicing'), |
|
778 | 778 | 'type' => 'header', |
779 | 779 | ), |
780 | 780 | |
781 | 781 | 'email_subscription_expired_active' => array( |
782 | 782 | 'id' => 'email_subscription_expired_active', |
783 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
784 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
783 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
784 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
785 | 785 | 'type' => 'checkbox', |
786 | 786 | 'std' => 1 |
787 | 787 | ), |
788 | 788 | |
789 | 789 | 'email_subscription_expired_admin_bcc' => array( |
790 | 790 | 'id' => 'email_subscription_expired_admin_bcc', |
791 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
792 | - 'desc' => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ), |
|
791 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
792 | + 'desc' => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'), |
|
793 | 793 | 'type' => 'checkbox', |
794 | 794 | 'std' => 1 |
795 | 795 | ), |
796 | 796 | |
797 | 797 | 'email_subscription_expired_subject' => array( |
798 | 798 | 'id' => 'email_subscription_expired_subject', |
799 | - 'name' => __( 'Subject', 'invoicing' ), |
|
800 | - 'desc' => __( 'Enter the subject line for the subscription expired email.', 'invoicing' ), |
|
799 | + 'name' => __('Subject', 'invoicing'), |
|
800 | + 'desc' => __('Enter the subject line for the subscription expired email.', 'invoicing'), |
|
801 | 801 | 'help-tip' => true, |
802 | 802 | 'type' => 'text', |
803 | - 'std' => __( '[{site_title}] Subscription Expired', 'invoicing' ), |
|
803 | + 'std' => __('[{site_title}] Subscription Expired', 'invoicing'), |
|
804 | 804 | 'size' => 'large' |
805 | 805 | ), |
806 | 806 | |
807 | 807 | 'email_subscription_expired_heading' => array( |
808 | 808 | 'id' => 'email_subscription_expired_heading', |
809 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
810 | - 'desc' => __( 'Enter the main heading of this email.', 'invoicing' ), |
|
809 | + 'name' => __('Email Heading', 'invoicing'), |
|
810 | + 'desc' => __('Enter the main heading of this email.', 'invoicing'), |
|
811 | 811 | 'type' => 'text', |
812 | - 'std' => __( 'Subscription Expired', 'invoicing' ), |
|
812 | + 'std' => __('Subscription Expired', 'invoicing'), |
|
813 | 813 | 'help-tip' => true, |
814 | 814 | 'size' => 'large' |
815 | 815 | ), |
816 | 816 | |
817 | 817 | 'email_subscription_expired_body' => array( |
818 | 818 | 'id' => 'email_subscription_expired_body', |
819 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
820 | - 'desc' => wpinv_get_merge_tags_help_text( true ), |
|
819 | + 'name' => __('Email Content', 'invoicing'), |
|
820 | + 'desc' => wpinv_get_merge_tags_help_text(true), |
|
821 | 821 | 'type' => 'rich_editor', |
822 | - 'std' => __( '<p>Hi {first_name},</p><p>Your subscription for {subscription_name} has expired.</p>', 'invoicing' ), |
|
822 | + 'std' => __('<p>Hi {first_name},</p><p>Your subscription for {subscription_name} has expired.</p>', 'invoicing'), |
|
823 | 823 | 'class' => 'large', |
824 | 824 | 'size' => 10, |
825 | 825 | ), |
@@ -829,53 +829,53 @@ discard block |
||
829 | 829 | |
830 | 830 | 'email_subscription_complete_header' => array( |
831 | 831 | 'id' => 'email_subscription_complete_header', |
832 | - 'name' => '<h3>' . __( 'Subscription Complete', 'invoicing' ) . '</h3>', |
|
833 | - 'desc' => __( 'These emails are sent when a customer completes their subscription.', 'invoicing' ), |
|
832 | + 'name' => '<h3>' . __('Subscription Complete', 'invoicing') . '</h3>', |
|
833 | + 'desc' => __('These emails are sent when a customer completes their subscription.', 'invoicing'), |
|
834 | 834 | 'type' => 'header', |
835 | 835 | ), |
836 | 836 | |
837 | 837 | 'email_subscription_complete_active' => array( |
838 | 838 | 'id' => 'email_subscription_complete_active', |
839 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
840 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
839 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
840 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
841 | 841 | 'type' => 'checkbox', |
842 | 842 | 'std' => 1 |
843 | 843 | ), |
844 | 844 | |
845 | 845 | 'email_subscription_complete_admin_bcc' => array( |
846 | 846 | 'id' => 'email_subscription_complete_admin_bcc', |
847 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
848 | - 'desc' => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ), |
|
847 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
848 | + 'desc' => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'), |
|
849 | 849 | 'type' => 'checkbox', |
850 | 850 | 'std' => 1 |
851 | 851 | ), |
852 | 852 | |
853 | 853 | 'email_subscription_complete_subject' => array( |
854 | 854 | 'id' => 'email_subscription_complete_subject', |
855 | - 'name' => __( 'Subject', 'invoicing' ), |
|
856 | - 'desc' => __( 'Enter the subject line for the subscription complete email.', 'invoicing' ), |
|
855 | + 'name' => __('Subject', 'invoicing'), |
|
856 | + 'desc' => __('Enter the subject line for the subscription complete email.', 'invoicing'), |
|
857 | 857 | 'help-tip' => true, |
858 | 858 | 'type' => 'text', |
859 | - 'std' => __( '[{site_title}] Subscription Complete', 'invoicing' ), |
|
859 | + 'std' => __('[{site_title}] Subscription Complete', 'invoicing'), |
|
860 | 860 | 'size' => 'large' |
861 | 861 | ), |
862 | 862 | |
863 | 863 | 'email_subscription_complete_heading' => array( |
864 | 864 | 'id' => 'email_subscription_complete_heading', |
865 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
866 | - 'desc' => __( 'Enter the main heading of this email.', 'invoicing' ), |
|
865 | + 'name' => __('Email Heading', 'invoicing'), |
|
866 | + 'desc' => __('Enter the main heading of this email.', 'invoicing'), |
|
867 | 867 | 'help-tip' => true, |
868 | 868 | 'type' => 'text', |
869 | - 'std' => __( 'Subscription Complete', 'invoicing' ), |
|
869 | + 'std' => __('Subscription Complete', 'invoicing'), |
|
870 | 870 | 'size' => 'large' |
871 | 871 | ), |
872 | 872 | |
873 | 873 | 'email_subscription_complete_body' => array( |
874 | 874 | 'id' => 'email_subscription_complete_body', |
875 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
876 | - 'desc' => wpinv_get_merge_tags_help_text( true ), |
|
875 | + 'name' => __('Email Content', 'invoicing'), |
|
876 | + 'desc' => wpinv_get_merge_tags_help_text(true), |
|
877 | 877 | 'type' => 'rich_editor', |
878 | - 'std' => __( '<p>Hi {first_name},</p><p>Your subscription for {subscription_name} is now complete.</p>', 'invoicing' ), |
|
878 | + 'std' => __('<p>Hi {first_name},</p><p>Your subscription for {subscription_name} is now complete.</p>', 'invoicing'), |
|
879 | 879 | 'class' => 'large', |
880 | 880 | 'size' => 10, |
881 | 881 | ), |
@@ -15,125 +15,125 @@ discard block |
||
15 | 15 | */ |
16 | 16 | class WPInv_Subscription extends GetPaid_Data { |
17 | 17 | |
18 | - /** |
|
19 | - * Which data store to load. |
|
20 | - * |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - protected $data_store_name = 'subscription'; |
|
24 | - |
|
25 | - /** |
|
26 | - * This is the name of this object type. |
|
27 | - * |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - protected $object_type = 'subscription'; |
|
31 | - |
|
32 | - /** |
|
33 | - * Item Data array. This is the core item data exposed in APIs. |
|
34 | - * |
|
35 | - * @since 1.0.19 |
|
36 | - * @var array |
|
37 | - */ |
|
38 | - protected $data = array( |
|
39 | - 'customer_id' => 0, |
|
40 | - 'frequency' => 1, |
|
41 | - 'period' => 'D', |
|
42 | - 'initial_amount' => null, |
|
43 | - 'recurring_amount' => null, |
|
44 | - 'bill_times' => 0, |
|
45 | - 'transaction_id' => '', |
|
46 | - 'parent_payment_id' => null, |
|
47 | - 'product_id' => 0, |
|
48 | - 'created' => '0000-00-00 00:00:00', |
|
49 | - 'expiration' => '0000-00-00 00:00:00', |
|
50 | - 'trial_period' => '', |
|
51 | - 'status' => 'pending', |
|
52 | - 'profile_id' => '', |
|
53 | - 'gateway' => '', |
|
54 | - 'customer' => '', |
|
55 | - ); |
|
56 | - |
|
57 | - /** |
|
58 | - * Stores the status transition information. |
|
59 | - * |
|
60 | - * @since 1.0.19 |
|
61 | - * @var bool |
|
62 | - */ |
|
63 | - protected $status_transition = false; |
|
64 | - |
|
65 | - /** |
|
66 | - * Get the subscription if ID is passed, otherwise the subscription is new and empty. |
|
67 | - * |
|
68 | - * @param int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read. |
|
69 | - * @param bool $deprecated |
|
70 | - */ |
|
71 | - function __construct( $subscription = 0, $deprecated = false ) { |
|
72 | - |
|
73 | - parent::__construct( $subscription ); |
|
74 | - |
|
75 | - if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) { |
|
76 | - $this->set_id( $subscription ); |
|
77 | - } elseif ( $subscription instanceof self ) { |
|
78 | - $this->set_id( $subscription->get_id() ); |
|
79 | - } elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) { |
|
80 | - $this->set_id( $subscription_id ); |
|
81 | - } elseif ( ! empty( $subscription->id ) ) { |
|
82 | - $this->set_id( $subscription->id ); |
|
83 | - } else { |
|
84 | - $this->set_object_read( true ); |
|
85 | - } |
|
86 | - |
|
87 | - // Load the datastore. |
|
88 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
89 | - |
|
90 | - if ( $this->get_id() > 0 ) { |
|
91 | - $this->data_store->read( $this ); |
|
92 | - } |
|
93 | - |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Given an invoice id, profile id, transaction id, it returns the subscription's id. |
|
98 | - * |
|
99 | - * |
|
100 | - * @static |
|
101 | - * @param string $value |
|
102 | - * @param string $field Either invoice_id, transaction_id or profile_id. |
|
103 | - * @since 1.0.19 |
|
104 | - * @return int |
|
105 | - */ |
|
106 | - public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) { |
|
18 | + /** |
|
19 | + * Which data store to load. |
|
20 | + * |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + protected $data_store_name = 'subscription'; |
|
24 | + |
|
25 | + /** |
|
26 | + * This is the name of this object type. |
|
27 | + * |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + protected $object_type = 'subscription'; |
|
31 | + |
|
32 | + /** |
|
33 | + * Item Data array. This is the core item data exposed in APIs. |
|
34 | + * |
|
35 | + * @since 1.0.19 |
|
36 | + * @var array |
|
37 | + */ |
|
38 | + protected $data = array( |
|
39 | + 'customer_id' => 0, |
|
40 | + 'frequency' => 1, |
|
41 | + 'period' => 'D', |
|
42 | + 'initial_amount' => null, |
|
43 | + 'recurring_amount' => null, |
|
44 | + 'bill_times' => 0, |
|
45 | + 'transaction_id' => '', |
|
46 | + 'parent_payment_id' => null, |
|
47 | + 'product_id' => 0, |
|
48 | + 'created' => '0000-00-00 00:00:00', |
|
49 | + 'expiration' => '0000-00-00 00:00:00', |
|
50 | + 'trial_period' => '', |
|
51 | + 'status' => 'pending', |
|
52 | + 'profile_id' => '', |
|
53 | + 'gateway' => '', |
|
54 | + 'customer' => '', |
|
55 | + ); |
|
56 | + |
|
57 | + /** |
|
58 | + * Stores the status transition information. |
|
59 | + * |
|
60 | + * @since 1.0.19 |
|
61 | + * @var bool |
|
62 | + */ |
|
63 | + protected $status_transition = false; |
|
64 | + |
|
65 | + /** |
|
66 | + * Get the subscription if ID is passed, otherwise the subscription is new and empty. |
|
67 | + * |
|
68 | + * @param int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read. |
|
69 | + * @param bool $deprecated |
|
70 | + */ |
|
71 | + function __construct( $subscription = 0, $deprecated = false ) { |
|
72 | + |
|
73 | + parent::__construct( $subscription ); |
|
74 | + |
|
75 | + if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) { |
|
76 | + $this->set_id( $subscription ); |
|
77 | + } elseif ( $subscription instanceof self ) { |
|
78 | + $this->set_id( $subscription->get_id() ); |
|
79 | + } elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) { |
|
80 | + $this->set_id( $subscription_id ); |
|
81 | + } elseif ( ! empty( $subscription->id ) ) { |
|
82 | + $this->set_id( $subscription->id ); |
|
83 | + } else { |
|
84 | + $this->set_object_read( true ); |
|
85 | + } |
|
86 | + |
|
87 | + // Load the datastore. |
|
88 | + $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
89 | + |
|
90 | + if ( $this->get_id() > 0 ) { |
|
91 | + $this->data_store->read( $this ); |
|
92 | + } |
|
93 | + |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Given an invoice id, profile id, transaction id, it returns the subscription's id. |
|
98 | + * |
|
99 | + * |
|
100 | + * @static |
|
101 | + * @param string $value |
|
102 | + * @param string $field Either invoice_id, transaction_id or profile_id. |
|
103 | + * @since 1.0.19 |
|
104 | + * @return int |
|
105 | + */ |
|
106 | + public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) { |
|
107 | 107 | global $wpdb; |
108 | 108 | |
109 | - // Trim the value. |
|
110 | - $value = trim( $value ); |
|
109 | + // Trim the value. |
|
110 | + $value = trim( $value ); |
|
111 | 111 | |
112 | - if ( empty( $value ) ) { |
|
113 | - return 0; |
|
114 | - } |
|
112 | + if ( empty( $value ) ) { |
|
113 | + return 0; |
|
114 | + } |
|
115 | 115 | |
116 | - if ( 'invoice_id' == $field ) { |
|
117 | - $field = 'parent_payment_id'; |
|
118 | - } |
|
116 | + if ( 'invoice_id' == $field ) { |
|
117 | + $field = 'parent_payment_id'; |
|
118 | + } |
|
119 | 119 | |
120 | 120 | // Valid fields. |
121 | 121 | $fields = array( |
122 | - 'parent_payment_id', |
|
123 | - 'transaction_id', |
|
124 | - 'profile_id' |
|
125 | - ); |
|
126 | - |
|
127 | - // Ensure a field has been passed. |
|
128 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
129 | - return 0; |
|
130 | - } |
|
131 | - |
|
132 | - // Maybe retrieve from the cache. |
|
133 | - $subscription_id = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" ); |
|
134 | - if ( ! empty( $subscription_id ) ) { |
|
135 | - return $subscription_id; |
|
136 | - } |
|
122 | + 'parent_payment_id', |
|
123 | + 'transaction_id', |
|
124 | + 'profile_id' |
|
125 | + ); |
|
126 | + |
|
127 | + // Ensure a field has been passed. |
|
128 | + if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
129 | + return 0; |
|
130 | + } |
|
131 | + |
|
132 | + // Maybe retrieve from the cache. |
|
133 | + $subscription_id = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" ); |
|
134 | + if ( ! empty( $subscription_id ) ) { |
|
135 | + return $subscription_id; |
|
136 | + } |
|
137 | 137 | |
138 | 138 | // Fetch from the db. |
139 | 139 | $table = $wpdb->prefix . 'wpinv_subscriptions'; |
@@ -141,34 +141,34 @@ discard block |
||
141 | 141 | $wpdb->prepare( "SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
142 | 142 | ); |
143 | 143 | |
144 | - if ( empty( $subscription_id ) ) { |
|
145 | - return 0; |
|
146 | - } |
|
144 | + if ( empty( $subscription_id ) ) { |
|
145 | + return 0; |
|
146 | + } |
|
147 | 147 | |
148 | - // Update the cache with our data. |
|
149 | - wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" ); |
|
148 | + // Update the cache with our data. |
|
149 | + wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" ); |
|
150 | 150 | |
151 | - return $subscription_id; |
|
152 | - } |
|
151 | + return $subscription_id; |
|
152 | + } |
|
153 | 153 | |
154 | - /** |
|
154 | + /** |
|
155 | 155 | * Clears the subscription's cache. |
156 | 156 | */ |
157 | 157 | public function clear_cache() { |
158 | - wp_cache_delete( $this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids' ); |
|
159 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids' ); |
|
160 | - wp_cache_delete( $this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids' ); |
|
161 | - wp_cache_delete( $this->get_id(), 'getpaid_subscriptions' ); |
|
162 | - } |
|
158 | + wp_cache_delete( $this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids' ); |
|
159 | + wp_cache_delete( $this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids' ); |
|
160 | + wp_cache_delete( $this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids' ); |
|
161 | + wp_cache_delete( $this->get_id(), 'getpaid_subscriptions' ); |
|
162 | + } |
|
163 | 163 | |
164 | - /** |
|
164 | + /** |
|
165 | 165 | * Checks if a subscription key is set. |
166 | 166 | */ |
167 | 167 | public function _isset( $key ) { |
168 | 168 | return isset( $this->data[$key] ) || method_exists( $this, "get_$key" ); |
169 | - } |
|
169 | + } |
|
170 | 170 | |
171 | - /* |
|
171 | + /* |
|
172 | 172 | |-------------------------------------------------------------------------- |
173 | 173 | | CRUD methods |
174 | 174 | |-------------------------------------------------------------------------- |
@@ -177,545 +177,545 @@ discard block |
||
177 | 177 | | |
178 | 178 | */ |
179 | 179 | |
180 | - /* |
|
181 | - |-------------------------------------------------------------------------- |
|
182 | - | Getters |
|
183 | - |-------------------------------------------------------------------------- |
|
184 | - */ |
|
180 | + /* |
|
181 | + |-------------------------------------------------------------------------- |
|
182 | + | Getters |
|
183 | + |-------------------------------------------------------------------------- |
|
184 | + */ |
|
185 | + |
|
186 | + /** |
|
187 | + * Get customer id. |
|
188 | + * |
|
189 | + * @since 1.0.19 |
|
190 | + * @param string $context View or edit context. |
|
191 | + * @return int |
|
192 | + */ |
|
193 | + public function get_customer_id( $context = 'view' ) { |
|
194 | + return (int) $this->get_prop( 'customer_id', $context ); |
|
195 | + } |
|
196 | + |
|
197 | + /** |
|
198 | + * Get customer information. |
|
199 | + * |
|
200 | + * @since 1.0.19 |
|
201 | + * @param string $context View or edit context. |
|
202 | + * @return WP_User|false WP_User object on success, false on failure. |
|
203 | + */ |
|
204 | + public function get_customer( $context = 'view' ) { |
|
205 | + return get_userdata( $this->get_customer_id( $context ) ); |
|
206 | + } |
|
207 | + |
|
208 | + /** |
|
209 | + * Get parent invoice id. |
|
210 | + * |
|
211 | + * @since 1.0.19 |
|
212 | + * @param string $context View or edit context. |
|
213 | + * @return int |
|
214 | + */ |
|
215 | + public function get_parent_invoice_id( $context = 'view' ) { |
|
216 | + return (int) $this->get_prop( 'parent_payment_id', $context ); |
|
217 | + } |
|
218 | + |
|
219 | + /** |
|
220 | + * Alias for self::get_parent_invoice_id(). |
|
221 | + * |
|
222 | + * @since 1.0.19 |
|
223 | + * @param string $context View or edit context. |
|
224 | + * @return int |
|
225 | + */ |
|
226 | + public function get_parent_payment_id( $context = 'view' ) { |
|
227 | + return $this->get_parent_invoice_id( $context ); |
|
228 | + } |
|
229 | + |
|
230 | + /** |
|
231 | + * Alias for self::get_parent_invoice_id(). |
|
232 | + * |
|
233 | + * @since 1.0.0 |
|
234 | + * @return int |
|
235 | + */ |
|
236 | + public function get_original_payment_id( $context = 'view' ) { |
|
237 | + return $this->get_parent_invoice_id( $context ); |
|
238 | + } |
|
239 | + |
|
240 | + /** |
|
241 | + * Get parent invoice. |
|
242 | + * |
|
243 | + * @since 1.0.19 |
|
244 | + * @param string $context View or edit context. |
|
245 | + * @return WPInv_Invoice |
|
246 | + */ |
|
247 | + public function get_parent_invoice( $context = 'view' ) { |
|
248 | + return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) ); |
|
249 | + } |
|
250 | + |
|
251 | + /** |
|
252 | + * Alias for self::get_parent_invoice(). |
|
253 | + * |
|
254 | + * @since 1.0.19 |
|
255 | + * @param string $context View or edit context. |
|
256 | + * @return WPInv_Invoice |
|
257 | + */ |
|
258 | + public function get_parent_payment( $context = 'view' ) { |
|
259 | + return $this->get_parent_invoice( $context ); |
|
260 | + } |
|
261 | + |
|
262 | + /** |
|
263 | + * Get subscription's product id. |
|
264 | + * |
|
265 | + * @since 1.0.19 |
|
266 | + * @param string $context View or edit context. |
|
267 | + * @return int |
|
268 | + */ |
|
269 | + public function get_product_id( $context = 'view' ) { |
|
270 | + return (int) $this->get_prop( 'product_id', $context ); |
|
271 | + } |
|
272 | + |
|
273 | + /** |
|
274 | + * Get the subscription product. |
|
275 | + * |
|
276 | + * @since 1.0.19 |
|
277 | + * @param string $context View or edit context. |
|
278 | + * @return WPInv_Item |
|
279 | + */ |
|
280 | + public function get_product( $context = 'view' ) { |
|
281 | + return new WPInv_Item( $this->get_product_id( $context ) ); |
|
282 | + } |
|
283 | + |
|
284 | + /** |
|
285 | + * Get parent invoice's gateway. |
|
286 | + * |
|
287 | + * Here for backwards compatibility. |
|
288 | + * |
|
289 | + * @since 1.0.19 |
|
290 | + * @param string $context View or edit context. |
|
291 | + * @return string |
|
292 | + */ |
|
293 | + public function get_gateway( $context = 'view' ) { |
|
294 | + return $this->get_parent_invoice( $context )->get_gateway(); |
|
295 | + } |
|
296 | + |
|
297 | + /** |
|
298 | + * Get the period of a renewal. |
|
299 | + * |
|
300 | + * @since 1.0.19 |
|
301 | + * @param string $context View or edit context. |
|
302 | + * @return string |
|
303 | + */ |
|
304 | + public function get_period( $context = 'view' ) { |
|
305 | + return $this->get_prop( 'period', $context ); |
|
306 | + } |
|
307 | + |
|
308 | + /** |
|
309 | + * Get number of periods each renewal is valid for. |
|
310 | + * |
|
311 | + * @since 1.0.19 |
|
312 | + * @param string $context View or edit context. |
|
313 | + * @return int |
|
314 | + */ |
|
315 | + public function get_frequency( $context = 'view' ) { |
|
316 | + return (int) $this->get_prop( 'frequency', $context ); |
|
317 | + } |
|
318 | + |
|
319 | + /** |
|
320 | + * Get the initial amount for the subscription. |
|
321 | + * |
|
322 | + * @since 1.0.19 |
|
323 | + * @param string $context View or edit context. |
|
324 | + * @return float |
|
325 | + */ |
|
326 | + public function get_initial_amount( $context = 'view' ) { |
|
327 | + return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) ); |
|
328 | + } |
|
329 | + |
|
330 | + /** |
|
331 | + * Get the recurring amount for the subscription. |
|
332 | + * |
|
333 | + * @since 1.0.19 |
|
334 | + * @param string $context View or edit context. |
|
335 | + * @return float |
|
336 | + */ |
|
337 | + public function get_recurring_amount( $context = 'view' ) { |
|
338 | + return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) ); |
|
339 | + } |
|
340 | + |
|
341 | + /** |
|
342 | + * Get number of times that this subscription can be renewed. |
|
343 | + * |
|
344 | + * @since 1.0.19 |
|
345 | + * @param string $context View or edit context. |
|
346 | + * @return int |
|
347 | + */ |
|
348 | + public function get_bill_times( $context = 'view' ) { |
|
349 | + return (int) $this->get_prop( 'bill_times', $context ); |
|
350 | + } |
|
351 | + |
|
352 | + /** |
|
353 | + * Get transaction id of this subscription's parent invoice. |
|
354 | + * |
|
355 | + * @since 1.0.19 |
|
356 | + * @param string $context View or edit context. |
|
357 | + * @return string |
|
358 | + */ |
|
359 | + public function get_transaction_id( $context = 'view' ) { |
|
360 | + return $this->get_prop( 'transaction_id', $context ); |
|
361 | + } |
|
362 | + |
|
363 | + /** |
|
364 | + * Get the date that the subscription was created. |
|
365 | + * |
|
366 | + * @since 1.0.19 |
|
367 | + * @param string $context View or edit context. |
|
368 | + * @return string |
|
369 | + */ |
|
370 | + public function get_created( $context = 'view' ) { |
|
371 | + return $this->get_prop( 'created', $context ); |
|
372 | + } |
|
373 | + |
|
374 | + /** |
|
375 | + * Alias for self::get_created(). |
|
376 | + * |
|
377 | + * @since 1.0.19 |
|
378 | + * @param string $context View or edit context. |
|
379 | + * @return string |
|
380 | + */ |
|
381 | + public function get_date_created( $context = 'view' ) { |
|
382 | + return $this->get_created( $context ); |
|
383 | + } |
|
384 | + |
|
385 | + /** |
|
386 | + * Retrieves the creation date in a timestamp |
|
387 | + * |
|
388 | + * @since 1.0.0 |
|
389 | + * @return int |
|
390 | + */ |
|
391 | + public function get_time_created() { |
|
392 | + $created = $this->get_date_created(); |
|
393 | + return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) ); |
|
394 | + } |
|
395 | + |
|
396 | + /** |
|
397 | + * Get GMT date when the subscription was created. |
|
398 | + * |
|
399 | + * @since 1.0.19 |
|
400 | + * @param string $context View or edit context. |
|
401 | + * @return string |
|
402 | + */ |
|
403 | + public function get_date_created_gmt( $context = 'view' ) { |
|
404 | + $date = $this->get_date_created( $context ); |
|
405 | + |
|
406 | + if ( $date ) { |
|
407 | + $date = get_gmt_from_date( $date ); |
|
408 | + } |
|
409 | + return $date; |
|
410 | + } |
|
411 | + |
|
412 | + /** |
|
413 | + * Get the date that the subscription will renew. |
|
414 | + * |
|
415 | + * @since 1.0.19 |
|
416 | + * @param string $context View or edit context. |
|
417 | + * @return string |
|
418 | + */ |
|
419 | + public function get_next_renewal_date( $context = 'view' ) { |
|
420 | + return $this->get_prop( 'expiration', $context ); |
|
421 | + } |
|
422 | + |
|
423 | + /** |
|
424 | + * Alias for self::get_next_renewal_date(). |
|
425 | + * |
|
426 | + * @since 1.0.19 |
|
427 | + * @param string $context View or edit context. |
|
428 | + * @return string |
|
429 | + */ |
|
430 | + public function get_expiration( $context = 'view' ) { |
|
431 | + return $this->get_next_renewal_date( $context ); |
|
432 | + } |
|
433 | + |
|
434 | + /** |
|
435 | + * Retrieves the expiration date in a timestamp |
|
436 | + * |
|
437 | + * @since 1.0.0 |
|
438 | + * @return int |
|
439 | + */ |
|
440 | + public function get_expiration_time() { |
|
441 | + $expiration = $this->get_expiration(); |
|
442 | + |
|
443 | + if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) { |
|
444 | + return current_time( 'timestamp' ); |
|
445 | + } |
|
446 | + |
|
447 | + $expiration = strtotime( $expiration, current_time( 'timestamp' ) ); |
|
448 | + return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration; |
|
449 | + } |
|
450 | + |
|
451 | + /** |
|
452 | + * Get GMT date when the subscription will renew. |
|
453 | + * |
|
454 | + * @since 1.0.19 |
|
455 | + * @param string $context View or edit context. |
|
456 | + * @return string |
|
457 | + */ |
|
458 | + public function get_next_renewal_date_gmt( $context = 'view' ) { |
|
459 | + $date = $this->get_next_renewal_date( $context ); |
|
460 | + |
|
461 | + if ( $date ) { |
|
462 | + $date = get_gmt_from_date( $date ); |
|
463 | + } |
|
464 | + return $date; |
|
465 | + } |
|
466 | + |
|
467 | + /** |
|
468 | + * Get the subscription's trial period. |
|
469 | + * |
|
470 | + * @since 1.0.19 |
|
471 | + * @param string $context View or edit context. |
|
472 | + * @return string |
|
473 | + */ |
|
474 | + public function get_trial_period( $context = 'view' ) { |
|
475 | + return $this->get_prop( 'trial_period', $context ); |
|
476 | + } |
|
477 | + |
|
478 | + /** |
|
479 | + * Get the subscription's status. |
|
480 | + * |
|
481 | + * @since 1.0.19 |
|
482 | + * @param string $context View or edit context. |
|
483 | + * @return string |
|
484 | + */ |
|
485 | + public function get_status( $context = 'view' ) { |
|
486 | + return $this->get_prop( 'status', $context ); |
|
487 | + } |
|
488 | + |
|
489 | + /** |
|
490 | + * Get the subscription's profile id. |
|
491 | + * |
|
492 | + * @since 1.0.19 |
|
493 | + * @param string $context View or edit context. |
|
494 | + * @return string |
|
495 | + */ |
|
496 | + public function get_profile_id( $context = 'view' ) { |
|
497 | + return $this->get_prop( 'profile_id', $context ); |
|
498 | + } |
|
499 | + |
|
500 | + /* |
|
501 | + |-------------------------------------------------------------------------- |
|
502 | + | Setters |
|
503 | + |-------------------------------------------------------------------------- |
|
504 | + */ |
|
505 | + |
|
506 | + /** |
|
507 | + * Set customer id. |
|
508 | + * |
|
509 | + * @since 1.0.19 |
|
510 | + * @param int $value The customer's id. |
|
511 | + */ |
|
512 | + public function set_customer_id( $value ) { |
|
513 | + $this->set_prop( 'customer_id', (int) $value ); |
|
514 | + } |
|
515 | + |
|
516 | + /** |
|
517 | + * Set parent invoice id. |
|
518 | + * |
|
519 | + * @since 1.0.19 |
|
520 | + * @param int $value The parent invoice id. |
|
521 | + */ |
|
522 | + public function set_parent_invoice_id( $value ) { |
|
523 | + $this->set_prop( 'parent_payment_id', (int) $value ); |
|
524 | + } |
|
525 | + |
|
526 | + /** |
|
527 | + * Alias for self::set_parent_invoice_id(). |
|
528 | + * |
|
529 | + * @since 1.0.19 |
|
530 | + * @param int $value The parent invoice id. |
|
531 | + */ |
|
532 | + public function set_parent_payment_id( $value ) { |
|
533 | + $this->set_parent_invoice_id( $value ); |
|
534 | + } |
|
535 | + |
|
536 | + /** |
|
537 | + * Alias for self::set_parent_invoice_id(). |
|
538 | + * |
|
539 | + * @since 1.0.19 |
|
540 | + * @param int $value The parent invoice id. |
|
541 | + */ |
|
542 | + public function set_original_payment_id( $value ) { |
|
543 | + $this->set_parent_invoice_id( $value ); |
|
544 | + } |
|
545 | + |
|
546 | + /** |
|
547 | + * Set subscription's product id. |
|
548 | + * |
|
549 | + * @since 1.0.19 |
|
550 | + * @param int $value The subscription product id. |
|
551 | + */ |
|
552 | + public function set_product_id( $value ) { |
|
553 | + $this->set_prop( 'product_id', (int) $value ); |
|
554 | + } |
|
555 | + |
|
556 | + /** |
|
557 | + * Set the period of a renewal. |
|
558 | + * |
|
559 | + * @since 1.0.19 |
|
560 | + * @param string $value The renewal period. |
|
561 | + */ |
|
562 | + public function set_period( $value ) { |
|
563 | + $this->set_prop( 'period', $value ); |
|
564 | + } |
|
565 | + |
|
566 | + /** |
|
567 | + * Set number of periods each renewal is valid for. |
|
568 | + * |
|
569 | + * @since 1.0.19 |
|
570 | + * @param int $value The subscription frequency. |
|
571 | + */ |
|
572 | + public function set_frequency( $value ) { |
|
573 | + $value = empty( $value ) ? 1 : (int) $value; |
|
574 | + $this->set_prop( 'frequency', absint( $value ) ); |
|
575 | + } |
|
576 | + |
|
577 | + /** |
|
578 | + * Set the initial amount for the subscription. |
|
579 | + * |
|
580 | + * @since 1.0.19 |
|
581 | + * @param float $value The initial subcription amount. |
|
582 | + */ |
|
583 | + public function set_initial_amount( $value ) { |
|
584 | + $this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) ); |
|
585 | + } |
|
586 | + |
|
587 | + /** |
|
588 | + * Set the recurring amount for the subscription. |
|
589 | + * |
|
590 | + * @since 1.0.19 |
|
591 | + * @param float $value The recurring subcription amount. |
|
592 | + */ |
|
593 | + public function set_recurring_amount( $value ) { |
|
594 | + $this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) ); |
|
595 | + } |
|
596 | + |
|
597 | + /** |
|
598 | + * Set number of times that this subscription can be renewed. |
|
599 | + * |
|
600 | + * @since 1.0.19 |
|
601 | + * @param int $value Bill times. |
|
602 | + */ |
|
603 | + public function set_bill_times( $value ) { |
|
604 | + $this->set_prop( 'bill_times', (int) $value ); |
|
605 | + } |
|
606 | + |
|
607 | + /** |
|
608 | + * Get transaction id of this subscription's parent invoice. |
|
609 | + * |
|
610 | + * @since 1.0.19 |
|
611 | + * @param string $value Bill times. |
|
612 | + */ |
|
613 | + public function set_transaction_id( $value ) { |
|
614 | + $this->set_prop( 'transaction_id', sanitize_text_field( $value ) ); |
|
615 | + } |
|
616 | + |
|
617 | + /** |
|
618 | + * Set date when this subscription started. |
|
619 | + * |
|
620 | + * @since 1.0.19 |
|
621 | + * @param string $value strtotime compliant date. |
|
622 | + */ |
|
623 | + public function set_created( $value ) { |
|
624 | + $date = strtotime( $value ); |
|
625 | + |
|
626 | + if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
627 | + $this->set_prop( 'created', date( 'Y-m-d H:i:s', $date ) ); |
|
628 | + return; |
|
629 | + } |
|
630 | + |
|
631 | + $this->set_prop( 'created', '' ); |
|
185 | 632 | |
186 | - /** |
|
187 | - * Get customer id. |
|
188 | - * |
|
189 | - * @since 1.0.19 |
|
190 | - * @param string $context View or edit context. |
|
191 | - * @return int |
|
192 | - */ |
|
193 | - public function get_customer_id( $context = 'view' ) { |
|
194 | - return (int) $this->get_prop( 'customer_id', $context ); |
|
195 | - } |
|
196 | - |
|
197 | - /** |
|
198 | - * Get customer information. |
|
199 | - * |
|
200 | - * @since 1.0.19 |
|
201 | - * @param string $context View or edit context. |
|
202 | - * @return WP_User|false WP_User object on success, false on failure. |
|
203 | - */ |
|
204 | - public function get_customer( $context = 'view' ) { |
|
205 | - return get_userdata( $this->get_customer_id( $context ) ); |
|
206 | - } |
|
207 | - |
|
208 | - /** |
|
209 | - * Get parent invoice id. |
|
210 | - * |
|
211 | - * @since 1.0.19 |
|
212 | - * @param string $context View or edit context. |
|
213 | - * @return int |
|
214 | - */ |
|
215 | - public function get_parent_invoice_id( $context = 'view' ) { |
|
216 | - return (int) $this->get_prop( 'parent_payment_id', $context ); |
|
217 | - } |
|
218 | - |
|
219 | - /** |
|
220 | - * Alias for self::get_parent_invoice_id(). |
|
221 | - * |
|
222 | - * @since 1.0.19 |
|
223 | - * @param string $context View or edit context. |
|
224 | - * @return int |
|
225 | - */ |
|
226 | - public function get_parent_payment_id( $context = 'view' ) { |
|
227 | - return $this->get_parent_invoice_id( $context ); |
|
228 | - } |
|
633 | + } |
|
229 | 634 | |
230 | - /** |
|
231 | - * Alias for self::get_parent_invoice_id(). |
|
635 | + /** |
|
636 | + * Alias for self::set_created(). |
|
232 | 637 | * |
233 | - * @since 1.0.0 |
|
234 | - * @return int |
|
638 | + * @since 1.0.19 |
|
639 | + * @param string $value strtotime compliant date. |
|
235 | 640 | */ |
236 | - public function get_original_payment_id( $context = 'view' ) { |
|
237 | - return $this->get_parent_invoice_id( $context ); |
|
641 | + public function set_date_created( $value ) { |
|
642 | + $this->set_created( $value ); |
|
238 | 643 | } |
239 | 644 | |
240 | - /** |
|
241 | - * Get parent invoice. |
|
242 | - * |
|
243 | - * @since 1.0.19 |
|
244 | - * @param string $context View or edit context. |
|
245 | - * @return WPInv_Invoice |
|
246 | - */ |
|
247 | - public function get_parent_invoice( $context = 'view' ) { |
|
248 | - return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) ); |
|
249 | - } |
|
250 | - |
|
251 | - /** |
|
252 | - * Alias for self::get_parent_invoice(). |
|
253 | - * |
|
254 | - * @since 1.0.19 |
|
255 | - * @param string $context View or edit context. |
|
256 | - * @return WPInv_Invoice |
|
257 | - */ |
|
258 | - public function get_parent_payment( $context = 'view' ) { |
|
259 | - return $this->get_parent_invoice( $context ); |
|
260 | - } |
|
261 | - |
|
262 | - /** |
|
263 | - * Get subscription's product id. |
|
264 | - * |
|
265 | - * @since 1.0.19 |
|
266 | - * @param string $context View or edit context. |
|
267 | - * @return int |
|
268 | - */ |
|
269 | - public function get_product_id( $context = 'view' ) { |
|
270 | - return (int) $this->get_prop( 'product_id', $context ); |
|
271 | - } |
|
272 | - |
|
273 | - /** |
|
274 | - * Get the subscription product. |
|
275 | - * |
|
276 | - * @since 1.0.19 |
|
277 | - * @param string $context View or edit context. |
|
278 | - * @return WPInv_Item |
|
279 | - */ |
|
280 | - public function get_product( $context = 'view' ) { |
|
281 | - return new WPInv_Item( $this->get_product_id( $context ) ); |
|
282 | - } |
|
283 | - |
|
284 | - /** |
|
285 | - * Get parent invoice's gateway. |
|
286 | - * |
|
287 | - * Here for backwards compatibility. |
|
288 | - * |
|
289 | - * @since 1.0.19 |
|
290 | - * @param string $context View or edit context. |
|
291 | - * @return string |
|
292 | - */ |
|
293 | - public function get_gateway( $context = 'view' ) { |
|
294 | - return $this->get_parent_invoice( $context )->get_gateway(); |
|
295 | - } |
|
296 | - |
|
297 | - /** |
|
298 | - * Get the period of a renewal. |
|
299 | - * |
|
300 | - * @since 1.0.19 |
|
301 | - * @param string $context View or edit context. |
|
302 | - * @return string |
|
303 | - */ |
|
304 | - public function get_period( $context = 'view' ) { |
|
305 | - return $this->get_prop( 'period', $context ); |
|
306 | - } |
|
307 | - |
|
308 | - /** |
|
309 | - * Get number of periods each renewal is valid for. |
|
310 | - * |
|
311 | - * @since 1.0.19 |
|
312 | - * @param string $context View or edit context. |
|
313 | - * @return int |
|
314 | - */ |
|
315 | - public function get_frequency( $context = 'view' ) { |
|
316 | - return (int) $this->get_prop( 'frequency', $context ); |
|
317 | - } |
|
318 | - |
|
319 | - /** |
|
320 | - * Get the initial amount for the subscription. |
|
321 | - * |
|
322 | - * @since 1.0.19 |
|
323 | - * @param string $context View or edit context. |
|
324 | - * @return float |
|
325 | - */ |
|
326 | - public function get_initial_amount( $context = 'view' ) { |
|
327 | - return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) ); |
|
328 | - } |
|
329 | - |
|
330 | - /** |
|
331 | - * Get the recurring amount for the subscription. |
|
332 | - * |
|
333 | - * @since 1.0.19 |
|
334 | - * @param string $context View or edit context. |
|
335 | - * @return float |
|
336 | - */ |
|
337 | - public function get_recurring_amount( $context = 'view' ) { |
|
338 | - return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) ); |
|
339 | - } |
|
340 | - |
|
341 | - /** |
|
342 | - * Get number of times that this subscription can be renewed. |
|
343 | - * |
|
344 | - * @since 1.0.19 |
|
345 | - * @param string $context View or edit context. |
|
346 | - * @return int |
|
347 | - */ |
|
348 | - public function get_bill_times( $context = 'view' ) { |
|
349 | - return (int) $this->get_prop( 'bill_times', $context ); |
|
350 | - } |
|
351 | - |
|
352 | - /** |
|
353 | - * Get transaction id of this subscription's parent invoice. |
|
354 | - * |
|
355 | - * @since 1.0.19 |
|
356 | - * @param string $context View or edit context. |
|
357 | - * @return string |
|
358 | - */ |
|
359 | - public function get_transaction_id( $context = 'view' ) { |
|
360 | - return $this->get_prop( 'transaction_id', $context ); |
|
361 | - } |
|
362 | - |
|
363 | - /** |
|
364 | - * Get the date that the subscription was created. |
|
365 | - * |
|
366 | - * @since 1.0.19 |
|
367 | - * @param string $context View or edit context. |
|
368 | - * @return string |
|
369 | - */ |
|
370 | - public function get_created( $context = 'view' ) { |
|
371 | - return $this->get_prop( 'created', $context ); |
|
372 | - } |
|
373 | - |
|
374 | - /** |
|
375 | - * Alias for self::get_created(). |
|
376 | - * |
|
377 | - * @since 1.0.19 |
|
378 | - * @param string $context View or edit context. |
|
379 | - * @return string |
|
380 | - */ |
|
381 | - public function get_date_created( $context = 'view' ) { |
|
382 | - return $this->get_created( $context ); |
|
383 | - } |
|
384 | - |
|
385 | - /** |
|
386 | - * Retrieves the creation date in a timestamp |
|
387 | - * |
|
388 | - * @since 1.0.0 |
|
389 | - * @return int |
|
390 | - */ |
|
391 | - public function get_time_created() { |
|
392 | - $created = $this->get_date_created(); |
|
393 | - return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) ); |
|
394 | - } |
|
395 | - |
|
396 | - /** |
|
397 | - * Get GMT date when the subscription was created. |
|
398 | - * |
|
399 | - * @since 1.0.19 |
|
400 | - * @param string $context View or edit context. |
|
401 | - * @return string |
|
402 | - */ |
|
403 | - public function get_date_created_gmt( $context = 'view' ) { |
|
404 | - $date = $this->get_date_created( $context ); |
|
645 | + /** |
|
646 | + * Set the date that the subscription will renew. |
|
647 | + * |
|
648 | + * @since 1.0.19 |
|
649 | + * @param string $value strtotime compliant date. |
|
650 | + */ |
|
651 | + public function set_next_renewal_date( $value ) { |
|
652 | + $date = strtotime( $value ); |
|
405 | 653 | |
406 | - if ( $date ) { |
|
407 | - $date = get_gmt_from_date( $date ); |
|
654 | + if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
655 | + $this->set_prop( 'expiration', date( 'Y-m-d H:i:s', $date ) ); |
|
656 | + return; |
|
408 | 657 | } |
409 | - return $date; |
|
410 | - } |
|
411 | - |
|
412 | - /** |
|
413 | - * Get the date that the subscription will renew. |
|
414 | - * |
|
415 | - * @since 1.0.19 |
|
416 | - * @param string $context View or edit context. |
|
417 | - * @return string |
|
418 | - */ |
|
419 | - public function get_next_renewal_date( $context = 'view' ) { |
|
420 | - return $this->get_prop( 'expiration', $context ); |
|
421 | - } |
|
422 | - |
|
423 | - /** |
|
424 | - * Alias for self::get_next_renewal_date(). |
|
425 | - * |
|
426 | - * @since 1.0.19 |
|
427 | - * @param string $context View or edit context. |
|
428 | - * @return string |
|
429 | - */ |
|
430 | - public function get_expiration( $context = 'view' ) { |
|
431 | - return $this->get_next_renewal_date( $context ); |
|
432 | - } |
|
433 | - |
|
434 | - /** |
|
435 | - * Retrieves the expiration date in a timestamp |
|
436 | - * |
|
437 | - * @since 1.0.0 |
|
438 | - * @return int |
|
439 | - */ |
|
440 | - public function get_expiration_time() { |
|
441 | - $expiration = $this->get_expiration(); |
|
442 | - |
|
443 | - if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) { |
|
444 | - return current_time( 'timestamp' ); |
|
445 | - } |
|
446 | - |
|
447 | - $expiration = strtotime( $expiration, current_time( 'timestamp' ) ); |
|
448 | - return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration; |
|
449 | - } |
|
450 | - |
|
451 | - /** |
|
452 | - * Get GMT date when the subscription will renew. |
|
453 | - * |
|
454 | - * @since 1.0.19 |
|
455 | - * @param string $context View or edit context. |
|
456 | - * @return string |
|
457 | - */ |
|
458 | - public function get_next_renewal_date_gmt( $context = 'view' ) { |
|
459 | - $date = $this->get_next_renewal_date( $context ); |
|
460 | 658 | |
461 | - if ( $date ) { |
|
462 | - $date = get_gmt_from_date( $date ); |
|
463 | - } |
|
464 | - return $date; |
|
465 | - } |
|
466 | - |
|
467 | - /** |
|
468 | - * Get the subscription's trial period. |
|
469 | - * |
|
470 | - * @since 1.0.19 |
|
471 | - * @param string $context View or edit context. |
|
472 | - * @return string |
|
473 | - */ |
|
474 | - public function get_trial_period( $context = 'view' ) { |
|
475 | - return $this->get_prop( 'trial_period', $context ); |
|
476 | - } |
|
477 | - |
|
478 | - /** |
|
479 | - * Get the subscription's status. |
|
480 | - * |
|
481 | - * @since 1.0.19 |
|
482 | - * @param string $context View or edit context. |
|
483 | - * @return string |
|
484 | - */ |
|
485 | - public function get_status( $context = 'view' ) { |
|
486 | - return $this->get_prop( 'status', $context ); |
|
487 | - } |
|
488 | - |
|
489 | - /** |
|
490 | - * Get the subscription's profile id. |
|
491 | - * |
|
492 | - * @since 1.0.19 |
|
493 | - * @param string $context View or edit context. |
|
494 | - * @return string |
|
495 | - */ |
|
496 | - public function get_profile_id( $context = 'view' ) { |
|
497 | - return $this->get_prop( 'profile_id', $context ); |
|
498 | - } |
|
499 | - |
|
500 | - /* |
|
501 | - |-------------------------------------------------------------------------- |
|
502 | - | Setters |
|
503 | - |-------------------------------------------------------------------------- |
|
504 | - */ |
|
659 | + $this->set_prop( 'expiration', '' ); |
|
505 | 660 | |
506 | - /** |
|
507 | - * Set customer id. |
|
508 | - * |
|
509 | - * @since 1.0.19 |
|
510 | - * @param int $value The customer's id. |
|
511 | - */ |
|
512 | - public function set_customer_id( $value ) { |
|
513 | - $this->set_prop( 'customer_id', (int) $value ); |
|
514 | - } |
|
515 | - |
|
516 | - /** |
|
517 | - * Set parent invoice id. |
|
518 | - * |
|
519 | - * @since 1.0.19 |
|
520 | - * @param int $value The parent invoice id. |
|
521 | - */ |
|
522 | - public function set_parent_invoice_id( $value ) { |
|
523 | - $this->set_prop( 'parent_payment_id', (int) $value ); |
|
524 | - } |
|
525 | - |
|
526 | - /** |
|
527 | - * Alias for self::set_parent_invoice_id(). |
|
528 | - * |
|
529 | - * @since 1.0.19 |
|
530 | - * @param int $value The parent invoice id. |
|
531 | - */ |
|
532 | - public function set_parent_payment_id( $value ) { |
|
533 | - $this->set_parent_invoice_id( $value ); |
|
534 | - } |
|
661 | + } |
|
535 | 662 | |
536 | - /** |
|
537 | - * Alias for self::set_parent_invoice_id(). |
|
663 | + /** |
|
664 | + * Alias for self::set_next_renewal_date(). |
|
538 | 665 | * |
539 | 666 | * @since 1.0.19 |
540 | - * @param int $value The parent invoice id. |
|
667 | + * @param string $value strtotime compliant date. |
|
541 | 668 | */ |
542 | - public function set_original_payment_id( $value ) { |
|
543 | - $this->set_parent_invoice_id( $value ); |
|
544 | - } |
|
545 | - |
|
546 | - /** |
|
547 | - * Set subscription's product id. |
|
548 | - * |
|
549 | - * @since 1.0.19 |
|
550 | - * @param int $value The subscription product id. |
|
551 | - */ |
|
552 | - public function set_product_id( $value ) { |
|
553 | - $this->set_prop( 'product_id', (int) $value ); |
|
554 | - } |
|
555 | - |
|
556 | - /** |
|
557 | - * Set the period of a renewal. |
|
558 | - * |
|
559 | - * @since 1.0.19 |
|
560 | - * @param string $value The renewal period. |
|
561 | - */ |
|
562 | - public function set_period( $value ) { |
|
563 | - $this->set_prop( 'period', $value ); |
|
564 | - } |
|
565 | - |
|
566 | - /** |
|
567 | - * Set number of periods each renewal is valid for. |
|
568 | - * |
|
569 | - * @since 1.0.19 |
|
570 | - * @param int $value The subscription frequency. |
|
571 | - */ |
|
572 | - public function set_frequency( $value ) { |
|
573 | - $value = empty( $value ) ? 1 : (int) $value; |
|
574 | - $this->set_prop( 'frequency', absint( $value ) ); |
|
575 | - } |
|
576 | - |
|
577 | - /** |
|
578 | - * Set the initial amount for the subscription. |
|
579 | - * |
|
580 | - * @since 1.0.19 |
|
581 | - * @param float $value The initial subcription amount. |
|
582 | - */ |
|
583 | - public function set_initial_amount( $value ) { |
|
584 | - $this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) ); |
|
585 | - } |
|
586 | - |
|
587 | - /** |
|
588 | - * Set the recurring amount for the subscription. |
|
589 | - * |
|
590 | - * @since 1.0.19 |
|
591 | - * @param float $value The recurring subcription amount. |
|
592 | - */ |
|
593 | - public function set_recurring_amount( $value ) { |
|
594 | - $this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) ); |
|
595 | - } |
|
596 | - |
|
597 | - /** |
|
598 | - * Set number of times that this subscription can be renewed. |
|
599 | - * |
|
600 | - * @since 1.0.19 |
|
601 | - * @param int $value Bill times. |
|
602 | - */ |
|
603 | - public function set_bill_times( $value ) { |
|
604 | - $this->set_prop( 'bill_times', (int) $value ); |
|
605 | - } |
|
606 | - |
|
607 | - /** |
|
608 | - * Get transaction id of this subscription's parent invoice. |
|
609 | - * |
|
610 | - * @since 1.0.19 |
|
611 | - * @param string $value Bill times. |
|
612 | - */ |
|
613 | - public function set_transaction_id( $value ) { |
|
614 | - $this->set_prop( 'transaction_id', sanitize_text_field( $value ) ); |
|
615 | - } |
|
616 | - |
|
617 | - /** |
|
618 | - * Set date when this subscription started. |
|
619 | - * |
|
620 | - * @since 1.0.19 |
|
621 | - * @param string $value strtotime compliant date. |
|
622 | - */ |
|
623 | - public function set_created( $value ) { |
|
624 | - $date = strtotime( $value ); |
|
669 | + public function set_expiration( $value ) { |
|
670 | + $this->set_next_renewal_date( $value ); |
|
671 | + } |
|
625 | 672 | |
626 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
627 | - $this->set_prop( 'created', date( 'Y-m-d H:i:s', $date ) ); |
|
673 | + /** |
|
674 | + * Set the subscription's trial period. |
|
675 | + * |
|
676 | + * @since 1.0.19 |
|
677 | + * @param string $value trial period e.g 1 year. |
|
678 | + */ |
|
679 | + public function set_trial_period( $value ) { |
|
680 | + $this->set_prop( 'trial_period', $value ); |
|
681 | + } |
|
682 | + |
|
683 | + /** |
|
684 | + * Set the subscription's status. |
|
685 | + * |
|
686 | + * @since 1.0.19 |
|
687 | + * @param string $new_status New subscription status. |
|
688 | + */ |
|
689 | + public function set_status( $new_status ) { |
|
690 | + |
|
691 | + // Abort if this is not a valid status; |
|
692 | + if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) { |
|
628 | 693 | return; |
629 | 694 | } |
630 | 695 | |
631 | - $this->set_prop( 'created', '' ); |
|
632 | 696 | |
633 | - } |
|
697 | + $old_status = ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $this->get_status(); |
|
698 | + if ( true === $this->object_read && $old_status !== $new_status ) { |
|
699 | + $this->status_transition = array( |
|
700 | + 'from' => $old_status, |
|
701 | + 'to' => $new_status, |
|
702 | + ); |
|
703 | + } |
|
634 | 704 | |
635 | - /** |
|
636 | - * Alias for self::set_created(). |
|
637 | - * |
|
638 | - * @since 1.0.19 |
|
639 | - * @param string $value strtotime compliant date. |
|
640 | - */ |
|
641 | - public function set_date_created( $value ) { |
|
642 | - $this->set_created( $value ); |
|
705 | + $this->set_prop( 'status', $new_status ); |
|
643 | 706 | } |
644 | 707 | |
645 | - /** |
|
646 | - * Set the date that the subscription will renew. |
|
647 | - * |
|
648 | - * @since 1.0.19 |
|
649 | - * @param string $value strtotime compliant date. |
|
650 | - */ |
|
651 | - public function set_next_renewal_date( $value ) { |
|
652 | - $date = strtotime( $value ); |
|
708 | + /** |
|
709 | + * Set the subscription's (remote) profile id. |
|
710 | + * |
|
711 | + * @since 1.0.19 |
|
712 | + * @param string $value the remote profile id. |
|
713 | + */ |
|
714 | + public function set_profile_id( $value ) { |
|
715 | + $this->set_prop( 'profile_id', sanitize_text_field( $value ) ); |
|
716 | + } |
|
653 | 717 | |
654 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
655 | - $this->set_prop( 'expiration', date( 'Y-m-d H:i:s', $date ) ); |
|
656 | - return; |
|
657 | - } |
|
658 | - |
|
659 | - $this->set_prop( 'expiration', '' ); |
|
660 | - |
|
661 | - } |
|
662 | - |
|
663 | - /** |
|
664 | - * Alias for self::set_next_renewal_date(). |
|
665 | - * |
|
666 | - * @since 1.0.19 |
|
667 | - * @param string $value strtotime compliant date. |
|
668 | - */ |
|
669 | - public function set_expiration( $value ) { |
|
670 | - $this->set_next_renewal_date( $value ); |
|
671 | - } |
|
672 | - |
|
673 | - /** |
|
674 | - * Set the subscription's trial period. |
|
675 | - * |
|
676 | - * @since 1.0.19 |
|
677 | - * @param string $value trial period e.g 1 year. |
|
678 | - */ |
|
679 | - public function set_trial_period( $value ) { |
|
680 | - $this->set_prop( 'trial_period', $value ); |
|
681 | - } |
|
682 | - |
|
683 | - /** |
|
684 | - * Set the subscription's status. |
|
685 | - * |
|
686 | - * @since 1.0.19 |
|
687 | - * @param string $new_status New subscription status. |
|
688 | - */ |
|
689 | - public function set_status( $new_status ) { |
|
690 | - |
|
691 | - // Abort if this is not a valid status; |
|
692 | - if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) { |
|
693 | - return; |
|
694 | - } |
|
695 | - |
|
696 | - |
|
697 | - $old_status = ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $this->get_status(); |
|
698 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
699 | - $this->status_transition = array( |
|
700 | - 'from' => $old_status, |
|
701 | - 'to' => $new_status, |
|
702 | - ); |
|
703 | - } |
|
704 | - |
|
705 | - $this->set_prop( 'status', $new_status ); |
|
706 | - } |
|
707 | - |
|
708 | - /** |
|
709 | - * Set the subscription's (remote) profile id. |
|
710 | - * |
|
711 | - * @since 1.0.19 |
|
712 | - * @param string $value the remote profile id. |
|
713 | - */ |
|
714 | - public function set_profile_id( $value ) { |
|
715 | - $this->set_prop( 'profile_id', sanitize_text_field( $value ) ); |
|
716 | - } |
|
717 | - |
|
718 | - /* |
|
718 | + /* |
|
719 | 719 | |-------------------------------------------------------------------------- |
720 | 720 | | Boolean methods |
721 | 721 | |-------------------------------------------------------------------------- |
@@ -724,55 +724,55 @@ discard block |
||
724 | 724 | | |
725 | 725 | */ |
726 | 726 | |
727 | - /** |
|
727 | + /** |
|
728 | 728 | * Checks if the subscription has a given status. |
729 | - * |
|
730 | - * @param string|array String or array of strings to check for. |
|
731 | - * @return bool |
|
729 | + * |
|
730 | + * @param string|array String or array of strings to check for. |
|
731 | + * @return bool |
|
732 | 732 | */ |
733 | 733 | public function has_status( $status ) { |
734 | 734 | return in_array( $this->get_status(), wpinv_clean( wpinv_parse_list( $status ) ) ); |
735 | - } |
|
735 | + } |
|
736 | 736 | |
737 | - /** |
|
737 | + /** |
|
738 | 738 | * Checks if the subscription has a trial period. |
739 | - * |
|
740 | - * @return bool |
|
739 | + * |
|
740 | + * @return bool |
|
741 | 741 | */ |
742 | 742 | public function has_trial_period() { |
743 | - $period = $this->get_trial_period(); |
|
743 | + $period = $this->get_trial_period(); |
|
744 | 744 | return ! empty( $period ); |
745 | - } |
|
746 | - |
|
747 | - /** |
|
748 | - * Is the subscription active? |
|
749 | - * |
|
750 | - * @return bool |
|
751 | - */ |
|
752 | - public function is_active() { |
|
753 | - return $this->has_status( 'active trialling' ) && ! $this->is_expired(); |
|
754 | - } |
|
755 | - |
|
756 | - /** |
|
757 | - * Is the subscription expired? |
|
758 | - * |
|
759 | - * @return bool |
|
760 | - */ |
|
761 | - public function is_expired() { |
|
762 | - return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'mysql' ) ); |
|
763 | - } |
|
764 | - |
|
765 | - /** |
|
766 | - * Is this the last renewals? |
|
767 | - * |
|
768 | - * @return bool |
|
769 | - */ |
|
770 | - public function is_last_renewal() { |
|
771 | - $max_bills = $this->get_bill_times(); |
|
772 | - return ! empty( $max_bills ) && $max_bills <= $this->get_times_billed(); |
|
773 | - } |
|
774 | - |
|
775 | - /* |
|
745 | + } |
|
746 | + |
|
747 | + /** |
|
748 | + * Is the subscription active? |
|
749 | + * |
|
750 | + * @return bool |
|
751 | + */ |
|
752 | + public function is_active() { |
|
753 | + return $this->has_status( 'active trialling' ) && ! $this->is_expired(); |
|
754 | + } |
|
755 | + |
|
756 | + /** |
|
757 | + * Is the subscription expired? |
|
758 | + * |
|
759 | + * @return bool |
|
760 | + */ |
|
761 | + public function is_expired() { |
|
762 | + return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'mysql' ) ); |
|
763 | + } |
|
764 | + |
|
765 | + /** |
|
766 | + * Is this the last renewals? |
|
767 | + * |
|
768 | + * @return bool |
|
769 | + */ |
|
770 | + public function is_last_renewal() { |
|
771 | + $max_bills = $this->get_bill_times(); |
|
772 | + return ! empty( $max_bills ) && $max_bills <= $this->get_times_billed(); |
|
773 | + } |
|
774 | + |
|
775 | + /* |
|
776 | 776 | |-------------------------------------------------------------------------- |
777 | 777 | | Additional methods |
778 | 778 | |-------------------------------------------------------------------------- |
@@ -781,27 +781,27 @@ discard block |
||
781 | 781 | | |
782 | 782 | */ |
783 | 783 | |
784 | - /** |
|
785 | - * Backwards compatibilty. |
|
786 | - */ |
|
787 | - public function create( $data = array() ) { |
|
784 | + /** |
|
785 | + * Backwards compatibilty. |
|
786 | + */ |
|
787 | + public function create( $data = array() ) { |
|
788 | 788 | |
789 | - // Set the properties. |
|
790 | - if ( is_array( $data ) ) { |
|
791 | - $this->set_props( $data ); |
|
792 | - } |
|
789 | + // Set the properties. |
|
790 | + if ( is_array( $data ) ) { |
|
791 | + $this->set_props( $data ); |
|
792 | + } |
|
793 | 793 | |
794 | - // Save the item. |
|
795 | - return $this->save(); |
|
794 | + // Save the item. |
|
795 | + return $this->save(); |
|
796 | 796 | |
797 | - } |
|
797 | + } |
|
798 | 798 | |
799 | - /** |
|
800 | - * Backwards compatibilty. |
|
801 | - */ |
|
802 | - public function update( $args = array() ) { |
|
803 | - return $this->create( $args ); |
|
804 | - } |
|
799 | + /** |
|
800 | + * Backwards compatibilty. |
|
801 | + */ |
|
802 | + public function update( $args = array() ) { |
|
803 | + return $this->create( $args ); |
|
804 | + } |
|
805 | 805 | |
806 | 806 | /** |
807 | 807 | * Retrieve renewal payments for a subscription |
@@ -811,22 +811,22 @@ discard block |
||
811 | 811 | */ |
812 | 812 | public function get_child_payments( $hide_pending = true ) { |
813 | 813 | |
814 | - $statuses = array( 'publish', 'wpi-processing', 'wpi-renewal' ); |
|
814 | + $statuses = array( 'publish', 'wpi-processing', 'wpi-renewal' ); |
|
815 | 815 | |
816 | - if ( ! $hide_pending ) { |
|
817 | - $statuses = array_keys( wpinv_get_invoice_statuses() ); |
|
818 | - } |
|
816 | + if ( ! $hide_pending ) { |
|
817 | + $statuses = array_keys( wpinv_get_invoice_statuses() ); |
|
818 | + } |
|
819 | 819 | |
820 | 820 | return get_posts( |
821 | - array( |
|
822 | - 'post_parent' => $this->get_parent_payment_id(), |
|
823 | - 'numberposts' => -1, |
|
824 | - 'post_status' => $statuses, |
|
825 | - 'orderby' => 'ID', |
|
826 | - 'order' => 'ASC', |
|
827 | - 'post_type' => 'wpi_invoice' |
|
828 | - ) |
|
829 | - ); |
|
821 | + array( |
|
822 | + 'post_parent' => $this->get_parent_payment_id(), |
|
823 | + 'numberposts' => -1, |
|
824 | + 'post_status' => $statuses, |
|
825 | + 'orderby' => 'ID', |
|
826 | + 'order' => 'ASC', |
|
827 | + 'post_type' => 'wpi_invoice' |
|
828 | + ) |
|
829 | + ); |
|
830 | 830 | } |
831 | 831 | |
832 | 832 | /** |
@@ -836,7 +836,7 @@ discard block |
||
836 | 836 | * @return int |
837 | 837 | */ |
838 | 838 | public function get_total_payments() { |
839 | - return getpaid_count_subscription_invoices( $this->get_parent_invoice_id(), $this->get_id() ); |
|
839 | + return getpaid_count_subscription_invoices( $this->get_parent_invoice_id(), $this->get_id() ); |
|
840 | 840 | } |
841 | 841 | |
842 | 842 | /** |
@@ -860,57 +860,57 @@ discard block |
||
860 | 860 | * |
861 | 861 | * @since 2.4 |
862 | 862 | * @param array $args Array of values for the payment, including amount and transaction ID |
863 | - * @param WPInv_Invoice $invoice If adding an existing invoice. |
|
863 | + * @param WPInv_Invoice $invoice If adding an existing invoice. |
|
864 | 864 | * @return bool |
865 | 865 | */ |
866 | 866 | public function add_payment( $args = array(), $invoice = false ) { |
867 | 867 | |
868 | - // Process each payment once. |
|
868 | + // Process each payment once. |
|
869 | 869 | if ( ! empty( $args['transaction_id'] ) && $this->payment_exists( $args['transaction_id'] ) ) { |
870 | 870 | return false; |
871 | 871 | } |
872 | 872 | |
873 | - // Are we creating a new invoice? |
|
874 | - if ( empty( $invoice ) ) { |
|
875 | - $invoice = $this->create_payment(); |
|
873 | + // Are we creating a new invoice? |
|
874 | + if ( empty( $invoice ) ) { |
|
875 | + $invoice = $this->create_payment(); |
|
876 | 876 | |
877 | - if ( empty( $invoice ) ) { |
|
878 | - return false; |
|
879 | - } |
|
877 | + if ( empty( $invoice ) ) { |
|
878 | + return false; |
|
879 | + } |
|
880 | 880 | |
881 | - } |
|
881 | + } |
|
882 | 882 | |
883 | - $invoice->set_status( 'wpi-renewal' ); |
|
883 | + $invoice->set_status( 'wpi-renewal' ); |
|
884 | 884 | |
885 | - // Maybe set a transaction id. |
|
886 | - if ( ! empty( $args['transaction_id'] ) ) { |
|
887 | - $invoice->set_transaction_id( $args['transaction_id'] ); |
|
888 | - } |
|
885 | + // Maybe set a transaction id. |
|
886 | + if ( ! empty( $args['transaction_id'] ) ) { |
|
887 | + $invoice->set_transaction_id( $args['transaction_id'] ); |
|
888 | + } |
|
889 | 889 | |
890 | - // Set the completed date. |
|
891 | - $invoice->set_completed_date( current_time( 'mysql' ) ); |
|
890 | + // Set the completed date. |
|
891 | + $invoice->set_completed_date( current_time( 'mysql' ) ); |
|
892 | 892 | |
893 | - // And the gateway. |
|
894 | - if ( ! empty( $args['gateway'] ) ) { |
|
895 | - $invoice->set_gateway( $args['gateway'] ); |
|
896 | - } |
|
893 | + // And the gateway. |
|
894 | + if ( ! empty( $args['gateway'] ) ) { |
|
895 | + $invoice->set_gateway( $args['gateway'] ); |
|
896 | + } |
|
897 | 897 | |
898 | - $invoice->save(); |
|
898 | + $invoice->save(); |
|
899 | 899 | |
900 | - if ( ! $invoice->exists() ) { |
|
901 | - return false; |
|
902 | - } |
|
900 | + if ( ! $invoice->exists() ) { |
|
901 | + return false; |
|
902 | + } |
|
903 | 903 | |
904 | - do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this ); |
|
905 | - do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this ); |
|
904 | + do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this ); |
|
905 | + do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this ); |
|
906 | 906 | do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id() ); |
907 | 907 | |
908 | 908 | update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id ); |
909 | 909 | |
910 | 910 | return $invoice->get_id(); |
911 | - } |
|
911 | + } |
|
912 | 912 | |
913 | - /** |
|
913 | + /** |
|
914 | 914 | * Creates a new invoice and returns it. |
915 | 915 | * |
916 | 916 | * @since 1.0.19 |
@@ -918,124 +918,124 @@ discard block |
||
918 | 918 | */ |
919 | 919 | public function create_payment() { |
920 | 920 | |
921 | - $parent_invoice = $this->get_parent_payment(); |
|
922 | - |
|
923 | - if ( ! $parent_invoice->exists() ) { |
|
924 | - return false; |
|
925 | - } |
|
926 | - |
|
927 | - // Duplicate the parent invoice. |
|
928 | - $invoice = getpaid_duplicate_invoice( $parent_invoice ); |
|
929 | - $invoice->set_parent_id( $parent_invoice->get_id() ); |
|
930 | - $invoice->set_subscription_id( $this->get_id() ); |
|
931 | - $invoice->set_remote_subscription_id( $this->get_profile_id() ); |
|
932 | - |
|
933 | - // Set invoice items. |
|
934 | - $subscription_group = getpaid_get_invoice_subscription_group( $parent_invoice->get_id(), $this->get_id() ); |
|
935 | - $allowed_items = empty( $subscription_group ) ? array( $this->get_product_id() ) : array_keys( $subscription_group['items'] ); |
|
936 | - $invoice_items = array(); |
|
937 | - |
|
938 | - foreach ( $invoice->get_items() as $item ) { |
|
939 | - if ( in_array( $item->get_id(), $allowed_items ) ) { |
|
940 | - $invoice_items[] = $item; |
|
941 | - } |
|
942 | - } |
|
943 | - |
|
944 | - $invoice->set_items( $invoice_items ); |
|
945 | - |
|
946 | - if ( ! empty( $subscription_group['fees'] ) ) { |
|
947 | - $invoice->set_fees( $subscription_group['fees'] ); |
|
948 | - } |
|
949 | - |
|
950 | - // Maybe recalculate discount (Pre-GetPaid Fix). |
|
951 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
952 | - if ( $discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount() ) { |
|
953 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
954 | - } |
|
955 | - |
|
956 | - $invoice->recalculate_total(); |
|
957 | - $invoice->set_status( 'wpi-pending' ); |
|
958 | - $invoice->save(); |
|
959 | - |
|
960 | - return $invoice->exists() ? $invoice : false; |
|
961 | - } |
|
962 | - |
|
963 | - /** |
|
964 | - * Renews or completes a subscription |
|
965 | - * |
|
966 | - * @since 1.0.0 |
|
967 | - * @return int The subscription's id |
|
968 | - */ |
|
969 | - public function renew() { |
|
970 | - |
|
971 | - // Complete subscription if applicable |
|
972 | - if ( $this->is_last_renewal() ) { |
|
973 | - return $this->complete(); |
|
974 | - } |
|
975 | - |
|
976 | - // Calculate new expiration |
|
977 | - $frequency = $this->get_frequency(); |
|
978 | - $period = $this->get_period(); |
|
979 | - $new_expiration = strtotime( "+ $frequency $period", $this->get_expiration_time() ); |
|
980 | - |
|
981 | - $this->set_expiration( date( 'Y-m-d H:i:s',$new_expiration ) ); |
|
982 | - $this->set_status( 'active' ); |
|
983 | - $this->save(); |
|
984 | - |
|
985 | - do_action( 'getpaid_subscription_renewed', $this ); |
|
986 | - |
|
987 | - return $this->get_id(); |
|
988 | - } |
|
989 | - |
|
990 | - /** |
|
991 | - * Marks a subscription as completed |
|
992 | - * |
|
993 | - * Subscription is completed when the number of payments matches the billing_times field |
|
994 | - * |
|
995 | - * @since 1.0.0 |
|
996 | - * @return int|bool Subscription id or false if the subscription is cancelled. |
|
997 | - */ |
|
998 | - public function complete() { |
|
999 | - |
|
1000 | - // Only mark a subscription as complete if it's not already cancelled. |
|
1001 | - if ( $this->has_status( 'cancelled' ) ) { |
|
1002 | - return false; |
|
1003 | - } |
|
1004 | - |
|
1005 | - $this->set_status( 'completed' ); |
|
1006 | - return $this->save(); |
|
1007 | - |
|
1008 | - } |
|
1009 | - |
|
1010 | - /** |
|
1011 | - * Marks a subscription as expired |
|
1012 | - * |
|
1013 | - * @since 1.0.0 |
|
1014 | - * @param bool $check_expiration |
|
1015 | - * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future. |
|
1016 | - */ |
|
1017 | - public function expire( $check_expiration = false ) { |
|
1018 | - |
|
1019 | - if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) { |
|
1020 | - // Do not mark as expired since real expiration date is in the future |
|
1021 | - return false; |
|
1022 | - } |
|
1023 | - |
|
1024 | - $this->set_status( 'expired' ); |
|
1025 | - return $this->save(); |
|
1026 | - |
|
1027 | - } |
|
1028 | - |
|
1029 | - /** |
|
1030 | - * Marks a subscription as failing |
|
1031 | - * |
|
1032 | - * @since 2.4.2 |
|
1033 | - * @return int Subscription id. |
|
1034 | - */ |
|
1035 | - public function failing() { |
|
1036 | - $this->set_status( 'failing' ); |
|
1037 | - return $this->save(); |
|
1038 | - } |
|
921 | + $parent_invoice = $this->get_parent_payment(); |
|
922 | + |
|
923 | + if ( ! $parent_invoice->exists() ) { |
|
924 | + return false; |
|
925 | + } |
|
926 | + |
|
927 | + // Duplicate the parent invoice. |
|
928 | + $invoice = getpaid_duplicate_invoice( $parent_invoice ); |
|
929 | + $invoice->set_parent_id( $parent_invoice->get_id() ); |
|
930 | + $invoice->set_subscription_id( $this->get_id() ); |
|
931 | + $invoice->set_remote_subscription_id( $this->get_profile_id() ); |
|
932 | + |
|
933 | + // Set invoice items. |
|
934 | + $subscription_group = getpaid_get_invoice_subscription_group( $parent_invoice->get_id(), $this->get_id() ); |
|
935 | + $allowed_items = empty( $subscription_group ) ? array( $this->get_product_id() ) : array_keys( $subscription_group['items'] ); |
|
936 | + $invoice_items = array(); |
|
937 | + |
|
938 | + foreach ( $invoice->get_items() as $item ) { |
|
939 | + if ( in_array( $item->get_id(), $allowed_items ) ) { |
|
940 | + $invoice_items[] = $item; |
|
941 | + } |
|
942 | + } |
|
943 | + |
|
944 | + $invoice->set_items( $invoice_items ); |
|
945 | + |
|
946 | + if ( ! empty( $subscription_group['fees'] ) ) { |
|
947 | + $invoice->set_fees( $subscription_group['fees'] ); |
|
948 | + } |
|
949 | + |
|
950 | + // Maybe recalculate discount (Pre-GetPaid Fix). |
|
951 | + $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
952 | + if ( $discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount() ) { |
|
953 | + $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
954 | + } |
|
955 | + |
|
956 | + $invoice->recalculate_total(); |
|
957 | + $invoice->set_status( 'wpi-pending' ); |
|
958 | + $invoice->save(); |
|
959 | + |
|
960 | + return $invoice->exists() ? $invoice : false; |
|
961 | + } |
|
962 | + |
|
963 | + /** |
|
964 | + * Renews or completes a subscription |
|
965 | + * |
|
966 | + * @since 1.0.0 |
|
967 | + * @return int The subscription's id |
|
968 | + */ |
|
969 | + public function renew() { |
|
970 | + |
|
971 | + // Complete subscription if applicable |
|
972 | + if ( $this->is_last_renewal() ) { |
|
973 | + return $this->complete(); |
|
974 | + } |
|
975 | + |
|
976 | + // Calculate new expiration |
|
977 | + $frequency = $this->get_frequency(); |
|
978 | + $period = $this->get_period(); |
|
979 | + $new_expiration = strtotime( "+ $frequency $period", $this->get_expiration_time() ); |
|
980 | + |
|
981 | + $this->set_expiration( date( 'Y-m-d H:i:s',$new_expiration ) ); |
|
982 | + $this->set_status( 'active' ); |
|
983 | + $this->save(); |
|
984 | + |
|
985 | + do_action( 'getpaid_subscription_renewed', $this ); |
|
986 | + |
|
987 | + return $this->get_id(); |
|
988 | + } |
|
989 | + |
|
990 | + /** |
|
991 | + * Marks a subscription as completed |
|
992 | + * |
|
993 | + * Subscription is completed when the number of payments matches the billing_times field |
|
994 | + * |
|
995 | + * @since 1.0.0 |
|
996 | + * @return int|bool Subscription id or false if the subscription is cancelled. |
|
997 | + */ |
|
998 | + public function complete() { |
|
999 | + |
|
1000 | + // Only mark a subscription as complete if it's not already cancelled. |
|
1001 | + if ( $this->has_status( 'cancelled' ) ) { |
|
1002 | + return false; |
|
1003 | + } |
|
1004 | + |
|
1005 | + $this->set_status( 'completed' ); |
|
1006 | + return $this->save(); |
|
1007 | + |
|
1008 | + } |
|
1009 | + |
|
1010 | + /** |
|
1011 | + * Marks a subscription as expired |
|
1012 | + * |
|
1013 | + * @since 1.0.0 |
|
1014 | + * @param bool $check_expiration |
|
1015 | + * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future. |
|
1016 | + */ |
|
1017 | + public function expire( $check_expiration = false ) { |
|
1018 | + |
|
1019 | + if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) { |
|
1020 | + // Do not mark as expired since real expiration date is in the future |
|
1021 | + return false; |
|
1022 | + } |
|
1023 | + |
|
1024 | + $this->set_status( 'expired' ); |
|
1025 | + return $this->save(); |
|
1026 | + |
|
1027 | + } |
|
1028 | + |
|
1029 | + /** |
|
1030 | + * Marks a subscription as failing |
|
1031 | + * |
|
1032 | + * @since 2.4.2 |
|
1033 | + * @return int Subscription id. |
|
1034 | + */ |
|
1035 | + public function failing() { |
|
1036 | + $this->set_status( 'failing' ); |
|
1037 | + return $this->save(); |
|
1038 | + } |
|
1039 | 1039 | |
1040 | 1040 | /** |
1041 | 1041 | * Marks a subscription as cancelled |
@@ -1044,19 +1044,19 @@ discard block |
||
1044 | 1044 | * @return int Subscription id. |
1045 | 1045 | */ |
1046 | 1046 | public function cancel() { |
1047 | - $this->set_status( 'cancelled' ); |
|
1048 | - return $this->save(); |
|
1047 | + $this->set_status( 'cancelled' ); |
|
1048 | + return $this->save(); |
|
1049 | 1049 | } |
1050 | 1050 | |
1051 | - /** |
|
1052 | - * Determines if a subscription can be cancelled both locally and with a payment processor. |
|
1053 | - * |
|
1054 | - * @since 1.0.0 |
|
1055 | - * @return bool |
|
1056 | - */ |
|
1057 | - public function can_cancel() { |
|
1058 | - return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this ); |
|
1059 | - } |
|
1051 | + /** |
|
1052 | + * Determines if a subscription can be cancelled both locally and with a payment processor. |
|
1053 | + * |
|
1054 | + * @since 1.0.0 |
|
1055 | + * @return bool |
|
1056 | + */ |
|
1057 | + public function can_cancel() { |
|
1058 | + return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this ); |
|
1059 | + } |
|
1060 | 1060 | |
1061 | 1061 | /** |
1062 | 1062 | * Returns an array of subscription statuses that can be cancelled |
@@ -1069,96 +1069,96 @@ discard block |
||
1069 | 1069 | return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) ); |
1070 | 1070 | } |
1071 | 1071 | |
1072 | - /** |
|
1073 | - * Retrieves the URL to cancel subscription |
|
1074 | - * |
|
1075 | - * @since 1.0.0 |
|
1076 | - * @return string |
|
1077 | - */ |
|
1078 | - public function get_cancel_url() { |
|
1079 | - $url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() ); |
|
1080 | - return apply_filters( 'wpinv_subscription_cancel_url', $url, $this ); |
|
1081 | - } |
|
1082 | - |
|
1083 | - /** |
|
1084 | - * Retrieves the URL to view a subscription |
|
1085 | - * |
|
1086 | - * @since 1.0.19 |
|
1087 | - * @return string |
|
1088 | - */ |
|
1089 | - public function get_view_url() { |
|
1090 | - |
|
1091 | - $url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
1092 | - $url = add_query_arg( 'subscription', $this->get_id(), $url ); |
|
1093 | - |
|
1094 | - return apply_filters( 'getpaid_get_subscription_view_url', $url, $this ); |
|
1095 | - } |
|
1096 | - |
|
1097 | - /** |
|
1098 | - * Determines if subscription can be manually renewed |
|
1099 | - * |
|
1100 | - * This method is filtered by payment gateways in order to return true on subscriptions |
|
1101 | - * that can be renewed manually |
|
1102 | - * |
|
1103 | - * @since 2.5 |
|
1104 | - * @return bool |
|
1105 | - */ |
|
1106 | - public function can_renew() { |
|
1107 | - return apply_filters( 'wpinv_subscription_can_renew', true, $this ); |
|
1108 | - } |
|
1109 | - |
|
1110 | - /** |
|
1111 | - * Retrieves the URL to renew a subscription |
|
1112 | - * |
|
1113 | - * @since 2.5 |
|
1114 | - * @return string |
|
1115 | - */ |
|
1116 | - public function get_renew_url() { |
|
1117 | - $url = wp_nonce_url( add_query_arg( array( 'getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id ) ), 'getpaid-nonce' ); |
|
1118 | - return apply_filters( 'wpinv_subscription_renew_url', $url, $this ); |
|
1119 | - } |
|
1120 | - |
|
1121 | - /** |
|
1122 | - * Determines if subscription can have their payment method updated |
|
1123 | - * |
|
1124 | - * @since 1.0.0 |
|
1125 | - * @return bool |
|
1126 | - */ |
|
1127 | - public function can_update() { |
|
1128 | - return apply_filters( 'wpinv_subscription_can_update', false, $this ); |
|
1129 | - } |
|
1130 | - |
|
1131 | - /** |
|
1132 | - * Retrieves the URL to update subscription |
|
1133 | - * |
|
1134 | - * @since 1.0.0 |
|
1135 | - * @return string |
|
1136 | - */ |
|
1137 | - public function get_update_url() { |
|
1138 | - $url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->get_id() ) ); |
|
1139 | - return apply_filters( 'wpinv_subscription_update_url', $url, $this ); |
|
1140 | - } |
|
1141 | - |
|
1142 | - /** |
|
1143 | - * Retrieves the subscription status label |
|
1144 | - * |
|
1145 | - * @since 1.0.0 |
|
1146 | - * @return string |
|
1147 | - */ |
|
1148 | - public function get_status_label() { |
|
1149 | - return getpaid_get_subscription_status_label( $this->get_status() ); |
|
1150 | - } |
|
1151 | - |
|
1152 | - /** |
|
1153 | - * Retrieves the subscription status class |
|
1154 | - * |
|
1155 | - * @since 1.0.19 |
|
1156 | - * @return string |
|
1157 | - */ |
|
1158 | - public function get_status_class() { |
|
1159 | - $statuses = getpaid_get_subscription_status_classes(); |
|
1160 | - return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark'; |
|
1161 | - } |
|
1072 | + /** |
|
1073 | + * Retrieves the URL to cancel subscription |
|
1074 | + * |
|
1075 | + * @since 1.0.0 |
|
1076 | + * @return string |
|
1077 | + */ |
|
1078 | + public function get_cancel_url() { |
|
1079 | + $url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() ); |
|
1080 | + return apply_filters( 'wpinv_subscription_cancel_url', $url, $this ); |
|
1081 | + } |
|
1082 | + |
|
1083 | + /** |
|
1084 | + * Retrieves the URL to view a subscription |
|
1085 | + * |
|
1086 | + * @since 1.0.19 |
|
1087 | + * @return string |
|
1088 | + */ |
|
1089 | + public function get_view_url() { |
|
1090 | + |
|
1091 | + $url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
1092 | + $url = add_query_arg( 'subscription', $this->get_id(), $url ); |
|
1093 | + |
|
1094 | + return apply_filters( 'getpaid_get_subscription_view_url', $url, $this ); |
|
1095 | + } |
|
1096 | + |
|
1097 | + /** |
|
1098 | + * Determines if subscription can be manually renewed |
|
1099 | + * |
|
1100 | + * This method is filtered by payment gateways in order to return true on subscriptions |
|
1101 | + * that can be renewed manually |
|
1102 | + * |
|
1103 | + * @since 2.5 |
|
1104 | + * @return bool |
|
1105 | + */ |
|
1106 | + public function can_renew() { |
|
1107 | + return apply_filters( 'wpinv_subscription_can_renew', true, $this ); |
|
1108 | + } |
|
1109 | + |
|
1110 | + /** |
|
1111 | + * Retrieves the URL to renew a subscription |
|
1112 | + * |
|
1113 | + * @since 2.5 |
|
1114 | + * @return string |
|
1115 | + */ |
|
1116 | + public function get_renew_url() { |
|
1117 | + $url = wp_nonce_url( add_query_arg( array( 'getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id ) ), 'getpaid-nonce' ); |
|
1118 | + return apply_filters( 'wpinv_subscription_renew_url', $url, $this ); |
|
1119 | + } |
|
1120 | + |
|
1121 | + /** |
|
1122 | + * Determines if subscription can have their payment method updated |
|
1123 | + * |
|
1124 | + * @since 1.0.0 |
|
1125 | + * @return bool |
|
1126 | + */ |
|
1127 | + public function can_update() { |
|
1128 | + return apply_filters( 'wpinv_subscription_can_update', false, $this ); |
|
1129 | + } |
|
1130 | + |
|
1131 | + /** |
|
1132 | + * Retrieves the URL to update subscription |
|
1133 | + * |
|
1134 | + * @since 1.0.0 |
|
1135 | + * @return string |
|
1136 | + */ |
|
1137 | + public function get_update_url() { |
|
1138 | + $url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->get_id() ) ); |
|
1139 | + return apply_filters( 'wpinv_subscription_update_url', $url, $this ); |
|
1140 | + } |
|
1141 | + |
|
1142 | + /** |
|
1143 | + * Retrieves the subscription status label |
|
1144 | + * |
|
1145 | + * @since 1.0.0 |
|
1146 | + * @return string |
|
1147 | + */ |
|
1148 | + public function get_status_label() { |
|
1149 | + return getpaid_get_subscription_status_label( $this->get_status() ); |
|
1150 | + } |
|
1151 | + |
|
1152 | + /** |
|
1153 | + * Retrieves the subscription status class |
|
1154 | + * |
|
1155 | + * @since 1.0.19 |
|
1156 | + * @return string |
|
1157 | + */ |
|
1158 | + public function get_status_class() { |
|
1159 | + $statuses = getpaid_get_subscription_status_classes(); |
|
1160 | + return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark'; |
|
1161 | + } |
|
1162 | 1162 | |
1163 | 1163 | /** |
1164 | 1164 | * Retrieves the subscription status label |
@@ -1168,11 +1168,11 @@ discard block |
||
1168 | 1168 | */ |
1169 | 1169 | public function get_status_label_html() { |
1170 | 1170 | |
1171 | - $status_label = sanitize_text_field( $this->get_status_label() ); |
|
1172 | - $class = esc_attr( $this->get_status_class() ); |
|
1173 | - $status = sanitize_html_class( $this->get_status() ); |
|
1171 | + $status_label = sanitize_text_field( $this->get_status_label() ); |
|
1172 | + $class = esc_attr( $this->get_status_class() ); |
|
1173 | + $status = sanitize_html_class( $this->get_status() ); |
|
1174 | 1174 | |
1175 | - return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>"; |
|
1175 | + return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>"; |
|
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | /** |
@@ -1183,75 +1183,75 @@ discard block |
||
1183 | 1183 | * @return bool |
1184 | 1184 | */ |
1185 | 1185 | public function payment_exists( $txn_id = '' ) { |
1186 | - $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' ); |
|
1186 | + $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' ); |
|
1187 | 1187 | return ! empty( $invoice_id ); |
1188 | - } |
|
1189 | - |
|
1190 | - /** |
|
1191 | - * Handle the status transition. |
|
1192 | - */ |
|
1193 | - protected function status_transition() { |
|
1194 | - $status_transition = $this->status_transition; |
|
1195 | - |
|
1196 | - // Reset status transition variable. |
|
1197 | - $this->status_transition = false; |
|
1198 | - |
|
1199 | - if ( $status_transition ) { |
|
1200 | - try { |
|
1201 | - |
|
1202 | - // Fire a hook for the status change. |
|
1203 | - do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition ); |
|
1204 | - do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition ); |
|
1205 | - |
|
1206 | - if ( ! empty( $status_transition['from'] ) ) { |
|
1207 | - |
|
1208 | - /* translators: 1: old subscription status 2: new subscription status */ |
|
1209 | - $transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) ); |
|
1210 | - |
|
1211 | - // Note the transition occurred. |
|
1212 | - $this->get_parent_payment()->add_note( $transition_note, false, false, true ); |
|
1213 | - |
|
1214 | - // Fire another hook. |
|
1215 | - do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); |
|
1216 | - do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
1217 | - |
|
1218 | - } else { |
|
1219 | - /* translators: %s: new invoice status */ |
|
1220 | - $transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) ); |
|
1221 | - |
|
1222 | - // Note the transition occurred. |
|
1223 | - $this->get_parent_payment()->add_note( $transition_note, false, false, true ); |
|
1224 | - |
|
1225 | - } |
|
1226 | - } catch ( Exception $e ) { |
|
1227 | - $this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
1228 | - } |
|
1229 | - } |
|
1230 | - |
|
1231 | - } |
|
1232 | - |
|
1233 | - /** |
|
1234 | - * Save data to the database. |
|
1235 | - * |
|
1236 | - * @since 1.0.19 |
|
1237 | - * @return int subscription ID |
|
1238 | - */ |
|
1239 | - public function save() { |
|
1240 | - parent::save(); |
|
1241 | - $this->status_transition(); |
|
1242 | - return $this->get_id(); |
|
1243 | - } |
|
1244 | - |
|
1245 | - /** |
|
1246 | - * Activates a subscription. |
|
1247 | - * |
|
1248 | - * @since 1.0.19 |
|
1249 | - * @return int subscription ID |
|
1250 | - */ |
|
1251 | - public function activate() { |
|
1252 | - $status = 'trialling' == $this->get_status() ? 'trialling' : 'active'; |
|
1253 | - $this->set_status( $status ); |
|
1254 | - return $this->save(); |
|
1255 | - } |
|
1188 | + } |
|
1189 | + |
|
1190 | + /** |
|
1191 | + * Handle the status transition. |
|
1192 | + */ |
|
1193 | + protected function status_transition() { |
|
1194 | + $status_transition = $this->status_transition; |
|
1195 | + |
|
1196 | + // Reset status transition variable. |
|
1197 | + $this->status_transition = false; |
|
1198 | + |
|
1199 | + if ( $status_transition ) { |
|
1200 | + try { |
|
1201 | + |
|
1202 | + // Fire a hook for the status change. |
|
1203 | + do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition ); |
|
1204 | + do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition ); |
|
1205 | + |
|
1206 | + if ( ! empty( $status_transition['from'] ) ) { |
|
1207 | + |
|
1208 | + /* translators: 1: old subscription status 2: new subscription status */ |
|
1209 | + $transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) ); |
|
1210 | + |
|
1211 | + // Note the transition occurred. |
|
1212 | + $this->get_parent_payment()->add_note( $transition_note, false, false, true ); |
|
1213 | + |
|
1214 | + // Fire another hook. |
|
1215 | + do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); |
|
1216 | + do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
1217 | + |
|
1218 | + } else { |
|
1219 | + /* translators: %s: new invoice status */ |
|
1220 | + $transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) ); |
|
1221 | + |
|
1222 | + // Note the transition occurred. |
|
1223 | + $this->get_parent_payment()->add_note( $transition_note, false, false, true ); |
|
1224 | + |
|
1225 | + } |
|
1226 | + } catch ( Exception $e ) { |
|
1227 | + $this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
1228 | + } |
|
1229 | + } |
|
1230 | + |
|
1231 | + } |
|
1232 | + |
|
1233 | + /** |
|
1234 | + * Save data to the database. |
|
1235 | + * |
|
1236 | + * @since 1.0.19 |
|
1237 | + * @return int subscription ID |
|
1238 | + */ |
|
1239 | + public function save() { |
|
1240 | + parent::save(); |
|
1241 | + $this->status_transition(); |
|
1242 | + return $this->get_id(); |
|
1243 | + } |
|
1244 | + |
|
1245 | + /** |
|
1246 | + * Activates a subscription. |
|
1247 | + * |
|
1248 | + * @since 1.0.19 |
|
1249 | + * @return int subscription ID |
|
1250 | + */ |
|
1251 | + public function activate() { |
|
1252 | + $status = 'trialling' == $this->get_status() ? 'trialling' : 'active'; |
|
1253 | + $this->set_status( $status ); |
|
1254 | + return $this->save(); |
|
1255 | + } |
|
1256 | 1256 | |
1257 | 1257 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * The Subscription Class |
@@ -68,27 +68,27 @@ discard block |
||
68 | 68 | * @param int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read. |
69 | 69 | * @param bool $deprecated |
70 | 70 | */ |
71 | - function __construct( $subscription = 0, $deprecated = false ) { |
|
71 | + function __construct($subscription = 0, $deprecated = false) { |
|
72 | 72 | |
73 | - parent::__construct( $subscription ); |
|
73 | + parent::__construct($subscription); |
|
74 | 74 | |
75 | - if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) { |
|
76 | - $this->set_id( $subscription ); |
|
77 | - } elseif ( $subscription instanceof self ) { |
|
78 | - $this->set_id( $subscription->get_id() ); |
|
79 | - } elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) { |
|
80 | - $this->set_id( $subscription_id ); |
|
81 | - } elseif ( ! empty( $subscription->id ) ) { |
|
82 | - $this->set_id( $subscription->id ); |
|
75 | + if (!$deprecated && !empty($subscription) && is_numeric($subscription)) { |
|
76 | + $this->set_id($subscription); |
|
77 | + } elseif ($subscription instanceof self) { |
|
78 | + $this->set_id($subscription->get_id()); |
|
79 | + } elseif ($deprecated && $subscription_id = self::get_subscription_id_by_field($subscription, 'profile_id')) { |
|
80 | + $this->set_id($subscription_id); |
|
81 | + } elseif (!empty($subscription->id)) { |
|
82 | + $this->set_id($subscription->id); |
|
83 | 83 | } else { |
84 | - $this->set_object_read( true ); |
|
84 | + $this->set_object_read(true); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | // Load the datastore. |
88 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
88 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
89 | 89 | |
90 | - if ( $this->get_id() > 0 ) { |
|
91 | - $this->data_store->read( $this ); |
|
90 | + if ($this->get_id() > 0) { |
|
91 | + $this->data_store->read($this); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | } |
@@ -103,17 +103,17 @@ discard block |
||
103 | 103 | * @since 1.0.19 |
104 | 104 | * @return int |
105 | 105 | */ |
106 | - public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) { |
|
106 | + public static function get_subscription_id_by_field($value, $field = 'profile_id') { |
|
107 | 107 | global $wpdb; |
108 | 108 | |
109 | 109 | // Trim the value. |
110 | - $value = trim( $value ); |
|
110 | + $value = trim($value); |
|
111 | 111 | |
112 | - if ( empty( $value ) ) { |
|
112 | + if (empty($value)) { |
|
113 | 113 | return 0; |
114 | 114 | } |
115 | 115 | |
116 | - if ( 'invoice_id' == $field ) { |
|
116 | + if ('invoice_id' == $field) { |
|
117 | 117 | $field = 'parent_payment_id'; |
118 | 118 | } |
119 | 119 | |
@@ -125,28 +125,28 @@ discard block |
||
125 | 125 | ); |
126 | 126 | |
127 | 127 | // Ensure a field has been passed. |
128 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
128 | + if (empty($field) || !in_array($field, $fields)) { |
|
129 | 129 | return 0; |
130 | 130 | } |
131 | 131 | |
132 | 132 | // Maybe retrieve from the cache. |
133 | - $subscription_id = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" ); |
|
134 | - if ( ! empty( $subscription_id ) ) { |
|
133 | + $subscription_id = wp_cache_get($value, "getpaid_subscription_{$field}s_to_subscription_ids"); |
|
134 | + if (!empty($subscription_id)) { |
|
135 | 135 | return $subscription_id; |
136 | 136 | } |
137 | 137 | |
138 | 138 | // Fetch from the db. |
139 | 139 | $table = $wpdb->prefix . 'wpinv_subscriptions'; |
140 | 140 | $subscription_id = (int) $wpdb->get_var( |
141 | - $wpdb->prepare( "SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
|
141 | + $wpdb->prepare("SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value) |
|
142 | 142 | ); |
143 | 143 | |
144 | - if ( empty( $subscription_id ) ) { |
|
144 | + if (empty($subscription_id)) { |
|
145 | 145 | return 0; |
146 | 146 | } |
147 | 147 | |
148 | 148 | // Update the cache with our data. |
149 | - wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" ); |
|
149 | + wp_cache_set($value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids"); |
|
150 | 150 | |
151 | 151 | return $subscription_id; |
152 | 152 | } |
@@ -155,17 +155,17 @@ discard block |
||
155 | 155 | * Clears the subscription's cache. |
156 | 156 | */ |
157 | 157 | public function clear_cache() { |
158 | - wp_cache_delete( $this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids' ); |
|
159 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids' ); |
|
160 | - wp_cache_delete( $this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids' ); |
|
161 | - wp_cache_delete( $this->get_id(), 'getpaid_subscriptions' ); |
|
158 | + wp_cache_delete($this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids'); |
|
159 | + wp_cache_delete($this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids'); |
|
160 | + wp_cache_delete($this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids'); |
|
161 | + wp_cache_delete($this->get_id(), 'getpaid_subscriptions'); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
165 | 165 | * Checks if a subscription key is set. |
166 | 166 | */ |
167 | - public function _isset( $key ) { |
|
168 | - return isset( $this->data[$key] ) || method_exists( $this, "get_$key" ); |
|
167 | + public function _isset($key) { |
|
168 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /* |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | * @param string $context View or edit context. |
191 | 191 | * @return int |
192 | 192 | */ |
193 | - public function get_customer_id( $context = 'view' ) { |
|
194 | - return (int) $this->get_prop( 'customer_id', $context ); |
|
193 | + public function get_customer_id($context = 'view') { |
|
194 | + return (int) $this->get_prop('customer_id', $context); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | * @param string $context View or edit context. |
202 | 202 | * @return WP_User|false WP_User object on success, false on failure. |
203 | 203 | */ |
204 | - public function get_customer( $context = 'view' ) { |
|
205 | - return get_userdata( $this->get_customer_id( $context ) ); |
|
204 | + public function get_customer($context = 'view') { |
|
205 | + return get_userdata($this->get_customer_id($context)); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | * @param string $context View or edit context. |
213 | 213 | * @return int |
214 | 214 | */ |
215 | - public function get_parent_invoice_id( $context = 'view' ) { |
|
216 | - return (int) $this->get_prop( 'parent_payment_id', $context ); |
|
215 | + public function get_parent_invoice_id($context = 'view') { |
|
216 | + return (int) $this->get_prop('parent_payment_id', $context); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | * @param string $context View or edit context. |
224 | 224 | * @return int |
225 | 225 | */ |
226 | - public function get_parent_payment_id( $context = 'view' ) { |
|
227 | - return $this->get_parent_invoice_id( $context ); |
|
226 | + public function get_parent_payment_id($context = 'view') { |
|
227 | + return $this->get_parent_invoice_id($context); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * @since 1.0.0 |
234 | 234 | * @return int |
235 | 235 | */ |
236 | - public function get_original_payment_id( $context = 'view' ) { |
|
237 | - return $this->get_parent_invoice_id( $context ); |
|
236 | + public function get_original_payment_id($context = 'view') { |
|
237 | + return $this->get_parent_invoice_id($context); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | * @param string $context View or edit context. |
245 | 245 | * @return WPInv_Invoice |
246 | 246 | */ |
247 | - public function get_parent_invoice( $context = 'view' ) { |
|
248 | - return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) ); |
|
247 | + public function get_parent_invoice($context = 'view') { |
|
248 | + return new WPInv_Invoice($this->get_parent_invoice_id($context)); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -255,8 +255,8 @@ discard block |
||
255 | 255 | * @param string $context View or edit context. |
256 | 256 | * @return WPInv_Invoice |
257 | 257 | */ |
258 | - public function get_parent_payment( $context = 'view' ) { |
|
259 | - return $this->get_parent_invoice( $context ); |
|
258 | + public function get_parent_payment($context = 'view') { |
|
259 | + return $this->get_parent_invoice($context); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | * @param string $context View or edit context. |
267 | 267 | * @return int |
268 | 268 | */ |
269 | - public function get_product_id( $context = 'view' ) { |
|
270 | - return (int) $this->get_prop( 'product_id', $context ); |
|
269 | + public function get_product_id($context = 'view') { |
|
270 | + return (int) $this->get_prop('product_id', $context); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | * @param string $context View or edit context. |
278 | 278 | * @return WPInv_Item |
279 | 279 | */ |
280 | - public function get_product( $context = 'view' ) { |
|
281 | - return new WPInv_Item( $this->get_product_id( $context ) ); |
|
280 | + public function get_product($context = 'view') { |
|
281 | + return new WPInv_Item($this->get_product_id($context)); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -290,8 +290,8 @@ discard block |
||
290 | 290 | * @param string $context View or edit context. |
291 | 291 | * @return string |
292 | 292 | */ |
293 | - public function get_gateway( $context = 'view' ) { |
|
294 | - return $this->get_parent_invoice( $context )->get_gateway(); |
|
293 | + public function get_gateway($context = 'view') { |
|
294 | + return $this->get_parent_invoice($context)->get_gateway(); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -301,8 +301,8 @@ discard block |
||
301 | 301 | * @param string $context View or edit context. |
302 | 302 | * @return string |
303 | 303 | */ |
304 | - public function get_period( $context = 'view' ) { |
|
305 | - return $this->get_prop( 'period', $context ); |
|
304 | + public function get_period($context = 'view') { |
|
305 | + return $this->get_prop('period', $context); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -312,8 +312,8 @@ discard block |
||
312 | 312 | * @param string $context View or edit context. |
313 | 313 | * @return int |
314 | 314 | */ |
315 | - public function get_frequency( $context = 'view' ) { |
|
316 | - return (int) $this->get_prop( 'frequency', $context ); |
|
315 | + public function get_frequency($context = 'view') { |
|
316 | + return (int) $this->get_prop('frequency', $context); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | * @param string $context View or edit context. |
324 | 324 | * @return float |
325 | 325 | */ |
326 | - public function get_initial_amount( $context = 'view' ) { |
|
327 | - return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) ); |
|
326 | + public function get_initial_amount($context = 'view') { |
|
327 | + return (float) wpinv_sanitize_amount($this->get_prop('initial_amount', $context)); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
@@ -334,8 +334,8 @@ discard block |
||
334 | 334 | * @param string $context View or edit context. |
335 | 335 | * @return float |
336 | 336 | */ |
337 | - public function get_recurring_amount( $context = 'view' ) { |
|
338 | - return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) ); |
|
337 | + public function get_recurring_amount($context = 'view') { |
|
338 | + return (float) wpinv_sanitize_amount($this->get_prop('recurring_amount', $context)); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
@@ -345,8 +345,8 @@ discard block |
||
345 | 345 | * @param string $context View or edit context. |
346 | 346 | * @return int |
347 | 347 | */ |
348 | - public function get_bill_times( $context = 'view' ) { |
|
349 | - return (int) $this->get_prop( 'bill_times', $context ); |
|
348 | + public function get_bill_times($context = 'view') { |
|
349 | + return (int) $this->get_prop('bill_times', $context); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | /** |
@@ -356,8 +356,8 @@ discard block |
||
356 | 356 | * @param string $context View or edit context. |
357 | 357 | * @return string |
358 | 358 | */ |
359 | - public function get_transaction_id( $context = 'view' ) { |
|
360 | - return $this->get_prop( 'transaction_id', $context ); |
|
359 | + public function get_transaction_id($context = 'view') { |
|
360 | + return $this->get_prop('transaction_id', $context); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
@@ -367,8 +367,8 @@ discard block |
||
367 | 367 | * @param string $context View or edit context. |
368 | 368 | * @return string |
369 | 369 | */ |
370 | - public function get_created( $context = 'view' ) { |
|
371 | - return $this->get_prop( 'created', $context ); |
|
370 | + public function get_created($context = 'view') { |
|
371 | + return $this->get_prop('created', $context); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | * @param string $context View or edit context. |
379 | 379 | * @return string |
380 | 380 | */ |
381 | - public function get_date_created( $context = 'view' ) { |
|
382 | - return $this->get_created( $context ); |
|
381 | + public function get_date_created($context = 'view') { |
|
382 | + return $this->get_created($context); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | */ |
391 | 391 | public function get_time_created() { |
392 | 392 | $created = $this->get_date_created(); |
393 | - return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) ); |
|
393 | + return empty($created) ? current_time('timestamp') : strtotime($created, current_time('timestamp')); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
@@ -400,11 +400,11 @@ discard block |
||
400 | 400 | * @param string $context View or edit context. |
401 | 401 | * @return string |
402 | 402 | */ |
403 | - public function get_date_created_gmt( $context = 'view' ) { |
|
404 | - $date = $this->get_date_created( $context ); |
|
403 | + public function get_date_created_gmt($context = 'view') { |
|
404 | + $date = $this->get_date_created($context); |
|
405 | 405 | |
406 | - if ( $date ) { |
|
407 | - $date = get_gmt_from_date( $date ); |
|
406 | + if ($date) { |
|
407 | + $date = get_gmt_from_date($date); |
|
408 | 408 | } |
409 | 409 | return $date; |
410 | 410 | } |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | * @param string $context View or edit context. |
417 | 417 | * @return string |
418 | 418 | */ |
419 | - public function get_next_renewal_date( $context = 'view' ) { |
|
420 | - return $this->get_prop( 'expiration', $context ); |
|
419 | + public function get_next_renewal_date($context = 'view') { |
|
420 | + return $this->get_prop('expiration', $context); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | * @param string $context View or edit context. |
428 | 428 | * @return string |
429 | 429 | */ |
430 | - public function get_expiration( $context = 'view' ) { |
|
431 | - return $this->get_next_renewal_date( $context ); |
|
430 | + public function get_expiration($context = 'view') { |
|
431 | + return $this->get_next_renewal_date($context); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
@@ -440,12 +440,12 @@ discard block |
||
440 | 440 | public function get_expiration_time() { |
441 | 441 | $expiration = $this->get_expiration(); |
442 | 442 | |
443 | - if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) { |
|
444 | - return current_time( 'timestamp' ); |
|
443 | + if (empty($expiration) || '0000-00-00 00:00:00' == $expiration) { |
|
444 | + return current_time('timestamp'); |
|
445 | 445 | } |
446 | 446 | |
447 | - $expiration = strtotime( $expiration, current_time( 'timestamp' ) ); |
|
448 | - return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration; |
|
447 | + $expiration = strtotime($expiration, current_time('timestamp')); |
|
448 | + return $expiration < current_time('timestamp') ? current_time('timestamp') : $expiration; |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | /** |
@@ -455,11 +455,11 @@ discard block |
||
455 | 455 | * @param string $context View or edit context. |
456 | 456 | * @return string |
457 | 457 | */ |
458 | - public function get_next_renewal_date_gmt( $context = 'view' ) { |
|
459 | - $date = $this->get_next_renewal_date( $context ); |
|
458 | + public function get_next_renewal_date_gmt($context = 'view') { |
|
459 | + $date = $this->get_next_renewal_date($context); |
|
460 | 460 | |
461 | - if ( $date ) { |
|
462 | - $date = get_gmt_from_date( $date ); |
|
461 | + if ($date) { |
|
462 | + $date = get_gmt_from_date($date); |
|
463 | 463 | } |
464 | 464 | return $date; |
465 | 465 | } |
@@ -471,8 +471,8 @@ discard block |
||
471 | 471 | * @param string $context View or edit context. |
472 | 472 | * @return string |
473 | 473 | */ |
474 | - public function get_trial_period( $context = 'view' ) { |
|
475 | - return $this->get_prop( 'trial_period', $context ); |
|
474 | + public function get_trial_period($context = 'view') { |
|
475 | + return $this->get_prop('trial_period', $context); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | /** |
@@ -482,8 +482,8 @@ discard block |
||
482 | 482 | * @param string $context View or edit context. |
483 | 483 | * @return string |
484 | 484 | */ |
485 | - public function get_status( $context = 'view' ) { |
|
486 | - return $this->get_prop( 'status', $context ); |
|
485 | + public function get_status($context = 'view') { |
|
486 | + return $this->get_prop('status', $context); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | /** |
@@ -493,8 +493,8 @@ discard block |
||
493 | 493 | * @param string $context View or edit context. |
494 | 494 | * @return string |
495 | 495 | */ |
496 | - public function get_profile_id( $context = 'view' ) { |
|
497 | - return $this->get_prop( 'profile_id', $context ); |
|
496 | + public function get_profile_id($context = 'view') { |
|
497 | + return $this->get_prop('profile_id', $context); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | /* |
@@ -509,8 +509,8 @@ discard block |
||
509 | 509 | * @since 1.0.19 |
510 | 510 | * @param int $value The customer's id. |
511 | 511 | */ |
512 | - public function set_customer_id( $value ) { |
|
513 | - $this->set_prop( 'customer_id', (int) $value ); |
|
512 | + public function set_customer_id($value) { |
|
513 | + $this->set_prop('customer_id', (int) $value); |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | /** |
@@ -519,8 +519,8 @@ discard block |
||
519 | 519 | * @since 1.0.19 |
520 | 520 | * @param int $value The parent invoice id. |
521 | 521 | */ |
522 | - public function set_parent_invoice_id( $value ) { |
|
523 | - $this->set_prop( 'parent_payment_id', (int) $value ); |
|
522 | + public function set_parent_invoice_id($value) { |
|
523 | + $this->set_prop('parent_payment_id', (int) $value); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | /** |
@@ -529,8 +529,8 @@ discard block |
||
529 | 529 | * @since 1.0.19 |
530 | 530 | * @param int $value The parent invoice id. |
531 | 531 | */ |
532 | - public function set_parent_payment_id( $value ) { |
|
533 | - $this->set_parent_invoice_id( $value ); |
|
532 | + public function set_parent_payment_id($value) { |
|
533 | + $this->set_parent_invoice_id($value); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
@@ -539,8 +539,8 @@ discard block |
||
539 | 539 | * @since 1.0.19 |
540 | 540 | * @param int $value The parent invoice id. |
541 | 541 | */ |
542 | - public function set_original_payment_id( $value ) { |
|
543 | - $this->set_parent_invoice_id( $value ); |
|
542 | + public function set_original_payment_id($value) { |
|
543 | + $this->set_parent_invoice_id($value); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | /** |
@@ -549,8 +549,8 @@ discard block |
||
549 | 549 | * @since 1.0.19 |
550 | 550 | * @param int $value The subscription product id. |
551 | 551 | */ |
552 | - public function set_product_id( $value ) { |
|
553 | - $this->set_prop( 'product_id', (int) $value ); |
|
552 | + public function set_product_id($value) { |
|
553 | + $this->set_prop('product_id', (int) $value); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | /** |
@@ -559,8 +559,8 @@ discard block |
||
559 | 559 | * @since 1.0.19 |
560 | 560 | * @param string $value The renewal period. |
561 | 561 | */ |
562 | - public function set_period( $value ) { |
|
563 | - $this->set_prop( 'period', $value ); |
|
562 | + public function set_period($value) { |
|
563 | + $this->set_prop('period', $value); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | /** |
@@ -569,9 +569,9 @@ discard block |
||
569 | 569 | * @since 1.0.19 |
570 | 570 | * @param int $value The subscription frequency. |
571 | 571 | */ |
572 | - public function set_frequency( $value ) { |
|
573 | - $value = empty( $value ) ? 1 : (int) $value; |
|
574 | - $this->set_prop( 'frequency', absint( $value ) ); |
|
572 | + public function set_frequency($value) { |
|
573 | + $value = empty($value) ? 1 : (int) $value; |
|
574 | + $this->set_prop('frequency', absint($value)); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | /** |
@@ -580,8 +580,8 @@ discard block |
||
580 | 580 | * @since 1.0.19 |
581 | 581 | * @param float $value The initial subcription amount. |
582 | 582 | */ |
583 | - public function set_initial_amount( $value ) { |
|
584 | - $this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) ); |
|
583 | + public function set_initial_amount($value) { |
|
584 | + $this->set_prop('initial_amount', wpinv_sanitize_amount($value)); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | /** |
@@ -590,8 +590,8 @@ discard block |
||
590 | 590 | * @since 1.0.19 |
591 | 591 | * @param float $value The recurring subcription amount. |
592 | 592 | */ |
593 | - public function set_recurring_amount( $value ) { |
|
594 | - $this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) ); |
|
593 | + public function set_recurring_amount($value) { |
|
594 | + $this->set_prop('recurring_amount', wpinv_sanitize_amount($value)); |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | /** |
@@ -600,8 +600,8 @@ discard block |
||
600 | 600 | * @since 1.0.19 |
601 | 601 | * @param int $value Bill times. |
602 | 602 | */ |
603 | - public function set_bill_times( $value ) { |
|
604 | - $this->set_prop( 'bill_times', (int) $value ); |
|
603 | + public function set_bill_times($value) { |
|
604 | + $this->set_prop('bill_times', (int) $value); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | /** |
@@ -610,8 +610,8 @@ discard block |
||
610 | 610 | * @since 1.0.19 |
611 | 611 | * @param string $value Bill times. |
612 | 612 | */ |
613 | - public function set_transaction_id( $value ) { |
|
614 | - $this->set_prop( 'transaction_id', sanitize_text_field( $value ) ); |
|
613 | + public function set_transaction_id($value) { |
|
614 | + $this->set_prop('transaction_id', sanitize_text_field($value)); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | /** |
@@ -620,15 +620,15 @@ discard block |
||
620 | 620 | * @since 1.0.19 |
621 | 621 | * @param string $value strtotime compliant date. |
622 | 622 | */ |
623 | - public function set_created( $value ) { |
|
624 | - $date = strtotime( $value ); |
|
623 | + public function set_created($value) { |
|
624 | + $date = strtotime($value); |
|
625 | 625 | |
626 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
627 | - $this->set_prop( 'created', date( 'Y-m-d H:i:s', $date ) ); |
|
626 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
627 | + $this->set_prop('created', date('Y-m-d H:i:s', $date)); |
|
628 | 628 | return; |
629 | 629 | } |
630 | 630 | |
631 | - $this->set_prop( 'created', '' ); |
|
631 | + $this->set_prop('created', ''); |
|
632 | 632 | |
633 | 633 | } |
634 | 634 | |
@@ -638,8 +638,8 @@ discard block |
||
638 | 638 | * @since 1.0.19 |
639 | 639 | * @param string $value strtotime compliant date. |
640 | 640 | */ |
641 | - public function set_date_created( $value ) { |
|
642 | - $this->set_created( $value ); |
|
641 | + public function set_date_created($value) { |
|
642 | + $this->set_created($value); |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | /** |
@@ -648,15 +648,15 @@ discard block |
||
648 | 648 | * @since 1.0.19 |
649 | 649 | * @param string $value strtotime compliant date. |
650 | 650 | */ |
651 | - public function set_next_renewal_date( $value ) { |
|
652 | - $date = strtotime( $value ); |
|
651 | + public function set_next_renewal_date($value) { |
|
652 | + $date = strtotime($value); |
|
653 | 653 | |
654 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
655 | - $this->set_prop( 'expiration', date( 'Y-m-d H:i:s', $date ) ); |
|
654 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
655 | + $this->set_prop('expiration', date('Y-m-d H:i:s', $date)); |
|
656 | 656 | return; |
657 | 657 | } |
658 | 658 | |
659 | - $this->set_prop( 'expiration', '' ); |
|
659 | + $this->set_prop('expiration', ''); |
|
660 | 660 | |
661 | 661 | } |
662 | 662 | |
@@ -666,8 +666,8 @@ discard block |
||
666 | 666 | * @since 1.0.19 |
667 | 667 | * @param string $value strtotime compliant date. |
668 | 668 | */ |
669 | - public function set_expiration( $value ) { |
|
670 | - $this->set_next_renewal_date( $value ); |
|
669 | + public function set_expiration($value) { |
|
670 | + $this->set_next_renewal_date($value); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | /** |
@@ -676,8 +676,8 @@ discard block |
||
676 | 676 | * @since 1.0.19 |
677 | 677 | * @param string $value trial period e.g 1 year. |
678 | 678 | */ |
679 | - public function set_trial_period( $value ) { |
|
680 | - $this->set_prop( 'trial_period', $value ); |
|
679 | + public function set_trial_period($value) { |
|
680 | + $this->set_prop('trial_period', $value); |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | /** |
@@ -686,23 +686,23 @@ discard block |
||
686 | 686 | * @since 1.0.19 |
687 | 687 | * @param string $new_status New subscription status. |
688 | 688 | */ |
689 | - public function set_status( $new_status ) { |
|
689 | + public function set_status($new_status) { |
|
690 | 690 | |
691 | 691 | // Abort if this is not a valid status; |
692 | - if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) { |
|
692 | + if (!array_key_exists($new_status, getpaid_get_subscription_statuses())) { |
|
693 | 693 | return; |
694 | 694 | } |
695 | 695 | |
696 | 696 | |
697 | - $old_status = ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $this->get_status(); |
|
698 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
697 | + $old_status = !empty($this->status_transition['from']) ? $this->status_transition['from'] : $this->get_status(); |
|
698 | + if (true === $this->object_read && $old_status !== $new_status) { |
|
699 | 699 | $this->status_transition = array( |
700 | 700 | 'from' => $old_status, |
701 | 701 | 'to' => $new_status, |
702 | 702 | ); |
703 | 703 | } |
704 | 704 | |
705 | - $this->set_prop( 'status', $new_status ); |
|
705 | + $this->set_prop('status', $new_status); |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | /** |
@@ -711,8 +711,8 @@ discard block |
||
711 | 711 | * @since 1.0.19 |
712 | 712 | * @param string $value the remote profile id. |
713 | 713 | */ |
714 | - public function set_profile_id( $value ) { |
|
715 | - $this->set_prop( 'profile_id', sanitize_text_field( $value ) ); |
|
714 | + public function set_profile_id($value) { |
|
715 | + $this->set_prop('profile_id', sanitize_text_field($value)); |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | /* |
@@ -730,8 +730,8 @@ discard block |
||
730 | 730 | * @param string|array String or array of strings to check for. |
731 | 731 | * @return bool |
732 | 732 | */ |
733 | - public function has_status( $status ) { |
|
734 | - return in_array( $this->get_status(), wpinv_clean( wpinv_parse_list( $status ) ) ); |
|
733 | + public function has_status($status) { |
|
734 | + return in_array($this->get_status(), wpinv_clean(wpinv_parse_list($status))); |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | /** |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | */ |
742 | 742 | public function has_trial_period() { |
743 | 743 | $period = $this->get_trial_period(); |
744 | - return ! empty( $period ); |
|
744 | + return !empty($period); |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | /** |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | * @return bool |
751 | 751 | */ |
752 | 752 | public function is_active() { |
753 | - return $this->has_status( 'active trialling' ) && ! $this->is_expired(); |
|
753 | + return $this->has_status('active trialling') && !$this->is_expired(); |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | /** |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | * @return bool |
760 | 760 | */ |
761 | 761 | public function is_expired() { |
762 | - return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'mysql' ) ); |
|
762 | + return $this->has_status('expired') || ($this->has_status('active cancelled trialling') && $this->get_expiration_time() < current_time('mysql')); |
|
763 | 763 | } |
764 | 764 | |
765 | 765 | /** |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | */ |
770 | 770 | public function is_last_renewal() { |
771 | 771 | $max_bills = $this->get_bill_times(); |
772 | - return ! empty( $max_bills ) && $max_bills <= $this->get_times_billed(); |
|
772 | + return !empty($max_bills) && $max_bills <= $this->get_times_billed(); |
|
773 | 773 | } |
774 | 774 | |
775 | 775 | /* |
@@ -784,11 +784,11 @@ discard block |
||
784 | 784 | /** |
785 | 785 | * Backwards compatibilty. |
786 | 786 | */ |
787 | - public function create( $data = array() ) { |
|
787 | + public function create($data = array()) { |
|
788 | 788 | |
789 | 789 | // Set the properties. |
790 | - if ( is_array( $data ) ) { |
|
791 | - $this->set_props( $data ); |
|
790 | + if (is_array($data)) { |
|
791 | + $this->set_props($data); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | // Save the item. |
@@ -799,8 +799,8 @@ discard block |
||
799 | 799 | /** |
800 | 800 | * Backwards compatibilty. |
801 | 801 | */ |
802 | - public function update( $args = array() ) { |
|
803 | - return $this->create( $args ); |
|
802 | + public function update($args = array()) { |
|
803 | + return $this->create($args); |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | /** |
@@ -809,12 +809,12 @@ discard block |
||
809 | 809 | * @since 1.0.0 |
810 | 810 | * @return WP_Post[] |
811 | 811 | */ |
812 | - public function get_child_payments( $hide_pending = true ) { |
|
812 | + public function get_child_payments($hide_pending = true) { |
|
813 | 813 | |
814 | - $statuses = array( 'publish', 'wpi-processing', 'wpi-renewal' ); |
|
814 | + $statuses = array('publish', 'wpi-processing', 'wpi-renewal'); |
|
815 | 815 | |
816 | - if ( ! $hide_pending ) { |
|
817 | - $statuses = array_keys( wpinv_get_invoice_statuses() ); |
|
816 | + if (!$hide_pending) { |
|
817 | + $statuses = array_keys(wpinv_get_invoice_statuses()); |
|
818 | 818 | } |
819 | 819 | |
820 | 820 | return get_posts( |
@@ -836,7 +836,7 @@ discard block |
||
836 | 836 | * @return int |
837 | 837 | */ |
838 | 838 | public function get_total_payments() { |
839 | - return getpaid_count_subscription_invoices( $this->get_parent_invoice_id(), $this->get_id() ); |
|
839 | + return getpaid_count_subscription_invoices($this->get_parent_invoice_id(), $this->get_id()); |
|
840 | 840 | } |
841 | 841 | |
842 | 842 | /** |
@@ -848,7 +848,7 @@ discard block |
||
848 | 848 | public function get_times_billed() { |
849 | 849 | $times_billed = $this->get_total_payments(); |
850 | 850 | |
851 | - if ( (float) $this->get_initial_amount() == 0 && $times_billed > 0 ) { |
|
851 | + if ((float) $this->get_initial_amount() == 0 && $times_billed > 0) { |
|
852 | 852 | $times_billed--; |
853 | 853 | } |
854 | 854 | |
@@ -863,49 +863,49 @@ discard block |
||
863 | 863 | * @param WPInv_Invoice $invoice If adding an existing invoice. |
864 | 864 | * @return bool |
865 | 865 | */ |
866 | - public function add_payment( $args = array(), $invoice = false ) { |
|
866 | + public function add_payment($args = array(), $invoice = false) { |
|
867 | 867 | |
868 | 868 | // Process each payment once. |
869 | - if ( ! empty( $args['transaction_id'] ) && $this->payment_exists( $args['transaction_id'] ) ) { |
|
869 | + if (!empty($args['transaction_id']) && $this->payment_exists($args['transaction_id'])) { |
|
870 | 870 | return false; |
871 | 871 | } |
872 | 872 | |
873 | 873 | // Are we creating a new invoice? |
874 | - if ( empty( $invoice ) ) { |
|
874 | + if (empty($invoice)) { |
|
875 | 875 | $invoice = $this->create_payment(); |
876 | 876 | |
877 | - if ( empty( $invoice ) ) { |
|
877 | + if (empty($invoice)) { |
|
878 | 878 | return false; |
879 | 879 | } |
880 | 880 | |
881 | 881 | } |
882 | 882 | |
883 | - $invoice->set_status( 'wpi-renewal' ); |
|
883 | + $invoice->set_status('wpi-renewal'); |
|
884 | 884 | |
885 | 885 | // Maybe set a transaction id. |
886 | - if ( ! empty( $args['transaction_id'] ) ) { |
|
887 | - $invoice->set_transaction_id( $args['transaction_id'] ); |
|
886 | + if (!empty($args['transaction_id'])) { |
|
887 | + $invoice->set_transaction_id($args['transaction_id']); |
|
888 | 888 | } |
889 | 889 | |
890 | 890 | // Set the completed date. |
891 | - $invoice->set_completed_date( current_time( 'mysql' ) ); |
|
891 | + $invoice->set_completed_date(current_time('mysql')); |
|
892 | 892 | |
893 | 893 | // And the gateway. |
894 | - if ( ! empty( $args['gateway'] ) ) { |
|
895 | - $invoice->set_gateway( $args['gateway'] ); |
|
894 | + if (!empty($args['gateway'])) { |
|
895 | + $invoice->set_gateway($args['gateway']); |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | $invoice->save(); |
899 | 899 | |
900 | - if ( ! $invoice->exists() ) { |
|
900 | + if (!$invoice->exists()) { |
|
901 | 901 | return false; |
902 | 902 | } |
903 | 903 | |
904 | - do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this ); |
|
905 | - do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this ); |
|
906 | - do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id() ); |
|
904 | + do_action('getpaid_after_create_subscription_renewal_invoice', $invoice, $this); |
|
905 | + do_action('wpinv_recurring_add_subscription_payment', $invoice, $this); |
|
906 | + do_action('wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id()); |
|
907 | 907 | |
908 | - update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id ); |
|
908 | + update_post_meta($invoice->get_id(), '_wpinv_subscription_id', $this->id); |
|
909 | 909 | |
910 | 910 | return $invoice->get_id(); |
911 | 911 | } |
@@ -920,41 +920,41 @@ discard block |
||
920 | 920 | |
921 | 921 | $parent_invoice = $this->get_parent_payment(); |
922 | 922 | |
923 | - if ( ! $parent_invoice->exists() ) { |
|
923 | + if (!$parent_invoice->exists()) { |
|
924 | 924 | return false; |
925 | 925 | } |
926 | 926 | |
927 | 927 | // Duplicate the parent invoice. |
928 | - $invoice = getpaid_duplicate_invoice( $parent_invoice ); |
|
929 | - $invoice->set_parent_id( $parent_invoice->get_id() ); |
|
930 | - $invoice->set_subscription_id( $this->get_id() ); |
|
931 | - $invoice->set_remote_subscription_id( $this->get_profile_id() ); |
|
928 | + $invoice = getpaid_duplicate_invoice($parent_invoice); |
|
929 | + $invoice->set_parent_id($parent_invoice->get_id()); |
|
930 | + $invoice->set_subscription_id($this->get_id()); |
|
931 | + $invoice->set_remote_subscription_id($this->get_profile_id()); |
|
932 | 932 | |
933 | 933 | // Set invoice items. |
934 | - $subscription_group = getpaid_get_invoice_subscription_group( $parent_invoice->get_id(), $this->get_id() ); |
|
935 | - $allowed_items = empty( $subscription_group ) ? array( $this->get_product_id() ) : array_keys( $subscription_group['items'] ); |
|
934 | + $subscription_group = getpaid_get_invoice_subscription_group($parent_invoice->get_id(), $this->get_id()); |
|
935 | + $allowed_items = empty($subscription_group) ? array($this->get_product_id()) : array_keys($subscription_group['items']); |
|
936 | 936 | $invoice_items = array(); |
937 | 937 | |
938 | - foreach ( $invoice->get_items() as $item ) { |
|
939 | - if ( in_array( $item->get_id(), $allowed_items ) ) { |
|
938 | + foreach ($invoice->get_items() as $item) { |
|
939 | + if (in_array($item->get_id(), $allowed_items)) { |
|
940 | 940 | $invoice_items[] = $item; |
941 | 941 | } |
942 | 942 | } |
943 | 943 | |
944 | - $invoice->set_items( $invoice_items ); |
|
944 | + $invoice->set_items($invoice_items); |
|
945 | 945 | |
946 | - if ( ! empty( $subscription_group['fees'] ) ) { |
|
947 | - $invoice->set_fees( $subscription_group['fees'] ); |
|
946 | + if (!empty($subscription_group['fees'])) { |
|
947 | + $invoice->set_fees($subscription_group['fees']); |
|
948 | 948 | } |
949 | 949 | |
950 | 950 | // Maybe recalculate discount (Pre-GetPaid Fix). |
951 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
952 | - if ( $discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount() ) { |
|
953 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
951 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
952 | + if ($discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount()) { |
|
953 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
954 | 954 | } |
955 | 955 | |
956 | 956 | $invoice->recalculate_total(); |
957 | - $invoice->set_status( 'wpi-pending' ); |
|
957 | + $invoice->set_status('wpi-pending'); |
|
958 | 958 | $invoice->save(); |
959 | 959 | |
960 | 960 | return $invoice->exists() ? $invoice : false; |
@@ -969,20 +969,20 @@ discard block |
||
969 | 969 | public function renew() { |
970 | 970 | |
971 | 971 | // Complete subscription if applicable |
972 | - if ( $this->is_last_renewal() ) { |
|
972 | + if ($this->is_last_renewal()) { |
|
973 | 973 | return $this->complete(); |
974 | 974 | } |
975 | 975 | |
976 | 976 | // Calculate new expiration |
977 | 977 | $frequency = $this->get_frequency(); |
978 | 978 | $period = $this->get_period(); |
979 | - $new_expiration = strtotime( "+ $frequency $period", $this->get_expiration_time() ); |
|
979 | + $new_expiration = strtotime("+ $frequency $period", $this->get_expiration_time()); |
|
980 | 980 | |
981 | - $this->set_expiration( date( 'Y-m-d H:i:s',$new_expiration ) ); |
|
982 | - $this->set_status( 'active' ); |
|
981 | + $this->set_expiration(date('Y-m-d H:i:s', $new_expiration)); |
|
982 | + $this->set_status('active'); |
|
983 | 983 | $this->save(); |
984 | 984 | |
985 | - do_action( 'getpaid_subscription_renewed', $this ); |
|
985 | + do_action('getpaid_subscription_renewed', $this); |
|
986 | 986 | |
987 | 987 | return $this->get_id(); |
988 | 988 | } |
@@ -998,11 +998,11 @@ discard block |
||
998 | 998 | public function complete() { |
999 | 999 | |
1000 | 1000 | // Only mark a subscription as complete if it's not already cancelled. |
1001 | - if ( $this->has_status( 'cancelled' ) ) { |
|
1001 | + if ($this->has_status('cancelled')) { |
|
1002 | 1002 | return false; |
1003 | 1003 | } |
1004 | 1004 | |
1005 | - $this->set_status( 'completed' ); |
|
1005 | + $this->set_status('completed'); |
|
1006 | 1006 | return $this->save(); |
1007 | 1007 | |
1008 | 1008 | } |
@@ -1014,14 +1014,14 @@ discard block |
||
1014 | 1014 | * @param bool $check_expiration |
1015 | 1015 | * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future. |
1016 | 1016 | */ |
1017 | - public function expire( $check_expiration = false ) { |
|
1017 | + public function expire($check_expiration = false) { |
|
1018 | 1018 | |
1019 | - if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) { |
|
1019 | + if ($check_expiration && $this->get_expiration_time() > current_time('timestamp')) { |
|
1020 | 1020 | // Do not mark as expired since real expiration date is in the future |
1021 | 1021 | return false; |
1022 | 1022 | } |
1023 | 1023 | |
1024 | - $this->set_status( 'expired' ); |
|
1024 | + $this->set_status('expired'); |
|
1025 | 1025 | return $this->save(); |
1026 | 1026 | |
1027 | 1027 | } |
@@ -1033,7 +1033,7 @@ discard block |
||
1033 | 1033 | * @return int Subscription id. |
1034 | 1034 | */ |
1035 | 1035 | public function failing() { |
1036 | - $this->set_status( 'failing' ); |
|
1036 | + $this->set_status('failing'); |
|
1037 | 1037 | return $this->save(); |
1038 | 1038 | } |
1039 | 1039 | |
@@ -1044,7 +1044,7 @@ discard block |
||
1044 | 1044 | * @return int Subscription id. |
1045 | 1045 | */ |
1046 | 1046 | public function cancel() { |
1047 | - $this->set_status( 'cancelled' ); |
|
1047 | + $this->set_status('cancelled'); |
|
1048 | 1048 | return $this->save(); |
1049 | 1049 | } |
1050 | 1050 | |
@@ -1055,7 +1055,7 @@ discard block |
||
1055 | 1055 | * @return bool |
1056 | 1056 | */ |
1057 | 1057 | public function can_cancel() { |
1058 | - return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this ); |
|
1058 | + return apply_filters('wpinv_subscription_can_cancel', $this->has_status($this->get_cancellable_statuses()), $this); |
|
1059 | 1059 | } |
1060 | 1060 | |
1061 | 1061 | /** |
@@ -1066,7 +1066,7 @@ discard block |
||
1066 | 1066 | * @return array |
1067 | 1067 | */ |
1068 | 1068 | public function get_cancellable_statuses() { |
1069 | - return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) ); |
|
1069 | + return apply_filters('wpinv_recurring_cancellable_statuses', array('active', 'trialling', 'failing')); |
|
1070 | 1070 | } |
1071 | 1071 | |
1072 | 1072 | /** |
@@ -1076,8 +1076,8 @@ discard block |
||
1076 | 1076 | * @return string |
1077 | 1077 | */ |
1078 | 1078 | public function get_cancel_url() { |
1079 | - $url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() ); |
|
1080 | - return apply_filters( 'wpinv_subscription_cancel_url', $url, $this ); |
|
1079 | + $url = getpaid_get_authenticated_action_url('subscription_cancel', $this->get_view_url()); |
|
1080 | + return apply_filters('wpinv_subscription_cancel_url', $url, $this); |
|
1081 | 1081 | } |
1082 | 1082 | |
1083 | 1083 | /** |
@@ -1088,10 +1088,10 @@ discard block |
||
1088 | 1088 | */ |
1089 | 1089 | public function get_view_url() { |
1090 | 1090 | |
1091 | - $url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
1092 | - $url = add_query_arg( 'subscription', $this->get_id(), $url ); |
|
1091 | + $url = getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page'))); |
|
1092 | + $url = add_query_arg('subscription', $this->get_id(), $url); |
|
1093 | 1093 | |
1094 | - return apply_filters( 'getpaid_get_subscription_view_url', $url, $this ); |
|
1094 | + return apply_filters('getpaid_get_subscription_view_url', $url, $this); |
|
1095 | 1095 | } |
1096 | 1096 | |
1097 | 1097 | /** |
@@ -1104,7 +1104,7 @@ discard block |
||
1104 | 1104 | * @return bool |
1105 | 1105 | */ |
1106 | 1106 | public function can_renew() { |
1107 | - return apply_filters( 'wpinv_subscription_can_renew', true, $this ); |
|
1107 | + return apply_filters('wpinv_subscription_can_renew', true, $this); |
|
1108 | 1108 | } |
1109 | 1109 | |
1110 | 1110 | /** |
@@ -1114,8 +1114,8 @@ discard block |
||
1114 | 1114 | * @return string |
1115 | 1115 | */ |
1116 | 1116 | public function get_renew_url() { |
1117 | - $url = wp_nonce_url( add_query_arg( array( 'getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id ) ), 'getpaid-nonce' ); |
|
1118 | - return apply_filters( 'wpinv_subscription_renew_url', $url, $this ); |
|
1117 | + $url = wp_nonce_url(add_query_arg(array('getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id)), 'getpaid-nonce'); |
|
1118 | + return apply_filters('wpinv_subscription_renew_url', $url, $this); |
|
1119 | 1119 | } |
1120 | 1120 | |
1121 | 1121 | /** |
@@ -1125,7 +1125,7 @@ discard block |
||
1125 | 1125 | * @return bool |
1126 | 1126 | */ |
1127 | 1127 | public function can_update() { |
1128 | - return apply_filters( 'wpinv_subscription_can_update', false, $this ); |
|
1128 | + return apply_filters('wpinv_subscription_can_update', false, $this); |
|
1129 | 1129 | } |
1130 | 1130 | |
1131 | 1131 | /** |
@@ -1135,8 +1135,8 @@ discard block |
||
1135 | 1135 | * @return string |
1136 | 1136 | */ |
1137 | 1137 | public function get_update_url() { |
1138 | - $url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->get_id() ) ); |
|
1139 | - return apply_filters( 'wpinv_subscription_update_url', $url, $this ); |
|
1138 | + $url = add_query_arg(array('action' => 'update', 'subscription_id' => $this->get_id())); |
|
1139 | + return apply_filters('wpinv_subscription_update_url', $url, $this); |
|
1140 | 1140 | } |
1141 | 1141 | |
1142 | 1142 | /** |
@@ -1146,7 +1146,7 @@ discard block |
||
1146 | 1146 | * @return string |
1147 | 1147 | */ |
1148 | 1148 | public function get_status_label() { |
1149 | - return getpaid_get_subscription_status_label( $this->get_status() ); |
|
1149 | + return getpaid_get_subscription_status_label($this->get_status()); |
|
1150 | 1150 | } |
1151 | 1151 | |
1152 | 1152 | /** |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | */ |
1158 | 1158 | public function get_status_class() { |
1159 | 1159 | $statuses = getpaid_get_subscription_status_classes(); |
1160 | - return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark'; |
|
1160 | + return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'badge-dark'; |
|
1161 | 1161 | } |
1162 | 1162 | |
1163 | 1163 | /** |
@@ -1168,9 +1168,9 @@ discard block |
||
1168 | 1168 | */ |
1169 | 1169 | public function get_status_label_html() { |
1170 | 1170 | |
1171 | - $status_label = sanitize_text_field( $this->get_status_label() ); |
|
1172 | - $class = esc_attr( $this->get_status_class() ); |
|
1173 | - $status = sanitize_html_class( $this->get_status() ); |
|
1171 | + $status_label = sanitize_text_field($this->get_status_label()); |
|
1172 | + $class = esc_attr($this->get_status_class()); |
|
1173 | + $status = sanitize_html_class($this->get_status()); |
|
1174 | 1174 | |
1175 | 1175 | return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>"; |
1176 | 1176 | } |
@@ -1182,9 +1182,9 @@ discard block |
||
1182 | 1182 | * @param string $txn_id The transaction ID from the merchant processor |
1183 | 1183 | * @return bool |
1184 | 1184 | */ |
1185 | - public function payment_exists( $txn_id = '' ) { |
|
1186 | - $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' ); |
|
1187 | - return ! empty( $invoice_id ); |
|
1185 | + public function payment_exists($txn_id = '') { |
|
1186 | + $invoice_id = WPInv_Invoice::get_invoice_id_by_field($txn_id, 'transaction_id'); |
|
1187 | + return !empty($invoice_id); |
|
1188 | 1188 | } |
1189 | 1189 | |
1190 | 1190 | /** |
@@ -1196,35 +1196,35 @@ discard block |
||
1196 | 1196 | // Reset status transition variable. |
1197 | 1197 | $this->status_transition = false; |
1198 | 1198 | |
1199 | - if ( $status_transition ) { |
|
1199 | + if ($status_transition) { |
|
1200 | 1200 | try { |
1201 | 1201 | |
1202 | 1202 | // Fire a hook for the status change. |
1203 | - do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition ); |
|
1204 | - do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition ); |
|
1203 | + do_action('wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition); |
|
1204 | + do_action('getpaid_subscription_' . $status_transition['to'], $this, $status_transition); |
|
1205 | 1205 | |
1206 | - if ( ! empty( $status_transition['from'] ) ) { |
|
1206 | + if (!empty($status_transition['from'])) { |
|
1207 | 1207 | |
1208 | 1208 | /* translators: 1: old subscription status 2: new subscription status */ |
1209 | - $transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) ); |
|
1209 | + $transition_note = sprintf(__('Subscription status changed from %1$s to %2$s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['from']), getpaid_get_subscription_status_label($status_transition['to'])); |
|
1210 | 1210 | |
1211 | 1211 | // Note the transition occurred. |
1212 | - $this->get_parent_payment()->add_note( $transition_note, false, false, true ); |
|
1212 | + $this->get_parent_payment()->add_note($transition_note, false, false, true); |
|
1213 | 1213 | |
1214 | 1214 | // Fire another hook. |
1215 | - do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); |
|
1216 | - do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
1215 | + do_action('getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this); |
|
1216 | + do_action('getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to']); |
|
1217 | 1217 | |
1218 | 1218 | } else { |
1219 | 1219 | /* translators: %s: new invoice status */ |
1220 | - $transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) ); |
|
1220 | + $transition_note = sprintf(__('Subscription status set to %s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['to'])); |
|
1221 | 1221 | |
1222 | 1222 | // Note the transition occurred. |
1223 | - $this->get_parent_payment()->add_note( $transition_note, false, false, true ); |
|
1223 | + $this->get_parent_payment()->add_note($transition_note, false, false, true); |
|
1224 | 1224 | |
1225 | 1225 | } |
1226 | - } catch ( Exception $e ) { |
|
1227 | - $this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
1226 | + } catch (Exception $e) { |
|
1227 | + $this->get_parent_payment()->add_note(__('Error during subscription status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
1228 | 1228 | } |
1229 | 1229 | } |
1230 | 1230 | |
@@ -1250,7 +1250,7 @@ discard block |
||
1250 | 1250 | */ |
1251 | 1251 | public function activate() { |
1252 | 1252 | $status = 'trialling' == $this->get_status() ? 'trialling' : 'active'; |
1253 | - $this->set_status( $status ); |
|
1253 | + $this->set_status($status); |
|
1254 | 1254 | return $this->save(); |
1255 | 1255 | } |
1256 | 1256 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | function wpinv_subscriptions_page() { |
16 | 16 | |
17 | - ?> |
|
17 | + ?> |
|
18 | 18 | |
19 | 19 | <div class="wrap"> |
20 | 20 | <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
@@ -22,27 +22,27 @@ discard block |
||
22 | 22 | |
23 | 23 | <?php |
24 | 24 | |
25 | - // Verify user permissions. |
|
26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
25 | + // Verify user permissions. |
|
26 | + if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
27 | 27 | |
28 | - echo aui()->alert( |
|
29 | - array( |
|
30 | - 'type' => 'danger', |
|
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
32 | - ) |
|
33 | - ); |
|
28 | + echo aui()->alert( |
|
29 | + array( |
|
30 | + 'type' => 'danger', |
|
31 | + 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
32 | + ) |
|
33 | + ); |
|
34 | 34 | |
35 | - } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
35 | + } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
36 | 36 | |
37 | - // Display a single subscription. |
|
38 | - wpinv_recurring_subscription_details(); |
|
39 | - } else { |
|
37 | + // Display a single subscription. |
|
38 | + wpinv_recurring_subscription_details(); |
|
39 | + } else { |
|
40 | 40 | |
41 | - // Display a list of available subscriptions. |
|
42 | - getpaid_print_subscriptions_list(); |
|
43 | - } |
|
41 | + // Display a list of available subscriptions. |
|
42 | + getpaid_print_subscriptions_list(); |
|
43 | + } |
|
44 | 44 | |
45 | - ?> |
|
45 | + ?> |
|
46 | 46 | |
47 | 47 | </div> |
48 | 48 | </div> |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | */ |
60 | 60 | function getpaid_print_subscriptions_list() { |
61 | 61 | |
62 | - $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
63 | - $subscribers_table->prepare_items(); |
|
62 | + $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
63 | + $subscribers_table->prepare_items(); |
|
64 | 64 | |
65 | - ?> |
|
65 | + ?> |
|
66 | 66 | <form id="subscribers-filter" class="bsui" method="get"> |
67 | 67 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
68 | 68 | <?php $subscribers_table->views(); ?> |
@@ -80,41 +80,41 @@ discard block |
||
80 | 80 | */ |
81 | 81 | function wpinv_recurring_subscription_details() { |
82 | 82 | |
83 | - // Fetch the subscription. |
|
84 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
85 | - if ( ! $sub->exists() ) { |
|
83 | + // Fetch the subscription. |
|
84 | + $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
85 | + if ( ! $sub->exists() ) { |
|
86 | 86 | |
87 | - echo aui()->alert( |
|
88 | - array( |
|
89 | - 'type' => 'danger', |
|
90 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
91 | - ) |
|
92 | - ); |
|
87 | + echo aui()->alert( |
|
88 | + array( |
|
89 | + 'type' => 'danger', |
|
90 | + 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
91 | + ) |
|
92 | + ); |
|
93 | 93 | |
94 | - return; |
|
95 | - } |
|
94 | + return; |
|
95 | + } |
|
96 | 96 | |
97 | - // Use metaboxes to display the subscription details. |
|
98 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
99 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
97 | + // Use metaboxes to display the subscription details. |
|
98 | + add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
99 | + add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
100 | 100 | |
101 | - $subscription_id = $sub->get_id(); |
|
102 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
103 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
101 | + $subscription_id = $sub->get_id(); |
|
102 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
103 | + $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
104 | 104 | |
105 | - if ( 1 < count( $subscription_groups ) ) { |
|
106 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
107 | - } |
|
105 | + if ( 1 < count( $subscription_groups ) ) { |
|
106 | + add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
107 | + } |
|
108 | 108 | |
109 | - if ( ! empty( $subscription_group ) ) { |
|
110 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
111 | - } |
|
109 | + if ( ! empty( $subscription_group ) ) { |
|
110 | + add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
111 | + } |
|
112 | 112 | |
113 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
113 | + add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
114 | 114 | |
115 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
115 | + do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
116 | 116 | |
117 | - ?> |
|
117 | + ?> |
|
118 | 118 | |
119 | 119 | <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
120 | 120 | |
@@ -154,45 +154,45 @@ discard block |
||
154 | 154 | */ |
155 | 155 | function getpaid_admin_subscription_details_metabox( $sub ) { |
156 | 156 | |
157 | - // Subscription items. |
|
158 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
159 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
160 | - |
|
161 | - // Prepare subscription detail columns. |
|
162 | - $fields = apply_filters( |
|
163 | - 'getpaid_subscription_admin_page_fields', |
|
164 | - array( |
|
165 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
166 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
167 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
168 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
169 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
170 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
171 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
172 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
173 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
174 | - 'status' => __( 'Status', 'invoicing' ), |
|
175 | - ) |
|
176 | - ); |
|
177 | - |
|
178 | - if ( ! $sub->is_active() ) { |
|
179 | - |
|
180 | - if ( isset( $fields['renews_on'] ) ) { |
|
181 | - unset( $fields['renews_on'] ); |
|
182 | - } |
|
183 | - |
|
184 | - if ( isset( $fields['gateway'] ) ) { |
|
185 | - unset( $fields['gateway'] ); |
|
186 | - } |
|
187 | - |
|
188 | - } |
|
189 | - |
|
190 | - $profile_id = $sub->get_profile_id(); |
|
191 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
192 | - unset( $fields['profile_id'] ); |
|
193 | - } |
|
194 | - |
|
195 | - ?> |
|
157 | + // Subscription items. |
|
158 | + $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
159 | + $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
160 | + |
|
161 | + // Prepare subscription detail columns. |
|
162 | + $fields = apply_filters( |
|
163 | + 'getpaid_subscription_admin_page_fields', |
|
164 | + array( |
|
165 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
166 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
167 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
168 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
169 | + 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
170 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
171 | + 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
172 | + 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
173 | + 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
174 | + 'status' => __( 'Status', 'invoicing' ), |
|
175 | + ) |
|
176 | + ); |
|
177 | + |
|
178 | + if ( ! $sub->is_active() ) { |
|
179 | + |
|
180 | + if ( isset( $fields['renews_on'] ) ) { |
|
181 | + unset( $fields['renews_on'] ); |
|
182 | + } |
|
183 | + |
|
184 | + if ( isset( $fields['gateway'] ) ) { |
|
185 | + unset( $fields['gateway'] ); |
|
186 | + } |
|
187 | + |
|
188 | + } |
|
189 | + |
|
190 | + $profile_id = $sub->get_profile_id(); |
|
191 | + if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
192 | + unset( $fields['profile_id'] ); |
|
193 | + } |
|
194 | + |
|
195 | + ?> |
|
196 | 196 | |
197 | 197 | <table class="table table-borderless" style="font-size: 14px;"> |
198 | 198 | <tbody> |
@@ -226,20 +226,20 @@ discard block |
||
226 | 226 | */ |
227 | 227 | function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
228 | 228 | |
229 | - $username = __( '(Missing User)', 'invoicing' ); |
|
229 | + $username = __( '(Missing User)', 'invoicing' ); |
|
230 | 230 | |
231 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
232 | - if ( $user ) { |
|
231 | + $user = get_userdata( $subscription->get_customer_id() ); |
|
232 | + if ( $user ) { |
|
233 | 233 | |
234 | - $username = sprintf( |
|
235 | - '<a href="user-edit.php?user_id=%s">%s</a>', |
|
236 | - absint( $user->ID ), |
|
237 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
238 | - ); |
|
234 | + $username = sprintf( |
|
235 | + '<a href="user-edit.php?user_id=%s">%s</a>', |
|
236 | + absint( $user->ID ), |
|
237 | + ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
238 | + ); |
|
239 | 239 | |
240 | - } |
|
240 | + } |
|
241 | 241 | |
242 | - echo $username; |
|
242 | + echo $username; |
|
243 | 243 | } |
244 | 244 | add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
245 | 245 | |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | * @param WPInv_Subscription $subscription |
250 | 250 | */ |
251 | 251 | function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
252 | - $amount = wp_kses_post( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
253 | - echo "<span>$amount</span>"; |
|
252 | + $amount = wp_kses_post( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
253 | + echo "<span>$amount</span>"; |
|
254 | 254 | } |
255 | 255 | add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
256 | 256 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @param WPInv_Subscription $subscription |
261 | 261 | */ |
262 | 262 | function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
263 | - echo '#' . absint( $subscription->get_id() ); |
|
263 | + echo '#' . absint( $subscription->get_id() ); |
|
264 | 264 | } |
265 | 265 | add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
266 | 266 | |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @param WPInv_Subscription $subscription |
271 | 271 | */ |
272 | 272 | function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
273 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
273 | + echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
274 | 274 | } |
275 | 275 | add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
276 | 276 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * @param WPInv_Subscription $subscription |
281 | 281 | */ |
282 | 282 | function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
283 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
283 | + echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
284 | 284 | } |
285 | 285 | add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
286 | 286 | |
@@ -290,8 +290,8 @@ discard block |
||
290 | 290 | * @param WPInv_Subscription $subscription |
291 | 291 | */ |
292 | 292 | function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
293 | - $max_bills = $subscription->get_bill_times(); |
|
294 | - echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
293 | + $max_bills = $subscription->get_bill_times(); |
|
294 | + echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
295 | 295 | } |
296 | 296 | add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
297 | 297 | /** |
@@ -302,13 +302,13 @@ discard block |
||
302 | 302 | */ |
303 | 303 | function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
304 | 304 | |
305 | - if ( empty( $subscription_group ) ) { |
|
306 | - echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
307 | - return; |
|
308 | - } |
|
305 | + if ( empty( $subscription_group ) ) { |
|
306 | + echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
307 | + return; |
|
308 | + } |
|
309 | 309 | |
310 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
311 | - echo implode( ' | ', $markup ); |
|
310 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
311 | + echo implode( ' | ', $markup ); |
|
312 | 312 | |
313 | 313 | } |
314 | 314 | add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
@@ -320,13 +320,13 @@ discard block |
||
320 | 320 | */ |
321 | 321 | function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
322 | 322 | |
323 | - $gateway = $subscription->get_gateway(); |
|
323 | + $gateway = $subscription->get_gateway(); |
|
324 | 324 | |
325 | - if ( ! empty( $gateway ) ) { |
|
326 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
327 | - } else { |
|
328 | - echo "—"; |
|
329 | - } |
|
325 | + if ( ! empty( $gateway ) ) { |
|
326 | + echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
327 | + } else { |
|
328 | + echo "—"; |
|
329 | + } |
|
330 | 330 | |
331 | 331 | } |
332 | 332 | add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | * @param WPInv_Subscription $subscription |
338 | 338 | */ |
339 | 339 | function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
340 | - echo $subscription->get_status_label_html(); |
|
340 | + echo $subscription->get_status_label_html(); |
|
341 | 341 | } |
342 | 342 | add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
343 | 343 | |
@@ -348,29 +348,29 @@ discard block |
||
348 | 348 | */ |
349 | 349 | function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
350 | 350 | |
351 | - $profile_id = $subscription->get_profile_id(); |
|
352 | - |
|
353 | - $input = aui()->input( |
|
354 | - array( |
|
355 | - 'type' => 'text', |
|
356 | - 'id' => 'wpinv_subscription_profile_id', |
|
357 | - 'name' => 'wpinv_subscription_profile_id', |
|
358 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
359 | - 'label_type' => 'hidden', |
|
360 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
361 | - 'value' => esc_attr( $profile_id ), |
|
362 | - 'input_group_right' => '', |
|
363 | - 'no_wrap' => true, |
|
364 | - ) |
|
365 | - ); |
|
366 | - |
|
367 | - echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
368 | - |
|
369 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
370 | - if ( ! empty( $url ) ) { |
|
371 | - $url = esc_url_raw( $url ); |
|
372 | - echo ' <a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
373 | - } |
|
351 | + $profile_id = $subscription->get_profile_id(); |
|
352 | + |
|
353 | + $input = aui()->input( |
|
354 | + array( |
|
355 | + 'type' => 'text', |
|
356 | + 'id' => 'wpinv_subscription_profile_id', |
|
357 | + 'name' => 'wpinv_subscription_profile_id', |
|
358 | + 'label' => __( 'Profile Id', 'invoicing' ), |
|
359 | + 'label_type' => 'hidden', |
|
360 | + 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
361 | + 'value' => esc_attr( $profile_id ), |
|
362 | + 'input_group_right' => '', |
|
363 | + 'no_wrap' => true, |
|
364 | + ) |
|
365 | + ); |
|
366 | + |
|
367 | + echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
368 | + |
|
369 | + $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
370 | + if ( ! empty( $url ) ) { |
|
371 | + $url = esc_url_raw( $url ); |
|
372 | + echo ' <a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
373 | + } |
|
374 | 374 | |
375 | 375 | } |
376 | 376 | add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
@@ -382,39 +382,39 @@ discard block |
||
382 | 382 | */ |
383 | 383 | function getpaid_admin_subscription_update_metabox( $subscription ) { |
384 | 384 | |
385 | - ?> |
|
385 | + ?> |
|
386 | 386 | <div class="mt-3"> |
387 | 387 | |
388 | 388 | <?php |
389 | - echo aui()->select( |
|
390 | - array( |
|
391 | - 'options' => getpaid_get_subscription_statuses(), |
|
392 | - 'name' => 'subscription_status', |
|
393 | - 'id' => 'subscription_status_update_select', |
|
394 | - 'required' => true, |
|
395 | - 'no_wrap' => false, |
|
396 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
397 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
398 | - 'select2' => true, |
|
399 | - 'value' => $subscription->get_status( 'edit' ), |
|
400 | - ) |
|
401 | - ); |
|
402 | - ?> |
|
389 | + echo aui()->select( |
|
390 | + array( |
|
391 | + 'options' => getpaid_get_subscription_statuses(), |
|
392 | + 'name' => 'subscription_status', |
|
393 | + 'id' => 'subscription_status_update_select', |
|
394 | + 'required' => true, |
|
395 | + 'no_wrap' => false, |
|
396 | + 'label' => __( 'Subscription Status', 'invoicing' ), |
|
397 | + 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
398 | + 'select2' => true, |
|
399 | + 'value' => $subscription->get_status( 'edit' ), |
|
400 | + ) |
|
401 | + ); |
|
402 | + ?> |
|
403 | 403 | |
404 | 404 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
405 | 405 | |
406 | 406 | <?php |
407 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
407 | + submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
408 | 408 | |
409 | - $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
410 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
411 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
409 | + $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
410 | + $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
411 | + $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
412 | 412 | |
413 | - if ( $subscription->is_active() ) { |
|
414 | - echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
415 | - } |
|
413 | + if ( $subscription->is_active() ) { |
|
414 | + echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
415 | + } |
|
416 | 416 | |
417 | - echo '</div></div>'; |
|
417 | + echo '</div></div>'; |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
@@ -425,33 +425,33 @@ discard block |
||
425 | 425 | */ |
426 | 426 | function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
427 | 427 | |
428 | - $columns = apply_filters( |
|
429 | - 'getpaid_subscription_related_invoices_columns', |
|
430 | - array( |
|
431 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
432 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
433 | - 'date' => __( 'Date', 'invoicing' ), |
|
434 | - 'status' => __( 'Status', 'invoicing' ), |
|
435 | - 'total' => __( 'Total', 'invoicing' ), |
|
436 | - ), |
|
437 | - $subscription |
|
438 | - ); |
|
439 | - |
|
440 | - // Prepare the invoices. |
|
441 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
442 | - $parent = $subscription->get_parent_invoice(); |
|
443 | - |
|
444 | - if ( $parent->exists() ) { |
|
445 | - $payments = array_merge( array( $parent ), $payments ); |
|
446 | - } |
|
447 | - |
|
448 | - $table_class = 'w-100 bg-white'; |
|
449 | - |
|
450 | - if ( ! is_admin() ) { |
|
451 | - $table_class = 'table table-bordered'; |
|
452 | - } |
|
453 | - |
|
454 | - ?> |
|
428 | + $columns = apply_filters( |
|
429 | + 'getpaid_subscription_related_invoices_columns', |
|
430 | + array( |
|
431 | + 'invoice' => __( 'Invoice', 'invoicing' ), |
|
432 | + 'relationship' => __( 'Relationship', 'invoicing' ), |
|
433 | + 'date' => __( 'Date', 'invoicing' ), |
|
434 | + 'status' => __( 'Status', 'invoicing' ), |
|
435 | + 'total' => __( 'Total', 'invoicing' ), |
|
436 | + ), |
|
437 | + $subscription |
|
438 | + ); |
|
439 | + |
|
440 | + // Prepare the invoices. |
|
441 | + $payments = $subscription->get_child_payments( ! is_admin() ); |
|
442 | + $parent = $subscription->get_parent_invoice(); |
|
443 | + |
|
444 | + if ( $parent->exists() ) { |
|
445 | + $payments = array_merge( array( $parent ), $payments ); |
|
446 | + } |
|
447 | + |
|
448 | + $table_class = 'w-100 bg-white'; |
|
449 | + |
|
450 | + if ( ! is_admin() ) { |
|
451 | + $table_class = 'table table-bordered'; |
|
452 | + } |
|
453 | + |
|
454 | + ?> |
|
455 | 455 | <div class="m-0" style="overflow: auto;"> |
456 | 456 | |
457 | 457 | <table class="<?php echo $table_class; ?>"> |
@@ -459,14 +459,14 @@ discard block |
||
459 | 459 | <thead> |
460 | 460 | <tr> |
461 | 461 | <?php |
462 | - foreach ( $columns as $key => $label ) { |
|
463 | - $key = esc_attr( $key ); |
|
464 | - $label = esc_html( $label ); |
|
465 | - $class = 'text-left'; |
|
466 | - |
|
467 | - echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
468 | - } |
|
469 | - ?> |
|
462 | + foreach ( $columns as $key => $label ) { |
|
463 | + $key = esc_attr( $key ); |
|
464 | + $label = esc_html( $label ); |
|
465 | + $class = 'text-left'; |
|
466 | + |
|
467 | + echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
468 | + } |
|
469 | + ?> |
|
470 | 470 | </tr> |
471 | 471 | </thead> |
472 | 472 | |
@@ -482,73 +482,73 @@ discard block |
||
482 | 482 | |
483 | 483 | <?php |
484 | 484 | |
485 | - foreach( $payments as $payment ) : |
|
485 | + foreach( $payments as $payment ) : |
|
486 | 486 | |
487 | - // Ensure that we have an invoice. |
|
488 | - $payment = new WPInv_Invoice( $payment ); |
|
487 | + // Ensure that we have an invoice. |
|
488 | + $payment = new WPInv_Invoice( $payment ); |
|
489 | 489 | |
490 | - // Abort if the invoice is invalid... |
|
491 | - if ( ! $payment->exists() ) { |
|
492 | - continue; |
|
493 | - } |
|
490 | + // Abort if the invoice is invalid... |
|
491 | + if ( ! $payment->exists() ) { |
|
492 | + continue; |
|
493 | + } |
|
494 | 494 | |
495 | - // ... or belongs to a different subscription. |
|
496 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
497 | - continue; |
|
498 | - } |
|
495 | + // ... or belongs to a different subscription. |
|
496 | + if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
497 | + continue; |
|
498 | + } |
|
499 | 499 | |
500 | - echo '<tr>'; |
|
500 | + echo '<tr>'; |
|
501 | 501 | |
502 | - foreach ( array_keys( $columns ) as $key ) { |
|
502 | + foreach ( array_keys( $columns ) as $key ) { |
|
503 | 503 | |
504 | - $class = 'text-left'; |
|
504 | + $class = 'text-left'; |
|
505 | 505 | |
506 | - echo "<td class='p-2 $class'>"; |
|
506 | + echo "<td class='p-2 $class'>"; |
|
507 | 507 | |
508 | - switch( $key ) { |
|
508 | + switch( $key ) { |
|
509 | 509 | |
510 | - case 'total': |
|
511 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
512 | - break; |
|
510 | + case 'total': |
|
511 | + echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
512 | + break; |
|
513 | 513 | |
514 | - case 'relationship': |
|
515 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
516 | - break; |
|
514 | + case 'relationship': |
|
515 | + echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
516 | + break; |
|
517 | 517 | |
518 | - case 'date': |
|
519 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
520 | - break; |
|
518 | + case 'date': |
|
519 | + echo getpaid_format_date_value( $payment->get_date_created() ); |
|
520 | + break; |
|
521 | 521 | |
522 | - case 'status': |
|
522 | + case 'status': |
|
523 | 523 | |
524 | - $status = $payment->get_status_nicename(); |
|
525 | - if ( is_admin() ) { |
|
526 | - $status = $payment->get_status_label_html(); |
|
527 | - } |
|
524 | + $status = $payment->get_status_nicename(); |
|
525 | + if ( is_admin() ) { |
|
526 | + $status = $payment->get_status_label_html(); |
|
527 | + } |
|
528 | 528 | |
529 | - echo $status; |
|
530 | - break; |
|
529 | + echo $status; |
|
530 | + break; |
|
531 | 531 | |
532 | - case 'invoice': |
|
533 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
532 | + case 'invoice': |
|
533 | + $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
534 | 534 | |
535 | - if ( ! is_admin() ) { |
|
536 | - $link = esc_url( $payment->get_view_url() ); |
|
537 | - } |
|
535 | + if ( ! is_admin() ) { |
|
536 | + $link = esc_url( $payment->get_view_url() ); |
|
537 | + } |
|
538 | 538 | |
539 | - $invoice = esc_html( $payment->get_number() ); |
|
540 | - echo "<a href='$link'>$invoice</a>"; |
|
541 | - break; |
|
542 | - } |
|
539 | + $invoice = esc_html( $payment->get_number() ); |
|
540 | + echo "<a href='$link'>$invoice</a>"; |
|
541 | + break; |
|
542 | + } |
|
543 | 543 | |
544 | - echo '</td>'; |
|
544 | + echo '</td>'; |
|
545 | 545 | |
546 | - } |
|
546 | + } |
|
547 | 547 | |
548 | - echo '</tr>'; |
|
548 | + echo '</tr>'; |
|
549 | 549 | |
550 | - endforeach; |
|
551 | - ?> |
|
550 | + endforeach; |
|
551 | + ?> |
|
552 | 552 | |
553 | 553 | </tbody> |
554 | 554 | |
@@ -566,42 +566,42 @@ discard block |
||
566 | 566 | */ |
567 | 567 | function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
568 | 568 | |
569 | - // Fetch the subscription group. |
|
570 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
569 | + // Fetch the subscription group. |
|
570 | + $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
571 | 571 | |
572 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
573 | - return; |
|
574 | - } |
|
572 | + if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
573 | + return; |
|
574 | + } |
|
575 | 575 | |
576 | - // Prepare table columns. |
|
577 | - $columns = apply_filters( |
|
578 | - 'getpaid_subscription_item_details_columns', |
|
579 | - array( |
|
580 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
581 | - 'price' => __( 'Price', 'invoicing' ), |
|
582 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
583 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
584 | - //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
585 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
586 | - ), |
|
587 | - $subscription |
|
588 | - ); |
|
576 | + // Prepare table columns. |
|
577 | + $columns = apply_filters( |
|
578 | + 'getpaid_subscription_item_details_columns', |
|
579 | + array( |
|
580 | + 'item_name' => __( 'Item', 'invoicing' ), |
|
581 | + 'price' => __( 'Price', 'invoicing' ), |
|
582 | + 'tax' => __( 'Tax', 'invoicing' ), |
|
583 | + 'discount' => __( 'Discount', 'invoicing' ), |
|
584 | + //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
585 | + 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
586 | + ), |
|
587 | + $subscription |
|
588 | + ); |
|
589 | 589 | |
590 | - // Prepare the invoices. |
|
590 | + // Prepare the invoices. |
|
591 | 591 | |
592 | - $invoice = $subscription->get_parent_invoice(); |
|
592 | + $invoice = $subscription->get_parent_invoice(); |
|
593 | 593 | |
594 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
595 | - unset( $columns['tax'] ); |
|
596 | - } |
|
594 | + if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
595 | + unset( $columns['tax'] ); |
|
596 | + } |
|
597 | 597 | |
598 | - $table_class = 'w-100 bg-white'; |
|
598 | + $table_class = 'w-100 bg-white'; |
|
599 | 599 | |
600 | - if ( ! is_admin() ) { |
|
601 | - $table_class = 'table table-bordered'; |
|
602 | - } |
|
600 | + if ( ! is_admin() ) { |
|
601 | + $table_class = 'table table-bordered'; |
|
602 | + } |
|
603 | 603 | |
604 | - ?> |
|
604 | + ?> |
|
605 | 605 | <div class="m-0" style="overflow: auto;"> |
606 | 606 | |
607 | 607 | <table class="<?php echo $table_class; ?>"> |
@@ -610,14 +610,14 @@ discard block |
||
610 | 610 | <tr> |
611 | 611 | <?php |
612 | 612 | |
613 | - foreach ( $columns as $key => $label ) { |
|
614 | - $key = esc_attr( $key ); |
|
615 | - $label = esc_html( $label ); |
|
616 | - $class = 'text-left'; |
|
613 | + foreach ( $columns as $key => $label ) { |
|
614 | + $key = esc_attr( $key ); |
|
615 | + $label = esc_html( $label ); |
|
616 | + $class = 'text-left'; |
|
617 | 617 | |
618 | - echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
619 | - } |
|
620 | - ?> |
|
618 | + echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
619 | + } |
|
620 | + ?> |
|
621 | 621 | </tr> |
622 | 622 | </thead> |
623 | 623 | |
@@ -625,106 +625,106 @@ discard block |
||
625 | 625 | |
626 | 626 | <?php |
627 | 627 | |
628 | - foreach( $subscription_group['items'] as $subscription_group_item ) : |
|
628 | + foreach( $subscription_group['items'] as $subscription_group_item ) : |
|
629 | 629 | |
630 | - echo '<tr>'; |
|
630 | + echo '<tr>'; |
|
631 | 631 | |
632 | - foreach ( array_keys( $columns ) as $key ) { |
|
632 | + foreach ( array_keys( $columns ) as $key ) { |
|
633 | 633 | |
634 | - $class = 'text-left'; |
|
634 | + $class = 'text-left'; |
|
635 | 635 | |
636 | - echo "<td class='p-2 $class'>"; |
|
636 | + echo "<td class='p-2 $class'>"; |
|
637 | 637 | |
638 | - switch( $key ) { |
|
638 | + switch( $key ) { |
|
639 | 639 | |
640 | - case 'item_name': |
|
641 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
642 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
640 | + case 'item_name': |
|
641 | + $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
642 | + $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
643 | 643 | |
644 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
645 | - echo esc_html( $item_name ); |
|
646 | - } else { |
|
647 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
648 | - } |
|
644 | + if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
645 | + echo esc_html( $item_name ); |
|
646 | + } else { |
|
647 | + printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
648 | + } |
|
649 | 649 | |
650 | - break; |
|
650 | + break; |
|
651 | 651 | |
652 | - case 'price': |
|
653 | - echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
654 | - break; |
|
652 | + case 'price': |
|
653 | + echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
654 | + break; |
|
655 | 655 | |
656 | - case 'tax': |
|
657 | - echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
658 | - break; |
|
656 | + case 'tax': |
|
657 | + echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
658 | + break; |
|
659 | 659 | |
660 | - case 'discount': |
|
661 | - echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
662 | - break; |
|
660 | + case 'discount': |
|
661 | + echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
662 | + break; |
|
663 | 663 | |
664 | - case 'initial': |
|
665 | - echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
666 | - break; |
|
664 | + case 'initial': |
|
665 | + echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
666 | + break; |
|
667 | 667 | |
668 | - case 'recurring': |
|
669 | - echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
670 | - break; |
|
668 | + case 'recurring': |
|
669 | + echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
670 | + break; |
|
671 | 671 | |
672 | - } |
|
672 | + } |
|
673 | 673 | |
674 | - echo '</td>'; |
|
674 | + echo '</td>'; |
|
675 | 675 | |
676 | - } |
|
676 | + } |
|
677 | 677 | |
678 | - echo '</tr>'; |
|
678 | + echo '</tr>'; |
|
679 | 679 | |
680 | - endforeach; |
|
680 | + endforeach; |
|
681 | 681 | |
682 | - foreach( $subscription_group['fees'] as $subscription_group_fee ) : |
|
682 | + foreach( $subscription_group['fees'] as $subscription_group_fee ) : |
|
683 | 683 | |
684 | - echo '<tr>'; |
|
684 | + echo '<tr>'; |
|
685 | 685 | |
686 | - foreach ( array_keys( $columns ) as $key ) { |
|
686 | + foreach ( array_keys( $columns ) as $key ) { |
|
687 | 687 | |
688 | - $class = 'text-left'; |
|
688 | + $class = 'text-left'; |
|
689 | 689 | |
690 | - echo "<td class='p-2 $class'>"; |
|
690 | + echo "<td class='p-2 $class'>"; |
|
691 | 691 | |
692 | - switch( $key ) { |
|
692 | + switch( $key ) { |
|
693 | 693 | |
694 | - case 'item_name': |
|
695 | - echo esc_html( $subscription_group_fee['name'] ); |
|
696 | - break; |
|
694 | + case 'item_name': |
|
695 | + echo esc_html( $subscription_group_fee['name'] ); |
|
696 | + break; |
|
697 | 697 | |
698 | - case 'price': |
|
699 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
700 | - break; |
|
698 | + case 'price': |
|
699 | + echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
700 | + break; |
|
701 | 701 | |
702 | - case 'tax': |
|
703 | - echo "—"; |
|
704 | - break; |
|
702 | + case 'tax': |
|
703 | + echo "—"; |
|
704 | + break; |
|
705 | 705 | |
706 | - case 'discount': |
|
707 | - echo "—"; |
|
708 | - break; |
|
706 | + case 'discount': |
|
707 | + echo "—"; |
|
708 | + break; |
|
709 | 709 | |
710 | - case 'initial': |
|
711 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
712 | - break; |
|
710 | + case 'initial': |
|
711 | + echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
712 | + break; |
|
713 | 713 | |
714 | - case 'recurring': |
|
715 | - echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
716 | - break; |
|
714 | + case 'recurring': |
|
715 | + echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
716 | + break; |
|
717 | 717 | |
718 | - } |
|
718 | + } |
|
719 | 719 | |
720 | - echo '</td>'; |
|
720 | + echo '</td>'; |
|
721 | 721 | |
722 | - } |
|
722 | + } |
|
723 | 723 | |
724 | - echo '</tr>'; |
|
724 | + echo '</tr>'; |
|
725 | 725 | |
726 | - endforeach; |
|
727 | - ?> |
|
726 | + endforeach; |
|
727 | + ?> |
|
728 | 728 | |
729 | 729 | </tbody> |
730 | 730 | |
@@ -743,38 +743,38 @@ discard block |
||
743 | 743 | */ |
744 | 744 | function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
745 | 745 | |
746 | - // Fetch the subscription groups. |
|
747 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
748 | - |
|
749 | - if ( empty( $subscription_groups ) ) { |
|
750 | - return; |
|
751 | - } |
|
752 | - |
|
753 | - // Prepare table columns. |
|
754 | - $columns = apply_filters( |
|
755 | - 'getpaid_subscription_related_subscriptions_columns', |
|
756 | - array( |
|
757 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
758 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
759 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
760 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
761 | - 'item' => __( 'Items', 'invoicing' ), |
|
762 | - 'status' => __( 'Status', 'invoicing' ), |
|
763 | - ), |
|
764 | - $subscription |
|
765 | - ); |
|
766 | - |
|
767 | - if ( $subscription->get_status() == 'pending' ) { |
|
768 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
769 | - } |
|
770 | - |
|
771 | - $table_class = 'w-100 bg-white'; |
|
772 | - |
|
773 | - if ( ! is_admin() ) { |
|
774 | - $table_class = 'table table-bordered'; |
|
775 | - } |
|
776 | - |
|
777 | - ?> |
|
746 | + // Fetch the subscription groups. |
|
747 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
748 | + |
|
749 | + if ( empty( $subscription_groups ) ) { |
|
750 | + return; |
|
751 | + } |
|
752 | + |
|
753 | + // Prepare table columns. |
|
754 | + $columns = apply_filters( |
|
755 | + 'getpaid_subscription_related_subscriptions_columns', |
|
756 | + array( |
|
757 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
758 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
759 | + 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
760 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
761 | + 'item' => __( 'Items', 'invoicing' ), |
|
762 | + 'status' => __( 'Status', 'invoicing' ), |
|
763 | + ), |
|
764 | + $subscription |
|
765 | + ); |
|
766 | + |
|
767 | + if ( $subscription->get_status() == 'pending' ) { |
|
768 | + unset( $columns['start_date'], $columns['renewal_date'] ); |
|
769 | + } |
|
770 | + |
|
771 | + $table_class = 'w-100 bg-white'; |
|
772 | + |
|
773 | + if ( ! is_admin() ) { |
|
774 | + $table_class = 'table table-bordered'; |
|
775 | + } |
|
776 | + |
|
777 | + ?> |
|
778 | 778 | <div class="m-0" style="overflow: auto;"> |
779 | 779 | |
780 | 780 | <table class="<?php echo $table_class; ?>"> |
@@ -783,14 +783,14 @@ discard block |
||
783 | 783 | <tr> |
784 | 784 | <?php |
785 | 785 | |
786 | - foreach ( $columns as $key => $label ) { |
|
787 | - $key = esc_attr( $key ); |
|
788 | - $label = esc_html( $label ); |
|
789 | - $class = 'text-left'; |
|
786 | + foreach ( $columns as $key => $label ) { |
|
787 | + $key = esc_attr( $key ); |
|
788 | + $label = esc_html( $label ); |
|
789 | + $class = 'text-left'; |
|
790 | 790 | |
791 | - echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
792 | - } |
|
793 | - ?> |
|
791 | + echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
792 | + } |
|
793 | + ?> |
|
794 | 794 | </tr> |
795 | 795 | </thead> |
796 | 796 | |
@@ -798,74 +798,74 @@ discard block |
||
798 | 798 | |
799 | 799 | <?php |
800 | 800 | |
801 | - foreach( $subscription_groups as $subscription_group ) : |
|
801 | + foreach( $subscription_groups as $subscription_group ) : |
|
802 | 802 | |
803 | - // Do not list current subscription. |
|
804 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
805 | - continue; |
|
806 | - } |
|
803 | + // Do not list current subscription. |
|
804 | + if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
805 | + continue; |
|
806 | + } |
|
807 | 807 | |
808 | - // Ensure the subscription exists. |
|
809 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
808 | + // Ensure the subscription exists. |
|
809 | + $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
810 | 810 | |
811 | - if ( ! $_suscription->exists() ) { |
|
812 | - continue; |
|
813 | - } |
|
811 | + if ( ! $_suscription->exists() ) { |
|
812 | + continue; |
|
813 | + } |
|
814 | 814 | |
815 | - echo '<tr>'; |
|
815 | + echo '<tr>'; |
|
816 | 816 | |
817 | - foreach ( array_keys( $columns ) as $key ) { |
|
817 | + foreach ( array_keys( $columns ) as $key ) { |
|
818 | 818 | |
819 | - $class = 'text-left'; |
|
819 | + $class = 'text-left'; |
|
820 | 820 | |
821 | - echo "<td class='p-2 $class'>"; |
|
821 | + echo "<td class='p-2 $class'>"; |
|
822 | 822 | |
823 | - switch( $key ) { |
|
823 | + switch( $key ) { |
|
824 | 824 | |
825 | - case 'status': |
|
826 | - echo $_suscription->get_status_label_html(); |
|
827 | - break; |
|
825 | + case 'status': |
|
826 | + echo $_suscription->get_status_label_html(); |
|
827 | + break; |
|
828 | 828 | |
829 | - case 'item': |
|
830 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
831 | - echo implode( ' | ', $markup ); |
|
832 | - break; |
|
829 | + case 'item': |
|
830 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
831 | + echo implode( ' | ', $markup ); |
|
832 | + break; |
|
833 | 833 | |
834 | - case 'renewals': |
|
835 | - $max_bills = $_suscription->get_bill_times(); |
|
836 | - echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
837 | - break; |
|
834 | + case 'renewals': |
|
835 | + $max_bills = $_suscription->get_bill_times(); |
|
836 | + echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
837 | + break; |
|
838 | 838 | |
839 | - case 'renewal_date': |
|
840 | - echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "—"; |
|
841 | - break; |
|
839 | + case 'renewal_date': |
|
840 | + echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "—"; |
|
841 | + break; |
|
842 | 842 | |
843 | - case 'start_date': |
|
844 | - echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
845 | - break; |
|
843 | + case 'start_date': |
|
844 | + echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
845 | + break; |
|
846 | 846 | |
847 | - case 'subscription': |
|
848 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
849 | - printf( |
|
850 | - '%1$s#%2$s%3$s', |
|
851 | - '<a href="' . esc_url( $url ) . '">', |
|
852 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
853 | - '</a>' |
|
854 | - ); |
|
847 | + case 'subscription': |
|
848 | + $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
849 | + printf( |
|
850 | + '%1$s#%2$s%3$s', |
|
851 | + '<a href="' . esc_url( $url ) . '">', |
|
852 | + '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
853 | + '</a>' |
|
854 | + ); |
|
855 | 855 | |
856 | - echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
857 | - break; |
|
856 | + echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
857 | + break; |
|
858 | 858 | |
859 | - } |
|
859 | + } |
|
860 | 860 | |
861 | - echo '</td>'; |
|
861 | + echo '</td>'; |
|
862 | 862 | |
863 | - } |
|
863 | + } |
|
864 | 864 | |
865 | - echo '</tr>'; |
|
865 | + echo '</tr>'; |
|
866 | 866 | |
867 | - endforeach; |
|
868 | - ?> |
|
867 | + endforeach; |
|
868 | + ?> |
|
869 | 869 | |
870 | 870 | </tbody> |
871 | 871 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Contains functions that display the subscriptions admin page. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Render the Subscriptions page |
@@ -17,22 +17,22 @@ discard block |
||
17 | 17 | ?> |
18 | 18 | |
19 | 19 | <div class="wrap"> |
20 | - <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
|
20 | + <h1><?php echo esc_html(get_admin_page_title()); ?></h1> |
|
21 | 21 | <div class="bsui"> |
22 | 22 | |
23 | 23 | <?php |
24 | 24 | |
25 | 25 | // Verify user permissions. |
26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
26 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
27 | 27 | |
28 | 28 | echo aui()->alert( |
29 | 29 | array( |
30 | 30 | 'type' => 'danger', |
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
31 | + 'content' => __('You are not permitted to view this page.', 'invoicing'), |
|
32 | 32 | ) |
33 | 33 | ); |
34 | 34 | |
35 | - } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
35 | + } else if (!empty($_GET['id']) && is_numeric($_GET['id'])) { |
|
36 | 36 | |
37 | 37 | // Display a single subscription. |
38 | 38 | wpinv_recurring_subscription_details(); |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | function wpinv_recurring_subscription_details() { |
82 | 82 | |
83 | 83 | // Fetch the subscription. |
84 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
85 | - if ( ! $sub->exists() ) { |
|
84 | + $sub = new WPInv_Subscription((int) $_GET['id']); |
|
85 | + if (!$sub->exists()) { |
|
86 | 86 | |
87 | 87 | echo aui()->alert( |
88 | 88 | array( |
89 | 89 | 'type' => 'danger', |
90 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
90 | + 'content' => __('Subscription not found.', 'invoicing'), |
|
91 | 91 | ) |
92 | 92 | ); |
93 | 93 | |
@@ -95,45 +95,45 @@ discard block |
||
95 | 95 | } |
96 | 96 | |
97 | 97 | // Use metaboxes to display the subscription details. |
98 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
99 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
98 | + add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high'); |
|
99 | + add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side'); |
|
100 | 100 | |
101 | 101 | $subscription_id = $sub->get_id(); |
102 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
103 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
102 | + $subscription_groups = getpaid_get_invoice_subscription_groups($sub->get_parent_invoice_id()); |
|
103 | + $subscription_group = wp_list_filter($subscription_groups, compact('subscription_id')); |
|
104 | 104 | |
105 | - if ( 1 < count( $subscription_groups ) ) { |
|
106 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
105 | + if (1 < count($subscription_groups)) { |
|
106 | + add_meta_box('getpaid_admin_subscription_related_subscriptions_metabox', __('Related Subscriptions', 'invoicing'), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced'); |
|
107 | 107 | } |
108 | 108 | |
109 | - if ( ! empty( $subscription_group ) ) { |
|
110 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
109 | + if (!empty($subscription_group)) { |
|
110 | + add_meta_box('getpaid_admin_subscription_item_details_metabox', __('Subscription Items', 'invoicing'), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low'); |
|
111 | 111 | } |
112 | 112 | |
113 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
113 | + add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Related Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced'); |
|
114 | 114 | |
115 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
115 | + do_action('getpaid_admin_single_subscription_register_metabox', $sub); |
|
116 | 116 | |
117 | 117 | ?> |
118 | 118 | |
119 | - <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
|
119 | + <form method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id())); ?>"> |
|
120 | 120 | |
121 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
122 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
123 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
121 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
122 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
123 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
124 | 124 | <input type="hidden" name="getpaid-admin-action" value="update_single_subscription" /> |
125 | - <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id() ;?>" /> |
|
125 | + <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" /> |
|
126 | 126 | |
127 | 127 | <div id="poststuff"> |
128 | 128 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
129 | 129 | |
130 | 130 | <div id="postbox-container-1" class="postbox-container"> |
131 | - <?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?> |
|
131 | + <?php do_meta_boxes(get_current_screen(), 'side', $sub); ?> |
|
132 | 132 | </div> |
133 | 133 | |
134 | 134 | <div id="postbox-container-2" class="postbox-container"> |
135 | - <?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?> |
|
136 | - <?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?> |
|
135 | + <?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?> |
|
136 | + <?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?> |
|
137 | 137 | </div> |
138 | 138 | |
139 | 139 | </div> |
@@ -152,44 +152,44 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @param WPInv_Subscription $sub |
154 | 154 | */ |
155 | -function getpaid_admin_subscription_details_metabox( $sub ) { |
|
155 | +function getpaid_admin_subscription_details_metabox($sub) { |
|
156 | 156 | |
157 | 157 | // Subscription items. |
158 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
159 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
158 | + $subscription_group = getpaid_get_invoice_subscription_group($sub->get_parent_invoice_id(), $sub->get_id()); |
|
159 | + $items_count = empty($subscription_group) ? 1 : count($subscription_group['items']); |
|
160 | 160 | |
161 | 161 | // Prepare subscription detail columns. |
162 | 162 | $fields = apply_filters( |
163 | 163 | 'getpaid_subscription_admin_page_fields', |
164 | 164 | array( |
165 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
166 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
167 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
168 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
169 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
170 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
171 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
172 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
173 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
174 | - 'status' => __( 'Status', 'invoicing' ), |
|
165 | + 'subscription' => __('Subscription', 'invoicing'), |
|
166 | + 'customer' => __('Customer', 'invoicing'), |
|
167 | + 'amount' => __('Amount', 'invoicing'), |
|
168 | + 'start_date' => __('Start Date', 'invoicing'), |
|
169 | + 'renews_on' => __('Next Payment', 'invoicing'), |
|
170 | + 'renewals' => __('Payments', 'invoicing'), |
|
171 | + 'item' => _n('Item', 'Items', $items_count, 'invoicing'), |
|
172 | + 'gateway' => __('Payment Method', 'invoicing'), |
|
173 | + 'profile_id' => __('Profile ID', 'invoicing'), |
|
174 | + 'status' => __('Status', 'invoicing'), |
|
175 | 175 | ) |
176 | 176 | ); |
177 | 177 | |
178 | - if ( ! $sub->is_active() ) { |
|
178 | + if (!$sub->is_active()) { |
|
179 | 179 | |
180 | - if ( isset( $fields['renews_on'] ) ) { |
|
181 | - unset( $fields['renews_on'] ); |
|
180 | + if (isset($fields['renews_on'])) { |
|
181 | + unset($fields['renews_on']); |
|
182 | 182 | } |
183 | 183 | |
184 | - if ( isset( $fields['gateway'] ) ) { |
|
185 | - unset( $fields['gateway'] ); |
|
184 | + if (isset($fields['gateway'])) { |
|
185 | + unset($fields['gateway']); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | } |
189 | 189 | |
190 | 190 | $profile_id = $sub->get_profile_id(); |
191 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
192 | - unset( $fields['profile_id'] ); |
|
191 | + if (empty($profile_id) && isset($fields['profile_id'])) { |
|
192 | + unset($fields['profile_id']); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | ?> |
@@ -197,16 +197,16 @@ discard block |
||
197 | 197 | <table class="table table-borderless" style="font-size: 14px;"> |
198 | 198 | <tbody> |
199 | 199 | |
200 | - <?php foreach ( $fields as $key => $label ) : ?> |
|
200 | + <?php foreach ($fields as $key => $label) : ?> |
|
201 | 201 | |
202 | - <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
202 | + <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>"> |
|
203 | 203 | |
204 | 204 | <th class="w-25" style="font-weight: 500;"> |
205 | - <?php echo esc_html( $label ); ?> |
|
205 | + <?php echo esc_html($label); ?> |
|
206 | 206 | </th> |
207 | 207 | |
208 | 208 | <td class="w-75 text-muted"> |
209 | - <?php do_action( 'getpaid_subscription_admin_display_' . sanitize_key( $key ), $sub, $subscription_group ); ?> |
|
209 | + <?php do_action('getpaid_subscription_admin_display_' . sanitize_key($key), $sub, $subscription_group); ?> |
|
210 | 210 | </td> |
211 | 211 | |
212 | 212 | </tr> |
@@ -224,129 +224,129 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @param WPInv_Subscription $subscription |
226 | 226 | */ |
227 | -function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
|
227 | +function getpaid_admin_subscription_metabox_display_customer($subscription) { |
|
228 | 228 | |
229 | - $username = __( '(Missing User)', 'invoicing' ); |
|
229 | + $username = __('(Missing User)', 'invoicing'); |
|
230 | 230 | |
231 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
232 | - if ( $user ) { |
|
231 | + $user = get_userdata($subscription->get_customer_id()); |
|
232 | + if ($user) { |
|
233 | 233 | |
234 | 234 | $username = sprintf( |
235 | 235 | '<a href="user-edit.php?user_id=%s">%s</a>', |
236 | - absint( $user->ID ), |
|
237 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
236 | + absint($user->ID), |
|
237 | + !empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email) |
|
238 | 238 | ); |
239 | 239 | |
240 | 240 | } |
241 | 241 | |
242 | 242 | echo $username; |
243 | 243 | } |
244 | -add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
|
244 | +add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer'); |
|
245 | 245 | |
246 | 246 | /** |
247 | 247 | * Displays the subscription amount. |
248 | 248 | * |
249 | 249 | * @param WPInv_Subscription $subscription |
250 | 250 | */ |
251 | -function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
|
252 | - $amount = wp_kses_post( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
251 | +function getpaid_admin_subscription_metabox_display_amount($subscription) { |
|
252 | + $amount = wp_kses_post(getpaid_get_formatted_subscription_amount($subscription)); |
|
253 | 253 | echo "<span>$amount</span>"; |
254 | 254 | } |
255 | -add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
|
255 | +add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount'); |
|
256 | 256 | |
257 | 257 | /** |
258 | 258 | * Displays the subscription id. |
259 | 259 | * |
260 | 260 | * @param WPInv_Subscription $subscription |
261 | 261 | */ |
262 | -function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
|
263 | - echo '#' . absint( $subscription->get_id() ); |
|
262 | +function getpaid_admin_subscription_metabox_display_id($subscription) { |
|
263 | + echo '#' . absint($subscription->get_id()); |
|
264 | 264 | } |
265 | -add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
|
265 | +add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id'); |
|
266 | 266 | |
267 | 267 | /** |
268 | 268 | * Displays the subscription renewal date. |
269 | 269 | * |
270 | 270 | * @param WPInv_Subscription $subscription |
271 | 271 | */ |
272 | -function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
|
273 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
272 | +function getpaid_admin_subscription_metabox_display_start_date($subscription) { |
|
273 | + echo getpaid_format_date_value($subscription->get_date_created()); |
|
274 | 274 | } |
275 | -add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
|
275 | +add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date'); |
|
276 | 276 | |
277 | 277 | /** |
278 | 278 | * Displays the subscription renewal date. |
279 | 279 | * |
280 | 280 | * @param WPInv_Subscription $subscription |
281 | 281 | */ |
282 | -function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
|
283 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
282 | +function getpaid_admin_subscription_metabox_display_renews_on($subscription) { |
|
283 | + echo getpaid_format_date_value($subscription->get_expiration()); |
|
284 | 284 | } |
285 | -add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
|
285 | +add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on'); |
|
286 | 286 | |
287 | 287 | /** |
288 | 288 | * Displays the subscription renewal count. |
289 | 289 | * |
290 | 290 | * @param WPInv_Subscription $subscription |
291 | 291 | */ |
292 | -function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
|
292 | +function getpaid_admin_subscription_metabox_display_renewals($subscription) { |
|
293 | 293 | $max_bills = $subscription->get_bill_times(); |
294 | - echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
294 | + echo $subscription->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
295 | 295 | } |
296 | -add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
|
296 | +add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals'); |
|
297 | 297 | /** |
298 | 298 | * Displays the subscription item. |
299 | 299 | * |
300 | 300 | * @param WPInv_Subscription $subscription |
301 | 301 | * @param false|array $subscription_group |
302 | 302 | */ |
303 | -function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
|
303 | +function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) { |
|
304 | 304 | |
305 | - if ( empty( $subscription_group ) ) { |
|
306 | - echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
305 | + if (empty($subscription_group)) { |
|
306 | + echo WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id()); |
|
307 | 307 | return; |
308 | 308 | } |
309 | 309 | |
310 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
311 | - echo implode( ' | ', $markup ); |
|
310 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
311 | + echo implode(' | ', $markup); |
|
312 | 312 | |
313 | 313 | } |
314 | -add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
|
314 | +add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2); |
|
315 | 315 | |
316 | 316 | /** |
317 | 317 | * Displays the subscription gateway. |
318 | 318 | * |
319 | 319 | * @param WPInv_Subscription $subscription |
320 | 320 | */ |
321 | -function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
|
321 | +function getpaid_admin_subscription_metabox_display_gateway($subscription) { |
|
322 | 322 | |
323 | 323 | $gateway = $subscription->get_gateway(); |
324 | 324 | |
325 | - if ( ! empty( $gateway ) ) { |
|
326 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
325 | + if (!empty($gateway)) { |
|
326 | + echo esc_html(wpinv_get_gateway_admin_label($gateway)); |
|
327 | 327 | } else { |
328 | 328 | echo "—"; |
329 | 329 | } |
330 | 330 | |
331 | 331 | } |
332 | -add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
|
332 | +add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway'); |
|
333 | 333 | |
334 | 334 | /** |
335 | 335 | * Displays the subscription status. |
336 | 336 | * |
337 | 337 | * @param WPInv_Subscription $subscription |
338 | 338 | */ |
339 | -function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
|
339 | +function getpaid_admin_subscription_metabox_display_status($subscription) { |
|
340 | 340 | echo $subscription->get_status_label_html(); |
341 | 341 | } |
342 | -add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
|
342 | +add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status'); |
|
343 | 343 | |
344 | 344 | /** |
345 | 345 | * Displays the subscription profile id. |
346 | 346 | * |
347 | 347 | * @param WPInv_Subscription $subscription |
348 | 348 | */ |
349 | -function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
|
349 | +function getpaid_admin_subscription_metabox_display_profile_id($subscription) { |
|
350 | 350 | |
351 | 351 | $profile_id = $subscription->get_profile_id(); |
352 | 352 | |
@@ -355,32 +355,32 @@ discard block |
||
355 | 355 | 'type' => 'text', |
356 | 356 | 'id' => 'wpinv_subscription_profile_id', |
357 | 357 | 'name' => 'wpinv_subscription_profile_id', |
358 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
358 | + 'label' => __('Profile Id', 'invoicing'), |
|
359 | 359 | 'label_type' => 'hidden', |
360 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
361 | - 'value' => esc_attr( $profile_id ), |
|
360 | + 'placeholder' => __('Profile Id', 'invoicing'), |
|
361 | + 'value' => esc_attr($profile_id), |
|
362 | 362 | 'input_group_right' => '', |
363 | 363 | 'no_wrap' => true, |
364 | 364 | ) |
365 | 365 | ); |
366 | 366 | |
367 | - echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
367 | + echo str_ireplace('form-control', 'regular-text', $input); |
|
368 | 368 | |
369 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
370 | - if ( ! empty( $url ) ) { |
|
371 | - $url = esc_url_raw( $url ); |
|
372 | - echo ' <a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
369 | + $url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription); |
|
370 | + if (!empty($url)) { |
|
371 | + $url = esc_url_raw($url); |
|
372 | + echo ' <a href="' . $url . '" title="' . __('View in Gateway', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | } |
376 | -add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
|
376 | +add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id'); |
|
377 | 377 | |
378 | 378 | /** |
379 | 379 | * Displays the subscriptions update metabox. |
380 | 380 | * |
381 | 381 | * @param WPInv_Subscription $subscription |
382 | 382 | */ |
383 | -function getpaid_admin_subscription_update_metabox( $subscription ) { |
|
383 | +function getpaid_admin_subscription_update_metabox($subscription) { |
|
384 | 384 | |
385 | 385 | ?> |
386 | 386 | <div class="mt-3"> |
@@ -393,10 +393,10 @@ discard block |
||
393 | 393 | 'id' => 'subscription_status_update_select', |
394 | 394 | 'required' => true, |
395 | 395 | 'no_wrap' => false, |
396 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
397 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
396 | + 'label' => __('Subscription Status', 'invoicing'), |
|
397 | + 'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'), |
|
398 | 398 | 'select2' => true, |
399 | - 'value' => $subscription->get_status( 'edit' ), |
|
399 | + 'value' => $subscription->get_status('edit'), |
|
400 | 400 | ) |
401 | 401 | ); |
402 | 402 | ?> |
@@ -404,13 +404,13 @@ discard block |
||
404 | 404 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
405 | 405 | |
406 | 406 | <?php |
407 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
407 | + submit_button(__('Update', 'invoicing'), 'primary', 'submit', false); |
|
408 | 408 | |
409 | - $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
410 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
411 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
409 | + $url = esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce')); |
|
410 | + $anchor = __('Renew Subscription', 'invoicing'); |
|
411 | + $title = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing'); |
|
412 | 412 | |
413 | - if ( $subscription->is_active() ) { |
|
413 | + if ($subscription->is_active()) { |
|
414 | 414 | echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
415 | 415 | } |
416 | 416 | |
@@ -423,31 +423,31 @@ discard block |
||
423 | 423 | * @param WPInv_Subscription $subscription |
424 | 424 | * @param bool $strict Whether or not to skip invoices of sibling subscriptions |
425 | 425 | */ |
426 | -function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
|
426 | +function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) { |
|
427 | 427 | |
428 | 428 | $columns = apply_filters( |
429 | 429 | 'getpaid_subscription_related_invoices_columns', |
430 | 430 | array( |
431 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
432 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
433 | - 'date' => __( 'Date', 'invoicing' ), |
|
434 | - 'status' => __( 'Status', 'invoicing' ), |
|
435 | - 'total' => __( 'Total', 'invoicing' ), |
|
431 | + 'invoice' => __('Invoice', 'invoicing'), |
|
432 | + 'relationship' => __('Relationship', 'invoicing'), |
|
433 | + 'date' => __('Date', 'invoicing'), |
|
434 | + 'status' => __('Status', 'invoicing'), |
|
435 | + 'total' => __('Total', 'invoicing'), |
|
436 | 436 | ), |
437 | 437 | $subscription |
438 | 438 | ); |
439 | 439 | |
440 | 440 | // Prepare the invoices. |
441 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
441 | + $payments = $subscription->get_child_payments(!is_admin()); |
|
442 | 442 | $parent = $subscription->get_parent_invoice(); |
443 | 443 | |
444 | - if ( $parent->exists() ) { |
|
445 | - $payments = array_merge( array( $parent ), $payments ); |
|
444 | + if ($parent->exists()) { |
|
445 | + $payments = array_merge(array($parent), $payments); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | $table_class = 'w-100 bg-white'; |
449 | 449 | |
450 | - if ( ! is_admin() ) { |
|
450 | + if (!is_admin()) { |
|
451 | 451 | $table_class = 'table table-bordered'; |
452 | 452 | } |
453 | 453 | |
@@ -459,9 +459,9 @@ discard block |
||
459 | 459 | <thead> |
460 | 460 | <tr> |
461 | 461 | <?php |
462 | - foreach ( $columns as $key => $label ) { |
|
463 | - $key = esc_attr( $key ); |
|
464 | - $label = esc_html( $label ); |
|
462 | + foreach ($columns as $key => $label) { |
|
463 | + $key = esc_attr($key); |
|
464 | + $label = esc_html($label); |
|
465 | 465 | $class = 'text-left'; |
466 | 466 | |
467 | 467 | echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -472,57 +472,57 @@ discard block |
||
472 | 472 | |
473 | 473 | <tbody> |
474 | 474 | |
475 | - <?php if ( empty( $payments ) ) : ?> |
|
475 | + <?php if (empty($payments)) : ?> |
|
476 | 476 | <tr> |
477 | 477 | <td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted"> |
478 | - <?php _e( 'This subscription has no invoices.', 'invoicing' ); ?> |
|
478 | + <?php _e('This subscription has no invoices.', 'invoicing'); ?> |
|
479 | 479 | </td> |
480 | 480 | </tr> |
481 | 481 | <?php endif; ?> |
482 | 482 | |
483 | 483 | <?php |
484 | 484 | |
485 | - foreach( $payments as $payment ) : |
|
485 | + foreach ($payments as $payment) : |
|
486 | 486 | |
487 | 487 | // Ensure that we have an invoice. |
488 | - $payment = new WPInv_Invoice( $payment ); |
|
488 | + $payment = new WPInv_Invoice($payment); |
|
489 | 489 | |
490 | 490 | // Abort if the invoice is invalid... |
491 | - if ( ! $payment->exists() ) { |
|
491 | + if (!$payment->exists()) { |
|
492 | 492 | continue; |
493 | 493 | } |
494 | 494 | |
495 | 495 | // ... or belongs to a different subscription. |
496 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
496 | + if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) { |
|
497 | 497 | continue; |
498 | 498 | } |
499 | 499 | |
500 | 500 | echo '<tr>'; |
501 | 501 | |
502 | - foreach ( array_keys( $columns ) as $key ) { |
|
502 | + foreach (array_keys($columns) as $key) { |
|
503 | 503 | |
504 | 504 | $class = 'text-left'; |
505 | 505 | |
506 | 506 | echo "<td class='p-2 $class'>"; |
507 | 507 | |
508 | - switch( $key ) { |
|
508 | + switch ($key) { |
|
509 | 509 | |
510 | 510 | case 'total': |
511 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
511 | + echo '<strong>' . wpinv_price($payment->get_total(), $payment->get_currency()) . '</strong>'; |
|
512 | 512 | break; |
513 | 513 | |
514 | 514 | case 'relationship': |
515 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
515 | + echo $payment->is_renewal() ? __('Renewal Invoice', 'invoicing') : __('Initial Invoice', 'invoicing'); |
|
516 | 516 | break; |
517 | 517 | |
518 | 518 | case 'date': |
519 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
519 | + echo getpaid_format_date_value($payment->get_date_created()); |
|
520 | 520 | break; |
521 | 521 | |
522 | 522 | case 'status': |
523 | 523 | |
524 | 524 | $status = $payment->get_status_nicename(); |
525 | - if ( is_admin() ) { |
|
525 | + if (is_admin()) { |
|
526 | 526 | $status = $payment->get_status_label_html(); |
527 | 527 | } |
528 | 528 | |
@@ -530,13 +530,13 @@ discard block |
||
530 | 530 | break; |
531 | 531 | |
532 | 532 | case 'invoice': |
533 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
533 | + $link = esc_url(get_edit_post_link($payment->get_id())); |
|
534 | 534 | |
535 | - if ( ! is_admin() ) { |
|
536 | - $link = esc_url( $payment->get_view_url() ); |
|
535 | + if (!is_admin()) { |
|
536 | + $link = esc_url($payment->get_view_url()); |
|
537 | 537 | } |
538 | 538 | |
539 | - $invoice = esc_html( $payment->get_number() ); |
|
539 | + $invoice = esc_html($payment->get_number()); |
|
540 | 540 | echo "<a href='$link'>$invoice</a>"; |
541 | 541 | break; |
542 | 542 | } |
@@ -564,12 +564,12 @@ discard block |
||
564 | 564 | * |
565 | 565 | * @param WPInv_Subscription $subscription |
566 | 566 | */ |
567 | -function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
|
567 | +function getpaid_admin_subscription_item_details_metabox($subscription) { |
|
568 | 568 | |
569 | 569 | // Fetch the subscription group. |
570 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
570 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id()); |
|
571 | 571 | |
572 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
572 | + if (empty($subscription_group) || empty($subscription_group['items'])) { |
|
573 | 573 | return; |
574 | 574 | } |
575 | 575 | |
@@ -577,12 +577,12 @@ discard block |
||
577 | 577 | $columns = apply_filters( |
578 | 578 | 'getpaid_subscription_item_details_columns', |
579 | 579 | array( |
580 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
581 | - 'price' => __( 'Price', 'invoicing' ), |
|
582 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
583 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
580 | + 'item_name' => __('Item', 'invoicing'), |
|
581 | + 'price' => __('Price', 'invoicing'), |
|
582 | + 'tax' => __('Tax', 'invoicing'), |
|
583 | + 'discount' => __('Discount', 'invoicing'), |
|
584 | 584 | //'initial' => __( 'Initial Amount', 'invoicing' ), |
585 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
585 | + 'recurring' => __('Subtotal', 'invoicing'), |
|
586 | 586 | ), |
587 | 587 | $subscription |
588 | 588 | ); |
@@ -591,13 +591,13 @@ discard block |
||
591 | 591 | |
592 | 592 | $invoice = $subscription->get_parent_invoice(); |
593 | 593 | |
594 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
595 | - unset( $columns['tax'] ); |
|
594 | + if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) { |
|
595 | + unset($columns['tax']); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | $table_class = 'w-100 bg-white'; |
599 | 599 | |
600 | - if ( ! is_admin() ) { |
|
600 | + if (!is_admin()) { |
|
601 | 601 | $table_class = 'table table-bordered'; |
602 | 602 | } |
603 | 603 | |
@@ -610,9 +610,9 @@ discard block |
||
610 | 610 | <tr> |
611 | 611 | <?php |
612 | 612 | |
613 | - foreach ( $columns as $key => $label ) { |
|
614 | - $key = esc_attr( $key ); |
|
615 | - $label = esc_html( $label ); |
|
613 | + foreach ($columns as $key => $label) { |
|
614 | + $key = esc_attr($key); |
|
615 | + $label = esc_html($label); |
|
616 | 616 | $class = 'text-left'; |
617 | 617 | |
618 | 618 | echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -625,48 +625,48 @@ discard block |
||
625 | 625 | |
626 | 626 | <?php |
627 | 627 | |
628 | - foreach( $subscription_group['items'] as $subscription_group_item ) : |
|
628 | + foreach ($subscription_group['items'] as $subscription_group_item) : |
|
629 | 629 | |
630 | 630 | echo '<tr>'; |
631 | 631 | |
632 | - foreach ( array_keys( $columns ) as $key ) { |
|
632 | + foreach (array_keys($columns) as $key) { |
|
633 | 633 | |
634 | 634 | $class = 'text-left'; |
635 | 635 | |
636 | 636 | echo "<td class='p-2 $class'>"; |
637 | 637 | |
638 | - switch( $key ) { |
|
638 | + switch ($key) { |
|
639 | 639 | |
640 | 640 | case 'item_name': |
641 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
642 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
641 | + $item_name = get_the_title($subscription_group_item['item_id']); |
|
642 | + $item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name; |
|
643 | 643 | |
644 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
645 | - echo esc_html( $item_name ); |
|
644 | + if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) { |
|
645 | + echo esc_html($item_name); |
|
646 | 646 | } else { |
647 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
647 | + printf('%1$s x %2$d', esc_html($item_name), (float) $subscription_group_item['quantity']); |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | break; |
651 | 651 | |
652 | 652 | case 'price': |
653 | - echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
653 | + echo wpinv_price($subscription_group_item['item_price'], $invoice->get_currency()); |
|
654 | 654 | break; |
655 | 655 | |
656 | 656 | case 'tax': |
657 | - echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
657 | + echo wpinv_price($subscription_group_item['tax'], $invoice->get_currency()); |
|
658 | 658 | break; |
659 | 659 | |
660 | 660 | case 'discount': |
661 | - echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
661 | + echo wpinv_price($subscription_group_item['discount'], $invoice->get_currency()); |
|
662 | 662 | break; |
663 | 663 | |
664 | 664 | case 'initial': |
665 | - echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
665 | + echo wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()); |
|
666 | 666 | break; |
667 | 667 | |
668 | 668 | case 'recurring': |
669 | - echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
669 | + echo '<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>'; |
|
670 | 670 | break; |
671 | 671 | |
672 | 672 | } |
@@ -679,24 +679,24 @@ discard block |
||
679 | 679 | |
680 | 680 | endforeach; |
681 | 681 | |
682 | - foreach( $subscription_group['fees'] as $subscription_group_fee ) : |
|
682 | + foreach ($subscription_group['fees'] as $subscription_group_fee) : |
|
683 | 683 | |
684 | 684 | echo '<tr>'; |
685 | 685 | |
686 | - foreach ( array_keys( $columns ) as $key ) { |
|
686 | + foreach (array_keys($columns) as $key) { |
|
687 | 687 | |
688 | 688 | $class = 'text-left'; |
689 | 689 | |
690 | 690 | echo "<td class='p-2 $class'>"; |
691 | 691 | |
692 | - switch( $key ) { |
|
692 | + switch ($key) { |
|
693 | 693 | |
694 | 694 | case 'item_name': |
695 | - echo esc_html( $subscription_group_fee['name'] ); |
|
695 | + echo esc_html($subscription_group_fee['name']); |
|
696 | 696 | break; |
697 | 697 | |
698 | 698 | case 'price': |
699 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
699 | + echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
700 | 700 | break; |
701 | 701 | |
702 | 702 | case 'tax': |
@@ -708,11 +708,11 @@ discard block |
||
708 | 708 | break; |
709 | 709 | |
710 | 710 | case 'initial': |
711 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
711 | + echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
712 | 712 | break; |
713 | 713 | |
714 | 714 | case 'recurring': |
715 | - echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
715 | + echo '<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>'; |
|
716 | 716 | break; |
717 | 717 | |
718 | 718 | } |
@@ -741,12 +741,12 @@ discard block |
||
741 | 741 | * @param WPInv_Subscription $subscription |
742 | 742 | * @param bool $skip_current |
743 | 743 | */ |
744 | -function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
|
744 | +function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) { |
|
745 | 745 | |
746 | 746 | // Fetch the subscription groups. |
747 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
747 | + $subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id()); |
|
748 | 748 | |
749 | - if ( empty( $subscription_groups ) ) { |
|
749 | + if (empty($subscription_groups)) { |
|
750 | 750 | return; |
751 | 751 | } |
752 | 752 | |
@@ -754,23 +754,23 @@ discard block |
||
754 | 754 | $columns = apply_filters( |
755 | 755 | 'getpaid_subscription_related_subscriptions_columns', |
756 | 756 | array( |
757 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
758 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
759 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
760 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
761 | - 'item' => __( 'Items', 'invoicing' ), |
|
762 | - 'status' => __( 'Status', 'invoicing' ), |
|
757 | + 'subscription' => __('Subscription', 'invoicing'), |
|
758 | + 'start_date' => __('Start Date', 'invoicing'), |
|
759 | + 'renewal_date' => __('Next Payment', 'invoicing'), |
|
760 | + 'renewals' => __('Payments', 'invoicing'), |
|
761 | + 'item' => __('Items', 'invoicing'), |
|
762 | + 'status' => __('Status', 'invoicing'), |
|
763 | 763 | ), |
764 | 764 | $subscription |
765 | 765 | ); |
766 | 766 | |
767 | - if ( $subscription->get_status() == 'pending' ) { |
|
768 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
767 | + if ($subscription->get_status() == 'pending') { |
|
768 | + unset($columns['start_date'], $columns['renewal_date']); |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | $table_class = 'w-100 bg-white'; |
772 | 772 | |
773 | - if ( ! is_admin() ) { |
|
773 | + if (!is_admin()) { |
|
774 | 774 | $table_class = 'table table-bordered'; |
775 | 775 | } |
776 | 776 | |
@@ -783,9 +783,9 @@ discard block |
||
783 | 783 | <tr> |
784 | 784 | <?php |
785 | 785 | |
786 | - foreach ( $columns as $key => $label ) { |
|
787 | - $key = esc_attr( $key ); |
|
788 | - $label = esc_html( $label ); |
|
786 | + foreach ($columns as $key => $label) { |
|
787 | + $key = esc_attr($key); |
|
788 | + $label = esc_html($label); |
|
789 | 789 | $class = 'text-left'; |
790 | 790 | |
791 | 791 | echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -798,62 +798,62 @@ discard block |
||
798 | 798 | |
799 | 799 | <?php |
800 | 800 | |
801 | - foreach( $subscription_groups as $subscription_group ) : |
|
801 | + foreach ($subscription_groups as $subscription_group) : |
|
802 | 802 | |
803 | 803 | // Do not list current subscription. |
804 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
804 | + if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) { |
|
805 | 805 | continue; |
806 | 806 | } |
807 | 807 | |
808 | 808 | // Ensure the subscription exists. |
809 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
809 | + $_suscription = new WPInv_Subscription($subscription_group['subscription_id']); |
|
810 | 810 | |
811 | - if ( ! $_suscription->exists() ) { |
|
811 | + if (!$_suscription->exists()) { |
|
812 | 812 | continue; |
813 | 813 | } |
814 | 814 | |
815 | 815 | echo '<tr>'; |
816 | 816 | |
817 | - foreach ( array_keys( $columns ) as $key ) { |
|
817 | + foreach (array_keys($columns) as $key) { |
|
818 | 818 | |
819 | 819 | $class = 'text-left'; |
820 | 820 | |
821 | 821 | echo "<td class='p-2 $class'>"; |
822 | 822 | |
823 | - switch( $key ) { |
|
823 | + switch ($key) { |
|
824 | 824 | |
825 | 825 | case 'status': |
826 | 826 | echo $_suscription->get_status_label_html(); |
827 | 827 | break; |
828 | 828 | |
829 | 829 | case 'item': |
830 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
831 | - echo implode( ' | ', $markup ); |
|
830 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
831 | + echo implode(' | ', $markup); |
|
832 | 832 | break; |
833 | 833 | |
834 | 834 | case 'renewals': |
835 | 835 | $max_bills = $_suscription->get_bill_times(); |
836 | - echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
836 | + echo $_suscription->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
837 | 837 | break; |
838 | 838 | |
839 | 839 | case 'renewal_date': |
840 | - echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "—"; |
|
840 | + echo $_suscription->is_active() ? getpaid_format_date_value($_suscription->get_expiration()) : "—"; |
|
841 | 841 | break; |
842 | 842 | |
843 | 843 | case 'start_date': |
844 | - echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
844 | + echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value($_suscription->get_date_created()); |
|
845 | 845 | break; |
846 | 846 | |
847 | 847 | case 'subscription': |
848 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
848 | + $url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url(); |
|
849 | 849 | printf( |
850 | 850 | '%1$s#%2$s%3$s', |
851 | - '<a href="' . esc_url( $url ) . '">', |
|
852 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
851 | + '<a href="' . esc_url($url) . '">', |
|
852 | + '<strong>' . intval($_suscription->get_id()) . '</strong>', |
|
853 | 853 | '</a>' |
854 | 854 | ); |
855 | 855 | |
856 | - echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
856 | + echo WPInv_Subscriptions_List_Table::column_amount($_suscription); |
|
857 | 857 | break; |
858 | 858 | |
859 | 859 | } |
@@ -1,32 +1,32 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | - // Is the request set up correctly? |
|
4 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
5 | - return aui()->alert( |
|
6 | - array( |
|
7 | - 'type' => 'warning', |
|
8 | - 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
9 | - ) |
|
10 | - ); |
|
11 | - wp_die( __( 'No payment form or item selected', 'invoicing' ), 400 ); |
|
12 | - } |
|
13 | - |
|
14 | - // Payment form or button? |
|
15 | - if ( ! empty( $_GET['form'] ) ) { |
|
16 | - |
|
17 | - $shortcode = sprintf( |
|
18 | - '[getpaid form=%s]', |
|
19 | - (int) urldecode( $_GET['form'] ) |
|
20 | - ); |
|
21 | - |
|
22 | - } else { |
|
23 | - |
|
24 | - $shortcode = sprintf( |
|
25 | - '[getpaid item=%s]', |
|
26 | - esc_attr( urldecode( $_GET['item'] ) ) |
|
27 | - ); |
|
28 | - |
|
29 | - } |
|
3 | + // Is the request set up correctly? |
|
4 | + if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
5 | + return aui()->alert( |
|
6 | + array( |
|
7 | + 'type' => 'warning', |
|
8 | + 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
9 | + ) |
|
10 | + ); |
|
11 | + wp_die( __( 'No payment form or item selected', 'invoicing' ), 400 ); |
|
12 | + } |
|
13 | + |
|
14 | + // Payment form or button? |
|
15 | + if ( ! empty( $_GET['form'] ) ) { |
|
16 | + |
|
17 | + $shortcode = sprintf( |
|
18 | + '[getpaid form=%s]', |
|
19 | + (int) urldecode( $_GET['form'] ) |
|
20 | + ); |
|
21 | + |
|
22 | + } else { |
|
23 | + |
|
24 | + $shortcode = sprintf( |
|
25 | + '[getpaid item=%s]', |
|
26 | + esc_attr( urldecode( $_GET['item'] ) ) |
|
27 | + ); |
|
28 | + |
|
29 | + } |
|
30 | 30 | |
31 | 31 | ?> |
32 | 32 | |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | <body class="body" style="font-weight: 400;"> |
52 | 52 | <div class="container my-5" style="max-width: 820px;"> |
53 | 53 | <?php |
54 | - do_action( 'getpaid_payment_form_embed_top' ); |
|
55 | - echo do_shortcode( $shortcode ); |
|
56 | - do_action( 'getpaid_payment_form_embed_bottom' ); |
|
57 | - ?> |
|
54 | + do_action( 'getpaid_payment_form_embed_top' ); |
|
55 | + echo do_shortcode( $shortcode ); |
|
56 | + do_action( 'getpaid_payment_form_embed_bottom' ); |
|
57 | + ?> |
|
58 | 58 | </div> |
59 | 59 | </body> |
60 | 60 | </html> |
@@ -1,29 +1,29 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Is the request set up correctly? |
4 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
4 | + if (empty($_GET['form']) && empty($_GET['item'])) { |
|
5 | 5 | return aui()->alert( |
6 | 6 | array( |
7 | 7 | 'type' => 'warning', |
8 | - 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
8 | + 'content' => __('No payment form or item selected', 'invoicing'), |
|
9 | 9 | ) |
10 | 10 | ); |
11 | - wp_die( __( 'No payment form or item selected', 'invoicing' ), 400 ); |
|
11 | + wp_die(__('No payment form or item selected', 'invoicing'), 400); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | // Payment form or button? |
15 | - if ( ! empty( $_GET['form'] ) ) { |
|
15 | + if (!empty($_GET['form'])) { |
|
16 | 16 | |
17 | 17 | $shortcode = sprintf( |
18 | 18 | '[getpaid form=%s]', |
19 | - (int) urldecode( $_GET['form'] ) |
|
19 | + (int) urldecode($_GET['form']) |
|
20 | 20 | ); |
21 | 21 | |
22 | 22 | } else { |
23 | 23 | |
24 | 24 | $shortcode = sprintf( |
25 | 25 | '[getpaid item=%s]', |
26 | - esc_attr( urldecode( $_GET['item'] ) ) |
|
26 | + esc_attr(urldecode($_GET['item'])) |
|
27 | 27 | ); |
28 | 28 | |
29 | 29 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | <head> |
37 | 37 | |
38 | - <meta charset="<?php bloginfo( 'charset' ); ?>"> |
|
38 | + <meta charset="<?php bloginfo('charset'); ?>"> |
|
39 | 39 | <meta name="viewport" content="width=device-width, initial-scale=1.0" > |
40 | 40 | |
41 | 41 | <meta name="robots" content="noindex,nofollow"> |
@@ -44,16 +44,16 @@ discard block |
||
44 | 44 | |
45 | 45 | <title>GetPaid</title> |
46 | 46 | |
47 | - <?php do_action( 'getpaid_payment_form_embed_head' ); ?> |
|
47 | + <?php do_action('getpaid_payment_form_embed_head'); ?> |
|
48 | 48 | |
49 | 49 | </head> |
50 | 50 | |
51 | 51 | <body class="body" style="font-weight: 400;"> |
52 | 52 | <div class="container my-5" style="max-width: 820px;"> |
53 | 53 | <?php |
54 | - do_action( 'getpaid_payment_form_embed_top' ); |
|
55 | - echo do_shortcode( $shortcode ); |
|
56 | - do_action( 'getpaid_payment_form_embed_bottom' ); |
|
54 | + do_action('getpaid_payment_form_embed_top'); |
|
55 | + echo do_shortcode($shortcode); |
|
56 | + do_action('getpaid_payment_form_embed_bottom'); |
|
57 | 57 | ?> |
58 | 58 | </div> |
59 | 59 | </body> |
@@ -7,64 +7,64 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Fetch the invoice. |
13 | -$invoice = new WPInv_Invoice( $invoice ); |
|
13 | +$invoice = new WPInv_Invoice($invoice); |
|
14 | 14 | |
15 | 15 | // @deprecated |
16 | -do_action( 'wpinv_success_content_before', $invoice ); |
|
17 | -do_action( 'wpinv_before_receipt', $invoice ); |
|
16 | +do_action('wpinv_success_content_before', $invoice); |
|
17 | +do_action('wpinv_before_receipt', $invoice); |
|
18 | 18 | |
19 | 19 | wpinv_print_errors(); |
20 | 20 | |
21 | 21 | // Prepare header text. |
22 | -if ( $invoice->is_paid() ) { |
|
22 | +if ($invoice->is_paid()) { |
|
23 | 23 | |
24 | 24 | $alert = aui()->alert( |
25 | 25 | array( |
26 | 26 | 'type' => 'success', |
27 | - 'content' => __( 'Thank you for your payment!', 'invoicing' ), |
|
27 | + 'content' => __('Thank you for your payment!', 'invoicing'), |
|
28 | 28 | ) |
29 | 29 | ); |
30 | 30 | |
31 | -} else if ( $invoice->is_refunded() ) { |
|
31 | +} else if ($invoice->is_refunded()) { |
|
32 | 32 | |
33 | 33 | $alert = aui()->alert( |
34 | 34 | array( |
35 | 35 | 'type' => 'info', |
36 | - 'content' => __( 'This invoice was refunded.', 'invoicing' ), |
|
36 | + 'content' => __('This invoice was refunded.', 'invoicing'), |
|
37 | 37 | ) |
38 | 38 | ); |
39 | 39 | |
40 | -} else if ( $invoice->is_held() ) { |
|
40 | +} else if ($invoice->is_held()) { |
|
41 | 41 | |
42 | 42 | $alert = aui()->alert( |
43 | 43 | array( |
44 | 44 | 'type' => 'info', |
45 | - 'content' => __( 'This invoice will be processed as soon we verify your payment.', 'invoicing' ), |
|
45 | + 'content' => __('This invoice will be processed as soon we verify your payment.', 'invoicing'), |
|
46 | 46 | ) |
47 | 47 | ); |
48 | 48 | |
49 | -} else if ( $invoice->needs_payment() ) { |
|
49 | +} else if ($invoice->needs_payment()) { |
|
50 | 50 | |
51 | - if ( ! empty( $_GET['token'] ) ) { |
|
51 | + if (!empty($_GET['token'])) { |
|
52 | 52 | |
53 | 53 | $alert = aui()->alert( |
54 | 54 | array( |
55 | 55 | 'type' => 'info', |
56 | - 'content' => __( "Sometimes it takes a few minutes for us to verify your payment. We'll notify you as soon as we've verified the payment.", 'invoicing' ), |
|
56 | + 'content' => __("Sometimes it takes a few minutes for us to verify your payment. We'll notify you as soon as we've verified the payment.", 'invoicing'), |
|
57 | 57 | ) |
58 | 58 | ); |
59 | 59 | |
60 | - } else if ( $invoice->is_due() ) { |
|
60 | + } else if ($invoice->is_due()) { |
|
61 | 61 | |
62 | 62 | $alert = aui()->alert( |
63 | 63 | array( |
64 | 64 | 'type' => 'danger', |
65 | 65 | 'content' => sprintf( |
66 | - __( 'This invoice was due on %.', 'invoicing' ), |
|
67 | - getpaid_format_date_value( $invoice->get_due_date() ) |
|
66 | + __('This invoice was due on %.', 'invoicing'), |
|
67 | + getpaid_format_date_value($invoice->get_due_date()) |
|
68 | 68 | ), |
69 | 69 | ) |
70 | 70 | ); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $alert = aui()->alert( |
75 | 75 | array( |
76 | 76 | 'type' => 'warning', |
77 | - 'content' => __( 'This invoice needs payment.', 'invoicing' ), |
|
77 | + 'content' => __('This invoice needs payment.', 'invoicing'), |
|
78 | 78 | ) |
79 | 79 | ); |
80 | 80 | |
@@ -89,19 +89,19 @@ discard block |
||
89 | 89 | |
90 | 90 | 'pay' => array( |
91 | 91 | 'url' => $invoice->get_checkout_payment_url(), |
92 | - 'name' => __( 'Pay For Invoice', 'invoicing' ), |
|
92 | + 'name' => __('Pay For Invoice', 'invoicing'), |
|
93 | 93 | 'class' => 'btn-success', |
94 | 94 | ), |
95 | 95 | |
96 | 96 | 'view' => array( |
97 | 97 | 'url' => $invoice->get_view_url(), |
98 | - 'name' => __( 'View Invoice', 'invoicing' ), |
|
98 | + 'name' => __('View Invoice', 'invoicing'), |
|
99 | 99 | 'class' => 'btn-primary', |
100 | 100 | ), |
101 | 101 | |
102 | 102 | 'history' => array( |
103 | 103 | 'url' => wpinv_get_history_page_uri(), |
104 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
104 | + 'name' => __('Invoice History', 'invoicing'), |
|
105 | 105 | 'class' => 'btn-warning', |
106 | 106 | ), |
107 | 107 | |
@@ -110,12 +110,12 @@ discard block |
||
110 | 110 | |
111 | 111 | ); |
112 | 112 | |
113 | -if ( ( ! $invoice->needs_payment() || $invoice->is_held() ) && isset( $actions['pay'] ) ) { |
|
114 | - unset( $actions['pay'] ); |
|
113 | +if ((!$invoice->needs_payment() || $invoice->is_held()) && isset($actions['pay'])) { |
|
114 | + unset($actions['pay']); |
|
115 | 115 | } |
116 | 116 | |
117 | -if ( ! is_user_logged_in() && isset( $actions['history'] ) ) { |
|
118 | - unset( $actions['history'] ); |
|
117 | +if (!is_user_logged_in() && isset($actions['history'])) { |
|
118 | + unset($actions['history']); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | ?> |
@@ -124,19 +124,19 @@ discard block |
||
124 | 124 | |
125 | 125 | <?php |
126 | 126 | |
127 | - do_action( 'wpinv_receipt_start', $invoice ); |
|
127 | + do_action('wpinv_receipt_start', $invoice); |
|
128 | 128 | |
129 | - if ( ! empty( $actions ) ) { |
|
129 | + if (!empty($actions)) { |
|
130 | 130 | |
131 | 131 | echo '<div class="wpinv-receipt-actions text-right mt-1 mb-4">'; |
132 | 132 | |
133 | - foreach ( $actions as $key => $action ) { |
|
133 | + foreach ($actions as $key => $action) { |
|
134 | 134 | |
135 | - $key = sanitize_html_class( $key ); |
|
136 | - $class = empty( $action['class'] ) ? 'btn-dark' : sanitize_html_class( $action['class'] ); |
|
137 | - $url = empty( $action['url'] ) ? '#' : esc_url( $action['url'] ); |
|
138 | - $attrs = empty( $action['attrs'] ) ? '' : $action['attrs']; |
|
139 | - $anchor = esc_html( $action['name'] ); |
|
135 | + $key = sanitize_html_class($key); |
|
136 | + $class = empty($action['class']) ? 'btn-dark' : sanitize_html_class($action['class']); |
|
137 | + $url = empty($action['url']) ? '#' : esc_url($action['url']); |
|
138 | + $attrs = empty($action['attrs']) ? '' : $action['attrs']; |
|
139 | + $anchor = esc_html($action['name']); |
|
140 | 140 | |
141 | 141 | echo "<a href='$url' class='btn btn-sm ml-1 $class $key' $attrs>$anchor</a>"; |
142 | 142 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | } |
147 | 147 | |
148 | - if ( ! empty( $alert ) ) { |
|
148 | + if (!empty($alert)) { |
|
149 | 149 | echo $alert; |
150 | 150 | } |
151 | 151 | |
@@ -154,19 +154,19 @@ discard block |
||
154 | 154 | <div class="wpinv-receipt-details"> |
155 | 155 | |
156 | 156 | <h4 class="wpinv-details-t mb-3 mt-3"> |
157 | - <?php echo apply_filters( 'wpinv_receipt_details_title', __( 'Invoice Details', 'invoicing' ), $invoice ); ?> |
|
157 | + <?php echo apply_filters('wpinv_receipt_details_title', __('Invoice Details', 'invoicing'), $invoice); ?> |
|
158 | 158 | </h4> |
159 | 159 | |
160 | - <?php getpaid_invoice_meta( $invoice ); ?> |
|
160 | + <?php getpaid_invoice_meta($invoice); ?> |
|
161 | 161 | |
162 | 162 | </div> |
163 | 163 | |
164 | - <?php do_action( 'wpinv_receipt_end', $invoice ); ?> |
|
164 | + <?php do_action('wpinv_receipt_end', $invoice); ?> |
|
165 | 165 | |
166 | 166 | </div> |
167 | 167 | |
168 | 168 | <?php |
169 | 169 | |
170 | 170 | // @deprecated |
171 | -do_action( 'wpinv_success_content_after', $invoice ); |
|
172 | -do_action( 'wpinv_after_receipt', $invoice ); |
|
171 | +do_action('wpinv_success_content_after', $invoice); |
|
172 | +do_action('wpinv_after_receipt', $invoice); |
@@ -13,30 +13,30 @@ discard block |
||
13 | 13 | class GetPaid_Bank_Transfer_Gateway extends GetPaid_Payment_Gateway { |
14 | 14 | |
15 | 15 | /** |
16 | - * Payment method id. |
|
17 | - * |
|
18 | - * @var string |
|
19 | - */ |
|
16 | + * Payment method id. |
|
17 | + * |
|
18 | + * @var string |
|
19 | + */ |
|
20 | 20 | public $id = 'bank_transfer'; |
21 | 21 | |
22 | - /** |
|
23 | - * An array of features that this gateway supports. |
|
24 | - * |
|
25 | - * @var array |
|
26 | - */ |
|
27 | - protected $supports = array( 'subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups' ); |
|
22 | + /** |
|
23 | + * An array of features that this gateway supports. |
|
24 | + * |
|
25 | + * @var array |
|
26 | + */ |
|
27 | + protected $supports = array( 'subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups' ); |
|
28 | 28 | |
29 | 29 | /** |
30 | - * Payment method order. |
|
31 | - * |
|
32 | - * @var int |
|
33 | - */ |
|
34 | - public $order = 8; |
|
30 | + * Payment method order. |
|
31 | + * |
|
32 | + * @var int |
|
33 | + */ |
|
34 | + public $order = 8; |
|
35 | 35 | |
36 | 36 | /** |
37 | - * Class constructor. |
|
38 | - */ |
|
39 | - public function __construct() { |
|
37 | + * Class constructor. |
|
38 | + */ |
|
39 | + public function __construct() { |
|
40 | 40 | parent::__construct(); |
41 | 41 | |
42 | 42 | $this->title = __( 'Direct bank transfer', 'invoicing' ); |
@@ -44,24 +44,24 @@ discard block |
||
44 | 44 | $this->checkout_button_text = __( 'Proceed', 'invoicing' ); |
45 | 45 | $this->instructions = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) ); |
46 | 46 | |
47 | - add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) ); |
|
48 | - add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 ); |
|
49 | - add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 ); |
|
50 | - add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 ); |
|
51 | - add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) ); |
|
52 | - add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 ); |
|
47 | + add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) ); |
|
48 | + add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 ); |
|
49 | + add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 ); |
|
50 | + add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 ); |
|
51 | + add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) ); |
|
52 | + add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 ); |
|
53 | 53 | |
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
57 | - * Process Payment. |
|
58 | - * |
|
59 | - * @param WPInv_Invoice $invoice Invoice. |
|
60 | - * @param array $submission_data Posted checkout fields. |
|
61 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
62 | - * @return array |
|
63 | - */ |
|
64 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
57 | + * Process Payment. |
|
58 | + * |
|
59 | + * @param WPInv_Invoice $invoice Invoice. |
|
60 | + * @param array $submission_data Posted checkout fields. |
|
61 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
62 | + * @return array |
|
63 | + */ |
|
64 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
65 | 65 | |
66 | 66 | // Add a transaction id. |
67 | 67 | $invoice->set_transaction_id( $invoice->generate_key('bt_') ); |
@@ -82,66 +82,66 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | - * Output for the order received page. |
|
86 | - * |
|
87 | - * @param WPInv_Invoice $invoice Invoice. |
|
88 | - */ |
|
89 | - public function thankyou_page( $invoice ) { |
|
85 | + * Output for the order received page. |
|
86 | + * |
|
87 | + * @param WPInv_Invoice $invoice Invoice. |
|
88 | + */ |
|
89 | + public function thankyou_page( $invoice ) { |
|
90 | 90 | |
91 | 91 | if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
92 | 92 | |
93 | - echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL; |
|
93 | + echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL; |
|
94 | 94 | |
95 | 95 | if ( ! empty( $this->instructions ) ) { |
96 | 96 | echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) ); |
97 | - } |
|
97 | + } |
|
98 | 98 | |
99 | - $this->bank_details( $invoice ); |
|
99 | + $this->bank_details( $invoice ); |
|
100 | 100 | |
101 | - echo '</div>'; |
|
101 | + echo '</div>'; |
|
102 | 102 | |
103 | 103 | } |
104 | 104 | |
105 | - } |
|
105 | + } |
|
106 | 106 | |
107 | 107 | /** |
108 | - * Add content to the WPI emails. |
|
109 | - * |
|
110 | - * @param WPInv_Invoice $invoice Invoice. |
|
111 | - * @param string $email_type Email format: plain text or HTML. |
|
112 | - * @param bool $sent_to_admin Sent to admin. |
|
113 | - */ |
|
114 | - public function email_instructions( $invoice, $email_type, $sent_to_admin ) { |
|
108 | + * Add content to the WPI emails. |
|
109 | + * |
|
110 | + * @param WPInv_Invoice $invoice Invoice. |
|
111 | + * @param string $email_type Email format: plain text or HTML. |
|
112 | + * @param bool $sent_to_admin Sent to admin. |
|
113 | + */ |
|
114 | + public function email_instructions( $invoice, $email_type, $sent_to_admin ) { |
|
115 | 115 | |
116 | - if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
|
116 | + if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
|
117 | 117 | |
118 | - echo '<div class="wpi-email-row getpaid-bank-transfer-details">'; |
|
118 | + echo '<div class="wpi-email-row getpaid-bank-transfer-details">'; |
|
119 | 119 | |
120 | - if ( $this->instructions ) { |
|
121 | - echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL ); |
|
120 | + if ( $this->instructions ) { |
|
121 | + echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL ); |
|
122 | 122 | } |
123 | 123 | |
124 | - $this->bank_details( $invoice ); |
|
124 | + $this->bank_details( $invoice ); |
|
125 | 125 | |
126 | - echo '</div>'; |
|
126 | + echo '</div>'; |
|
127 | 127 | |
128 | - } |
|
128 | + } |
|
129 | 129 | |
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
133 | - * Get bank details and place into a list format. |
|
134 | - * |
|
135 | - * @param WPInv_Invoice $invoice Invoice. |
|
136 | - */ |
|
137 | - protected function bank_details( $invoice ) { |
|
133 | + * Get bank details and place into a list format. |
|
134 | + * |
|
135 | + * @param WPInv_Invoice $invoice Invoice. |
|
136 | + */ |
|
137 | + protected function bank_details( $invoice ) { |
|
138 | 138 | |
139 | - // Get the invoice country and country $locale. |
|
140 | - $country = $invoice->get_country(); |
|
141 | - $locale = $this->get_country_locale(); |
|
139 | + // Get the invoice country and country $locale. |
|
140 | + $country = $invoice->get_country(); |
|
141 | + $locale = $this->get_country_locale(); |
|
142 | 142 | |
143 | - // Get sortcode label in the $locale array and use appropriate one. |
|
144 | - $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
143 | + // Get sortcode label in the $locale array and use appropriate one. |
|
144 | + $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
145 | 145 | |
146 | 146 | $bank_fields = array( |
147 | 147 | 'ac_name' => __( 'Account Name', 'invoicing' ), |
@@ -170,144 +170,144 @@ discard block |
||
170 | 170 | return; |
171 | 171 | } |
172 | 172 | |
173 | - echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL; |
|
173 | + echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL; |
|
174 | + |
|
175 | + echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL; |
|
176 | + |
|
177 | + foreach ( $bank_info as $key => $data ) { |
|
178 | + |
|
179 | + $key = sanitize_html_class( $key ); |
|
180 | + $label = wp_kses_post( $data['label'] ); |
|
181 | + $value = wp_kses_post( wptexturize( $data['value'] ) ); |
|
182 | + |
|
183 | + echo "<tr class='getpaid-bank-transfer-$key'><th class='font-weight-bold'>$label</th><td class='w-75'>$value</td></tr>" . PHP_EOL; |
|
184 | + } |
|
174 | 185 | |
175 | - echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL; |
|
186 | + echo '</table>'; |
|
176 | 187 | |
177 | - foreach ( $bank_info as $key => $data ) { |
|
188 | + } |
|
178 | 189 | |
179 | - $key = sanitize_html_class( $key ); |
|
180 | - $label = wp_kses_post( $data['label'] ); |
|
181 | - $value = wp_kses_post( wptexturize( $data['value'] ) ); |
|
190 | + /** |
|
191 | + * Get country locale if localized. |
|
192 | + * |
|
193 | + * @return array |
|
194 | + */ |
|
195 | + public function get_country_locale() { |
|
196 | + |
|
197 | + if ( empty( $this->locale ) ) { |
|
198 | + |
|
199 | + // Locale information to be used - only those that are not 'Sort Code'. |
|
200 | + $this->locale = apply_filters( |
|
201 | + 'getpaid_get_bank_transfer_locale', |
|
202 | + array( |
|
203 | + 'AU' => array( |
|
204 | + 'sortcode' => array( |
|
205 | + 'label' => __( 'BSB', 'invoicing' ), |
|
206 | + ), |
|
207 | + ), |
|
208 | + 'CA' => array( |
|
209 | + 'sortcode' => array( |
|
210 | + 'label' => __( 'Bank transit number', 'invoicing' ), |
|
211 | + ), |
|
212 | + ), |
|
213 | + 'IN' => array( |
|
214 | + 'sortcode' => array( |
|
215 | + 'label' => __( 'IFSC', 'invoicing' ), |
|
216 | + ), |
|
217 | + ), |
|
218 | + 'IT' => array( |
|
219 | + 'sortcode' => array( |
|
220 | + 'label' => __( 'Branch sort', 'invoicing' ), |
|
221 | + ), |
|
222 | + ), |
|
223 | + 'NZ' => array( |
|
224 | + 'sortcode' => array( |
|
225 | + 'label' => __( 'Bank code', 'invoicing' ), |
|
226 | + ), |
|
227 | + ), |
|
228 | + 'SE' => array( |
|
229 | + 'sortcode' => array( |
|
230 | + 'label' => __( 'Bank code', 'invoicing' ), |
|
231 | + ), |
|
232 | + ), |
|
233 | + 'US' => array( |
|
234 | + 'sortcode' => array( |
|
235 | + 'label' => __( 'Routing number', 'invoicing' ), |
|
236 | + ), |
|
237 | + ), |
|
238 | + 'ZA' => array( |
|
239 | + 'sortcode' => array( |
|
240 | + 'label' => __( 'Branch code', 'invoicing' ), |
|
241 | + ), |
|
242 | + ), |
|
243 | + ) |
|
244 | + ); |
|
182 | 245 | |
183 | - echo "<tr class='getpaid-bank-transfer-$key'><th class='font-weight-bold'>$label</th><td class='w-75'>$value</td></tr>" . PHP_EOL; |
|
184 | - } |
|
246 | + } |
|
185 | 247 | |
186 | - echo '</table>'; |
|
248 | + return $this->locale; |
|
187 | 249 | |
188 | 250 | } |
189 | 251 | |
190 | 252 | /** |
191 | - * Get country locale if localized. |
|
192 | - * |
|
193 | - * @return array |
|
194 | - */ |
|
195 | - public function get_country_locale() { |
|
196 | - |
|
197 | - if ( empty( $this->locale ) ) { |
|
198 | - |
|
199 | - // Locale information to be used - only those that are not 'Sort Code'. |
|
200 | - $this->locale = apply_filters( |
|
201 | - 'getpaid_get_bank_transfer_locale', |
|
202 | - array( |
|
203 | - 'AU' => array( |
|
204 | - 'sortcode' => array( |
|
205 | - 'label' => __( 'BSB', 'invoicing' ), |
|
206 | - ), |
|
207 | - ), |
|
208 | - 'CA' => array( |
|
209 | - 'sortcode' => array( |
|
210 | - 'label' => __( 'Bank transit number', 'invoicing' ), |
|
211 | - ), |
|
212 | - ), |
|
213 | - 'IN' => array( |
|
214 | - 'sortcode' => array( |
|
215 | - 'label' => __( 'IFSC', 'invoicing' ), |
|
216 | - ), |
|
217 | - ), |
|
218 | - 'IT' => array( |
|
219 | - 'sortcode' => array( |
|
220 | - 'label' => __( 'Branch sort', 'invoicing' ), |
|
221 | - ), |
|
222 | - ), |
|
223 | - 'NZ' => array( |
|
224 | - 'sortcode' => array( |
|
225 | - 'label' => __( 'Bank code', 'invoicing' ), |
|
226 | - ), |
|
227 | - ), |
|
228 | - 'SE' => array( |
|
229 | - 'sortcode' => array( |
|
230 | - 'label' => __( 'Bank code', 'invoicing' ), |
|
231 | - ), |
|
232 | - ), |
|
233 | - 'US' => array( |
|
234 | - 'sortcode' => array( |
|
235 | - 'label' => __( 'Routing number', 'invoicing' ), |
|
236 | - ), |
|
237 | - ), |
|
238 | - 'ZA' => array( |
|
239 | - 'sortcode' => array( |
|
240 | - 'label' => __( 'Branch code', 'invoicing' ), |
|
241 | - ), |
|
242 | - ), |
|
243 | - ) |
|
244 | - ); |
|
245 | - |
|
246 | - } |
|
247 | - |
|
248 | - return $this->locale; |
|
249 | - |
|
250 | - } |
|
251 | - |
|
252 | - /** |
|
253 | - * Filters the gateway settings. |
|
254 | - * |
|
255 | - * @param array $admin_settings |
|
256 | - */ |
|
257 | - public function admin_settings( $admin_settings ) { |
|
253 | + * Filters the gateway settings. |
|
254 | + * |
|
255 | + * @param array $admin_settings |
|
256 | + */ |
|
257 | + public function admin_settings( $admin_settings ) { |
|
258 | 258 | |
259 | 259 | $admin_settings['bank_transfer_desc']['std'] = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ); |
260 | - $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' ); |
|
260 | + $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' ); |
|
261 | 261 | |
262 | - $locale = $this->get_country_locale(); |
|
262 | + $locale = $this->get_country_locale(); |
|
263 | 263 | |
264 | - // Get sortcode label in the $locale array and use appropriate one. |
|
265 | - $country = wpinv_default_billing_country(); |
|
266 | - $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
264 | + // Get sortcode label in the $locale array and use appropriate one. |
|
265 | + $country = wpinv_default_billing_country(); |
|
266 | + $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
267 | 267 | |
268 | - $admin_settings['bank_transfer_ac_name'] = array( |
|
268 | + $admin_settings['bank_transfer_ac_name'] = array( |
|
269 | 269 | 'type' => 'text', |
270 | 270 | 'id' => 'bank_transfer_ac_name', |
271 | 271 | 'name' => __( 'Account Name', 'invoicing' ), |
272 | - ); |
|
272 | + ); |
|
273 | 273 | |
274 | - $admin_settings['bank_transfer_ac_no'] = array( |
|
274 | + $admin_settings['bank_transfer_ac_no'] = array( |
|
275 | 275 | 'type' => 'text', |
276 | 276 | 'id' => 'bank_transfer_ac_no', |
277 | 277 | 'name' => __( 'Account Number', 'invoicing' ), |
278 | - ); |
|
278 | + ); |
|
279 | 279 | |
280 | - $admin_settings['bank_transfer_bank_name'] = array( |
|
280 | + $admin_settings['bank_transfer_bank_name'] = array( |
|
281 | 281 | 'type' => 'text', |
282 | 282 | 'id' => 'bank_transfer_bank_name', |
283 | 283 | 'name' => __( 'Bank Name', 'invoicing' ), |
284 | - ); |
|
284 | + ); |
|
285 | 285 | |
286 | - $admin_settings['bank_transfer_ifsc'] = array( |
|
286 | + $admin_settings['bank_transfer_ifsc'] = array( |
|
287 | 287 | 'type' => 'text', |
288 | 288 | 'id' => 'bank_transfer_ifsc', |
289 | 289 | 'name' => __( 'IFSC Code', 'invoicing' ), |
290 | - ); |
|
290 | + ); |
|
291 | 291 | |
292 | - $admin_settings['bank_transfer_iban'] = array( |
|
292 | + $admin_settings['bank_transfer_iban'] = array( |
|
293 | 293 | 'type' => 'text', |
294 | 294 | 'id' => 'bank_transfer_iban', |
295 | 295 | 'name' => __( 'IBAN', 'invoicing' ), |
296 | - ); |
|
296 | + ); |
|
297 | 297 | |
298 | - $admin_settings['bank_transfer_bic'] = array( |
|
298 | + $admin_settings['bank_transfer_bic'] = array( |
|
299 | 299 | 'type' => 'text', |
300 | 300 | 'id' => 'bank_transfer_bic', |
301 | 301 | 'name' => __( 'BIC/Swift Code', 'invoicing' ), |
302 | - ); |
|
302 | + ); |
|
303 | 303 | |
304 | - $admin_settings['bank_transfer_sort_code'] = array( |
|
305 | - 'type' => 'text', |
|
306 | - 'id' => 'bank_transfer_sort_code', |
|
307 | - 'name' => $sortcode, |
|
308 | - ); |
|
304 | + $admin_settings['bank_transfer_sort_code'] = array( |
|
305 | + 'type' => 'text', |
|
306 | + 'id' => 'bank_transfer_sort_code', |
|
307 | + 'name' => $sortcode, |
|
308 | + ); |
|
309 | 309 | |
310 | - $admin_settings['bank_transfer_info'] = array( |
|
310 | + $admin_settings['bank_transfer_info'] = array( |
|
311 | 311 | 'id' => 'bank_transfer_info', |
312 | 312 | 'name' => __( 'Instructions', 'invoicing' ), |
313 | 313 | 'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ), |
@@ -317,17 +317,17 @@ discard block |
||
317 | 317 | 'rows' => 5 |
318 | 318 | ); |
319 | 319 | |
320 | - return $admin_settings; |
|
321 | - } |
|
320 | + return $admin_settings; |
|
321 | + } |
|
322 | 322 | |
323 | - /** |
|
324 | - * Processes invoice addons. |
|
325 | - * |
|
326 | - * @param WPInv_Invoice $invoice |
|
327 | - * @param GetPaid_Form_Item[] $items |
|
328 | - * @return WPInv_Invoice |
|
329 | - */ |
|
330 | - public function process_addons( $invoice, $items ) { |
|
323 | + /** |
|
324 | + * Processes invoice addons. |
|
325 | + * |
|
326 | + * @param WPInv_Invoice $invoice |
|
327 | + * @param GetPaid_Form_Item[] $items |
|
328 | + * @return WPInv_Invoice |
|
329 | + */ |
|
330 | + public function process_addons( $invoice, $items ) { |
|
331 | 331 | |
332 | 332 | foreach ( $items as $item ) { |
333 | 333 | $invoice->add_item( $item ); |
@@ -335,70 +335,70 @@ discard block |
||
335 | 335 | |
336 | 336 | $invoice->recalculate_total(); |
337 | 337 | $invoice->save(); |
338 | - } |
|
338 | + } |
|
339 | 339 | |
340 | - /** |
|
341 | - * (Maybe) renews a bank transfer subscription profile. |
|
342 | - * |
|
343 | - * |
|
340 | + /** |
|
341 | + * (Maybe) renews a bank transfer subscription profile. |
|
342 | + * |
|
343 | + * |
|
344 | 344 | * @param WPInv_Subscription $subscription |
345 | - */ |
|
346 | - public function maybe_renew_subscription( $subscription ) { |
|
345 | + */ |
|
346 | + public function maybe_renew_subscription( $subscription ) { |
|
347 | 347 | |
348 | 348 | // Ensure its our subscription && it's active. |
349 | 349 | if ( $this->id == $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) { |
350 | - $subscription->create_payment(); |
|
350 | + $subscription->create_payment(); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | } |
354 | 354 | |
355 | - /** |
|
356 | - * Process a bank transfer payment. |
|
357 | - * |
|
358 | - * |
|
355 | + /** |
|
356 | + * Process a bank transfer payment. |
|
357 | + * |
|
358 | + * |
|
359 | 359 | * @param WPInv_Invoice $invoice |
360 | - */ |
|
361 | - public function invoice_paid( $invoice ) { |
|
360 | + */ |
|
361 | + public function invoice_paid( $invoice ) { |
|
362 | 362 | |
363 | - // Abort if not paid by bank transfer. |
|
364 | - if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) { |
|
365 | - return; |
|
366 | - } |
|
363 | + // Abort if not paid by bank transfer. |
|
364 | + if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) { |
|
365 | + return; |
|
366 | + } |
|
367 | 367 | |
368 | - // Is it a parent payment? |
|
369 | - if ( 0 == $invoice->get_parent_id() ) { |
|
368 | + // Is it a parent payment? |
|
369 | + if ( 0 == $invoice->get_parent_id() ) { |
|
370 | 370 | |
371 | - // (Maybe) activate subscriptions. |
|
372 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
371 | + // (Maybe) activate subscriptions. |
|
372 | + $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
373 | 373 | |
374 | - if ( ! empty( $subscriptions ) ) { |
|
375 | - $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions ); |
|
374 | + if ( ! empty( $subscriptions ) ) { |
|
375 | + $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions ); |
|
376 | 376 | |
377 | - foreach ( $subscriptions as $subscription ) { |
|
378 | - if ( $subscription->exists() ) { |
|
379 | - $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
380 | - $expiry = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
377 | + foreach ( $subscriptions as $subscription ) { |
|
378 | + if ( $subscription->exists() ) { |
|
379 | + $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
380 | + $expiry = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
381 | 381 | |
382 | - $subscription->set_next_renewal_date( $expiry ); |
|
383 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
384 | - $subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ); |
|
385 | - $subscription->activate(); |
|
386 | - } |
|
387 | - } |
|
382 | + $subscription->set_next_renewal_date( $expiry ); |
|
383 | + $subscription->set_date_created( current_time( 'mysql' ) ); |
|
384 | + $subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ); |
|
385 | + $subscription->activate(); |
|
386 | + } |
|
387 | + } |
|
388 | 388 | |
389 | - } |
|
389 | + } |
|
390 | 390 | |
391 | - } else { |
|
391 | + } else { |
|
392 | 392 | |
393 | - $subscription = getpaid_get_subscription( $invoice->get_subscription_id() ); |
|
393 | + $subscription = getpaid_get_subscription( $invoice->get_subscription_id() ); |
|
394 | 394 | |
395 | - // Renew the subscription. |
|
396 | - if ( $subscription && $subscription->exists() ) { |
|
397 | - $subscription->add_payment( array(), $invoice ); |
|
398 | - $subscription->renew(); |
|
399 | - } |
|
395 | + // Renew the subscription. |
|
396 | + if ( $subscription && $subscription->exists() ) { |
|
397 | + $subscription->add_payment( array(), $invoice ); |
|
398 | + $subscription->renew(); |
|
399 | + } |
|
400 | 400 | |
401 | - } |
|
401 | + } |
|
402 | 402 | |
403 | 403 | } |
404 | 404 |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Bank transfer Payment Gateway class. |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @var array |
26 | 26 | */ |
27 | - protected $supports = array( 'subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups' ); |
|
27 | + protected $supports = array('subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups'); |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Payment method order. |
@@ -39,17 +39,17 @@ discard block |
||
39 | 39 | public function __construct() { |
40 | 40 | parent::__construct(); |
41 | 41 | |
42 | - $this->title = __( 'Direct bank transfer', 'invoicing' ); |
|
43 | - $this->method_title = __( 'Bank transfer', 'invoicing' ); |
|
44 | - $this->checkout_button_text = __( 'Proceed', 'invoicing' ); |
|
45 | - $this->instructions = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) ); |
|
42 | + $this->title = __('Direct bank transfer', 'invoicing'); |
|
43 | + $this->method_title = __('Bank transfer', 'invoicing'); |
|
44 | + $this->checkout_button_text = __('Proceed', 'invoicing'); |
|
45 | + $this->instructions = apply_filters('wpinv_bank_instructions', $this->get_option('info')); |
|
46 | 46 | |
47 | - add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) ); |
|
48 | - add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 ); |
|
49 | - add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 ); |
|
50 | - add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 ); |
|
51 | - add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) ); |
|
52 | - add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 ); |
|
47 | + add_action('wpinv_receipt_end', array($this, 'thankyou_page')); |
|
48 | + add_action('getpaid_invoice_line_items', array($this, 'thankyou_page'), 40); |
|
49 | + add_action('wpinv_pdf_content_billing', array($this, 'thankyou_page'), 11); |
|
50 | + add_action('wpinv_email_invoice_details', array($this, 'email_instructions'), 10, 3); |
|
51 | + add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription')); |
|
52 | + add_action('getpaid_invoice_status_publish', array($this, 'invoice_paid'), 20); |
|
53 | 53 | |
54 | 54 | } |
55 | 55 | |
@@ -61,23 +61,23 @@ discard block |
||
61 | 61 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
62 | 62 | * @return array |
63 | 63 | */ |
64 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
64 | + public function process_payment($invoice, $submission_data, $submission) { |
|
65 | 65 | |
66 | 66 | // Add a transaction id. |
67 | - $invoice->set_transaction_id( $invoice->generate_key('bt_') ); |
|
67 | + $invoice->set_transaction_id($invoice->generate_key('bt_')); |
|
68 | 68 | |
69 | 69 | // Set it as pending payment. |
70 | - if ( ! $invoice->needs_payment() ) { |
|
70 | + if (!$invoice->needs_payment()) { |
|
71 | 71 | $invoice->mark_paid(); |
72 | - } else if ( ! $invoice->is_paid() ) { |
|
73 | - $invoice->set_status( 'wpi-onhold' ); |
|
72 | + } else if (!$invoice->is_paid()) { |
|
73 | + $invoice->set_status('wpi-onhold'); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | // Save it. |
77 | 77 | $invoice->save(); |
78 | 78 | |
79 | 79 | // Send to the success page. |
80 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
80 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
81 | 81 | |
82 | 82 | } |
83 | 83 | |
@@ -86,17 +86,17 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @param WPInv_Invoice $invoice Invoice. |
88 | 88 | */ |
89 | - public function thankyou_page( $invoice ) { |
|
89 | + public function thankyou_page($invoice) { |
|
90 | 90 | |
91 | - if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
|
91 | + if ('bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) { |
|
92 | 92 | |
93 | 93 | echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL; |
94 | 94 | |
95 | - if ( ! empty( $this->instructions ) ) { |
|
96 | - echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) ); |
|
95 | + if (!empty($this->instructions)) { |
|
96 | + echo wp_kses_post(wpautop(wptexturize($this->instructions))); |
|
97 | 97 | } |
98 | 98 | |
99 | - $this->bank_details( $invoice ); |
|
99 | + $this->bank_details($invoice); |
|
100 | 100 | |
101 | 101 | echo '</div>'; |
102 | 102 | |
@@ -111,17 +111,17 @@ discard block |
||
111 | 111 | * @param string $email_type Email format: plain text or HTML. |
112 | 112 | * @param bool $sent_to_admin Sent to admin. |
113 | 113 | */ |
114 | - public function email_instructions( $invoice, $email_type, $sent_to_admin ) { |
|
114 | + public function email_instructions($invoice, $email_type, $sent_to_admin) { |
|
115 | 115 | |
116 | - if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
|
116 | + if (!$sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) { |
|
117 | 117 | |
118 | 118 | echo '<div class="wpi-email-row getpaid-bank-transfer-details">'; |
119 | 119 | |
120 | - if ( $this->instructions ) { |
|
121 | - echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL ); |
|
120 | + if ($this->instructions) { |
|
121 | + echo wp_kses_post(wpautop(wptexturize($this->instructions)) . PHP_EOL); |
|
122 | 122 | } |
123 | 123 | |
124 | - $this->bank_details( $invoice ); |
|
124 | + $this->bank_details($invoice); |
|
125 | 125 | |
126 | 126 | echo '</div>'; |
127 | 127 | |
@@ -134,51 +134,51 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @param WPInv_Invoice $invoice Invoice. |
136 | 136 | */ |
137 | - protected function bank_details( $invoice ) { |
|
137 | + protected function bank_details($invoice) { |
|
138 | 138 | |
139 | 139 | // Get the invoice country and country $locale. |
140 | 140 | $country = $invoice->get_country(); |
141 | 141 | $locale = $this->get_country_locale(); |
142 | 142 | |
143 | 143 | // Get sortcode label in the $locale array and use appropriate one. |
144 | - $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
144 | + $sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing'); |
|
145 | 145 | |
146 | 146 | $bank_fields = array( |
147 | - 'ac_name' => __( 'Account Name', 'invoicing' ), |
|
148 | - 'ac_no' => __( 'Account Number', 'invoicing' ), |
|
149 | - 'bank_name' => __( 'Bank Name', 'invoicing' ), |
|
150 | - 'ifsc' => __( 'IFSC code', 'invoicing' ), |
|
151 | - 'iban' => __( 'IBAN', 'invoicing' ), |
|
152 | - 'bic' => __( 'BIC/Swift code', 'invoicing' ), |
|
147 | + 'ac_name' => __('Account Name', 'invoicing'), |
|
148 | + 'ac_no' => __('Account Number', 'invoicing'), |
|
149 | + 'bank_name' => __('Bank Name', 'invoicing'), |
|
150 | + 'ifsc' => __('IFSC code', 'invoicing'), |
|
151 | + 'iban' => __('IBAN', 'invoicing'), |
|
152 | + 'bic' => __('BIC/Swift code', 'invoicing'), |
|
153 | 153 | 'sort_code' => $sortcode, |
154 | 154 | ); |
155 | 155 | |
156 | 156 | $bank_info = array(); |
157 | 157 | |
158 | - foreach ( $bank_fields as $field => $label ) { |
|
159 | - $value = $this->get_option( $field ); |
|
158 | + foreach ($bank_fields as $field => $label) { |
|
159 | + $value = $this->get_option($field); |
|
160 | 160 | |
161 | - if ( ! empty( $value ) ) { |
|
162 | - $bank_info[$field] = array( 'label' => $label, 'value' => $value ); |
|
161 | + if (!empty($value)) { |
|
162 | + $bank_info[$field] = array('label' => $label, 'value' => $value); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | } |
166 | 166 | |
167 | - $bank_info = apply_filters( 'wpinv_bank_info', $bank_info ); |
|
167 | + $bank_info = apply_filters('wpinv_bank_info', $bank_info); |
|
168 | 168 | |
169 | - if ( empty( $bank_info ) ) { |
|
169 | + if (empty($bank_info)) { |
|
170 | 170 | return; |
171 | 171 | } |
172 | 172 | |
173 | - echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL; |
|
173 | + echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters('wpinv_receipt_bank_details_title', __('Bank Details', 'invoicing')) . '</h3>' . PHP_EOL; |
|
174 | 174 | |
175 | 175 | echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL; |
176 | 176 | |
177 | - foreach ( $bank_info as $key => $data ) { |
|
177 | + foreach ($bank_info as $key => $data) { |
|
178 | 178 | |
179 | - $key = sanitize_html_class( $key ); |
|
180 | - $label = wp_kses_post( $data['label'] ); |
|
181 | - $value = wp_kses_post( wptexturize( $data['value'] ) ); |
|
179 | + $key = sanitize_html_class($key); |
|
180 | + $label = wp_kses_post($data['label']); |
|
181 | + $value = wp_kses_post(wptexturize($data['value'])); |
|
182 | 182 | |
183 | 183 | echo "<tr class='getpaid-bank-transfer-$key'><th class='font-weight-bold'>$label</th><td class='w-75'>$value</td></tr>" . PHP_EOL; |
184 | 184 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | */ |
195 | 195 | public function get_country_locale() { |
196 | 196 | |
197 | - if ( empty( $this->locale ) ) { |
|
197 | + if (empty($this->locale)) { |
|
198 | 198 | |
199 | 199 | // Locale information to be used - only those that are not 'Sort Code'. |
200 | 200 | $this->locale = apply_filters( |
@@ -202,42 +202,42 @@ discard block |
||
202 | 202 | array( |
203 | 203 | 'AU' => array( |
204 | 204 | 'sortcode' => array( |
205 | - 'label' => __( 'BSB', 'invoicing' ), |
|
205 | + 'label' => __('BSB', 'invoicing'), |
|
206 | 206 | ), |
207 | 207 | ), |
208 | 208 | 'CA' => array( |
209 | 209 | 'sortcode' => array( |
210 | - 'label' => __( 'Bank transit number', 'invoicing' ), |
|
210 | + 'label' => __('Bank transit number', 'invoicing'), |
|
211 | 211 | ), |
212 | 212 | ), |
213 | 213 | 'IN' => array( |
214 | 214 | 'sortcode' => array( |
215 | - 'label' => __( 'IFSC', 'invoicing' ), |
|
215 | + 'label' => __('IFSC', 'invoicing'), |
|
216 | 216 | ), |
217 | 217 | ), |
218 | 218 | 'IT' => array( |
219 | 219 | 'sortcode' => array( |
220 | - 'label' => __( 'Branch sort', 'invoicing' ), |
|
220 | + 'label' => __('Branch sort', 'invoicing'), |
|
221 | 221 | ), |
222 | 222 | ), |
223 | 223 | 'NZ' => array( |
224 | 224 | 'sortcode' => array( |
225 | - 'label' => __( 'Bank code', 'invoicing' ), |
|
225 | + 'label' => __('Bank code', 'invoicing'), |
|
226 | 226 | ), |
227 | 227 | ), |
228 | 228 | 'SE' => array( |
229 | 229 | 'sortcode' => array( |
230 | - 'label' => __( 'Bank code', 'invoicing' ), |
|
230 | + 'label' => __('Bank code', 'invoicing'), |
|
231 | 231 | ), |
232 | 232 | ), |
233 | 233 | 'US' => array( |
234 | 234 | 'sortcode' => array( |
235 | - 'label' => __( 'Routing number', 'invoicing' ), |
|
235 | + 'label' => __('Routing number', 'invoicing'), |
|
236 | 236 | ), |
237 | 237 | ), |
238 | 238 | 'ZA' => array( |
239 | 239 | 'sortcode' => array( |
240 | - 'label' => __( 'Branch code', 'invoicing' ), |
|
240 | + 'label' => __('Branch code', 'invoicing'), |
|
241 | 241 | ), |
242 | 242 | ), |
243 | 243 | ) |
@@ -254,51 +254,51 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @param array $admin_settings |
256 | 256 | */ |
257 | - public function admin_settings( $admin_settings ) { |
|
257 | + public function admin_settings($admin_settings) { |
|
258 | 258 | |
259 | - $admin_settings['bank_transfer_desc']['std'] = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ); |
|
260 | - $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' ); |
|
259 | + $admin_settings['bank_transfer_desc']['std'] = __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing'); |
|
260 | + $admin_settings['bank_transfer_active']['desc'] = __('Enable bank transfer', 'invoicing'); |
|
261 | 261 | |
262 | - $locale = $this->get_country_locale(); |
|
262 | + $locale = $this->get_country_locale(); |
|
263 | 263 | |
264 | 264 | // Get sortcode label in the $locale array and use appropriate one. |
265 | 265 | $country = wpinv_default_billing_country(); |
266 | - $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
266 | + $sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing'); |
|
267 | 267 | |
268 | 268 | $admin_settings['bank_transfer_ac_name'] = array( |
269 | 269 | 'type' => 'text', |
270 | 270 | 'id' => 'bank_transfer_ac_name', |
271 | - 'name' => __( 'Account Name', 'invoicing' ), |
|
271 | + 'name' => __('Account Name', 'invoicing'), |
|
272 | 272 | ); |
273 | 273 | |
274 | 274 | $admin_settings['bank_transfer_ac_no'] = array( |
275 | 275 | 'type' => 'text', |
276 | 276 | 'id' => 'bank_transfer_ac_no', |
277 | - 'name' => __( 'Account Number', 'invoicing' ), |
|
277 | + 'name' => __('Account Number', 'invoicing'), |
|
278 | 278 | ); |
279 | 279 | |
280 | 280 | $admin_settings['bank_transfer_bank_name'] = array( |
281 | 281 | 'type' => 'text', |
282 | 282 | 'id' => 'bank_transfer_bank_name', |
283 | - 'name' => __( 'Bank Name', 'invoicing' ), |
|
283 | + 'name' => __('Bank Name', 'invoicing'), |
|
284 | 284 | ); |
285 | 285 | |
286 | 286 | $admin_settings['bank_transfer_ifsc'] = array( |
287 | 287 | 'type' => 'text', |
288 | 288 | 'id' => 'bank_transfer_ifsc', |
289 | - 'name' => __( 'IFSC Code', 'invoicing' ), |
|
289 | + 'name' => __('IFSC Code', 'invoicing'), |
|
290 | 290 | ); |
291 | 291 | |
292 | 292 | $admin_settings['bank_transfer_iban'] = array( |
293 | 293 | 'type' => 'text', |
294 | 294 | 'id' => 'bank_transfer_iban', |
295 | - 'name' => __( 'IBAN', 'invoicing' ), |
|
295 | + 'name' => __('IBAN', 'invoicing'), |
|
296 | 296 | ); |
297 | 297 | |
298 | 298 | $admin_settings['bank_transfer_bic'] = array( |
299 | 299 | 'type' => 'text', |
300 | 300 | 'id' => 'bank_transfer_bic', |
301 | - 'name' => __( 'BIC/Swift Code', 'invoicing' ), |
|
301 | + 'name' => __('BIC/Swift Code', 'invoicing'), |
|
302 | 302 | ); |
303 | 303 | |
304 | 304 | $admin_settings['bank_transfer_sort_code'] = array( |
@@ -309,10 +309,10 @@ discard block |
||
309 | 309 | |
310 | 310 | $admin_settings['bank_transfer_info'] = array( |
311 | 311 | 'id' => 'bank_transfer_info', |
312 | - 'name' => __( 'Instructions', 'invoicing' ), |
|
313 | - 'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ), |
|
312 | + 'name' => __('Instructions', 'invoicing'), |
|
313 | + 'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'), |
|
314 | 314 | 'type' => 'textarea', |
315 | - 'std' => __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ), |
|
315 | + 'std' => __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing'), |
|
316 | 316 | 'cols' => 50, |
317 | 317 | 'rows' => 5 |
318 | 318 | ); |
@@ -327,10 +327,10 @@ discard block |
||
327 | 327 | * @param GetPaid_Form_Item[] $items |
328 | 328 | * @return WPInv_Invoice |
329 | 329 | */ |
330 | - public function process_addons( $invoice, $items ) { |
|
330 | + public function process_addons($invoice, $items) { |
|
331 | 331 | |
332 | - foreach ( $items as $item ) { |
|
333 | - $invoice->add_item( $item ); |
|
332 | + foreach ($items as $item) { |
|
333 | + $invoice->add_item($item); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | $invoice->recalculate_total(); |
@@ -343,10 +343,10 @@ discard block |
||
343 | 343 | * |
344 | 344 | * @param WPInv_Subscription $subscription |
345 | 345 | */ |
346 | - public function maybe_renew_subscription( $subscription ) { |
|
346 | + public function maybe_renew_subscription($subscription) { |
|
347 | 347 | |
348 | 348 | // Ensure its our subscription && it's active. |
349 | - if ( $this->id == $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) { |
|
349 | + if ($this->id == $subscription->get_gateway() && $subscription->has_status('active trialling')) { |
|
350 | 350 | $subscription->create_payment(); |
351 | 351 | } |
352 | 352 | |
@@ -358,30 +358,30 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @param WPInv_Invoice $invoice |
360 | 360 | */ |
361 | - public function invoice_paid( $invoice ) { |
|
361 | + public function invoice_paid($invoice) { |
|
362 | 362 | |
363 | 363 | // Abort if not paid by bank transfer. |
364 | - if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) { |
|
364 | + if ($this->id !== $invoice->get_gateway() || !$invoice->is_recurring()) { |
|
365 | 365 | return; |
366 | 366 | } |
367 | 367 | |
368 | 368 | // Is it a parent payment? |
369 | - if ( 0 == $invoice->get_parent_id() ) { |
|
369 | + if (0 == $invoice->get_parent_id()) { |
|
370 | 370 | |
371 | 371 | // (Maybe) activate subscriptions. |
372 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
372 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
373 | 373 | |
374 | - if ( ! empty( $subscriptions ) ) { |
|
375 | - $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions ); |
|
374 | + if (!empty($subscriptions)) { |
|
375 | + $subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions); |
|
376 | 376 | |
377 | - foreach ( $subscriptions as $subscription ) { |
|
378 | - if ( $subscription->exists() ) { |
|
379 | - $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
380 | - $expiry = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
377 | + foreach ($subscriptions as $subscription) { |
|
378 | + if ($subscription->exists()) { |
|
379 | + $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created()); |
|
380 | + $expiry = date('Y-m-d H:i:s', (current_time('timestamp') + $duration)); |
|
381 | 381 | |
382 | - $subscription->set_next_renewal_date( $expiry ); |
|
383 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
384 | - $subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ); |
|
382 | + $subscription->set_next_renewal_date($expiry); |
|
383 | + $subscription->set_date_created(current_time('mysql')); |
|
384 | + $subscription->set_profile_id('bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id()); |
|
385 | 385 | $subscription->activate(); |
386 | 386 | } |
387 | 387 | } |
@@ -390,11 +390,11 @@ discard block |
||
390 | 390 | |
391 | 391 | } else { |
392 | 392 | |
393 | - $subscription = getpaid_get_subscription( $invoice->get_subscription_id() ); |
|
393 | + $subscription = getpaid_get_subscription($invoice->get_subscription_id()); |
|
394 | 394 | |
395 | 395 | // Renew the subscription. |
396 | - if ( $subscription && $subscription->exists() ) { |
|
397 | - $subscription->add_payment( array(), $invoice ); |
|
396 | + if ($subscription && $subscription->exists()) { |
|
397 | + $subscription->add_payment(array(), $invoice); |
|
398 | 398 | $subscription->renew(); |
399 | 399 | } |
400 | 400 |
@@ -14,615 +14,615 @@ |
||
14 | 14 | */ |
15 | 15 | class WPInv_Plugin { |
16 | 16 | |
17 | - /** |
|
18 | - * GetPaid version. |
|
19 | - * |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - public $version; |
|
23 | - |
|
24 | - /** |
|
25 | - * Data container. |
|
26 | - * |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - protected $data = array(); |
|
30 | - |
|
31 | - /** |
|
32 | - * Form elements instance. |
|
33 | - * |
|
34 | - * @var WPInv_Payment_Form_Elements |
|
35 | - */ |
|
36 | - public $form_elements; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var array An array of payment gateways. |
|
40 | - */ |
|
41 | - public $gateways; |
|
42 | - |
|
43 | - /** |
|
44 | - * Class constructor. |
|
45 | - */ |
|
46 | - public function __construct() { |
|
47 | - $this->define_constants(); |
|
48 | - $this->includes(); |
|
49 | - $this->init_hooks(); |
|
50 | - $this->set_properties(); |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * Sets a custom data property. |
|
55 | - * |
|
56 | - * @param string $prop The prop to set. |
|
57 | - * @param mixed $value The value to retrieve. |
|
58 | - */ |
|
59 | - public function set( $prop, $value ) { |
|
60 | - $this->data[ $prop ] = $value; |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Gets a custom data property. |
|
65 | - * |
|
66 | - * @param string $prop The prop to set. |
|
67 | - * @return mixed The value. |
|
68 | - */ |
|
69 | - public function get( $prop ) { |
|
70 | - |
|
71 | - if ( isset( $this->data[ $prop ] ) ) { |
|
72 | - return $this->data[ $prop ]; |
|
73 | - } |
|
74 | - |
|
75 | - return null; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * Define class properties. |
|
80 | - */ |
|
81 | - public function set_properties() { |
|
82 | - |
|
83 | - // Sessions. |
|
84 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
85 | - $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
86 | - $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility. |
|
87 | - |
|
88 | - // Init other objects. |
|
89 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
90 | - $this->set( 'notes', new WPInv_Notes() ); |
|
91 | - $this->set( 'api', new WPInv_API() ); |
|
92 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
93 | - $this->set( 'template', new GetPaid_Template() ); |
|
94 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
95 | - $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
96 | - $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
97 | - $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
98 | - $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
99 | - $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
100 | - $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
101 | - |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * Define plugin constants. |
|
106 | - */ |
|
107 | - public function define_constants() { |
|
108 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
109 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
110 | - $this->version = WPINV_VERSION; |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * Hook into actions and filters. |
|
115 | - * |
|
116 | - * @since 1.0.19 |
|
117 | - */ |
|
118 | - protected function init_hooks() { |
|
119 | - /* Internationalize the text strings used. */ |
|
120 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
121 | - |
|
122 | - // Init the plugin after WordPress inits. |
|
123 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
124 | - add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
125 | - add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
126 | - add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
127 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 ); |
|
128 | - add_action( 'wp_footer', array( $this, 'wp_footer' ) ); |
|
129 | - add_action( 'wp_head', array( $this, 'wp_head' ) ); |
|
130 | - add_action( 'widgets_init', array( $this, 'register_widgets' ) ); |
|
131 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
132 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
133 | - |
|
134 | - add_filter( 'query_vars', array( $this, 'custom_query_vars' ) ); |
|
17 | + /** |
|
18 | + * GetPaid version. |
|
19 | + * |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + public $version; |
|
23 | + |
|
24 | + /** |
|
25 | + * Data container. |
|
26 | + * |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + protected $data = array(); |
|
30 | + |
|
31 | + /** |
|
32 | + * Form elements instance. |
|
33 | + * |
|
34 | + * @var WPInv_Payment_Form_Elements |
|
35 | + */ |
|
36 | + public $form_elements; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var array An array of payment gateways. |
|
40 | + */ |
|
41 | + public $gateways; |
|
42 | + |
|
43 | + /** |
|
44 | + * Class constructor. |
|
45 | + */ |
|
46 | + public function __construct() { |
|
47 | + $this->define_constants(); |
|
48 | + $this->includes(); |
|
49 | + $this->init_hooks(); |
|
50 | + $this->set_properties(); |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * Sets a custom data property. |
|
55 | + * |
|
56 | + * @param string $prop The prop to set. |
|
57 | + * @param mixed $value The value to retrieve. |
|
58 | + */ |
|
59 | + public function set( $prop, $value ) { |
|
60 | + $this->data[ $prop ] = $value; |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Gets a custom data property. |
|
65 | + * |
|
66 | + * @param string $prop The prop to set. |
|
67 | + * @return mixed The value. |
|
68 | + */ |
|
69 | + public function get( $prop ) { |
|
70 | + |
|
71 | + if ( isset( $this->data[ $prop ] ) ) { |
|
72 | + return $this->data[ $prop ]; |
|
73 | + } |
|
74 | + |
|
75 | + return null; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Define class properties. |
|
80 | + */ |
|
81 | + public function set_properties() { |
|
82 | + |
|
83 | + // Sessions. |
|
84 | + $this->set( 'session', new WPInv_Session_Handler() ); |
|
85 | + $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
86 | + $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility. |
|
87 | + |
|
88 | + // Init other objects. |
|
89 | + $this->set( 'session', new WPInv_Session_Handler() ); |
|
90 | + $this->set( 'notes', new WPInv_Notes() ); |
|
91 | + $this->set( 'api', new WPInv_API() ); |
|
92 | + $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
93 | + $this->set( 'template', new GetPaid_Template() ); |
|
94 | + $this->set( 'admin', new GetPaid_Admin() ); |
|
95 | + $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
96 | + $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
97 | + $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
98 | + $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
99 | + $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
100 | + $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
101 | + |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * Define plugin constants. |
|
106 | + */ |
|
107 | + public function define_constants() { |
|
108 | + define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
109 | + define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
110 | + $this->version = WPINV_VERSION; |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * Hook into actions and filters. |
|
115 | + * |
|
116 | + * @since 1.0.19 |
|
117 | + */ |
|
118 | + protected function init_hooks() { |
|
119 | + /* Internationalize the text strings used. */ |
|
120 | + add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
121 | + |
|
122 | + // Init the plugin after WordPress inits. |
|
123 | + add_action( 'init', array( $this, 'init' ), 1 ); |
|
124 | + add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
125 | + add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
126 | + add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
127 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 ); |
|
128 | + add_action( 'wp_footer', array( $this, 'wp_footer' ) ); |
|
129 | + add_action( 'wp_head', array( $this, 'wp_head' ) ); |
|
130 | + add_action( 'widgets_init', array( $this, 'register_widgets' ) ); |
|
131 | + add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
132 | + add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
133 | + |
|
134 | + add_filter( 'query_vars', array( $this, 'custom_query_vars' ) ); |
|
135 | 135 | add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 ); |
136 | - add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 ); |
|
137 | - |
|
138 | - // Fires after registering actions. |
|
139 | - do_action( 'wpinv_actions', $this ); |
|
140 | - do_action( 'getpaid_actions', $this ); |
|
141 | - |
|
142 | - } |
|
143 | - |
|
144 | - public function plugins_loaded() { |
|
145 | - /* Internationalize the text strings used. */ |
|
146 | - $this->load_textdomain(); |
|
147 | - |
|
148 | - do_action( 'wpinv_loaded' ); |
|
149 | - |
|
150 | - // Fix oxygen page builder conflict |
|
151 | - if ( function_exists( 'ct_css_output' ) ) { |
|
152 | - wpinv_oxygen_fix_conflict(); |
|
153 | - } |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * Load Localisation files. |
|
158 | - * |
|
159 | - * Note: the first-loaded translation file overrides any following ones if the same translation is present. |
|
160 | - * |
|
161 | - * Locales found in: |
|
162 | - * - WP_LANG_DIR/plugins/invoicing-LOCALE.mo |
|
163 | - * - WP_PLUGIN_DIR/invoicing/languages/invoicing-LOCALE.mo |
|
164 | - * |
|
165 | - * @since 1.0.0 |
|
166 | - */ |
|
167 | - public function load_textdomain() { |
|
168 | - |
|
169 | - load_plugin_textdomain( |
|
170 | - 'invoicing', |
|
171 | - false, |
|
172 | - plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/' |
|
173 | - ); |
|
174 | - |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * Include required core files used in admin and on the frontend. |
|
179 | - */ |
|
180 | - public function includes() { |
|
181 | - |
|
182 | - // Start with the settings. |
|
183 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
184 | - |
|
185 | - // Packages/libraries. |
|
186 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
187 | - require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
188 | - |
|
189 | - // Load functions. |
|
190 | - require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
191 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
192 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
193 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
194 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
195 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
196 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
197 | - require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
198 | - require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
199 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
200 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
201 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
202 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
203 | - require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' ); |
|
204 | - require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
205 | - |
|
206 | - // Register autoloader. |
|
207 | - try { |
|
208 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
209 | - } catch ( Exception $e ) { |
|
210 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
211 | - } |
|
212 | - |
|
213 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
214 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
215 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
216 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
217 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
218 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
219 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
220 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
221 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
222 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
223 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
224 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
225 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
226 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
227 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
228 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
229 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
230 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
231 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
232 | - require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
233 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
234 | - |
|
235 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
236 | - GetPaid_Post_Types_Admin::init(); |
|
237 | - |
|
238 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
239 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
240 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
241 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
242 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
243 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
244 | - // load the user class only on the users.php page |
|
245 | - global $pagenow; |
|
246 | - if($pagenow=='users.php'){ |
|
247 | - new WPInv_Admin_Users(); |
|
248 | - } |
|
249 | - } |
|
250 | - |
|
251 | - // Register cli commands |
|
252 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
253 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
254 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
255 | - } |
|
256 | - |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * Class autoloader |
|
261 | - * |
|
262 | - * @param string $class_name The name of the class to load. |
|
263 | - * @access public |
|
264 | - * @since 1.0.19 |
|
265 | - * @return void |
|
266 | - */ |
|
267 | - public function autoload( $class_name ) { |
|
268 | - |
|
269 | - // Normalize the class name... |
|
270 | - $class_name = strtolower( $class_name ); |
|
271 | - |
|
272 | - // ... and make sure it is our class. |
|
273 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
274 | - return; |
|
275 | - } |
|
276 | - |
|
277 | - // Next, prepare the file name from the class. |
|
278 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
279 | - |
|
280 | - // Base path of the classes. |
|
281 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
282 | - |
|
283 | - // And an array of possible locations in order of importance. |
|
284 | - $locations = array( |
|
285 | - "$plugin_path/includes", |
|
286 | - "$plugin_path/includes/data-stores", |
|
287 | - "$plugin_path/includes/gateways", |
|
288 | - "$plugin_path/includes/payments", |
|
289 | - "$plugin_path/includes/geolocation", |
|
290 | - "$plugin_path/includes/reports", |
|
291 | - "$plugin_path/includes/api", |
|
292 | - "$plugin_path/includes/admin", |
|
293 | - "$plugin_path/includes/admin/meta-boxes", |
|
294 | - ); |
|
295 | - |
|
296 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
297 | - |
|
298 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
299 | - include trailingslashit( $location ) . $file_name; |
|
300 | - break; |
|
301 | - } |
|
302 | - |
|
303 | - } |
|
304 | - |
|
305 | - } |
|
306 | - |
|
307 | - /** |
|
308 | - * Inits hooks etc. |
|
309 | - */ |
|
310 | - public function init() { |
|
311 | - |
|
312 | - // Fires before getpaid inits. |
|
313 | - do_action( 'before_getpaid_init', $this ); |
|
314 | - |
|
315 | - // Maybe upgrade. |
|
316 | - $this->maybe_upgrade_database(); |
|
317 | - |
|
318 | - // Load default gateways. |
|
319 | - $gateways = apply_filters( |
|
320 | - 'getpaid_default_gateways', |
|
321 | - array( |
|
322 | - 'manual' => 'GetPaid_Manual_Gateway', |
|
323 | - 'paypal' => 'GetPaid_Paypal_Gateway', |
|
324 | - 'worldpay' => 'GetPaid_Worldpay_Gateway', |
|
325 | - 'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway', |
|
326 | - 'authorizenet' => 'GetPaid_Authorize_Net_Gateway', |
|
327 | - ) |
|
328 | - ); |
|
329 | - |
|
330 | - foreach ( $gateways as $id => $class ) { |
|
331 | - $this->gateways[ $id ] = new $class(); |
|
332 | - } |
|
333 | - |
|
334 | - if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) { |
|
335 | - GetPaid_Installer::rename_gateways_label(); |
|
336 | - update_option( 'wpinv_renamed_gateways', 'yes' ); |
|
337 | - } |
|
338 | - |
|
339 | - // Fires after getpaid inits. |
|
340 | - do_action( 'getpaid_init', $this ); |
|
341 | - |
|
342 | - } |
|
343 | - |
|
344 | - /** |
|
345 | - * Checks if this is an IPN request and processes it. |
|
346 | - */ |
|
347 | - public function maybe_process_ipn() { |
|
348 | - |
|
349 | - // Ensure that this is an IPN request. |
|
350 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
351 | - return; |
|
352 | - } |
|
353 | - |
|
354 | - $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
355 | - |
|
356 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
357 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
358 | - exit; |
|
359 | - |
|
360 | - } |
|
361 | - |
|
362 | - public function enqueue_scripts() { |
|
363 | - |
|
364 | - // Fires before adding scripts. |
|
365 | - do_action( 'getpaid_enqueue_scripts' ); |
|
366 | - |
|
367 | - $localize = array(); |
|
368 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
369 | - $localize['thousands'] = wpinv_thousands_separator(); |
|
370 | - $localize['decimals'] = wpinv_decimal_separator(); |
|
371 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
372 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
373 | - $localize['UseTaxes'] = wpinv_use_taxes(); |
|
374 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
375 | - $localize['loading'] = __( 'Loading...', 'invoicing' ); |
|
376 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
377 | - |
|
378 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
379 | - |
|
380 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
381 | - wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true ); |
|
382 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
383 | - } |
|
384 | - |
|
385 | - public function wpinv_actions() { |
|
386 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
387 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
388 | - } |
|
389 | - } |
|
390 | - |
|
391 | - /** |
|
136 | + add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 ); |
|
137 | + |
|
138 | + // Fires after registering actions. |
|
139 | + do_action( 'wpinv_actions', $this ); |
|
140 | + do_action( 'getpaid_actions', $this ); |
|
141 | + |
|
142 | + } |
|
143 | + |
|
144 | + public function plugins_loaded() { |
|
145 | + /* Internationalize the text strings used. */ |
|
146 | + $this->load_textdomain(); |
|
147 | + |
|
148 | + do_action( 'wpinv_loaded' ); |
|
149 | + |
|
150 | + // Fix oxygen page builder conflict |
|
151 | + if ( function_exists( 'ct_css_output' ) ) { |
|
152 | + wpinv_oxygen_fix_conflict(); |
|
153 | + } |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * Load Localisation files. |
|
158 | + * |
|
159 | + * Note: the first-loaded translation file overrides any following ones if the same translation is present. |
|
160 | + * |
|
161 | + * Locales found in: |
|
162 | + * - WP_LANG_DIR/plugins/invoicing-LOCALE.mo |
|
163 | + * - WP_PLUGIN_DIR/invoicing/languages/invoicing-LOCALE.mo |
|
164 | + * |
|
165 | + * @since 1.0.0 |
|
166 | + */ |
|
167 | + public function load_textdomain() { |
|
168 | + |
|
169 | + load_plugin_textdomain( |
|
170 | + 'invoicing', |
|
171 | + false, |
|
172 | + plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/' |
|
173 | + ); |
|
174 | + |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * Include required core files used in admin and on the frontend. |
|
179 | + */ |
|
180 | + public function includes() { |
|
181 | + |
|
182 | + // Start with the settings. |
|
183 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
184 | + |
|
185 | + // Packages/libraries. |
|
186 | + require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
187 | + require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
188 | + |
|
189 | + // Load functions. |
|
190 | + require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
191 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
192 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
193 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
194 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
195 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
196 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
197 | + require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
198 | + require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
199 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
200 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
201 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
202 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
203 | + require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' ); |
|
204 | + require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
205 | + |
|
206 | + // Register autoloader. |
|
207 | + try { |
|
208 | + spl_autoload_register( array( $this, 'autoload' ), true ); |
|
209 | + } catch ( Exception $e ) { |
|
210 | + wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
211 | + } |
|
212 | + |
|
213 | + require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
214 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
215 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
216 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
217 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
218 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
219 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
220 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
221 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
222 | + require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
223 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
224 | + require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
225 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
226 | + require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
227 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
228 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
229 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
230 | + require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
231 | + require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
232 | + require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
233 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
234 | + |
|
235 | + if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
236 | + GetPaid_Post_Types_Admin::init(); |
|
237 | + |
|
238 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
239 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
240 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
241 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
242 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
243 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
244 | + // load the user class only on the users.php page |
|
245 | + global $pagenow; |
|
246 | + if($pagenow=='users.php'){ |
|
247 | + new WPInv_Admin_Users(); |
|
248 | + } |
|
249 | + } |
|
250 | + |
|
251 | + // Register cli commands |
|
252 | + if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
253 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
254 | + WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
255 | + } |
|
256 | + |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * Class autoloader |
|
261 | + * |
|
262 | + * @param string $class_name The name of the class to load. |
|
263 | + * @access public |
|
264 | + * @since 1.0.19 |
|
265 | + * @return void |
|
266 | + */ |
|
267 | + public function autoload( $class_name ) { |
|
268 | + |
|
269 | + // Normalize the class name... |
|
270 | + $class_name = strtolower( $class_name ); |
|
271 | + |
|
272 | + // ... and make sure it is our class. |
|
273 | + if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
274 | + return; |
|
275 | + } |
|
276 | + |
|
277 | + // Next, prepare the file name from the class. |
|
278 | + $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
279 | + |
|
280 | + // Base path of the classes. |
|
281 | + $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
282 | + |
|
283 | + // And an array of possible locations in order of importance. |
|
284 | + $locations = array( |
|
285 | + "$plugin_path/includes", |
|
286 | + "$plugin_path/includes/data-stores", |
|
287 | + "$plugin_path/includes/gateways", |
|
288 | + "$plugin_path/includes/payments", |
|
289 | + "$plugin_path/includes/geolocation", |
|
290 | + "$plugin_path/includes/reports", |
|
291 | + "$plugin_path/includes/api", |
|
292 | + "$plugin_path/includes/admin", |
|
293 | + "$plugin_path/includes/admin/meta-boxes", |
|
294 | + ); |
|
295 | + |
|
296 | + foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
297 | + |
|
298 | + if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
299 | + include trailingslashit( $location ) . $file_name; |
|
300 | + break; |
|
301 | + } |
|
302 | + |
|
303 | + } |
|
304 | + |
|
305 | + } |
|
306 | + |
|
307 | + /** |
|
308 | + * Inits hooks etc. |
|
309 | + */ |
|
310 | + public function init() { |
|
311 | + |
|
312 | + // Fires before getpaid inits. |
|
313 | + do_action( 'before_getpaid_init', $this ); |
|
314 | + |
|
315 | + // Maybe upgrade. |
|
316 | + $this->maybe_upgrade_database(); |
|
317 | + |
|
318 | + // Load default gateways. |
|
319 | + $gateways = apply_filters( |
|
320 | + 'getpaid_default_gateways', |
|
321 | + array( |
|
322 | + 'manual' => 'GetPaid_Manual_Gateway', |
|
323 | + 'paypal' => 'GetPaid_Paypal_Gateway', |
|
324 | + 'worldpay' => 'GetPaid_Worldpay_Gateway', |
|
325 | + 'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway', |
|
326 | + 'authorizenet' => 'GetPaid_Authorize_Net_Gateway', |
|
327 | + ) |
|
328 | + ); |
|
329 | + |
|
330 | + foreach ( $gateways as $id => $class ) { |
|
331 | + $this->gateways[ $id ] = new $class(); |
|
332 | + } |
|
333 | + |
|
334 | + if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) { |
|
335 | + GetPaid_Installer::rename_gateways_label(); |
|
336 | + update_option( 'wpinv_renamed_gateways', 'yes' ); |
|
337 | + } |
|
338 | + |
|
339 | + // Fires after getpaid inits. |
|
340 | + do_action( 'getpaid_init', $this ); |
|
341 | + |
|
342 | + } |
|
343 | + |
|
344 | + /** |
|
345 | + * Checks if this is an IPN request and processes it. |
|
346 | + */ |
|
347 | + public function maybe_process_ipn() { |
|
348 | + |
|
349 | + // Ensure that this is an IPN request. |
|
350 | + if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
351 | + return; |
|
352 | + } |
|
353 | + |
|
354 | + $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
355 | + |
|
356 | + do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
357 | + do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
358 | + exit; |
|
359 | + |
|
360 | + } |
|
361 | + |
|
362 | + public function enqueue_scripts() { |
|
363 | + |
|
364 | + // Fires before adding scripts. |
|
365 | + do_action( 'getpaid_enqueue_scripts' ); |
|
366 | + |
|
367 | + $localize = array(); |
|
368 | + $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
369 | + $localize['thousands'] = wpinv_thousands_separator(); |
|
370 | + $localize['decimals'] = wpinv_decimal_separator(); |
|
371 | + $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
372 | + $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
373 | + $localize['UseTaxes'] = wpinv_use_taxes(); |
|
374 | + $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
375 | + $localize['loading'] = __( 'Loading...', 'invoicing' ); |
|
376 | + $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
377 | + |
|
378 | + $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
379 | + |
|
380 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
381 | + wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true ); |
|
382 | + wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
383 | + } |
|
384 | + |
|
385 | + public function wpinv_actions() { |
|
386 | + if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
387 | + do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
388 | + } |
|
389 | + } |
|
390 | + |
|
391 | + /** |
|
392 | 392 | * Fires an action after verifying that a user can fire them. |
393 | - * |
|
394 | - * Note: If the action is on an invoice, subscription etc, esure that the |
|
395 | - * current user owns the invoice/subscription. |
|
393 | + * |
|
394 | + * Note: If the action is on an invoice, subscription etc, esure that the |
|
395 | + * current user owns the invoice/subscription. |
|
396 | 396 | */ |
397 | 397 | public function maybe_do_authenticated_action() { |
398 | 398 | |
399 | - if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
399 | + if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
400 | 400 | |
401 | - $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
402 | - $data = wp_unslash( $_REQUEST ); |
|
403 | - if ( is_user_logged_in() ) { |
|
404 | - do_action( "getpaid_authenticated_action_$key", $data ); |
|
405 | - } |
|
401 | + $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
402 | + $data = wp_unslash( $_REQUEST ); |
|
403 | + if ( is_user_logged_in() ) { |
|
404 | + do_action( "getpaid_authenticated_action_$key", $data ); |
|
405 | + } |
|
406 | 406 | |
407 | - do_action( "getpaid_unauthenticated_action_$key", $data ); |
|
407 | + do_action( "getpaid_unauthenticated_action_$key", $data ); |
|
408 | 408 | |
409 | - } |
|
409 | + } |
|
410 | 410 | |
411 | 411 | } |
412 | 412 | |
413 | - public function pre_get_posts( $wp_query ) { |
|
413 | + public function pre_get_posts( $wp_query ) { |
|
414 | 414 | |
415 | - if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
416 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
417 | - } |
|
418 | - |
|
419 | - return $wp_query; |
|
420 | - } |
|
415 | + if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
416 | + $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
417 | + } |
|
421 | 418 | |
422 | - /** |
|
423 | - * Register widgets |
|
424 | - * |
|
425 | - */ |
|
426 | - public function register_widgets() { |
|
427 | - global $pagenow; |
|
419 | + return $wp_query; |
|
420 | + } |
|
428 | 421 | |
429 | - // Currently, UX Builder does not work particulaly well with SuperDuper. |
|
430 | - // So we disable our widgets when editing a page with UX Builder. |
|
431 | - if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) { |
|
432 | - return; |
|
433 | - } |
|
434 | - |
|
435 | - $block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array(); |
|
436 | - |
|
437 | - if ( is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) { |
|
438 | - // don't initiate in these conditions. |
|
439 | - }else{ |
|
440 | - |
|
441 | - // Only load allowed widgets. |
|
442 | - $exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array(); |
|
443 | - $widgets = apply_filters( |
|
444 | - 'getpaid_widget_classes', |
|
445 | - array( |
|
446 | - 'WPInv_Checkout_Widget', |
|
447 | - 'WPInv_History_Widget', |
|
448 | - 'WPInv_Receipt_Widget', |
|
449 | - 'WPInv_Subscriptions_Widget', |
|
450 | - 'WPInv_Buy_Item_Widget', |
|
451 | - 'WPInv_Messages_Widget', |
|
452 | - 'WPInv_GetPaid_Widget' |
|
453 | - ) |
|
454 | - ); |
|
455 | - |
|
456 | - // For each widget... |
|
457 | - foreach ( $widgets as $widget ) { |
|
422 | + /** |
|
423 | + * Register widgets |
|
424 | + * |
|
425 | + */ |
|
426 | + public function register_widgets() { |
|
427 | + global $pagenow; |
|
458 | 428 | |
459 | - // Abort early if it is excluded for this page. |
|
460 | - if ( in_array( $widget, $exclude ) ) { |
|
461 | - continue; |
|
462 | - } |
|
429 | + // Currently, UX Builder does not work particulaly well with SuperDuper. |
|
430 | + // So we disable our widgets when editing a page with UX Builder. |
|
431 | + if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) { |
|
432 | + return; |
|
433 | + } |
|
463 | 434 | |
464 | - // SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it. |
|
465 | - if ( is_subclass_of( $widget, 'WP_Widget' ) ) { |
|
466 | - register_widget( $widget ); |
|
467 | - } else { |
|
468 | - new $widget(); |
|
469 | - } |
|
435 | + $block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array(); |
|
436 | + |
|
437 | + if ( is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) { |
|
438 | + // don't initiate in these conditions. |
|
439 | + }else{ |
|
440 | + |
|
441 | + // Only load allowed widgets. |
|
442 | + $exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array(); |
|
443 | + $widgets = apply_filters( |
|
444 | + 'getpaid_widget_classes', |
|
445 | + array( |
|
446 | + 'WPInv_Checkout_Widget', |
|
447 | + 'WPInv_History_Widget', |
|
448 | + 'WPInv_Receipt_Widget', |
|
449 | + 'WPInv_Subscriptions_Widget', |
|
450 | + 'WPInv_Buy_Item_Widget', |
|
451 | + 'WPInv_Messages_Widget', |
|
452 | + 'WPInv_GetPaid_Widget' |
|
453 | + ) |
|
454 | + ); |
|
455 | + |
|
456 | + // For each widget... |
|
457 | + foreach ( $widgets as $widget ) { |
|
458 | + |
|
459 | + // Abort early if it is excluded for this page. |
|
460 | + if ( in_array( $widget, $exclude ) ) { |
|
461 | + continue; |
|
462 | + } |
|
463 | + |
|
464 | + // SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it. |
|
465 | + if ( is_subclass_of( $widget, 'WP_Widget' ) ) { |
|
466 | + register_widget( $widget ); |
|
467 | + } else { |
|
468 | + new $widget(); |
|
469 | + } |
|
470 | + |
|
471 | + } |
|
470 | 472 | |
471 | - } |
|
473 | + } |
|
472 | 474 | |
473 | - } |
|
475 | + } |
|
474 | 476 | |
475 | - } |
|
477 | + /** |
|
478 | + * Upgrades the database. |
|
479 | + * |
|
480 | + * @since 2.0.2 |
|
481 | + */ |
|
482 | + public function maybe_upgrade_database() { |
|
476 | 483 | |
477 | - /** |
|
478 | - * Upgrades the database. |
|
479 | - * |
|
480 | - * @since 2.0.2 |
|
481 | - */ |
|
482 | - public function maybe_upgrade_database() { |
|
483 | - |
|
484 | - $wpi_version = get_option( 'wpinv_version', 0 ); |
|
485 | - |
|
486 | - if ( $wpi_version == WPINV_VERSION ) { |
|
487 | - return; |
|
488 | - } |
|
489 | - |
|
490 | - $installer = new GetPaid_Installer(); |
|
491 | - |
|
492 | - if ( empty( $wpi_version ) ) { |
|
493 | - return $installer->upgrade_db( 0 ); |
|
494 | - } |
|
495 | - |
|
496 | - $upgrades = array( |
|
497 | - '0.0.5' => '004', |
|
498 | - '1.0.3' => '102', |
|
499 | - '2.0.0' => '118', |
|
500 | - '2.0.8' => '207', |
|
501 | - ); |
|
502 | - |
|
503 | - foreach ( $upgrades as $key => $method ) { |
|
504 | - |
|
505 | - if ( version_compare( $wpi_version, $key, '<' ) ) { |
|
506 | - return $installer->upgrade_db( $method ); |
|
507 | - } |
|
508 | - |
|
509 | - } |
|
510 | - |
|
511 | - } |
|
512 | - |
|
513 | - /** |
|
514 | - * Flushes the permalinks if needed. |
|
515 | - * |
|
516 | - * @since 2.0.8 |
|
517 | - */ |
|
518 | - public function maybe_flush_permalinks() { |
|
519 | - |
|
520 | - $flush = get_option( 'wpinv_flush_permalinks', 0 ); |
|
521 | - |
|
522 | - if ( ! empty( $flush ) ) { |
|
523 | - flush_rewrite_rules(); |
|
524 | - delete_option( 'wpinv_flush_permalinks' ); |
|
525 | - } |
|
526 | - |
|
527 | - } |
|
528 | - |
|
529 | - /** |
|
530 | - * Remove our pages from yoast sitemaps. |
|
531 | - * |
|
532 | - * @since 1.0.19 |
|
533 | - * @param int[] $excluded_posts_ids |
|
534 | - */ |
|
535 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
536 | - |
|
537 | - // Ensure that we have an array. |
|
538 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
539 | - $excluded_posts_ids = array(); |
|
540 | - } |
|
541 | - |
|
542 | - // Prepare our pages. |
|
543 | - $our_pages = array(); |
|
544 | - |
|
545 | - // Checkout page. |
|
546 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
547 | - |
|
548 | - // Success page. |
|
549 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
550 | - |
|
551 | - // Failure page. |
|
552 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
484 | + $wpi_version = get_option( 'wpinv_version', 0 ); |
|
553 | 485 | |
554 | - // History page. |
|
555 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
486 | + if ( $wpi_version == WPINV_VERSION ) { |
|
487 | + return; |
|
488 | + } |
|
556 | 489 | |
557 | - // Subscriptions page. |
|
558 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
490 | + $installer = new GetPaid_Installer(); |
|
559 | 491 | |
560 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
492 | + if ( empty( $wpi_version ) ) { |
|
493 | + return $installer->upgrade_db( 0 ); |
|
494 | + } |
|
561 | 495 | |
562 | - $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
|
563 | - return array_unique( $excluded_posts_ids ); |
|
496 | + $upgrades = array( |
|
497 | + '0.0.5' => '004', |
|
498 | + '1.0.3' => '102', |
|
499 | + '2.0.0' => '118', |
|
500 | + '2.0.8' => '207', |
|
501 | + ); |
|
564 | 502 | |
565 | - } |
|
503 | + foreach ( $upgrades as $key => $method ) { |
|
566 | 504 | |
567 | - /** |
|
568 | - * Displays additional footer code. |
|
569 | - * |
|
570 | - * @since 2.0.0 |
|
571 | - */ |
|
572 | - public function wp_footer() { |
|
573 | - wpinv_get_template( 'frontend-footer.php' ); |
|
574 | - } |
|
505 | + if ( version_compare( $wpi_version, $key, '<' ) ) { |
|
506 | + return $installer->upgrade_db( $method ); |
|
507 | + } |
|
575 | 508 | |
576 | - /** |
|
577 | - * Displays additional header code. |
|
578 | - * |
|
579 | - * @since 2.0.0 |
|
580 | - */ |
|
581 | - public function wp_head() { |
|
582 | - wpinv_get_template( 'frontend-head.php' ); |
|
583 | - } |
|
509 | + } |
|
584 | 510 | |
585 | - /** |
|
586 | - * Custom query vars. |
|
587 | - * |
|
588 | - */ |
|
589 | - public function custom_query_vars( $vars ) { |
|
511 | + } |
|
512 | + |
|
513 | + /** |
|
514 | + * Flushes the permalinks if needed. |
|
515 | + * |
|
516 | + * @since 2.0.8 |
|
517 | + */ |
|
518 | + public function maybe_flush_permalinks() { |
|
519 | + |
|
520 | + $flush = get_option( 'wpinv_flush_permalinks', 0 ); |
|
521 | + |
|
522 | + if ( ! empty( $flush ) ) { |
|
523 | + flush_rewrite_rules(); |
|
524 | + delete_option( 'wpinv_flush_permalinks' ); |
|
525 | + } |
|
526 | + |
|
527 | + } |
|
528 | + |
|
529 | + /** |
|
530 | + * Remove our pages from yoast sitemaps. |
|
531 | + * |
|
532 | + * @since 1.0.19 |
|
533 | + * @param int[] $excluded_posts_ids |
|
534 | + */ |
|
535 | + public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
536 | + |
|
537 | + // Ensure that we have an array. |
|
538 | + if ( ! is_array( $excluded_posts_ids ) ) { |
|
539 | + $excluded_posts_ids = array(); |
|
540 | + } |
|
541 | + |
|
542 | + // Prepare our pages. |
|
543 | + $our_pages = array(); |
|
544 | + |
|
545 | + // Checkout page. |
|
546 | + $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
547 | + |
|
548 | + // Success page. |
|
549 | + $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
550 | + |
|
551 | + // Failure page. |
|
552 | + $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
553 | + |
|
554 | + // History page. |
|
555 | + $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
556 | + |
|
557 | + // Subscriptions page. |
|
558 | + $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
559 | + |
|
560 | + $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
561 | + |
|
562 | + $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
|
563 | + return array_unique( $excluded_posts_ids ); |
|
564 | + |
|
565 | + } |
|
566 | + |
|
567 | + /** |
|
568 | + * Displays additional footer code. |
|
569 | + * |
|
570 | + * @since 2.0.0 |
|
571 | + */ |
|
572 | + public function wp_footer() { |
|
573 | + wpinv_get_template( 'frontend-footer.php' ); |
|
574 | + } |
|
575 | + |
|
576 | + /** |
|
577 | + * Displays additional header code. |
|
578 | + * |
|
579 | + * @since 2.0.0 |
|
580 | + */ |
|
581 | + public function wp_head() { |
|
582 | + wpinv_get_template( 'frontend-head.php' ); |
|
583 | + } |
|
584 | + |
|
585 | + /** |
|
586 | + * Custom query vars. |
|
587 | + * |
|
588 | + */ |
|
589 | + public function custom_query_vars( $vars ) { |
|
590 | 590 | $vars[] = 'getpaid-ipn'; |
591 | 591 | return $vars; |
592 | - } |
|
592 | + } |
|
593 | 593 | |
594 | - /** |
|
595 | - * Add rewrite tags and rules. |
|
596 | - * |
|
597 | - */ |
|
598 | - public function add_rewrite_rule() { |
|
594 | + /** |
|
595 | + * Add rewrite tags and rules. |
|
596 | + * |
|
597 | + */ |
|
598 | + public function add_rewrite_rule() { |
|
599 | 599 | $tag = 'getpaid-ipn'; |
600 | 600 | add_rewrite_tag( "%$tag%", '([^&]+)' ); |
601 | 601 | add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]",'top' ); |
602 | - } |
|
602 | + } |
|
603 | 603 | |
604 | - /** |
|
605 | - * Processes non-query string ipns. |
|
606 | - * |
|
607 | - */ |
|
608 | - public function maybe_process_new_ipn( $query ) { |
|
604 | + /** |
|
605 | + * Processes non-query string ipns. |
|
606 | + * |
|
607 | + */ |
|
608 | + public function maybe_process_new_ipn( $query ) { |
|
609 | 609 | |
610 | 610 | if ( is_admin() || ! $query->is_main_query() ) { |
611 | 611 | return; |
612 | 612 | } |
613 | 613 | |
614 | - $gateway = get_query_var( 'getpaid-ipn' ); |
|
614 | + $gateway = get_query_var( 'getpaid-ipn' ); |
|
615 | 615 | |
616 | 616 | if ( ! empty( $gateway ) ){ |
617 | 617 | |
618 | - $gateway = sanitize_text_field( $gateway ); |
|
619 | - nocache_headers(); |
|
620 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
621 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
622 | - exit; |
|
618 | + $gateway = sanitize_text_field( $gateway ); |
|
619 | + nocache_headers(); |
|
620 | + do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
621 | + do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
622 | + exit; |
|
623 | 623 | |
624 | 624 | } |
625 | 625 | |
626 | - } |
|
626 | + } |
|
627 | 627 | |
628 | 628 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 1.0.0 |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Main Invoicing class. |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param string $prop The prop to set. |
57 | 57 | * @param mixed $value The value to retrieve. |
58 | 58 | */ |
59 | - public function set( $prop, $value ) { |
|
60 | - $this->data[ $prop ] = $value; |
|
59 | + public function set($prop, $value) { |
|
60 | + $this->data[$prop] = $value; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | * @param string $prop The prop to set. |
67 | 67 | * @return mixed The value. |
68 | 68 | */ |
69 | - public function get( $prop ) { |
|
69 | + public function get($prop) { |
|
70 | 70 | |
71 | - if ( isset( $this->data[ $prop ] ) ) { |
|
72 | - return $this->data[ $prop ]; |
|
71 | + if (isset($this->data[$prop])) { |
|
72 | + return $this->data[$prop]; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | return null; |
@@ -81,23 +81,23 @@ discard block |
||
81 | 81 | public function set_properties() { |
82 | 82 | |
83 | 83 | // Sessions. |
84 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
85 | - $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
84 | + $this->set('session', new WPInv_Session_Handler()); |
|
85 | + $GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility. |
|
86 | 86 | $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility. |
87 | 87 | |
88 | 88 | // Init other objects. |
89 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
90 | - $this->set( 'notes', new WPInv_Notes() ); |
|
91 | - $this->set( 'api', new WPInv_API() ); |
|
92 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
93 | - $this->set( 'template', new GetPaid_Template() ); |
|
94 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
95 | - $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
96 | - $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
97 | - $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
98 | - $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
99 | - $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
100 | - $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
89 | + $this->set('session', new WPInv_Session_Handler()); |
|
90 | + $this->set('notes', new WPInv_Notes()); |
|
91 | + $this->set('api', new WPInv_API()); |
|
92 | + $this->set('post_types', new GetPaid_Post_Types()); |
|
93 | + $this->set('template', new GetPaid_Template()); |
|
94 | + $this->set('admin', new GetPaid_Admin()); |
|
95 | + $this->set('subscriptions', new WPInv_Subscriptions()); |
|
96 | + $this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails()); |
|
97 | + $this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails()); |
|
98 | + $this->set('daily_maintenace', new GetPaid_Daily_Maintenance()); |
|
99 | + $this->set('payment_forms', new GetPaid_Payment_Forms()); |
|
100 | + $this->set('maxmind', new GetPaid_MaxMind_Geolocation()); |
|
101 | 101 | |
102 | 102 | } |
103 | 103 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * Define plugin constants. |
106 | 106 | */ |
107 | 107 | public function define_constants() { |
108 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
109 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
108 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
109 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
110 | 110 | $this->version = WPINV_VERSION; |
111 | 111 | } |
112 | 112 | |
@@ -117,27 +117,27 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function init_hooks() { |
119 | 119 | /* Internationalize the text strings used. */ |
120 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
120 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
121 | 121 | |
122 | 122 | // Init the plugin after WordPress inits. |
123 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
124 | - add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
125 | - add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
126 | - add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
127 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 ); |
|
128 | - add_action( 'wp_footer', array( $this, 'wp_footer' ) ); |
|
129 | - add_action( 'wp_head', array( $this, 'wp_head' ) ); |
|
130 | - add_action( 'widgets_init', array( $this, 'register_widgets' ) ); |
|
131 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
132 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
133 | - |
|
134 | - add_filter( 'query_vars', array( $this, 'custom_query_vars' ) ); |
|
135 | - add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 ); |
|
136 | - add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 ); |
|
123 | + add_action('init', array($this, 'init'), 1); |
|
124 | + add_action('init', array($this, 'maybe_process_ipn'), 10); |
|
125 | + add_action('init', array($this, 'wpinv_actions')); |
|
126 | + add_action('init', array($this, 'maybe_do_authenticated_action'), 100); |
|
127 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 11); |
|
128 | + add_action('wp_footer', array($this, 'wp_footer')); |
|
129 | + add_action('wp_head', array($this, 'wp_head')); |
|
130 | + add_action('widgets_init', array($this, 'register_widgets')); |
|
131 | + add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids')); |
|
132 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
133 | + |
|
134 | + add_filter('query_vars', array($this, 'custom_query_vars')); |
|
135 | + add_action('init', array($this, 'add_rewrite_rule'), 10, 0); |
|
136 | + add_action('pre_get_posts', array($this, 'maybe_process_new_ipn'), 1); |
|
137 | 137 | |
138 | 138 | // Fires after registering actions. |
139 | - do_action( 'wpinv_actions', $this ); |
|
140 | - do_action( 'getpaid_actions', $this ); |
|
139 | + do_action('wpinv_actions', $this); |
|
140 | + do_action('getpaid_actions', $this); |
|
141 | 141 | |
142 | 142 | } |
143 | 143 | |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | /* Internationalize the text strings used. */ |
146 | 146 | $this->load_textdomain(); |
147 | 147 | |
148 | - do_action( 'wpinv_loaded' ); |
|
148 | + do_action('wpinv_loaded'); |
|
149 | 149 | |
150 | 150 | // Fix oxygen page builder conflict |
151 | - if ( function_exists( 'ct_css_output' ) ) { |
|
151 | + if (function_exists('ct_css_output')) { |
|
152 | 152 | wpinv_oxygen_fix_conflict(); |
153 | 153 | } |
154 | 154 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | load_plugin_textdomain( |
170 | 170 | 'invoicing', |
171 | 171 | false, |
172 | - plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/' |
|
172 | + plugin_basename(dirname(WPINV_PLUGIN_FILE)) . '/languages/' |
|
173 | 173 | ); |
174 | 174 | |
175 | 175 | } |
@@ -180,78 +180,78 @@ discard block |
||
180 | 180 | public function includes() { |
181 | 181 | |
182 | 182 | // Start with the settings. |
183 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
183 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
184 | 184 | |
185 | 185 | // Packages/libraries. |
186 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
187 | - require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
186 | + require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php'); |
|
187 | + require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php'); |
|
188 | 188 | |
189 | 189 | // Load functions. |
190 | - require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
191 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
192 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
193 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
194 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
195 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
196 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
197 | - require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
198 | - require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
199 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
200 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
201 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
202 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
203 | - require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' ); |
|
204 | - require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
190 | + require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php'); |
|
191 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
192 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
193 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
194 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
195 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
196 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
197 | + require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php'); |
|
198 | + require_once(WPINV_PLUGIN_DIR . 'includes/subscription-functions.php'); |
|
199 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
200 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
201 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
202 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
203 | + require_once(WPINV_PLUGIN_DIR . 'includes/user-functions.php'); |
|
204 | + require_once(WPINV_PLUGIN_DIR . 'includes/error-functions.php'); |
|
205 | 205 | |
206 | 206 | // Register autoloader. |
207 | 207 | try { |
208 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
209 | - } catch ( Exception $e ) { |
|
210 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
208 | + spl_autoload_register(array($this, 'autoload'), true); |
|
209 | + } catch (Exception $e) { |
|
210 | + wpinv_error_log($e->getMessage(), '', __FILE__, 149, true); |
|
211 | 211 | } |
212 | 212 | |
213 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
214 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
215 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
216 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
217 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
218 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
219 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
220 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
221 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
222 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
223 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
224 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
225 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
226 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
227 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
228 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
229 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
230 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
231 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
232 | - require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
233 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
234 | - |
|
235 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
213 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'); |
|
214 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php'); |
|
215 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
216 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
217 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
218 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
219 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
220 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
221 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
222 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php'); |
|
223 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
224 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php'); |
|
225 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php'); |
|
226 | + require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php'); |
|
227 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php'); |
|
228 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php'); |
|
229 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php'); |
|
230 | + require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php'); |
|
231 | + require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php'); |
|
232 | + require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php'); |
|
233 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
234 | + |
|
235 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
236 | 236 | GetPaid_Post_Types_Admin::init(); |
237 | 237 | |
238 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
239 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
240 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
241 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
242 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
243 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
238 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
239 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php'); |
|
240 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
241 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
242 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
243 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php'); |
|
244 | 244 | // load the user class only on the users.php page |
245 | 245 | global $pagenow; |
246 | - if($pagenow=='users.php'){ |
|
246 | + if ($pagenow == 'users.php') { |
|
247 | 247 | new WPInv_Admin_Users(); |
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
251 | 251 | // Register cli commands |
252 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
253 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
254 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
252 | + if (defined('WP_CLI') && WP_CLI) { |
|
253 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'); |
|
254 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | } |
@@ -264,21 +264,21 @@ discard block |
||
264 | 264 | * @since 1.0.19 |
265 | 265 | * @return void |
266 | 266 | */ |
267 | - public function autoload( $class_name ) { |
|
267 | + public function autoload($class_name) { |
|
268 | 268 | |
269 | 269 | // Normalize the class name... |
270 | - $class_name = strtolower( $class_name ); |
|
270 | + $class_name = strtolower($class_name); |
|
271 | 271 | |
272 | 272 | // ... and make sure it is our class. |
273 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
273 | + if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) { |
|
274 | 274 | return; |
275 | 275 | } |
276 | 276 | |
277 | 277 | // Next, prepare the file name from the class. |
278 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
278 | + $file_name = 'class-' . str_replace('_', '-', $class_name) . '.php'; |
|
279 | 279 | |
280 | 280 | // Base path of the classes. |
281 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
281 | + $plugin_path = untrailingslashit(WPINV_PLUGIN_DIR); |
|
282 | 282 | |
283 | 283 | // And an array of possible locations in order of importance. |
284 | 284 | $locations = array( |
@@ -293,10 +293,10 @@ discard block |
||
293 | 293 | "$plugin_path/includes/admin/meta-boxes", |
294 | 294 | ); |
295 | 295 | |
296 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
296 | + foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) { |
|
297 | 297 | |
298 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
299 | - include trailingslashit( $location ) . $file_name; |
|
298 | + if (file_exists(trailingslashit($location) . $file_name)) { |
|
299 | + include trailingslashit($location) . $file_name; |
|
300 | 300 | break; |
301 | 301 | } |
302 | 302 | |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | public function init() { |
311 | 311 | |
312 | 312 | // Fires before getpaid inits. |
313 | - do_action( 'before_getpaid_init', $this ); |
|
313 | + do_action('before_getpaid_init', $this); |
|
314 | 314 | |
315 | 315 | // Maybe upgrade. |
316 | 316 | $this->maybe_upgrade_database(); |
@@ -327,17 +327,17 @@ discard block |
||
327 | 327 | ) |
328 | 328 | ); |
329 | 329 | |
330 | - foreach ( $gateways as $id => $class ) { |
|
331 | - $this->gateways[ $id ] = new $class(); |
|
330 | + foreach ($gateways as $id => $class) { |
|
331 | + $this->gateways[$id] = new $class(); |
|
332 | 332 | } |
333 | 333 | |
334 | - if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) { |
|
334 | + if ('yes' != get_option('wpinv_renamed_gateways')) { |
|
335 | 335 | GetPaid_Installer::rename_gateways_label(); |
336 | - update_option( 'wpinv_renamed_gateways', 'yes' ); |
|
336 | + update_option('wpinv_renamed_gateways', 'yes'); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | // Fires after getpaid inits. |
340 | - do_action( 'getpaid_init', $this ); |
|
340 | + do_action('getpaid_init', $this); |
|
341 | 341 | |
342 | 342 | } |
343 | 343 | |
@@ -347,14 +347,14 @@ discard block |
||
347 | 347 | public function maybe_process_ipn() { |
348 | 348 | |
349 | 349 | // Ensure that this is an IPN request. |
350 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
350 | + if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) { |
|
351 | 351 | return; |
352 | 352 | } |
353 | 353 | |
354 | - $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
354 | + $gateway = wpinv_clean($_GET['wpi-gateway']); |
|
355 | 355 | |
356 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
357 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
356 | + do_action('wpinv_verify_payment_ipn', $gateway); |
|
357 | + do_action("wpinv_verify_{$gateway}_ipn"); |
|
358 | 358 | exit; |
359 | 359 | |
360 | 360 | } |
@@ -362,29 +362,29 @@ discard block |
||
362 | 362 | public function enqueue_scripts() { |
363 | 363 | |
364 | 364 | // Fires before adding scripts. |
365 | - do_action( 'getpaid_enqueue_scripts' ); |
|
365 | + do_action('getpaid_enqueue_scripts'); |
|
366 | 366 | |
367 | 367 | $localize = array(); |
368 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
368 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
369 | 369 | $localize['thousands'] = wpinv_thousands_separator(); |
370 | 370 | $localize['decimals'] = wpinv_decimal_separator(); |
371 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
372 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
371 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
372 | + $localize['txtComplete'] = __('Continue', 'invoicing'); |
|
373 | 373 | $localize['UseTaxes'] = wpinv_use_taxes(); |
374 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
375 | - $localize['loading'] = __( 'Loading...', 'invoicing' ); |
|
376 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
374 | + $localize['formNonce'] = wp_create_nonce('getpaid_form_nonce'); |
|
375 | + $localize['loading'] = __('Loading...', 'invoicing'); |
|
376 | + $localize['connectionError'] = __('Could not establish a connection to the server.', 'invoicing'); |
|
377 | 377 | |
378 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
378 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
379 | 379 | |
380 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
381 | - wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true ); |
|
382 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
380 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js'); |
|
381 | + wp_enqueue_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('jquery'), $version, true); |
|
382 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | public function wpinv_actions() { |
386 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
387 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
386 | + if (isset($_REQUEST['wpi_action'])) { |
|
387 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
388 | 388 | } |
389 | 389 | } |
390 | 390 | |
@@ -396,24 +396,24 @@ discard block |
||
396 | 396 | */ |
397 | 397 | public function maybe_do_authenticated_action() { |
398 | 398 | |
399 | - if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
399 | + if (isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
400 | 400 | |
401 | - $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
402 | - $data = wp_unslash( $_REQUEST ); |
|
403 | - if ( is_user_logged_in() ) { |
|
404 | - do_action( "getpaid_authenticated_action_$key", $data ); |
|
401 | + $key = sanitize_key($_REQUEST['getpaid-action']); |
|
402 | + $data = wp_unslash($_REQUEST); |
|
403 | + if (is_user_logged_in()) { |
|
404 | + do_action("getpaid_authenticated_action_$key", $data); |
|
405 | 405 | } |
406 | 406 | |
407 | - do_action( "getpaid_unauthenticated_action_$key", $data ); |
|
407 | + do_action("getpaid_unauthenticated_action_$key", $data); |
|
408 | 408 | |
409 | 409 | } |
410 | 410 | |
411 | 411 | } |
412 | 412 | |
413 | - public function pre_get_posts( $wp_query ) { |
|
413 | + public function pre_get_posts($wp_query) { |
|
414 | 414 | |
415 | - if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
416 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
415 | + if (!is_admin() && !empty($wp_query->query_vars['post_type']) && getpaid_is_invoice_post_type($wp_query->query_vars['post_type']) && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
416 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses(false, false, $wp_query->query_vars['post_type'])); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | return $wp_query; |
@@ -428,18 +428,18 @@ discard block |
||
428 | 428 | |
429 | 429 | // Currently, UX Builder does not work particulaly well with SuperDuper. |
430 | 430 | // So we disable our widgets when editing a page with UX Builder. |
431 | - if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) { |
|
431 | + if (function_exists('ux_builder_is_active') && ux_builder_is_active()) { |
|
432 | 432 | return; |
433 | 433 | } |
434 | 434 | |
435 | 435 | $block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array(); |
436 | 436 | |
437 | - if ( is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) { |
|
437 | + if (is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) { |
|
438 | 438 | // don't initiate in these conditions. |
439 | - }else{ |
|
439 | + } else { |
|
440 | 440 | |
441 | 441 | // Only load allowed widgets. |
442 | - $exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array(); |
|
442 | + $exclude = function_exists('sd_widget_exclude') ? sd_widget_exclude() : array(); |
|
443 | 443 | $widgets = apply_filters( |
444 | 444 | 'getpaid_widget_classes', |
445 | 445 | array( |
@@ -454,16 +454,16 @@ discard block |
||
454 | 454 | ); |
455 | 455 | |
456 | 456 | // For each widget... |
457 | - foreach ( $widgets as $widget ) { |
|
457 | + foreach ($widgets as $widget) { |
|
458 | 458 | |
459 | 459 | // Abort early if it is excluded for this page. |
460 | - if ( in_array( $widget, $exclude ) ) { |
|
460 | + if (in_array($widget, $exclude)) { |
|
461 | 461 | continue; |
462 | 462 | } |
463 | 463 | |
464 | 464 | // SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it. |
465 | - if ( is_subclass_of( $widget, 'WP_Widget' ) ) { |
|
466 | - register_widget( $widget ); |
|
465 | + if (is_subclass_of($widget, 'WP_Widget')) { |
|
466 | + register_widget($widget); |
|
467 | 467 | } else { |
468 | 468 | new $widget(); |
469 | 469 | } |
@@ -481,29 +481,29 @@ discard block |
||
481 | 481 | */ |
482 | 482 | public function maybe_upgrade_database() { |
483 | 483 | |
484 | - $wpi_version = get_option( 'wpinv_version', 0 ); |
|
484 | + $wpi_version = get_option('wpinv_version', 0); |
|
485 | 485 | |
486 | - if ( $wpi_version == WPINV_VERSION ) { |
|
486 | + if ($wpi_version == WPINV_VERSION) { |
|
487 | 487 | return; |
488 | 488 | } |
489 | 489 | |
490 | 490 | $installer = new GetPaid_Installer(); |
491 | 491 | |
492 | - if ( empty( $wpi_version ) ) { |
|
493 | - return $installer->upgrade_db( 0 ); |
|
492 | + if (empty($wpi_version)) { |
|
493 | + return $installer->upgrade_db(0); |
|
494 | 494 | } |
495 | 495 | |
496 | - $upgrades = array( |
|
496 | + $upgrades = array( |
|
497 | 497 | '0.0.5' => '004', |
498 | 498 | '1.0.3' => '102', |
499 | 499 | '2.0.0' => '118', |
500 | 500 | '2.0.8' => '207', |
501 | 501 | ); |
502 | 502 | |
503 | - foreach ( $upgrades as $key => $method ) { |
|
503 | + foreach ($upgrades as $key => $method) { |
|
504 | 504 | |
505 | - if ( version_compare( $wpi_version, $key, '<' ) ) { |
|
506 | - return $installer->upgrade_db( $method ); |
|
505 | + if (version_compare($wpi_version, $key, '<')) { |
|
506 | + return $installer->upgrade_db($method); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | } |
@@ -517,11 +517,11 @@ discard block |
||
517 | 517 | */ |
518 | 518 | public function maybe_flush_permalinks() { |
519 | 519 | |
520 | - $flush = get_option( 'wpinv_flush_permalinks', 0 ); |
|
520 | + $flush = get_option('wpinv_flush_permalinks', 0); |
|
521 | 521 | |
522 | - if ( ! empty( $flush ) ) { |
|
522 | + if (!empty($flush)) { |
|
523 | 523 | flush_rewrite_rules(); |
524 | - delete_option( 'wpinv_flush_permalinks' ); |
|
524 | + delete_option('wpinv_flush_permalinks'); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | } |
@@ -532,10 +532,10 @@ discard block |
||
532 | 532 | * @since 1.0.19 |
533 | 533 | * @param int[] $excluded_posts_ids |
534 | 534 | */ |
535 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
535 | + public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) { |
|
536 | 536 | |
537 | 537 | // Ensure that we have an array. |
538 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
538 | + if (!is_array($excluded_posts_ids)) { |
|
539 | 539 | $excluded_posts_ids = array(); |
540 | 540 | } |
541 | 541 | |
@@ -543,24 +543,24 @@ discard block |
||
543 | 543 | $our_pages = array(); |
544 | 544 | |
545 | 545 | // Checkout page. |
546 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
546 | + $our_pages[] = wpinv_get_option('checkout_page', false); |
|
547 | 547 | |
548 | 548 | // Success page. |
549 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
549 | + $our_pages[] = wpinv_get_option('success_page', false); |
|
550 | 550 | |
551 | 551 | // Failure page. |
552 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
552 | + $our_pages[] = wpinv_get_option('failure_page', false); |
|
553 | 553 | |
554 | 554 | // History page. |
555 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
555 | + $our_pages[] = wpinv_get_option('invoice_history_page', false); |
|
556 | 556 | |
557 | 557 | // Subscriptions page. |
558 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
558 | + $our_pages[] = wpinv_get_option('invoice_subscription_page', false); |
|
559 | 559 | |
560 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
560 | + $our_pages = array_map('intval', array_filter($our_pages)); |
|
561 | 561 | |
562 | 562 | $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
563 | - return array_unique( $excluded_posts_ids ); |
|
563 | + return array_unique($excluded_posts_ids); |
|
564 | 564 | |
565 | 565 | } |
566 | 566 | |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | * @since 2.0.0 |
571 | 571 | */ |
572 | 572 | public function wp_footer() { |
573 | - wpinv_get_template( 'frontend-footer.php' ); |
|
573 | + wpinv_get_template('frontend-footer.php'); |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | /** |
@@ -579,14 +579,14 @@ discard block |
||
579 | 579 | * @since 2.0.0 |
580 | 580 | */ |
581 | 581 | public function wp_head() { |
582 | - wpinv_get_template( 'frontend-head.php' ); |
|
582 | + wpinv_get_template('frontend-head.php'); |
|
583 | 583 | } |
584 | 584 | |
585 | 585 | /** |
586 | 586 | * Custom query vars. |
587 | 587 | * |
588 | 588 | */ |
589 | - public function custom_query_vars( $vars ) { |
|
589 | + public function custom_query_vars($vars) { |
|
590 | 590 | $vars[] = 'getpaid-ipn'; |
591 | 591 | return $vars; |
592 | 592 | } |
@@ -597,28 +597,28 @@ discard block |
||
597 | 597 | */ |
598 | 598 | public function add_rewrite_rule() { |
599 | 599 | $tag = 'getpaid-ipn'; |
600 | - add_rewrite_tag( "%$tag%", '([^&]+)' ); |
|
601 | - add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]",'top' ); |
|
600 | + add_rewrite_tag("%$tag%", '([^&]+)'); |
|
601 | + add_rewrite_rule("^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top'); |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | /** |
605 | 605 | * Processes non-query string ipns. |
606 | 606 | * |
607 | 607 | */ |
608 | - public function maybe_process_new_ipn( $query ) { |
|
608 | + public function maybe_process_new_ipn($query) { |
|
609 | 609 | |
610 | - if ( is_admin() || ! $query->is_main_query() ) { |
|
610 | + if (is_admin() || !$query->is_main_query()) { |
|
611 | 611 | return; |
612 | 612 | } |
613 | 613 | |
614 | - $gateway = get_query_var( 'getpaid-ipn' ); |
|
614 | + $gateway = get_query_var('getpaid-ipn'); |
|
615 | 615 | |
616 | - if ( ! empty( $gateway ) ){ |
|
616 | + if (!empty($gateway)) { |
|
617 | 617 | |
618 | - $gateway = sanitize_text_field( $gateway ); |
|
618 | + $gateway = sanitize_text_field($gateway); |
|
619 | 619 | nocache_headers(); |
620 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
621 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
620 | + do_action('wpinv_verify_payment_ipn', $gateway); |
|
621 | + do_action("wpinv_verify_{$gateway}_ipn"); |
|
622 | 622 | exit; |
623 | 623 | |
624 | 624 | } |
@@ -436,7 +436,7 @@ |
||
436 | 436 | |
437 | 437 | if ( is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) { |
438 | 438 | // don't initiate in these conditions. |
439 | - }else{ |
|
439 | + } else{ |
|
440 | 440 | |
441 | 441 | // Only load allowed widgets. |
442 | 442 | $exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array(); |
@@ -6,35 +6,35 @@ discard block |
||
6 | 6 | |
7 | 7 | class ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5 |
8 | 8 | { |
9 | - public static $files = array ( |
|
9 | + public static $files = array( |
|
10 | 10 | 'e8d544c98e79f913e13eae1306ab635e' => __DIR__ . '/..' . '/ayecode/wp-ayecode-ui/ayecode-ui-loader.php', |
11 | 11 | '24583d3588ebda5228dd453cfaa070da' => __DIR__ . '/..' . '/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php', |
12 | 12 | '42671a413efb740d7040437ff2a982cd' => __DIR__ . '/..' . '/ayecode/wp-super-duper/sd-functions.php', |
13 | 13 | ); |
14 | 14 | |
15 | - public static $prefixLengthsPsr4 = array ( |
|
15 | + public static $prefixLengthsPsr4 = array( |
|
16 | 16 | 'M' => |
17 | - array ( |
|
17 | + array( |
|
18 | 18 | 'MaxMind\\Db\\' => 11, |
19 | 19 | ), |
20 | 20 | 'C' => |
21 | - array ( |
|
21 | + array( |
|
22 | 22 | 'Composer\\Installers\\' => 20, |
23 | 23 | ), |
24 | 24 | ); |
25 | 25 | |
26 | - public static $prefixDirsPsr4 = array ( |
|
26 | + public static $prefixDirsPsr4 = array( |
|
27 | 27 | 'MaxMind\\Db\\' => |
28 | - array ( |
|
28 | + array( |
|
29 | 29 | 0 => __DIR__ . '/..' . '/maxmind-db/reader/src/MaxMind/Db', |
30 | 30 | ), |
31 | 31 | 'Composer\\Installers\\' => |
32 | - array ( |
|
32 | + array( |
|
33 | 33 | 0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers', |
34 | 34 | ), |
35 | 35 | ); |
36 | 36 | |
37 | - public static $classMap = array ( |
|
37 | + public static $classMap = array( |
|
38 | 38 | 'AyeCode_Connect_Helper' => __DIR__ . '/..' . '/ayecode/ayecode-connect-helper/ayecode-connect-helper.php', |
39 | 39 | 'AyeCode_Deactivation_Survey' => __DIR__ . '/..' . '/ayecode/wp-deactivation-survey/wp-deactivation-survey.php', |
40 | 40 | 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | public static function getInitializer(ClassLoader $loader) |
45 | 45 | { |
46 | - return \Closure::bind(function () use ($loader) { |
|
46 | + return \Closure::bind(function() use ($loader) { |
|
47 | 47 | $loader->prefixLengthsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixLengthsPsr4; |
48 | 48 | $loader->prefixDirsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixDirsPsr4; |
49 | 49 | $loader->classMap = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$classMap; |
@@ -312,9 +312,9 @@ |
||
312 | 312 | foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { |
313 | 313 | if (isset(self::$installedByVendor[$vendorDir])) { |
314 | 314 | $installed[] = self::$installedByVendor[$vendorDir]; |
315 | - } elseif (is_file($vendorDir.'/composer/installed.php')) { |
|
316 | - $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; |
|
317 | - if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { |
|
315 | + } elseif (is_file($vendorDir . '/composer/installed.php')) { |
|
316 | + $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir . '/composer/installed.php'; |
|
317 | + if (null === self::$installed && strtr($vendorDir . '/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { |
|
318 | 318 | self::$installed = $installed[count($installed) - 1]; |
319 | 319 | } |
320 | 320 | } |