@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | /** |
9 | 9 | * Main Subscriptions class. |
10 | 10 | * |
@@ -14,31 +14,31 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * Class constructor. |
16 | 16 | */ |
17 | - public function __construct(){ |
|
17 | + public function __construct() { |
|
18 | 18 | |
19 | 19 | // Fire gateway specific hooks when a subscription changes. |
20 | - add_action( 'getpaid_subscription_status_changed', array( $this, 'process_subscription_status_change' ), 10, 3 ); |
|
20 | + add_action('getpaid_subscription_status_changed', array($this, 'process_subscription_status_change'), 10, 3); |
|
21 | 21 | |
22 | 22 | // De-activate a subscription whenever the invoice changes payment statuses. |
23 | - add_action( 'getpaid_invoice_status_wpi-refunded', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
|
24 | - add_action( 'getpaid_invoice_status_wpi-failed', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
|
25 | - add_action( 'getpaid_invoice_status_wpi-cancelled', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
|
26 | - add_action( 'getpaid_invoice_status_wpi-pending', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
|
23 | + add_action('getpaid_invoice_status_wpi-refunded', array($this, 'maybe_deactivate_invoice_subscription'), 20); |
|
24 | + add_action('getpaid_invoice_status_wpi-failed', array($this, 'maybe_deactivate_invoice_subscription'), 20); |
|
25 | + add_action('getpaid_invoice_status_wpi-cancelled', array($this, 'maybe_deactivate_invoice_subscription'), 20); |
|
26 | + add_action('getpaid_invoice_status_wpi-pending', array($this, 'maybe_deactivate_invoice_subscription'), 20); |
|
27 | 27 | |
28 | 28 | // Handles subscription cancelations. |
29 | - add_action( 'getpaid_authenticated_action_subscription_cancel', array( $this, 'user_cancel_single_subscription' ) ); |
|
29 | + add_action('getpaid_authenticated_action_subscription_cancel', array($this, 'user_cancel_single_subscription')); |
|
30 | 30 | |
31 | 31 | // Create a subscription whenever an invoice is created, (and update it when it is updated). |
32 | - add_action( 'getpaid_new_invoice', array( $this, 'maybe_create_invoice_subscription' ) ); |
|
33 | - add_action( 'getpaid_update_invoice', array( $this, 'maybe_update_invoice_subscription' ) ); |
|
32 | + add_action('getpaid_new_invoice', array($this, 'maybe_create_invoice_subscription')); |
|
33 | + add_action('getpaid_update_invoice', array($this, 'maybe_update_invoice_subscription')); |
|
34 | 34 | |
35 | 35 | // Handles admin subscription update actions. |
36 | - add_action( 'getpaid_authenticated_admin_action_update_single_subscription', array( $this, 'admin_update_single_subscription' ) ); |
|
37 | - add_action( 'getpaid_authenticated_admin_action_subscription_manual_renew', array( $this, 'admin_renew_single_subscription' ) ); |
|
38 | - add_action( 'getpaid_authenticated_admin_action_subscription_manual_delete', array( $this, 'admin_delete_single_subscription' ) ); |
|
36 | + add_action('getpaid_authenticated_admin_action_update_single_subscription', array($this, 'admin_update_single_subscription')); |
|
37 | + add_action('getpaid_authenticated_admin_action_subscription_manual_renew', array($this, 'admin_renew_single_subscription')); |
|
38 | + add_action('getpaid_authenticated_admin_action_subscription_manual_delete', array($this, 'admin_delete_single_subscription')); |
|
39 | 39 | |
40 | 40 | // Filter invoice item row actions. |
41 | - add_action( 'getpaid-invoice-page-line-item-actions', array( $this, 'filter_invoice_line_item_actions' ), 10, 3 ); |
|
41 | + add_action('getpaid-invoice-page-line-item-actions', array($this, 'filter_invoice_line_item_actions'), 10, 3); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -47,19 +47,19 @@ discard block |
||
47 | 47 | * @param WPInv_Invoice $invoice |
48 | 48 | * @return WPInv_Subscription|bool |
49 | 49 | */ |
50 | - public function get_invoice_subscription( $invoice ) { |
|
50 | + public function get_invoice_subscription($invoice) { |
|
51 | 51 | $subscription_id = $invoice->get_subscription_id(); |
52 | 52 | |
53 | 53 | // Fallback to the parent invoice if the child invoice has no subscription id. |
54 | - if ( empty( $subscription_id && $invoice->is_renewal() ) ) { |
|
54 | + if (empty($subscription_id && $invoice->is_renewal())) { |
|
55 | 55 | $subscription_id = $invoice->get_parent_payment()->get_subscription_id(); |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Fetch the subscription. |
59 | - $subscription = new WPInv_Subscription( $subscription_id ); |
|
59 | + $subscription = new WPInv_Subscription($subscription_id); |
|
60 | 60 | |
61 | 61 | // Return subscription or use a fallback for backwards compatibility. |
62 | - return $subscription->get_id() ? $subscription : wpinv_get_subscription( $invoice ); |
|
62 | + return $subscription->get_id() ? $subscription : wpinv_get_subscription($invoice); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -67,16 +67,16 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @param WPInv_Invoice $invoice |
69 | 69 | */ |
70 | - public function maybe_deactivate_invoice_subscription( $invoice ) { |
|
70 | + public function maybe_deactivate_invoice_subscription($invoice) { |
|
71 | 71 | |
72 | - $subscription = $this->get_invoice_subscription( $invoice ); |
|
72 | + $subscription = $this->get_invoice_subscription($invoice); |
|
73 | 73 | |
74 | 74 | // Abort if the subscription is missing or not active. |
75 | - if ( empty( $subscription ) || ! $subscription->is_active() ) { |
|
75 | + if (empty($subscription) || !$subscription->is_active()) { |
|
76 | 76 | return; |
77 | 77 | } |
78 | 78 | |
79 | - $subscription->set_status( 'pending' ); |
|
79 | + $subscription->set_status('pending'); |
|
80 | 80 | $subscription->save(); |
81 | 81 | |
82 | 82 | } |
@@ -88,15 +88,15 @@ discard block |
||
88 | 88 | * @param string $from |
89 | 89 | * @param string $to |
90 | 90 | */ |
91 | - public function process_subscription_status_change( $subscription, $from, $to ) { |
|
91 | + public function process_subscription_status_change($subscription, $from, $to) { |
|
92 | 92 | |
93 | 93 | $gateway = $subscription->get_gateway(); |
94 | 94 | |
95 | - if ( ! empty( $gateway ) ) { |
|
96 | - $gateway = sanitize_key( $gateway ); |
|
97 | - $from = sanitize_key( $from ); |
|
98 | - $to = sanitize_key( $to ); |
|
99 | - do_action( "getpaid_{$gateway}_subscription_$to", $subscription, $from ); |
|
95 | + if (!empty($gateway)) { |
|
96 | + $gateway = sanitize_key($gateway); |
|
97 | + $from = sanitize_key($from); |
|
98 | + $to = sanitize_key($to); |
|
99 | + do_action("getpaid_{$gateway}_subscription_$to", $subscription, $from); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | } |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | * @deprecated |
110 | 110 | * @return mixed|string|void |
111 | 111 | */ |
112 | - public static function wpinv_get_pretty_subscription_frequency( $period, $frequency_count = 1 ) { |
|
113 | - return getpaid_get_subscription_period_label( $period, $frequency_count ); |
|
112 | + public static function wpinv_get_pretty_subscription_frequency($period, $frequency_count = 1) { |
|
113 | + return getpaid_get_subscription_period_label($period, $frequency_count); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -120,29 +120,29 @@ discard block |
||
120 | 120 | * @since 1.0.0 |
121 | 121 | * @return void |
122 | 122 | */ |
123 | - public function user_cancel_single_subscription( $data ) { |
|
123 | + public function user_cancel_single_subscription($data) { |
|
124 | 124 | |
125 | 125 | // Ensure there is a subscription to cancel. |
126 | - if ( empty( $data['subscription'] ) ) { |
|
126 | + if (empty($data['subscription'])) { |
|
127 | 127 | return; |
128 | 128 | } |
129 | 129 | |
130 | - $subscription = new WPInv_Subscription( (int) $data['subscription'] ); |
|
130 | + $subscription = new WPInv_Subscription((int) $data['subscription']); |
|
131 | 131 | |
132 | 132 | // Ensure that it exists and that it belongs to the current user. |
133 | - if ( ! $subscription->get_id() || $subscription->get_customer_id() != get_current_user_id() ) { |
|
134 | - wpinv_set_error( 'invalid_subscription', __( 'You do not have permission to cancel this subscription', 'invoicing' ) ); |
|
133 | + if (!$subscription->get_id() || $subscription->get_customer_id() != get_current_user_id()) { |
|
134 | + wpinv_set_error('invalid_subscription', __('You do not have permission to cancel this subscription', 'invoicing')); |
|
135 | 135 | |
136 | 136 | // Can it be cancelled. |
137 | - } else if ( ! $subscription->can_cancel() ) { |
|
138 | - wpinv_set_error( 'cannot_cancel', __( 'This subscription cannot be cancelled as it is not active.', 'invoicing' ) ); |
|
137 | + } else if (!$subscription->can_cancel()) { |
|
138 | + wpinv_set_error('cannot_cancel', __('This subscription cannot be cancelled as it is not active.', 'invoicing')); |
|
139 | 139 | |
140 | 140 | |
141 | 141 | // Cancel it. |
142 | 142 | } else { |
143 | 143 | |
144 | 144 | $subscription->cancel(); |
145 | - wpinv_set_error( 'cancelled', __( 'This subscription has been cancelled.', 'invoicing' ), 'info' ); |
|
145 | + wpinv_set_error('cancelled', __('This subscription has been cancelled.', 'invoicing'), 'info'); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | $redirect = add_query_arg( |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | ) |
153 | 153 | ); |
154 | 154 | |
155 | - wp_safe_redirect( esc_url( $redirect ) ); |
|
155 | + wp_safe_redirect(esc_url($redirect)); |
|
156 | 156 | exit; |
157 | 157 | |
158 | 158 | } |
@@ -164,15 +164,15 @@ discard block |
||
164 | 164 | * @param WPInv_Invoice $invoice |
165 | 165 | * @since 1.0.0 |
166 | 166 | */ |
167 | - public function maybe_create_invoice_subscription( $invoice ) { |
|
167 | + public function maybe_create_invoice_subscription($invoice) { |
|
168 | 168 | |
169 | 169 | // Abort if it is not recurring. |
170 | - if ( $invoice->is_free() || ! $invoice->is_recurring() || $invoice->is_renewal() ) { |
|
170 | + if ($invoice->is_free() || !$invoice->is_recurring() || $invoice->is_renewal()) { |
|
171 | 171 | return; |
172 | 172 | } |
173 | 173 | |
174 | 174 | $subscription = new WPInv_Subscription(); |
175 | - return $this->update_invoice_subscription( $subscription, $invoice ); |
|
175 | + return $this->update_invoice_subscription($subscription, $invoice); |
|
176 | 176 | |
177 | 177 | } |
178 | 178 | |
@@ -183,25 +183,25 @@ discard block |
||
183 | 183 | * @param WPInv_Invoice $invoice |
184 | 184 | * @since 1.0.19 |
185 | 185 | */ |
186 | - public function maybe_update_invoice_subscription( $invoice ) { |
|
186 | + public function maybe_update_invoice_subscription($invoice) { |
|
187 | 187 | |
188 | 188 | // Do not process renewals. |
189 | - if ( $invoice->is_renewal() ) { |
|
189 | + if ($invoice->is_renewal()) { |
|
190 | 190 | return; |
191 | 191 | } |
192 | 192 | |
193 | 193 | // (Maybe) create a new subscription. |
194 | - $subscription = $this->get_invoice_subscription( $invoice ); |
|
195 | - if ( empty( $subscription ) ) { |
|
196 | - return $this->maybe_create_invoice_subscription( $invoice ); |
|
194 | + $subscription = $this->get_invoice_subscription($invoice); |
|
195 | + if (empty($subscription)) { |
|
196 | + return $this->maybe_create_invoice_subscription($invoice); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | // Abort if an invoice is paid and already has a subscription. |
200 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
200 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
201 | 201 | return; |
202 | 202 | } |
203 | 203 | |
204 | - return $this->update_invoice_subscription( $subscription, $invoice ); |
|
204 | + return $this->update_invoice_subscription($subscription, $invoice); |
|
205 | 205 | |
206 | 206 | } |
207 | 207 | |
@@ -213,55 +213,55 @@ discard block |
||
213 | 213 | * @param WPInv_Invoice $invoice |
214 | 214 | * @since 1.0.19 |
215 | 215 | */ |
216 | - public function update_invoice_subscription( $subscription, $invoice ) { |
|
216 | + public function update_invoice_subscription($subscription, $invoice) { |
|
217 | 217 | |
218 | 218 | // Delete the subscription if an invoice is free or nolonger recurring. |
219 | - if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_free() || ! $invoice->is_recurring() ) { |
|
219 | + if (!$invoice->is_type('invoice') || $invoice->is_free() || !$invoice->is_recurring()) { |
|
220 | 220 | return $subscription->delete(); |
221 | 221 | } |
222 | 222 | |
223 | - $subscription->set_customer_id( $invoice->get_customer_id() ); |
|
224 | - $subscription->set_parent_invoice_id( $invoice->get_id() ); |
|
225 | - $subscription->set_initial_amount( $invoice->get_initial_total() ); |
|
226 | - $subscription->set_recurring_amount( $invoice->get_recurring_total() ); |
|
227 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
228 | - $subscription->set_status( $invoice->is_paid() ? 'active' : 'pending' ); |
|
223 | + $subscription->set_customer_id($invoice->get_customer_id()); |
|
224 | + $subscription->set_parent_invoice_id($invoice->get_id()); |
|
225 | + $subscription->set_initial_amount($invoice->get_initial_total()); |
|
226 | + $subscription->set_recurring_amount($invoice->get_recurring_total()); |
|
227 | + $subscription->set_date_created(current_time('mysql')); |
|
228 | + $subscription->set_status($invoice->is_paid() ? 'active' : 'pending'); |
|
229 | 229 | |
230 | 230 | // Get the recurring item and abort if it does not exist. |
231 | - $subscription_item = $invoice->get_recurring( true ); |
|
232 | - if ( ! $subscription_item->get_id() ) { |
|
231 | + $subscription_item = $invoice->get_recurring(true); |
|
232 | + if (!$subscription_item->get_id()) { |
|
233 | 233 | $invoice->set_subscription_id(0); |
234 | 234 | $invoice->save(); |
235 | 235 | return $subscription->delete(); |
236 | 236 | } |
237 | 237 | |
238 | - $subscription->set_product_id( $subscription_item->get_id() ); |
|
239 | - $subscription->set_period( $subscription_item->get_recurring_period( true ) ); |
|
240 | - $subscription->set_frequency( $subscription_item->get_recurring_interval() ); |
|
241 | - $subscription->set_bill_times( $subscription_item->get_recurring_limit() ); |
|
238 | + $subscription->set_product_id($subscription_item->get_id()); |
|
239 | + $subscription->set_period($subscription_item->get_recurring_period(true)); |
|
240 | + $subscription->set_frequency($subscription_item->get_recurring_interval()); |
|
241 | + $subscription->set_bill_times($subscription_item->get_recurring_limit()); |
|
242 | 242 | |
243 | 243 | // Calculate the next renewal date. |
244 | - $period = $subscription_item->get_recurring_period( true ); |
|
244 | + $period = $subscription_item->get_recurring_period(true); |
|
245 | 245 | $interval = $subscription_item->get_recurring_interval(); |
246 | 246 | |
247 | 247 | // If the subscription item has a trial period... |
248 | - if ( $subscription_item->has_free_trial() ) { |
|
249 | - $period = $subscription_item->get_trial_period( true ); |
|
248 | + if ($subscription_item->has_free_trial()) { |
|
249 | + $period = $subscription_item->get_trial_period(true); |
|
250 | 250 | $interval = $subscription_item->get_trial_interval(); |
251 | - $subscription->set_trial_period( $interval . ' ' . $period ); |
|
252 | - $subscription->set_status( 'trialling' ); |
|
251 | + $subscription->set_trial_period($interval . ' ' . $period); |
|
252 | + $subscription->set_status('trialling'); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | // If initial amount is free, treat it as a free trial even if the subscription item does not have a free trial. |
256 | - if ( $invoice->has_free_trial() ) { |
|
257 | - $subscription->set_trial_period( $interval . ' ' . $period ); |
|
258 | - $subscription->set_status( 'trialling' ); |
|
256 | + if ($invoice->has_free_trial()) { |
|
257 | + $subscription->set_trial_period($interval . ' ' . $period); |
|
258 | + $subscription->set_status('trialling'); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | // Calculate the next renewal date. |
262 | - $expiration = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", strtotime( $subscription->get_date_created() ) ) ); |
|
262 | + $expiration = date('Y-m-d H:i:s', strtotime("+$interval $period", strtotime($subscription->get_date_created()))); |
|
263 | 263 | |
264 | - $subscription->set_next_renewal_date( $expiration ); |
|
264 | + $subscription->set_next_renewal_date($expiration); |
|
265 | 265 | return $subscription->save(); |
266 | 266 | |
267 | 267 | } |
@@ -272,21 +272,21 @@ discard block |
||
272 | 272 | * @param array $data |
273 | 273 | * @since 1.0.19 |
274 | 274 | */ |
275 | - public function admin_update_single_subscription( $args ) { |
|
275 | + public function admin_update_single_subscription($args) { |
|
276 | 276 | |
277 | 277 | // Ensure the subscription exists and that a status has been given. |
278 | - if ( empty( $args['subscription_id'] ) || empty( $args['subscription_status'] ) ) { |
|
278 | + if (empty($args['subscription_id']) || empty($args['subscription_status'])) { |
|
279 | 279 | return; |
280 | 280 | } |
281 | 281 | |
282 | 282 | // Retrieve the subscriptions. |
283 | - $subscription = new WPInv_Subscription( $args['subscription_id'] ); |
|
283 | + $subscription = new WPInv_Subscription($args['subscription_id']); |
|
284 | 284 | |
285 | - if ( $subscription->get_id() ) { |
|
285 | + if ($subscription->get_id()) { |
|
286 | 286 | |
287 | - $subscription->set_status( $args['subscription_status'] ); |
|
287 | + $subscription->set_status($args['subscription_status']); |
|
288 | 288 | $subscription->save(); |
289 | - getpaid_admin()->show_info( __( 'Your changes have been saved', 'invoicing' ) ); |
|
289 | + getpaid_admin()->show_info(__('Your changes have been saved', 'invoicing')); |
|
290 | 290 | |
291 | 291 | } |
292 | 292 | |
@@ -298,27 +298,27 @@ discard block |
||
298 | 298 | * @param array $data |
299 | 299 | * @since 1.0.19 |
300 | 300 | */ |
301 | - public function admin_renew_single_subscription( $args ) { |
|
301 | + public function admin_renew_single_subscription($args) { |
|
302 | 302 | |
303 | 303 | // Ensure the subscription exists and that a status has been given. |
304 | - if ( empty( $args['id'] ) ) { |
|
304 | + if (empty($args['id'])) { |
|
305 | 305 | return; |
306 | 306 | } |
307 | 307 | |
308 | 308 | // Retrieve the subscriptions. |
309 | - $subscription = new WPInv_Subscription( $args['id'] ); |
|
309 | + $subscription = new WPInv_Subscription($args['id']); |
|
310 | 310 | |
311 | - if ( $subscription->get_id() ) { |
|
311 | + if ($subscription->get_id()) { |
|
312 | 312 | |
313 | - do_action( 'getpaid_admin_renew_subscription', $subscription ); |
|
313 | + do_action('getpaid_admin_renew_subscription', $subscription); |
|
314 | 314 | |
315 | - $args = array( 'transaction_id', $subscription->get_parent_invoice()->generate_key( 'renewal_' ) ); |
|
315 | + $args = array('transaction_id', $subscription->get_parent_invoice()->generate_key('renewal_')); |
|
316 | 316 | |
317 | - if ( ! $subscription->add_payment( $args ) ) { |
|
318 | - getpaid_admin()->show_error( __( 'We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing' ) ); |
|
317 | + if (!$subscription->add_payment($args)) { |
|
318 | + getpaid_admin()->show_error(__('We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing')); |
|
319 | 319 | } else { |
320 | 320 | $subscription->renew(); |
321 | - getpaid_admin()->show_info( __( 'This subscription has been renewed and extended.', 'invoicing' ) ); |
|
321 | + getpaid_admin()->show_info(__('This subscription has been renewed and extended.', 'invoicing')); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | wp_safe_redirect( |
@@ -341,20 +341,20 @@ discard block |
||
341 | 341 | * @param array $data |
342 | 342 | * @since 1.0.19 |
343 | 343 | */ |
344 | - public function admin_delete_single_subscription( $args ) { |
|
344 | + public function admin_delete_single_subscription($args) { |
|
345 | 345 | |
346 | 346 | // Ensure the subscription exists and that a status has been given. |
347 | - if ( empty( $args['id'] ) ) { |
|
347 | + if (empty($args['id'])) { |
|
348 | 348 | return; |
349 | 349 | } |
350 | 350 | |
351 | 351 | // Retrieve the subscriptions. |
352 | - $subscription = new WPInv_Subscription( $args['id'] ); |
|
352 | + $subscription = new WPInv_Subscription($args['id']); |
|
353 | 353 | |
354 | - if ( $subscription->delete() ) { |
|
355 | - getpaid_admin()->show_info( __( 'This subscription has been deleted.', 'invoicing' ) ); |
|
354 | + if ($subscription->delete()) { |
|
355 | + getpaid_admin()->show_info(__('This subscription has been deleted.', 'invoicing')); |
|
356 | 356 | } else { |
357 | - getpaid_admin()->show_error( __( 'We are unable to delete this subscription. Please try again.', 'invoicing' ) ); |
|
357 | + getpaid_admin()->show_error(__('We are unable to delete this subscription. Please try again.', 'invoicing')); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | $redirected = wp_safe_redirect( |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | ) |
368 | 368 | ); |
369 | 369 | |
370 | - if ( $redirected ) { |
|
370 | + if ($redirected) { |
|
371 | 371 | exit; |
372 | 372 | } |
373 | 373 | |
@@ -380,10 +380,10 @@ discard block |
||
380 | 380 | * @param WPInv_Item $item |
381 | 381 | * @param WPInv_Invoice $invoice |
382 | 382 | */ |
383 | - public function filter_invoice_line_item_actions( $actions, $item, $invoice ) { |
|
383 | + public function filter_invoice_line_item_actions($actions, $item, $invoice) { |
|
384 | 384 | |
385 | 385 | // Fetch item subscription. |
386 | - $args = array( |
|
386 | + $args = array( |
|
387 | 387 | 'invoice_in' => $invoice->is_parent() ? $invoice->get_id() : $invoice->get_parent_id(), |
388 | 388 | 'item_in' => $item->get_id(), |
389 | 389 | 'number' => 1, |
@@ -391,13 +391,13 @@ discard block |
||
391 | 391 | 'fields' => 'id', |
392 | 392 | ); |
393 | 393 | |
394 | - $subscription = new GetPaid_Subscriptions_Query( $args ); |
|
394 | + $subscription = new GetPaid_Subscriptions_Query($args); |
|
395 | 395 | $subscription = $subscription->get_results(); |
396 | 396 | |
397 | 397 | // In case we found a match... |
398 | - if ( ! empty( $subscription ) ) { |
|
399 | - $url = esc_url( add_query_arg( 'subscription', (int) $subscription[0], get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ) ); |
|
400 | - $actions['subscription'] = "<a href='$url' class='text-decoration-none'>" . __( 'Manage Subscription', 'getpaid-license-manager' ) . '</a>'; |
|
398 | + if (!empty($subscription)) { |
|
399 | + $url = esc_url(add_query_arg('subscription', (int) $subscription[0], get_permalink((int) wpinv_get_option('invoice_subscription_page')))); |
|
400 | + $actions['subscription'] = "<a href='$url' class='text-decoration-none'>" . __('Manage Subscription', 'getpaid-license-manager') . '</a>'; |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | return $actions; |
@@ -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. |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | * @param string $prop The prop to set. |
64 | 64 | * @param mixed $value The value to retrieve. |
65 | 65 | */ |
66 | - public function set( $prop, $value ) { |
|
67 | - $this->data[ $prop ] = $value; |
|
66 | + public function set($prop, $value) { |
|
67 | + $this->data[$prop] = $value; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | * @param string $prop The prop to set. |
74 | 74 | * @return mixed The value. |
75 | 75 | */ |
76 | - public function get( $prop ) { |
|
76 | + public function get($prop) { |
|
77 | 77 | |
78 | - if ( isset( $this->data[ $prop ] ) ) { |
|
79 | - return $this->data[ $prop ]; |
|
78 | + if (isset($this->data[$prop])) { |
|
79 | + return $this->data[$prop]; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | return null; |
@@ -88,25 +88,25 @@ discard block |
||
88 | 88 | public function set_properties() { |
89 | 89 | |
90 | 90 | // Sessions. |
91 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
92 | - $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
91 | + $this->set('session', new WPInv_Session_Handler()); |
|
92 | + $GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility. |
|
93 | 93 | $this->tax = new WPInv_EUVat(); |
94 | 94 | $this->tax->init(); |
95 | 95 | $GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility. |
96 | 96 | |
97 | 97 | // Init other objects. |
98 | - $this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor. |
|
99 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
100 | - $this->set( 'notes', new WPInv_Notes() ); |
|
101 | - $this->set( 'api', new WPInv_API() ); |
|
102 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
103 | - $this->set( 'template', new GetPaid_Template() ); |
|
104 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
105 | - $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
106 | - $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
107 | - $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
108 | - $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
109 | - $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
98 | + $this->set('reports', new WPInv_Reports()); // TODO: Refactor. |
|
99 | + $this->set('session', new WPInv_Session_Handler()); |
|
100 | + $this->set('notes', new WPInv_Notes()); |
|
101 | + $this->set('api', new WPInv_API()); |
|
102 | + $this->set('post_types', new GetPaid_Post_Types()); |
|
103 | + $this->set('template', new GetPaid_Template()); |
|
104 | + $this->set('admin', new GetPaid_Admin()); |
|
105 | + $this->set('subscriptions', new WPInv_Subscriptions()); |
|
106 | + $this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails()); |
|
107 | + $this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails()); |
|
108 | + $this->set('daily_maintenace', new GetPaid_Daily_Maintenance()); |
|
109 | + $this->set('payment_forms', new GetPaid_Payment_Forms()); |
|
110 | 110 | |
111 | 111 | } |
112 | 112 | |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | * Define plugin constants. |
115 | 115 | */ |
116 | 116 | public function define_constants() { |
117 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
118 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
117 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
118 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
119 | 119 | $this->version = WPINV_VERSION; |
120 | 120 | } |
121 | 121 | |
@@ -126,27 +126,27 @@ discard block |
||
126 | 126 | */ |
127 | 127 | protected function init_hooks() { |
128 | 128 | /* Internationalize the text strings used. */ |
129 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
129 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
130 | 130 | |
131 | 131 | // Init the plugin after WordPress inits. |
132 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
133 | - add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
134 | - add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
135 | - add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
132 | + add_action('init', array($this, 'init'), 1); |
|
133 | + add_action('init', array($this, 'maybe_process_ipn'), 10); |
|
134 | + add_action('init', array($this, 'wpinv_actions')); |
|
135 | + add_action('init', array($this, 'maybe_do_authenticated_action'), 100); |
|
136 | 136 | |
137 | - if ( class_exists( 'BuddyPress' ) ) { |
|
138 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
137 | + if (class_exists('BuddyPress')) { |
|
138 | + add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
|
139 | 139 | } |
140 | 140 | |
141 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
142 | - add_action( 'wp_footer', array( &$this, 'wp_footer' ) ); |
|
143 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
144 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
145 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
141 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
142 | + add_action('wp_footer', array(&$this, 'wp_footer')); |
|
143 | + add_action('widgets_init', array(&$this, 'register_widgets')); |
|
144 | + add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids')); |
|
145 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
146 | 146 | |
147 | 147 | // Fires after registering actions. |
148 | - do_action( 'wpinv_actions', $this ); |
|
149 | - do_action( 'getpaid_actions', $this ); |
|
148 | + do_action('wpinv_actions', $this); |
|
149 | + do_action('getpaid_actions', $this); |
|
150 | 150 | |
151 | 151 | } |
152 | 152 | |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | /* Internationalize the text strings used. */ |
155 | 155 | $this->load_textdomain(); |
156 | 156 | |
157 | - do_action( 'wpinv_loaded' ); |
|
157 | + do_action('wpinv_loaded'); |
|
158 | 158 | |
159 | 159 | // Fix oxygen page builder conflict |
160 | - if ( function_exists( 'ct_css_output' ) ) { |
|
160 | + if (function_exists('ct_css_output')) { |
|
161 | 161 | wpinv_oxygen_fix_conflict(); |
162 | 162 | } |
163 | 163 | } |
@@ -167,21 +167,21 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @since 1.0 |
169 | 169 | */ |
170 | - public function load_textdomain( $locale = NULL ) { |
|
171 | - if ( empty( $locale ) ) { |
|
172 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
170 | + public function load_textdomain($locale = NULL) { |
|
171 | + if (empty($locale)) { |
|
172 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
173 | 173 | } |
174 | 174 | |
175 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
175 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
176 | 176 | |
177 | - unload_textdomain( 'invoicing' ); |
|
178 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
179 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
177 | + unload_textdomain('invoicing'); |
|
178 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
179 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
180 | 180 | |
181 | 181 | /** |
182 | 182 | * Define language constants. |
183 | 183 | */ |
184 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
184 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
@@ -190,90 +190,90 @@ discard block |
||
190 | 190 | public function includes() { |
191 | 191 | |
192 | 192 | // Start with the settings. |
193 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
193 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
194 | 194 | |
195 | 195 | // Packages/libraries. |
196 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
197 | - require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
196 | + require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php'); |
|
197 | + require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php'); |
|
198 | 198 | |
199 | 199 | // Load functions. |
200 | - require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
201 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
202 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
203 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
204 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
205 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
206 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
207 | - require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
208 | - require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
209 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
210 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
211 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
212 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
213 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
214 | - require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
200 | + require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php'); |
|
201 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
202 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
203 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
204 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
205 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
206 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
207 | + require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php'); |
|
208 | + require_once(WPINV_PLUGIN_DIR . 'includes/subscription-functions.php'); |
|
209 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
210 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
211 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
212 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
213 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
214 | + require_once(WPINV_PLUGIN_DIR . 'includes/error-functions.php'); |
|
215 | 215 | |
216 | 216 | // Register autoloader. |
217 | 217 | try { |
218 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
219 | - } catch ( Exception $e ) { |
|
220 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
218 | + spl_autoload_register(array($this, 'autoload'), true); |
|
219 | + } catch (Exception $e) { |
|
220 | + wpinv_error_log($e->getMessage(), '', __FILE__, 149, true); |
|
221 | 221 | } |
222 | 222 | |
223 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
224 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
225 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
226 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
227 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
228 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
229 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
230 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
231 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
232 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
233 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
234 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
235 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
236 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
237 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
238 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
239 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
240 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
241 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
242 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
243 | - require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
223 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'); |
|
224 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php'); |
|
225 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
226 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
227 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
228 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
229 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
230 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
231 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
232 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
233 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php'); |
|
234 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
235 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php'); |
|
236 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php'); |
|
237 | + require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php'); |
|
238 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php'); |
|
239 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php'); |
|
240 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php'); |
|
241 | + require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php'); |
|
242 | + require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php'); |
|
243 | + require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php'); |
|
244 | 244 | |
245 | 245 | /** |
246 | 246 | * Load the tax class. |
247 | 247 | */ |
248 | - if ( ! class_exists( 'WPInv_EUVat' ) ) { |
|
249 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
248 | + if (!class_exists('WPInv_EUVat')) { |
|
249 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
250 | 250 | } |
251 | 251 | |
252 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
252 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
253 | 253 | GetPaid_Post_Types_Admin::init(); |
254 | 254 | |
255 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
256 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
257 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
258 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
259 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
260 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
261 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
262 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
255 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
256 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
257 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php'); |
|
258 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
259 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
260 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
261 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
262 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php'); |
|
263 | 263 | // load the user class only on the users.php page |
264 | 264 | global $pagenow; |
265 | - if($pagenow=='users.php'){ |
|
265 | + if ($pagenow == 'users.php') { |
|
266 | 266 | new WPInv_Admin_Users(); |
267 | 267 | } |
268 | 268 | } |
269 | 269 | |
270 | 270 | // Register cli commands |
271 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
272 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
273 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
271 | + if (defined('WP_CLI') && WP_CLI) { |
|
272 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'); |
|
273 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
274 | 274 | } |
275 | 275 | |
276 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
276 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -284,21 +284,21 @@ discard block |
||
284 | 284 | * @since 1.0.19 |
285 | 285 | * @return void |
286 | 286 | */ |
287 | - public function autoload( $class_name ) { |
|
287 | + public function autoload($class_name) { |
|
288 | 288 | |
289 | 289 | // Normalize the class name... |
290 | - $class_name = strtolower( $class_name ); |
|
290 | + $class_name = strtolower($class_name); |
|
291 | 291 | |
292 | 292 | // ... and make sure it is our class. |
293 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
293 | + if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) { |
|
294 | 294 | return; |
295 | 295 | } |
296 | 296 | |
297 | 297 | // Next, prepare the file name from the class. |
298 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
298 | + $file_name = 'class-' . str_replace('_', '-', $class_name) . '.php'; |
|
299 | 299 | |
300 | 300 | // Base path of the classes. |
301 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
301 | + $plugin_path = untrailingslashit(WPINV_PLUGIN_DIR); |
|
302 | 302 | |
303 | 303 | // And an array of possible locations in order of importance. |
304 | 304 | $locations = array( |
@@ -311,10 +311,10 @@ discard block |
||
311 | 311 | "$plugin_path/includes/admin/meta-boxes", |
312 | 312 | ); |
313 | 313 | |
314 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
314 | + foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) { |
|
315 | 315 | |
316 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
317 | - include trailingslashit( $location ) . $file_name; |
|
316 | + if (file_exists(trailingslashit($location) . $file_name)) { |
|
317 | + include trailingslashit($location) . $file_name; |
|
318 | 318 | break; |
319 | 319 | } |
320 | 320 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | public function init() { |
329 | 329 | |
330 | 330 | // Fires before getpaid inits. |
331 | - do_action( 'before_getpaid_init', $this ); |
|
331 | + do_action('before_getpaid_init', $this); |
|
332 | 332 | |
333 | 333 | // Load default gateways. |
334 | 334 | $gateways = apply_filters( |
@@ -342,12 +342,12 @@ discard block |
||
342 | 342 | ) |
343 | 343 | ); |
344 | 344 | |
345 | - foreach ( $gateways as $id => $class ) { |
|
346 | - $this->gateways[ $id ] = new $class(); |
|
345 | + foreach ($gateways as $id => $class) { |
|
346 | + $this->gateways[$id] = new $class(); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | // Fires after getpaid inits. |
350 | - do_action( 'getpaid_init', $this ); |
|
350 | + do_action('getpaid_init', $this); |
|
351 | 351 | |
352 | 352 | } |
353 | 353 | |
@@ -357,55 +357,55 @@ discard block |
||
357 | 357 | public function maybe_process_ipn() { |
358 | 358 | |
359 | 359 | // Ensure that this is an IPN request. |
360 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
360 | + if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) { |
|
361 | 361 | return; |
362 | 362 | } |
363 | 363 | |
364 | - $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
364 | + $gateway = wpinv_clean($_GET['wpi-gateway']); |
|
365 | 365 | |
366 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
367 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
366 | + do_action('wpinv_verify_payment_ipn', $gateway); |
|
367 | + do_action("wpinv_verify_{$gateway}_ipn"); |
|
368 | 368 | exit; |
369 | 369 | |
370 | 370 | } |
371 | 371 | |
372 | 372 | public function enqueue_scripts() { |
373 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
373 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
374 | 374 | |
375 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' ); |
|
376 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version ); |
|
377 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
375 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css'); |
|
376 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version); |
|
377 | + wp_enqueue_style('wpinv_front_style'); |
|
378 | 378 | |
379 | 379 | // Register scripts |
380 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
381 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ), filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) ); |
|
380 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
381 | + wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), filemtime(WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js')); |
|
382 | 382 | |
383 | 383 | $localize = array(); |
384 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
385 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
386 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
384 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
385 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
386 | + $localize['txtComplete'] = __('Continue', 'invoicing'); |
|
387 | 387 | $localize['UseTaxes'] = wpinv_use_taxes(); |
388 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
389 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
390 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
388 | + $localize['checkoutNonce'] = wp_create_nonce('wpinv_checkout_nonce'); |
|
389 | + $localize['formNonce'] = wp_create_nonce('getpaid_form_nonce'); |
|
390 | + $localize['connectionError'] = __('Could not establish a connection to the server.', 'invoicing'); |
|
391 | 391 | |
392 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
392 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
393 | 393 | |
394 | - wp_enqueue_script( 'jquery-blockui' ); |
|
394 | + wp_enqueue_script('jquery-blockui'); |
|
395 | 395 | |
396 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all' ); |
|
397 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
396 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all'); |
|
397 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
398 | 398 | |
399 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
400 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
399 | + wp_enqueue_script('wpinv-front-script'); |
|
400 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
401 | 401 | |
402 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
403 | - wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ), $version, true ); |
|
402 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js'); |
|
403 | + wp_enqueue_script('wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('wpinv-front-script', 'wp-hooks'), $version, true); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | public function wpinv_actions() { |
407 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
408 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
407 | + if (isset($_REQUEST['wpi_action'])) { |
|
408 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
409 | 409 | } |
410 | 410 | } |
411 | 411 | |
@@ -417,31 +417,31 @@ discard block |
||
417 | 417 | */ |
418 | 418 | public function maybe_do_authenticated_action() { |
419 | 419 | |
420 | - if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
420 | + if (isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
421 | 421 | |
422 | - $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
423 | - if ( is_user_logged_in() ) { |
|
424 | - do_action( "getpaid_authenticated_action_$key", $_REQUEST ); |
|
422 | + $key = sanitize_key($_REQUEST['getpaid-action']); |
|
423 | + if (is_user_logged_in()) { |
|
424 | + do_action("getpaid_authenticated_action_$key", $_REQUEST); |
|
425 | 425 | } |
426 | 426 | |
427 | - do_action( "getpaid_unauthenticated_action_$key", $_REQUEST ); |
|
427 | + do_action("getpaid_unauthenticated_action_$key", $_REQUEST); |
|
428 | 428 | |
429 | 429 | } |
430 | 430 | |
431 | 431 | |
432 | 432 | } |
433 | 433 | |
434 | - public function pre_get_posts( $wp_query ) { |
|
434 | + public function pre_get_posts($wp_query) { |
|
435 | 435 | |
436 | - 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() ) { |
|
437 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
436 | + 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()) { |
|
437 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses(false, false, $wp_query->query_vars['post_type'])); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | return $wp_query; |
441 | 441 | } |
442 | 442 | |
443 | 443 | public function bp_invoicing_init() { |
444 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
444 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
@@ -462,8 +462,8 @@ discard block |
||
462 | 462 | ) |
463 | 463 | ); |
464 | 464 | |
465 | - foreach ( $widgets as $widget ) { |
|
466 | - register_widget( $widget ); |
|
465 | + foreach ($widgets as $widget) { |
|
466 | + register_widget($widget); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | } |
@@ -474,10 +474,10 @@ discard block |
||
474 | 474 | * @since 1.0.19 |
475 | 475 | * @param int[] $excluded_posts_ids |
476 | 476 | */ |
477 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
477 | + public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) { |
|
478 | 478 | |
479 | 479 | // Ensure that we have an array. |
480 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
480 | + if (!is_array($excluded_posts_ids)) { |
|
481 | 481 | $excluded_posts_ids = array(); |
482 | 482 | } |
483 | 483 | |
@@ -485,24 +485,24 @@ discard block |
||
485 | 485 | $our_pages = array(); |
486 | 486 | |
487 | 487 | // Checkout page. |
488 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
488 | + $our_pages[] = wpinv_get_option('checkout_page', false); |
|
489 | 489 | |
490 | 490 | // Success page. |
491 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
491 | + $our_pages[] = wpinv_get_option('success_page', false); |
|
492 | 492 | |
493 | 493 | // Failure page. |
494 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
494 | + $our_pages[] = wpinv_get_option('failure_page', false); |
|
495 | 495 | |
496 | 496 | // History page. |
497 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
497 | + $our_pages[] = wpinv_get_option('invoice_history_page', false); |
|
498 | 498 | |
499 | 499 | // Subscriptions page. |
500 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
500 | + $our_pages[] = wpinv_get_option('invoice_subscription_page', false); |
|
501 | 501 | |
502 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
502 | + $our_pages = array_map('intval', array_filter($our_pages)); |
|
503 | 503 | |
504 | 504 | $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
505 | - return array_unique( $excluded_posts_ids ); |
|
505 | + return array_unique($excluded_posts_ids); |
|
506 | 506 | |
507 | 507 | } |
508 | 508 |
@@ -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 | * This class handles invoice notificaiton emails. |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $this->invoice_actions = apply_filters( |
29 | 29 | 'getpaid_notification_email_invoice_triggers', |
30 | 30 | array( |
31 | - 'getpaid_new_invoice' => array( 'new_invoice', 'user_invoice' ), |
|
31 | + 'getpaid_new_invoice' => array('new_invoice', 'user_invoice'), |
|
32 | 32 | 'getpaid_invoice_status_wpi-cancelled' => 'cancelled_invoice', |
33 | 33 | 'getpaid_invoice_status_wpi-failed' => 'failed_invoice', |
34 | 34 | 'getpaid_invoice_status_wpi-onhold' => 'onhold_invoice', |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function init_hooks() { |
52 | 52 | |
53 | - add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 ); |
|
54 | - add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 ); |
|
53 | + add_filter('getpaid_get_email_merge_tags', array($this, 'invoice_merge_tags'), 10, 2); |
|
54 | + add_filter('getpaid_invoice_email_recipients', array($this, 'filter_email_recipients'), 10, 2); |
|
55 | 55 | |
56 | - foreach ( $this->invoice_actions as $hook => $email_type ) { |
|
57 | - $this->init_email_type_hook( $hook, $email_type ); |
|
56 | + foreach ($this->invoice_actions as $hook => $email_type) { |
|
57 | + $this->init_email_type_hook($hook, $email_type); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
@@ -64,25 +64,25 @@ discard block |
||
64 | 64 | * @param string $hook |
65 | 65 | * @param string|array $email_type |
66 | 66 | */ |
67 | - public function init_email_type_hook( $hook, $email_type ) { |
|
67 | + public function init_email_type_hook($hook, $email_type) { |
|
68 | 68 | |
69 | - $email_type = wpinv_parse_list( $email_type ); |
|
69 | + $email_type = wpinv_parse_list($email_type); |
|
70 | 70 | |
71 | - foreach ( $email_type as $type ) { |
|
71 | + foreach ($email_type as $type) { |
|
72 | 72 | |
73 | - $email = new GetPaid_Notification_Email( $type ); |
|
73 | + $email = new GetPaid_Notification_Email($type); |
|
74 | 74 | |
75 | 75 | // Abort if it is not active. |
76 | - if ( ! $email->is_active() ) { |
|
76 | + if (!$email->is_active()) { |
|
77 | 77 | continue; |
78 | 78 | } |
79 | 79 | |
80 | - if ( method_exists( $this, $type ) ) { |
|
81 | - add_action( $hook, array( $this, $type ), 100, 2 ); |
|
80 | + if (method_exists($this, $type)) { |
|
81 | + add_action($hook, array($this, $type), 100, 2); |
|
82 | 82 | continue; |
83 | 83 | } |
84 | 84 | |
85 | - do_action( 'getpaid_invoice_init_email_type_hook', $type, $hook ); |
|
85 | + do_action('getpaid_invoice_init_email_type_hook', $type, $hook); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | } |
@@ -93,19 +93,19 @@ discard block |
||
93 | 93 | * @param array $merge_tags |
94 | 94 | * @param mixed|WPInv_Invoice|WPInv_Subscription $object |
95 | 95 | */ |
96 | - public function invoice_merge_tags( $merge_tags, $object ) { |
|
96 | + public function invoice_merge_tags($merge_tags, $object) { |
|
97 | 97 | |
98 | - if ( is_a( $object, 'WPInv_Invoice' ) ) { |
|
98 | + if (is_a($object, 'WPInv_Invoice')) { |
|
99 | 99 | return array_merge( |
100 | 100 | $merge_tags, |
101 | - $this->get_invoice_merge_tags( $object ) |
|
101 | + $this->get_invoice_merge_tags($object) |
|
102 | 102 | ); |
103 | 103 | } |
104 | 104 | |
105 | - if ( is_a( $object, 'WPInv_Subscription' ) ) { |
|
105 | + if (is_a($object, 'WPInv_Subscription')) { |
|
106 | 106 | return array_merge( |
107 | 107 | $merge_tags, |
108 | - $this->get_invoice_merge_tags( $object->get_parent_payment() ) |
|
108 | + $this->get_invoice_merge_tags($object->get_parent_payment()) |
|
109 | 109 | ); |
110 | 110 | } |
111 | 111 | |
@@ -119,32 +119,32 @@ discard block |
||
119 | 119 | * @param WPInv_Invoice $invoice |
120 | 120 | * @return array |
121 | 121 | */ |
122 | - public function get_invoice_merge_tags( $invoice ) { |
|
122 | + public function get_invoice_merge_tags($invoice) { |
|
123 | 123 | |
124 | 124 | // Abort if it does not exist. |
125 | - if ( ! $invoice->get_id() ) { |
|
125 | + if (!$invoice->get_id()) { |
|
126 | 126 | return array(); |
127 | 127 | } |
128 | 128 | |
129 | 129 | return array( |
130 | - '{name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
131 | - '{full_name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
132 | - '{first_name}' => sanitize_text_field( $invoice->get_first_name() ), |
|
133 | - '{last_name}' => sanitize_text_field( $invoice->get_last_name() ), |
|
134 | - '{email}' => sanitize_email( $invoice->get_email() ), |
|
135 | - '{invoice_number}' => sanitize_text_field( $invoice->get_number() ), |
|
136 | - '{invoice_currency}' => sanitize_text_field( $invoice->get_currency() ), |
|
137 | - '{invoice_total}' => wpinv_price( wpinv_format_amount( $invoice->get_total() ) ), |
|
138 | - '{invoice_link}' => esc_url( $invoice->get_view_url() ), |
|
139 | - '{invoice_pay_link}' => esc_url( $invoice->get_checkout_payment_url() ), |
|
140 | - '{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ), |
|
141 | - '{invoice_date}' => getpaid_format_date_value( $invoice->get_date_created() ), |
|
142 | - '{invoice_due_date}' => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ), |
|
143 | - '{invoice_quote}' => sanitize_text_field( $invoice->get_type() ), |
|
144 | - '{invoice_label}' => sanitize_text_field( ucfirst( $invoice->get_type() ) ), |
|
145 | - '{invoice_description}' => wp_kses_post( $invoice->get_description() ), |
|
146 | - '{subscription_name}' => wp_kses_post( $invoice->get_subscription_name() ), |
|
147 | - '{is_was}' => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ), |
|
130 | + '{name}' => sanitize_text_field($invoice->get_user_full_name()), |
|
131 | + '{full_name}' => sanitize_text_field($invoice->get_user_full_name()), |
|
132 | + '{first_name}' => sanitize_text_field($invoice->get_first_name()), |
|
133 | + '{last_name}' => sanitize_text_field($invoice->get_last_name()), |
|
134 | + '{email}' => sanitize_email($invoice->get_email()), |
|
135 | + '{invoice_number}' => sanitize_text_field($invoice->get_number()), |
|
136 | + '{invoice_currency}' => sanitize_text_field($invoice->get_currency()), |
|
137 | + '{invoice_total}' => wpinv_price(wpinv_format_amount($invoice->get_total())), |
|
138 | + '{invoice_link}' => esc_url($invoice->get_view_url()), |
|
139 | + '{invoice_pay_link}' => esc_url($invoice->get_checkout_payment_url()), |
|
140 | + '{invoice_receipt_link}'=> esc_url($invoice->get_receipt_url()), |
|
141 | + '{invoice_date}' => getpaid_format_date_value($invoice->get_date_created()), |
|
142 | + '{invoice_due_date}' => getpaid_format_date_value($invoice->get_due_date(), __('on receipt', 'invoicing')), |
|
143 | + '{invoice_quote}' => sanitize_text_field($invoice->get_type()), |
|
144 | + '{invoice_label}' => sanitize_text_field(ucfirst($invoice->get_type())), |
|
145 | + '{invoice_description}' => wp_kses_post($invoice->get_description()), |
|
146 | + '{subscription_name}' => wp_kses_post($invoice->get_subscription_name()), |
|
147 | + '{is_was}' => strtotime($invoice->get_due_date()) < current_time('timestamp') ? __('was', 'invoicing') : __('is', 'invoicing'), |
|
148 | 148 | ); |
149 | 149 | |
150 | 150 | } |
@@ -158,35 +158,35 @@ discard block |
||
158 | 158 | * @param string|array $recipients |
159 | 159 | * @param array $extra_args Extra template args. |
160 | 160 | */ |
161 | - public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) { |
|
161 | + public function send_email($invoice, $email, $type, $recipients, $extra_args = array()) { |
|
162 | 162 | |
163 | - do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email ); |
|
163 | + do_action('getpaid_before_send_invoice_notification', $type, $invoice, $email); |
|
164 | 164 | |
165 | 165 | $mailer = new GetPaid_Notification_Email_Sender(); |
166 | 166 | $merge_tags = $email->get_merge_tags(); |
167 | 167 | |
168 | 168 | $result = $mailer->send( |
169 | - apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ), |
|
170 | - $email->add_merge_tags( $email->get_subject(), $merge_tags ), |
|
171 | - $email->get_content( $merge_tags, $extra_args ), |
|
169 | + apply_filters('getpaid_invoice_email_recipients', wpinv_parse_list($recipients), $email), |
|
170 | + $email->add_merge_tags($email->get_subject(), $merge_tags), |
|
171 | + $email->get_content($merge_tags, $extra_args), |
|
172 | 172 | $email->get_attachments() |
173 | 173 | ); |
174 | 174 | |
175 | 175 | // Maybe send a copy to the admin. |
176 | - if ( $email->include_admin_bcc() ) { |
|
176 | + if ($email->include_admin_bcc()) { |
|
177 | 177 | $mailer->send( |
178 | 178 | wpinv_get_admin_email(), |
179 | - $email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ), |
|
180 | - $email->get_content( $merge_tags ), |
|
179 | + $email->add_merge_tags($email->get_subject() . __(' - ADMIN BCC COPY', 'invoicing'), $merge_tags), |
|
180 | + $email->get_content($merge_tags), |
|
181 | 181 | $email->get_attachments() |
182 | 182 | ); |
183 | 183 | } |
184 | 184 | |
185 | - if ( ! $result ) { |
|
186 | - $invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
185 | + if (!$result) { |
|
186 | + $invoice->add_note(sprintf(__('Failed sending %s notification email.', 'invoicing'), sanitize_key($type)), false, false, true); |
|
187 | 187 | } |
188 | 188 | |
189 | - do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email ); |
|
189 | + do_action('getpaid_after_send_invoice_notification', $type, $invoice, $email); |
|
190 | 190 | |
191 | 191 | return $result; |
192 | 192 | } |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | * @param array $recipients |
198 | 198 | * @param GetPaid_Notification_Email $email |
199 | 199 | */ |
200 | - public function filter_email_recipients( $recipients, $email ) { |
|
200 | + public function filter_email_recipients($recipients, $email) { |
|
201 | 201 | |
202 | - if ( ! $email->is_admin_email() ) { |
|
202 | + if (!$email->is_admin_email()) { |
|
203 | 203 | $cc = $email->object->get_email_cc(); |
204 | 204 | |
205 | - if ( ! empty( $cc ) ) { |
|
206 | - $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) ); |
|
207 | - $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) ); |
|
205 | + if (!empty($cc)) { |
|
206 | + $cc = array_map('sanitize_email', wpinv_parse_list($cc)); |
|
207 | + $recipients = array_filter(array_unique(array_merge($recipients, $cc))); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | } |
@@ -218,17 +218,17 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @param WPInv_Invoice $invoice |
220 | 220 | */ |
221 | - public function new_invoice( $invoice ) { |
|
221 | + public function new_invoice($invoice) { |
|
222 | 222 | |
223 | 223 | // Only send this email for invoices created via the admin page. |
224 | - if ( ! $invoice->is_type( 'invoice' ) || $this->is_payment_form_invoice( $invoice->get_id() ) ) { |
|
224 | + if (!$invoice->is_type('invoice') || $this->is_payment_form_invoice($invoice->get_id())) { |
|
225 | 225 | return; |
226 | 226 | } |
227 | 227 | |
228 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
228 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
229 | 229 | $recipient = wpinv_get_admin_email(); |
230 | 230 | |
231 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
231 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
232 | 232 | |
233 | 233 | } |
234 | 234 | |
@@ -237,12 +237,12 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @param WPInv_Invoice $invoice |
239 | 239 | */ |
240 | - public function cancelled_invoice( $invoice ) { |
|
240 | + public function cancelled_invoice($invoice) { |
|
241 | 241 | |
242 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
242 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
243 | 243 | $recipient = wpinv_get_admin_email(); |
244 | 244 | |
245 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
245 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
246 | 246 | |
247 | 247 | } |
248 | 248 | |
@@ -251,12 +251,12 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @param WPInv_Invoice $invoice |
253 | 253 | */ |
254 | - public function failed_invoice( $invoice ) { |
|
254 | + public function failed_invoice($invoice) { |
|
255 | 255 | |
256 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
256 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
257 | 257 | $recipient = wpinv_get_admin_email(); |
258 | 258 | |
259 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
259 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
260 | 260 | |
261 | 261 | } |
262 | 262 | |
@@ -265,12 +265,12 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @param WPInv_Invoice $invoice |
267 | 267 | */ |
268 | - public function onhold_invoice( $invoice ) { |
|
268 | + public function onhold_invoice($invoice) { |
|
269 | 269 | |
270 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
270 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
271 | 271 | $recipient = $invoice->get_email(); |
272 | 272 | |
273 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
273 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
274 | 274 | |
275 | 275 | } |
276 | 276 | |
@@ -279,12 +279,12 @@ discard block |
||
279 | 279 | * |
280 | 280 | * @param WPInv_Invoice $invoice |
281 | 281 | */ |
282 | - public function processing_invoice( $invoice ) { |
|
282 | + public function processing_invoice($invoice) { |
|
283 | 283 | |
284 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
284 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
285 | 285 | $recipient = $invoice->get_email(); |
286 | 286 | |
287 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
287 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
288 | 288 | |
289 | 289 | } |
290 | 290 | |
@@ -293,17 +293,17 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @param WPInv_Invoice $invoice |
295 | 295 | */ |
296 | - public function completed_invoice( $invoice ) { |
|
296 | + public function completed_invoice($invoice) { |
|
297 | 297 | |
298 | 298 | // (Maybe) abort if it is a renewal invoice. |
299 | - if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) { |
|
299 | + if ($invoice->is_renewal() && !wpinv_get_option('email_completed_invoice_renewal_active', false)) { |
|
300 | 300 | return; |
301 | 301 | } |
302 | 302 | |
303 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
303 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
304 | 304 | $recipient = $invoice->get_email(); |
305 | 305 | |
306 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
306 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
307 | 307 | |
308 | 308 | } |
309 | 309 | |
@@ -312,12 +312,12 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @param WPInv_Invoice $invoice |
314 | 314 | */ |
315 | - public function refunded_invoice( $invoice ) { |
|
315 | + public function refunded_invoice($invoice) { |
|
316 | 316 | |
317 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
317 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
318 | 318 | $recipient = $invoice->get_email(); |
319 | 319 | |
320 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
320 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
321 | 321 | |
322 | 322 | } |
323 | 323 | |
@@ -326,17 +326,17 @@ discard block |
||
326 | 326 | * |
327 | 327 | * @param WPInv_Invoice $invoice |
328 | 328 | */ |
329 | - public function user_invoice( $invoice ) { |
|
329 | + public function user_invoice($invoice) { |
|
330 | 330 | |
331 | 331 | // Only send this email for invoices created via the admin page. |
332 | - if ( ! $invoice->is_type( 'invoice' ) || $this->is_payment_form_invoice( $invoice->get_id() ) ) { |
|
332 | + if (!$invoice->is_type('invoice') || $this->is_payment_form_invoice($invoice->get_id())) { |
|
333 | 333 | return; |
334 | 334 | } |
335 | 335 | |
336 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
336 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
337 | 337 | $recipient = $invoice->get_email(); |
338 | 338 | |
339 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
339 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
340 | 340 | |
341 | 341 | } |
342 | 342 | |
@@ -346,8 +346,8 @@ discard block |
||
346 | 346 | * @param int $invoice |
347 | 347 | * @return bool |
348 | 348 | */ |
349 | - public function is_payment_form_invoice( $invoice ) { |
|
350 | - return empty( $_GET['getpaid-admin-action'] ) && 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true ); |
|
349 | + public function is_payment_form_invoice($invoice) { |
|
350 | + return empty($_GET['getpaid-admin-action']) && 'payment_form' == get_post_meta($invoice, 'wpinv_created_via', true); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | /** |
@@ -356,12 +356,12 @@ discard block |
||
356 | 356 | * @param WPInv_Invoice $invoice |
357 | 357 | * @param string $note |
358 | 358 | */ |
359 | - public function user_note( $invoice, $note ) { |
|
359 | + public function user_note($invoice, $note) { |
|
360 | 360 | |
361 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
361 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
362 | 362 | $recipient = $invoice->get_email(); |
363 | 363 | |
364 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) ); |
|
364 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient, array('customer_note' => $note)); |
|
365 | 365 | |
366 | 366 | } |
367 | 367 | |
@@ -370,9 +370,9 @@ discard block |
||
370 | 370 | * |
371 | 371 | * @param WPInv_Invoice $invoice |
372 | 372 | */ |
373 | - public function force_send_overdue_notice( $invoice ) { |
|
374 | - $email = new GetPaid_Notification_Email( 'overdue', $invoice ); |
|
375 | - return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() ); |
|
373 | + public function force_send_overdue_notice($invoice) { |
|
374 | + $email = new GetPaid_Notification_Email('overdue', $invoice); |
|
375 | + return $this->send_email($invoice, $email, 'overdue', $invoice->get_email()); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | /** |
@@ -383,37 +383,37 @@ discard block |
||
383 | 383 | public function overdue() { |
384 | 384 | global $wpdb; |
385 | 385 | |
386 | - $email = new GetPaid_Notification_Email( __FUNCTION__ ); |
|
386 | + $email = new GetPaid_Notification_Email(__FUNCTION__); |
|
387 | 387 | |
388 | 388 | // Fetch reminder days. |
389 | - $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) ); |
|
389 | + $reminder_days = array_unique(wp_parse_id_list($email->get_option('days'))); |
|
390 | 390 | |
391 | 391 | // Abort if non is set. |
392 | - if ( empty( $reminder_days ) ) { |
|
392 | + if (empty($reminder_days)) { |
|
393 | 393 | return; |
394 | 394 | } |
395 | 395 | |
396 | 396 | // Retrieve date query. |
397 | - $date_query = $this->get_date_query( $reminder_days ); |
|
397 | + $date_query = $this->get_date_query($reminder_days); |
|
398 | 398 | |
399 | 399 | // Invoices table. |
400 | 400 | $table = $wpdb->prefix . 'getpaid_invoices'; |
401 | 401 | |
402 | 402 | // Fetch invoices. |
403 | - $invoices = $wpdb->get_col( |
|
403 | + $invoices = $wpdb->get_col( |
|
404 | 404 | "SELECT posts.ID FROM $wpdb->posts as posts |
405 | 405 | LEFT JOIN $table as invoices ON invoices.post_id = posts.ID |
406 | 406 | WHERE posts.post_type = 'wpi_invoice' AND posts.post_status = 'wpi-pending' $date_query"); |
407 | 407 | |
408 | - foreach ( $invoices as $invoice ) { |
|
408 | + foreach ($invoices as $invoice) { |
|
409 | 409 | |
410 | 410 | // Only send this email for invoices created via the admin page. |
411 | - if ( ! $this->is_payment_form_invoice( $invoice ) ) { |
|
412 | - $invoice = new WPInv_Invoice( $invoice ); |
|
411 | + if (!$this->is_payment_form_invoice($invoice)) { |
|
412 | + $invoice = new WPInv_Invoice($invoice); |
|
413 | 413 | $email->object = $invoice; |
414 | 414 | |
415 | - if ( $invoice->needs_payment() ) { |
|
416 | - $this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() ); |
|
415 | + if ($invoice->needs_payment()) { |
|
416 | + $this->send_email($invoice, $email, __FUNCTION__, $invoice->get_email()); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | } |
@@ -428,14 +428,14 @@ discard block |
||
428 | 428 | * @param array $reminder_days |
429 | 429 | * @return string |
430 | 430 | */ |
431 | - public function get_date_query( $reminder_days ) { |
|
431 | + public function get_date_query($reminder_days) { |
|
432 | 432 | |
433 | 433 | $date_query = array( |
434 | 434 | 'relation' => 'OR' |
435 | 435 | ); |
436 | 436 | |
437 | - foreach ( $reminder_days as $days ) { |
|
438 | - $date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) ); |
|
437 | + foreach ($reminder_days as $days) { |
|
438 | + $date = date_parse(date('Y-m-d', strtotime("-$days days", current_time('timestamp')))); |
|
439 | 439 | |
440 | 440 | $date_query[] = array( |
441 | 441 | 'year' => $date['year'], |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | |
446 | 446 | } |
447 | 447 | |
448 | - $date_query = new WP_Date_Query( $date_query, 'invoices.due_date' ); |
|
448 | + $date_query = new WP_Date_Query($date_query, 'invoices.due_date'); |
|
449 | 449 | |
450 | 450 | return $date_query->get_sql(); |
451 | 451 |
@@ -11,55 +11,55 @@ discard block |
||
11 | 11 | * @since 1.0.0 |
12 | 12 | */ |
13 | 13 | function wpinv_automatic_upgrade() { |
14 | - $wpi_version = get_option( 'wpinv_version' ); |
|
14 | + $wpi_version = get_option('wpinv_version'); |
|
15 | 15 | |
16 | 16 | // Update tables. |
17 | - if ( ! get_option( 'getpaid_created_invoice_tables' ) ) { |
|
17 | + if (!get_option('getpaid_created_invoice_tables')) { |
|
18 | 18 | wpinv_v119_upgrades(); |
19 | - update_option( 'getpaid_created_invoice_tables', true ); |
|
19 | + update_option('getpaid_created_invoice_tables', true); |
|
20 | 20 | } |
21 | 21 | |
22 | - if ( $wpi_version == WPINV_VERSION ) { |
|
22 | + if ($wpi_version == WPINV_VERSION) { |
|
23 | 23 | return; |
24 | 24 | } |
25 | 25 | |
26 | - if ( version_compare( $wpi_version, '0.0.5', '<' ) ) { |
|
26 | + if (version_compare($wpi_version, '0.0.5', '<')) { |
|
27 | 27 | wpinv_v005_upgrades(); |
28 | 28 | } |
29 | 29 | |
30 | - if ( version_compare( $wpi_version, '1.0.3', '<' ) ) { |
|
30 | + if (version_compare($wpi_version, '1.0.3', '<')) { |
|
31 | 31 | wpinv_v110_upgrades(); |
32 | 32 | } |
33 | 33 | |
34 | - update_option( 'wpinv_version', WPINV_VERSION ); |
|
34 | + update_option('wpinv_version', WPINV_VERSION); |
|
35 | 35 | } |
36 | -add_action( 'admin_init', 'wpinv_automatic_upgrade' ); |
|
36 | +add_action('admin_init', 'wpinv_automatic_upgrade'); |
|
37 | 37 | |
38 | 38 | function wpinv_v005_upgrades() { |
39 | 39 | global $wpdb; |
40 | 40 | |
41 | 41 | // Invoices status |
42 | - $results = $wpdb->get_results( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" ); |
|
43 | - if ( !empty( $results ) ) { |
|
44 | - $wpdb->query( "UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" ); |
|
42 | + $results = $wpdb->get_results("SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )"); |
|
43 | + if (!empty($results)) { |
|
44 | + $wpdb->query("UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )"); |
|
45 | 45 | |
46 | 46 | // Clean post cache |
47 | - foreach ( $results as $row ) { |
|
48 | - clean_post_cache( $row->ID ); |
|
47 | + foreach ($results as $row) { |
|
48 | + clean_post_cache($row->ID); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | 52 | // Item meta key changes |
53 | 53 | $query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )"; |
54 | - $results = $wpdb->get_results( $query ); |
|
54 | + $results = $wpdb->get_results($query); |
|
55 | 55 | |
56 | - if ( !empty( $results ) ) { |
|
57 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" ); |
|
58 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" ); |
|
59 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" ); |
|
56 | + if (!empty($results)) { |
|
57 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )"); |
|
58 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'"); |
|
59 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'"); |
|
60 | 60 | |
61 | - foreach ( $results as $row ) { |
|
62 | - clean_post_cache( $row->post_id ); |
|
61 | + foreach ($results as $row) { |
|
62 | + clean_post_cache($row->post_id); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | function wpinv_create_invoices_table() { |
89 | 89 | global $wpdb; |
90 | 90 | |
91 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
91 | + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
92 | 92 | |
93 | 93 | // Create invoices table. |
94 | 94 | $table = $wpdb->prefix . 'getpaid_invoices'; |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | KEY `key` ( `key` ) |
133 | 133 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
134 | 134 | |
135 | - dbDelta( $sql ); |
|
135 | + dbDelta($sql); |
|
136 | 136 | |
137 | 137 | // Create invoice items table. |
138 | 138 | $table = $wpdb->prefix . 'getpaid_invoice_items'; |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | KEY post_id ( post_id ) |
161 | 161 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
162 | 162 | |
163 | - dbDelta( $sql ); |
|
163 | + dbDelta($sql); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -172,10 +172,10 @@ discard block |
||
172 | 172 | $invoices = array_unique( |
173 | 173 | get_posts( |
174 | 174 | array( |
175 | - 'post_type' => array( 'wpi_invoice', 'wpi_quote' ), |
|
175 | + 'post_type' => array('wpi_invoice', 'wpi_quote'), |
|
176 | 176 | 'posts_per_page' => -1, |
177 | 177 | 'fields' => 'ids', |
178 | - 'post_status' => array_keys( get_post_stati() ), |
|
178 | + 'post_status' => array_keys(get_post_stati()), |
|
179 | 179 | ) |
180 | 180 | ) |
181 | 181 | ); |
@@ -183,19 +183,19 @@ discard block |
||
183 | 183 | $invoices_table = $wpdb->prefix . 'getpaid_invoices'; |
184 | 184 | $invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items'; |
185 | 185 | |
186 | - if ( ! class_exists( 'WPInv_Legacy_Invoice' ) ) { |
|
187 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php' ); |
|
186 | + if (!class_exists('WPInv_Legacy_Invoice')) { |
|
187 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php'); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | $invoice_rows = array(); |
191 | - foreach ( $invoices as $invoice ) { |
|
191 | + foreach ($invoices as $invoice) { |
|
192 | 192 | |
193 | - $invoice = new WPInv_Legacy_Invoice( $invoice ); |
|
194 | - $fields = array ( |
|
193 | + $invoice = new WPInv_Legacy_Invoice($invoice); |
|
194 | + $fields = array( |
|
195 | 195 | 'post_id' => $invoice->ID, |
196 | 196 | 'number' => $invoice->get_number(), |
197 | 197 | 'key' => $invoice->get_key(), |
198 | - 'type' => str_replace( 'wpi_', '', $invoice->post_type ), |
|
198 | + 'type' => str_replace('wpi_', '', $invoice->post_type), |
|
199 | 199 | 'mode' => $invoice->mode, |
200 | 200 | 'user_ip' => $invoice->get_ip(), |
201 | 201 | 'first_name' => $invoice->get_first_name(), |
@@ -224,27 +224,27 @@ discard block |
||
224 | 224 | 'custom_meta' => $invoice->payment_meta |
225 | 225 | ); |
226 | 226 | |
227 | - foreach ( $fields as $key => $val ) { |
|
228 | - if ( is_null( $val ) ) { |
|
227 | + foreach ($fields as $key => $val) { |
|
228 | + if (is_null($val)) { |
|
229 | 229 | $val = ''; |
230 | 230 | } |
231 | - $val = maybe_serialize( $val ); |
|
232 | - $fields[ $key ] = $wpdb->prepare( '%s', $val ); |
|
231 | + $val = maybe_serialize($val); |
|
232 | + $fields[$key] = $wpdb->prepare('%s', $val); |
|
233 | 233 | } |
234 | 234 | |
235 | - $fields = implode( ', ', $fields ); |
|
235 | + $fields = implode(', ', $fields); |
|
236 | 236 | $invoice_rows[] = "($fields)"; |
237 | 237 | |
238 | 238 | $item_rows = array(); |
239 | 239 | $item_columns = array(); |
240 | - foreach ( $invoice->get_cart_details() as $details ) { |
|
240 | + foreach ($invoice->get_cart_details() as $details) { |
|
241 | 241 | $fields = array( |
242 | 242 | 'post_id' => $invoice->ID, |
243 | 243 | 'item_id' => $details['id'], |
244 | 244 | 'item_name' => $details['name'], |
245 | - 'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'], |
|
245 | + 'item_description' => empty($details['meta']['description']) ? '' : $details['meta']['description'], |
|
246 | 246 | 'vat_rate' => $details['vat_rate'], |
247 | - 'vat_class' => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'], |
|
247 | + 'vat_class' => empty($details['vat_class']) ? '_standard' : $details['vat_class'], |
|
248 | 248 | 'tax' => $details['tax'], |
249 | 249 | 'item_price' => $details['item_price'], |
250 | 250 | 'custom_price' => $details['custom_price'], |
@@ -256,26 +256,26 @@ discard block |
||
256 | 256 | 'fees' => $details['fees'], |
257 | 257 | ); |
258 | 258 | |
259 | - $item_columns = array_keys ( $fields ); |
|
259 | + $item_columns = array_keys($fields); |
|
260 | 260 | |
261 | - foreach ( $fields as $key => $val ) { |
|
262 | - if ( is_null( $val ) ) { |
|
261 | + foreach ($fields as $key => $val) { |
|
262 | + if (is_null($val)) { |
|
263 | 263 | $val = ''; |
264 | 264 | } |
265 | - $val = maybe_serialize( $val ); |
|
266 | - $fields[ $key ] = $wpdb->prepare( '%s', $val ); |
|
265 | + $val = maybe_serialize($val); |
|
266 | + $fields[$key] = $wpdb->prepare('%s', $val); |
|
267 | 267 | } |
268 | 268 | |
269 | - $fields = implode( ', ', $fields ); |
|
269 | + $fields = implode(', ', $fields); |
|
270 | 270 | $item_rows[] = "($fields)"; |
271 | 271 | } |
272 | 272 | |
273 | - $item_rows = implode( ', ', $item_rows ); |
|
274 | - $item_columns = implode( ', ', $item_columns ); |
|
275 | - $wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" ); |
|
273 | + $item_rows = implode(', ', $item_rows); |
|
274 | + $item_columns = implode(', ', $item_columns); |
|
275 | + $wpdb->query("INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows"); |
|
276 | 276 | } |
277 | 277 | |
278 | - $invoice_rows = implode( ', ', $invoice_rows ); |
|
279 | - $wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" ); |
|
278 | + $invoice_rows = implode(', ', $invoice_rows); |
|
279 | + $wpdb->query("INSERT INTO $invoices_table VALUES $invoice_rows"); |
|
280 | 280 | |
281 | 281 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,10 +21,10 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the invoice. |
27 | - $invoice = new WPInv_Invoice( $post ); |
|
27 | + $invoice = new WPInv_Invoice($post); |
|
28 | 28 | |
29 | 29 | ?> |
30 | 30 | |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | 'id' => 'wpinv_key', |
48 | 48 | 'name' => 'wpinv_key', |
49 | 49 | 'label' => sprintf( |
50 | - __( '%s Key:', 'invoicing' ), |
|
51 | - ucfirst( $invoice->get_type() ) |
|
50 | + __('%s Key:', 'invoicing'), |
|
51 | + ucfirst($invoice->get_type()) |
|
52 | 52 | ), |
53 | 53 | 'label_type' => 'vertical', |
54 | 54 | 'class' => 'form-control-sm', |
55 | - 'value' => $invoice->get_key( 'edit' ), |
|
55 | + 'value' => $invoice->get_key('edit'), |
|
56 | 56 | 'extra_attributes' => array( |
57 | 57 | 'onclick' => 'this.select();', |
58 | 58 | 'readonly' => 'true', |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | 'id' => 'wpinv_view_url', |
68 | 68 | 'name' => 'wpinv_view_url', |
69 | 69 | 'label' => sprintf( |
70 | - __( '%s URL:', 'invoicing' ), |
|
71 | - ucfirst( $invoice->get_type() ) |
|
70 | + __('%s URL:', 'invoicing'), |
|
71 | + ucfirst($invoice->get_type()) |
|
72 | 72 | ), |
73 | 73 | 'label_type' => 'vertical', |
74 | 74 | 'class' => 'form-control-sm', |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | ); |
82 | 82 | |
83 | 83 | // If the invoice is paid... |
84 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
84 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
85 | 85 | |
86 | 86 | // Payment date. |
87 | 87 | echo aui()->input( |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | 'type' => 'datepicker', |
90 | 90 | 'id' => 'wpinv_date_completed', |
91 | 91 | 'name' => 'date_completed', |
92 | - 'label' => __( 'Payment Date:', 'invoicing' ), |
|
92 | + 'label' => __('Payment Date:', 'invoicing'), |
|
93 | 93 | 'label_type' => 'vertical', |
94 | 94 | 'placeholder' => 'YYYY-MM-DD 00:00', |
95 | 95 | 'class' => 'form-control-sm', |
96 | - 'value' => $invoice->get_date_completed( 'edit' ), |
|
96 | + 'value' => $invoice->get_date_completed('edit'), |
|
97 | 97 | 'extra_attributes' => array( |
98 | 98 | 'data-enable-time' => 'true', |
99 | 99 | 'data-time_24hr' => 'true', |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | 'type' => 'text', |
109 | 109 | 'id' => 'wpinv_gateway', |
110 | 110 | 'name' => 'wpinv_gateway', |
111 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
111 | + 'label' => __('Gateway:', 'invoicing'), |
|
112 | 112 | 'label_type' => 'vertical', |
113 | 113 | 'class' => 'form-control-sm', |
114 | - 'value' => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ), |
|
114 | + 'value' => wpinv_get_gateway_admin_label($invoice->get_gateway('edit')), |
|
115 | 115 | 'extra_attributes' => array( |
116 | 116 | 'onclick' => 'this.select();', |
117 | 117 | 'readonly' => 'true', |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | 'type' => 'text', |
126 | 126 | 'id' => 'wpinv_transaction_id', |
127 | 127 | 'name' => 'wpinv_transaction_id', |
128 | - 'label' => __( 'Transaction ID:', 'invoicing' ), |
|
128 | + 'label' => __('Transaction ID:', 'invoicing'), |
|
129 | 129 | 'label_type' => 'vertical', |
130 | 130 | 'class' => 'form-control-sm', |
131 | - 'value' => $invoice->get_transaction_id( 'edit' ), |
|
132 | - 'help_text' => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), '', $invoice->get_transaction_id(), $invoice ), |
|
131 | + 'value' => $invoice->get_transaction_id('edit'), |
|
132 | + 'help_text' => apply_filters('wpinv_invoice_transaction_link_' . $invoice->get_gateway('edit'), '', $invoice->get_transaction_id(), $invoice), |
|
133 | 133 | 'extra_attributes' => array( |
134 | 134 | 'onclick' => 'this.select();', |
135 | 135 | 'readonly' => 'true', |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | 'type' => 'text', |
144 | 144 | 'id' => 'wpinv_currency', |
145 | 145 | 'name' => 'wpinv_currency', |
146 | - 'label' => __( 'Currency:', 'invoicing' ), |
|
146 | + 'label' => __('Currency:', 'invoicing'), |
|
147 | 147 | 'label_type' => 'vertical', |
148 | 148 | 'class' => 'form-control-sm', |
149 | - 'value' => $invoice->get_currency( 'edit' ), |
|
149 | + 'value' => $invoice->get_currency('edit'), |
|
150 | 150 | 'extra_attributes' => array( |
151 | 151 | 'onclick' => 'this.select();', |
152 | 152 | 'readonly' => 'true', |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | } else { |
158 | 158 | |
159 | - if ( 'wpi_invoice' == $invoice->get_post_type() ) { |
|
159 | + if ('wpi_invoice' == $invoice->get_post_type()) { |
|
160 | 160 | |
161 | 161 | // Payment URL. |
162 | 162 | echo aui()->input( |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | 'type' => 'text', |
165 | 165 | 'id' => 'wpinv_payment_url', |
166 | 166 | 'name' => 'wpinv_payment_url', |
167 | - 'label' => __( 'Payment URL:', 'invoicing' ), |
|
167 | + 'label' => __('Payment URL:', 'invoicing'), |
|
168 | 168 | 'label_type' => 'vertical', |
169 | 169 | 'class' => 'form-control-sm', |
170 | 170 | 'value' => $invoice->get_checkout_payment_url(), |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | array( |
181 | 181 | 'id' => 'wpinv_gateway', |
182 | 182 | 'name' => 'wpinv_gateway', |
183 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
183 | + 'label' => __('Gateway:', 'invoicing'), |
|
184 | 184 | 'label_type' => 'vertical', |
185 | - 'placeholder' => __( 'Select Gateway', 'invoicing' ), |
|
186 | - 'value' => $invoice->get_gateway( 'edit' ), |
|
185 | + 'placeholder' => __('Select Gateway', 'invoicing'), |
|
186 | + 'value' => $invoice->get_gateway('edit'), |
|
187 | 187 | 'select2' => true, |
188 | 188 | 'data-allow-clear' => 'false', |
189 | - 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
|
189 | + 'options' => wp_list_pluck(wpinv_get_enabled_payment_gateways(true), 'admin_label'), |
|
190 | 190 | ) |
191 | 191 | ); |
192 | 192 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the invoice. |
27 | - $invoice = new WPInv_Invoice( $post ); |
|
27 | + $invoice = new WPInv_Invoice($post); |
|
28 | 28 | |
29 | 29 | // Nonce field. |
30 | - wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ; |
|
30 | + wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); |
|
31 | 31 | |
32 | 32 | |
33 | 33 | ?> |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | |
47 | 47 | <div class="bsui" style="margin-top: 1.5rem" id="gdmbx2-metabox-wpinv_details"> |
48 | 48 | |
49 | - <?php if ( ! $invoice->is_draft() ) : ?> |
|
49 | + <?php if (!$invoice->is_draft()) : ?> |
|
50 | 50 | <div class="form-group"> |
51 | - <strong><?php _e( 'Viewed by Customer:', 'invoicing' );?></strong> |
|
52 | - <?php ( $invoice->get_is_viewed() ) ? _e( 'Yes', 'invoicing' ) : _e( 'No', 'invoicing' ); ?> |
|
51 | + <strong><?php _e('Viewed by Customer:', 'invoicing'); ?></strong> |
|
52 | + <?php ($invoice->get_is_viewed()) ? _e('Yes', 'invoicing') : _e('No', 'invoicing'); ?> |
|
53 | 53 | </div> |
54 | 54 | <?php endif; ?> |
55 | 55 | |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | |
58 | 58 | // Date created. |
59 | 59 | $label = sprintf( |
60 | - __( '%s Date:', 'invoicing' ), |
|
61 | - ucfirst( $invoice->get_type() ) |
|
60 | + __('%s Date:', 'invoicing'), |
|
61 | + ucfirst($invoice->get_type()) |
|
62 | 62 | ); |
63 | 63 | |
64 | - $info = sprintf( |
|
65 | - __( 'The date this %s was created.', 'invoicing' ), |
|
66 | - strtolower( $invoice->get_type() ) |
|
64 | + $info = sprintf( |
|
65 | + __('The date this %s was created.', 'invoicing'), |
|
66 | + strtolower($invoice->get_type()) |
|
67 | 67 | ); |
68 | 68 | |
69 | 69 | echo aui()->input( |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | 'type' => 'datepicker', |
72 | 72 | 'id' => 'wpinv_date_created', |
73 | 73 | 'name' => 'date_created', |
74 | - 'label' => $label . getpaid_get_help_tip( $info ), |
|
74 | + 'label' => $label . getpaid_get_help_tip($info), |
|
75 | 75 | 'label_type' => 'vertical', |
76 | 76 | 'placeholder' => 'YYYY-MM-DD 00:00', |
77 | 77 | 'class' => 'form-control-sm', |
78 | - 'value' => $invoice->get_date_created( 'edit' ), |
|
78 | + 'value' => $invoice->get_date_created('edit'), |
|
79 | 79 | 'extra_attributes' => array( |
80 | 80 | 'data-enable-time' => 'true', |
81 | 81 | 'data-time_24hr' => 'true', |
@@ -86,30 +86,30 @@ discard block |
||
86 | 86 | ); |
87 | 87 | |
88 | 88 | // Due date. |
89 | - if ( $invoice->is_type( 'invoice' ) && wpinv_get_option( 'overdue_active' ) && ( $invoice->needs_payment() || $invoice->is_draft() ) ) { |
|
89 | + if ($invoice->is_type('invoice') && wpinv_get_option('overdue_active') && ($invoice->needs_payment() || $invoice->is_draft())) { |
|
90 | 90 | |
91 | 91 | echo aui()->input( |
92 | 92 | array( |
93 | 93 | 'type' => 'text', |
94 | 94 | 'id' => 'wpinv_due_date', |
95 | 95 | 'name' => 'wpinv_due_date', |
96 | - 'label' => __( 'Due Date:', 'invoicing' ) . getpaid_get_help_tip( __( 'Leave blank to disable automated reminder emails for this invoice.', 'invoicing' ) ), |
|
96 | + 'label' => __('Due Date:', 'invoicing') . getpaid_get_help_tip(__('Leave blank to disable automated reminder emails for this invoice.', 'invoicing')), |
|
97 | 97 | 'label_type' => 'vertical', |
98 | - 'placeholder' => __( 'No due date', 'invoicing' ), |
|
98 | + 'placeholder' => __('No due date', 'invoicing'), |
|
99 | 99 | 'class' => 'form-control-sm', |
100 | - 'value' => $invoice->get_due_date( 'edit' ), |
|
100 | + 'value' => $invoice->get_due_date('edit'), |
|
101 | 101 | ) |
102 | 102 | ); |
103 | 103 | |
104 | 104 | } |
105 | 105 | |
106 | - do_action( 'wpinv_meta_box_details_after_due_date', $invoice->get_id() ); |
|
107 | - do_action( 'getpaid_metabox_after_due_date', $invoice ); |
|
106 | + do_action('wpinv_meta_box_details_after_due_date', $invoice->get_id()); |
|
107 | + do_action('getpaid_metabox_after_due_date', $invoice); |
|
108 | 108 | |
109 | 109 | // Status. |
110 | 110 | $label = sprintf( |
111 | - __( '%s Status:', 'invoicing' ), |
|
112 | - ucfirst( $invoice->get_type() ) |
|
111 | + __('%s Status:', 'invoicing'), |
|
112 | + ucfirst($invoice->get_type()) |
|
113 | 113 | ); |
114 | 114 | |
115 | 115 | echo aui()->select( |
@@ -118,23 +118,23 @@ discard block |
||
118 | 118 | 'name' => 'wpinv_status', |
119 | 119 | 'label' => $label, |
120 | 120 | 'label_type' => 'vertical', |
121 | - 'placeholder' => __( 'Select Status', 'invoicing' ), |
|
122 | - 'value' => $invoice->get_status( 'edit' ), |
|
121 | + 'placeholder' => __('Select Status', 'invoicing'), |
|
122 | + 'value' => $invoice->get_status('edit'), |
|
123 | 123 | 'select2' => true, |
124 | 124 | 'data-allow-clear' => 'false', |
125 | - 'options' => wpinv_get_invoice_statuses( true, false, $invoice ) |
|
125 | + 'options' => wpinv_get_invoice_statuses(true, false, $invoice) |
|
126 | 126 | ) |
127 | 127 | ); |
128 | 128 | |
129 | 129 | // Invoice number. |
130 | 130 | $label = sprintf( |
131 | - __( '%s Number:', 'invoicing' ), |
|
132 | - ucfirst( $invoice->get_type() ) |
|
131 | + __('%s Number:', 'invoicing'), |
|
132 | + ucfirst($invoice->get_type()) |
|
133 | 133 | ); |
134 | 134 | |
135 | - $info = sprintf( |
|
136 | - __( 'Each %s number must be unique.', 'invoicing' ), |
|
137 | - strtolower( $invoice->get_type() ) |
|
135 | + $info = sprintf( |
|
136 | + __('Each %s number must be unique.', 'invoicing'), |
|
137 | + strtolower($invoice->get_type()) |
|
138 | 138 | ); |
139 | 139 | |
140 | 140 | echo aui()->input( |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | 'type' => 'text', |
143 | 143 | 'id' => 'wpinv_number', |
144 | 144 | 'name' => 'wpinv_number', |
145 | - 'label' => $label . getpaid_get_help_tip( $info ), |
|
145 | + 'label' => $label . getpaid_get_help_tip($info), |
|
146 | 146 | 'label_type' => 'vertical', |
147 | - 'placeholder' => __( 'Autogenerate', 'invoicing' ), |
|
147 | + 'placeholder' => __('Autogenerate', 'invoicing'), |
|
148 | 148 | 'class' => 'form-control-sm', |
149 | - 'value' => $invoice->get_number( 'edit' ), |
|
149 | + 'value' => $invoice->get_number('edit'), |
|
150 | 150 | ) |
151 | 151 | ); |
152 | 152 | |
@@ -156,25 +156,25 @@ discard block |
||
156 | 156 | 'type' => 'text', |
157 | 157 | 'id' => 'wpinv_cc', |
158 | 158 | 'name' => 'wpinv_cc', |
159 | - 'label' => __( 'Email CC:', 'invoicing' ) . getpaid_get_help_tip( __( 'Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing' ) ), |
|
159 | + 'label' => __('Email CC:', 'invoicing') . getpaid_get_help_tip(__('Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing')), |
|
160 | 160 | 'label_type' => 'vertical', |
161 | - 'placeholder' => __( '[email protected], [email protected]', 'invoicing' ), |
|
161 | + 'placeholder' => __('[email protected], [email protected]', 'invoicing'), |
|
162 | 162 | 'class' => 'form-control-sm', |
163 | - 'value' => $invoice->get_email_cc( 'edit' ), |
|
163 | + 'value' => $invoice->get_email_cc('edit'), |
|
164 | 164 | ) |
165 | 165 | ); |
166 | 166 | |
167 | - do_action( 'wpinv_meta_box_details_inner', $invoice->get_id() ); |
|
167 | + do_action('wpinv_meta_box_details_inner', $invoice->get_id()); |
|
168 | 168 | |
169 | 169 | // Disable taxes. |
170 | - if ( wpinv_use_taxes() && ! ( $invoice->is_paid() || $invoice->is_refunded() ) ) { |
|
170 | + if (wpinv_use_taxes() && !($invoice->is_paid() || $invoice->is_refunded())) { |
|
171 | 171 | |
172 | 172 | echo aui()->input( |
173 | 173 | array( |
174 | 174 | 'id' => 'wpinv_taxable', |
175 | 175 | 'name' => 'disable_taxes', |
176 | 176 | 'type' => 'checkbox', |
177 | - 'label' => __( 'Disable taxes', 'invoicing' ), |
|
177 | + 'label' => __('Disable taxes', 'invoicing'), |
|
178 | 178 | 'value' => '1', |
179 | 179 | 'checked' => (bool) $invoice->get_disable_taxes(), |
180 | 180 | ) |
@@ -183,17 +183,17 @@ discard block |
||
183 | 183 | } |
184 | 184 | |
185 | 185 | // Apply a discount. |
186 | - if ( $invoice->get_discount_code( 'edit' ) ) { |
|
186 | + if ($invoice->get_discount_code('edit')) { |
|
187 | 187 | |
188 | 188 | echo aui()->input( |
189 | 189 | array( |
190 | 190 | 'type' => 'text', |
191 | 191 | 'id' => 'wpinv_discount_code', |
192 | 192 | 'name' => 'wpinv_discount_code', |
193 | - 'label' => __( 'Discount Code:', 'invoicing' ), |
|
193 | + 'label' => __('Discount Code:', 'invoicing'), |
|
194 | 194 | 'label_type' => 'vertical', |
195 | 195 | 'class' => 'form-control-sm', |
196 | - 'value' => $invoice->get_discount_code( 'edit' ), |
|
196 | + 'value' => $invoice->get_discount_code('edit'), |
|
197 | 197 | 'extra_attributes' => array( |
198 | 198 | 'onclick' => 'this.select();', |
199 | 199 | 'readonly' => 'true', |
@@ -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 | * Metaboxes Admin Class |
@@ -25,36 +25,36 @@ discard block |
||
25 | 25 | public static function init() { |
26 | 26 | |
27 | 27 | // Register metaboxes. |
28 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 ); |
|
28 | + add_action('add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2); |
|
29 | 29 | |
30 | 30 | // Remove metaboxes. |
31 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 ); |
|
31 | + add_action('add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30); |
|
32 | 32 | |
33 | 33 | // Rename metaboxes. |
34 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 ); |
|
34 | + add_action('add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45); |
|
35 | 35 | |
36 | 36 | // Save metaboxes. |
37 | - add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 ); |
|
37 | + add_action('save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Register core metaboxes. |
42 | 42 | */ |
43 | - public static function add_meta_boxes( $post_type, $post ) { |
|
43 | + public static function add_meta_boxes($post_type, $post) { |
|
44 | 44 | global $wpinv_euvat; |
45 | 45 | |
46 | 46 | // For invoices... |
47 | - if ( getpaid_is_invoice_post_type( $post_type ) ) { |
|
48 | - $invoice = new WPInv_Invoice( $post ); |
|
47 | + if (getpaid_is_invoice_post_type($post_type)) { |
|
48 | + $invoice = new WPInv_Invoice($post); |
|
49 | 49 | |
50 | 50 | // Resend invoice. |
51 | - if ( ! $invoice->is_draft() && ! $invoice->is_paid() ) { |
|
51 | + if (!$invoice->is_draft() && !$invoice->is_paid()) { |
|
52 | 52 | |
53 | 53 | add_meta_box( |
54 | 54 | 'wpinv-mb-resend-invoice', |
55 | 55 | sprintf( |
56 | - __( 'Resend %s', 'invoicing' ), |
|
57 | - ucfirst( $invoice->get_type() ) |
|
56 | + __('Resend %s', 'invoicing'), |
|
57 | + ucfirst($invoice->get_type()) |
|
58 | 58 | ), |
59 | 59 | 'GetPaid_Meta_Box_Resend_Invoice::output', |
60 | 60 | $post_type, |
@@ -65,18 +65,18 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | // Subscriptions. |
68 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
69 | - if ( ! empty( $subscription ) ) { |
|
70 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' ); |
|
71 | - add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' ); |
|
68 | + $subscription = getpaid_get_invoice_subscription($invoice); |
|
69 | + if (!empty($subscription)) { |
|
70 | + add_meta_box('wpinv-mb-subscriptions', __('Subscription Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced'); |
|
71 | + add_meta_box('wpinv-mb-subscription-invoices', __('Related Payments', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced'); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | // Invoice details. |
75 | 75 | add_meta_box( |
76 | 76 | 'wpinv-details', |
77 | 77 | sprintf( |
78 | - __( '%s Details', 'invoicing' ), |
|
79 | - ucfirst( $invoice->get_type() ) |
|
78 | + __('%s Details', 'invoicing'), |
|
79 | + ucfirst($invoice->get_type()) |
|
80 | 80 | ), |
81 | 81 | 'GetPaid_Meta_Box_Invoice_Details::output', |
82 | 82 | $post_type, |
@@ -84,19 +84,19 @@ discard block |
||
84 | 84 | ); |
85 | 85 | |
86 | 86 | // Payment details. |
87 | - if ( ! $invoice->is_draft() ) { |
|
88 | - add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' ); |
|
87 | + if (!$invoice->is_draft()) { |
|
88 | + add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default'); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | // Billing details. |
92 | - add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' ); |
|
92 | + add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high'); |
|
93 | 93 | |
94 | 94 | // Invoice items. |
95 | 95 | add_meta_box( |
96 | 96 | 'wpinv-items', |
97 | 97 | sprintf( |
98 | - __( '%s Items', 'invoicing' ), |
|
99 | - ucfirst( $invoice->get_type() ) |
|
98 | + __('%s Items', 'invoicing'), |
|
99 | + ucfirst($invoice->get_type()) |
|
100 | 100 | ), |
101 | 101 | 'GetPaid_Meta_Box_Invoice_Items::output', |
102 | 102 | $post_type, |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | add_meta_box( |
109 | 109 | 'wpinv-notes', |
110 | 110 | sprintf( |
111 | - __( '%s Notes', 'invoicing' ), |
|
112 | - ucfirst( $invoice->get_type() ) |
|
111 | + __('%s Notes', 'invoicing'), |
|
112 | + ucfirst($invoice->get_type()) |
|
113 | 113 | ), |
114 | 114 | 'WPInv_Meta_Box_Notes::output', |
115 | 115 | $post_type, |
@@ -118,41 +118,41 @@ discard block |
||
118 | 118 | ); |
119 | 119 | |
120 | 120 | // Payment form information. |
121 | - if ( ! empty( $post->ID ) && get_post_meta( $post->ID, 'payment_form_data', true ) ) { |
|
122 | - add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' ); |
|
121 | + if (!empty($post->ID) && get_post_meta($post->ID, 'payment_form_data', true)) { |
|
122 | + add_meta_box('wpinv-invoice-payment-form-details', __('Payment Form Details', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high'); |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | 126 | // For payment forms. |
127 | - if ( $post_type == 'wpi_payment_form' ) { |
|
127 | + if ($post_type == 'wpi_payment_form') { |
|
128 | 128 | |
129 | 129 | // Design payment form. |
130 | - add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' ); |
|
130 | + add_meta_box('wpinv-payment-form-design', __('Payment Form', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal'); |
|
131 | 131 | |
132 | 132 | // Payment form information. |
133 | - add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' ); |
|
133 | + add_meta_box('wpinv-payment-form-info', __('Details', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side'); |
|
134 | 134 | |
135 | 135 | } |
136 | 136 | |
137 | 137 | // For invoice items. |
138 | - if ( $post_type == 'wpi_item' ) { |
|
138 | + if ($post_type == 'wpi_item') { |
|
139 | 139 | |
140 | 140 | // Item details. |
141 | - add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' ); |
|
141 | + add_meta_box('wpinv_item_details', __('Item Details', 'invoicing'), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high'); |
|
142 | 142 | |
143 | 143 | // If taxes are enabled, register the tax metabox. |
144 | - if ( $wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes() ) { |
|
145 | - add_meta_box( 'wpinv_item_vat', __( 'VAT / Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' ); |
|
144 | + if ($wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes()) { |
|
145 | + add_meta_box('wpinv_item_vat', __('VAT / Tax', 'invoicing'), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high'); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | // Item info. |
149 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' ); |
|
149 | + add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core'); |
|
150 | 150 | |
151 | 151 | } |
152 | 152 | |
153 | 153 | // For invoice discounts. |
154 | - if ( $post_type == 'wpi_discount' ) { |
|
155 | - add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' ); |
|
154 | + if ($post_type == 'wpi_discount') { |
|
155 | + add_meta_box('wpinv_discount_details', __('Discount Details', 'invoicing'), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high'); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * Remove some metaboxes. |
163 | 163 | */ |
164 | 164 | public static function remove_meta_boxes() { |
165 | - remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' ); |
|
165 | + remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal'); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -178,46 +178,46 @@ discard block |
||
178 | 178 | * @param int $post_id Post ID. |
179 | 179 | * @param object $post Post object. |
180 | 180 | */ |
181 | - public static function save_meta_boxes( $post_id, $post ) { |
|
182 | - $post_id = absint( $post_id ); |
|
183 | - $data = wp_unslash( $_POST ); |
|
181 | + public static function save_meta_boxes($post_id, $post) { |
|
182 | + $post_id = absint($post_id); |
|
183 | + $data = wp_unslash($_POST); |
|
184 | 184 | |
185 | 185 | // Do not save for ajax requests. |
186 | - if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
186 | + if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
187 | 187 | return; |
188 | 188 | } |
189 | 189 | |
190 | 190 | // $post_id and $post are required |
191 | - if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) { |
|
191 | + if (empty($post_id) || empty($post) || self::$saved_meta_boxes) { |
|
192 | 192 | return; |
193 | 193 | } |
194 | 194 | |
195 | 195 | // Dont' save meta boxes for revisions or autosaves. |
196 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
196 | + if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
197 | 197 | return; |
198 | 198 | } |
199 | 199 | |
200 | 200 | // Check the nonce. |
201 | - if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) { |
|
201 | + if (empty($data['getpaid_meta_nonce']) || !wp_verify_nonce($data['getpaid_meta_nonce'], 'getpaid_meta_nonce')) { |
|
202 | 202 | return; |
203 | 203 | } |
204 | 204 | |
205 | 205 | // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
206 | - if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) { |
|
206 | + if (empty($data['post_ID']) || absint($data['post_ID']) !== $post_id) { |
|
207 | 207 | return; |
208 | 208 | } |
209 | 209 | |
210 | 210 | // Check user has permission to edit. |
211 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
211 | + if (!current_user_can('edit_post', $post_id)) { |
|
212 | 212 | return; |
213 | 213 | } |
214 | 214 | |
215 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
215 | + if (getpaid_is_invoice_post_type($post->post_type)) { |
|
216 | 216 | |
217 | 217 | // We need this save event to run once to avoid potential endless loops. |
218 | 218 | self::$saved_meta_boxes = true; |
219 | 219 | |
220 | - return GetPaid_Meta_Box_Invoice_Address::save( $post_id ); |
|
220 | + return GetPaid_Meta_Box_Invoice_Address::save($post_id); |
|
221 | 221 | |
222 | 222 | } |
223 | 223 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | ); |
230 | 230 | |
231 | 231 | // Is this our post type? |
232 | - if ( ! isset( $post_types_map[ $post->post_type ] ) ) { |
|
232 | + if (!isset($post_types_map[$post->post_type])) { |
|
233 | 233 | return; |
234 | 234 | } |
235 | 235 | |
@@ -237,8 +237,8 @@ discard block |
||
237 | 237 | self::$saved_meta_boxes = true; |
238 | 238 | |
239 | 239 | // Save the post. |
240 | - $class = $post_types_map[ $post->post_type ]; |
|
241 | - $class::save( $post_id, $_POST, $post ); |
|
240 | + $class = $post_types_map[$post->post_type]; |
|
241 | + $class::save($post_id, $_POST, $post); |
|
242 | 242 | |
243 | 243 | } |
244 | 244 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Setup menus in WP admin. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * WC_Admin_Menus Class. |
@@ -13,25 +13,25 @@ discard block |
||
13 | 13 | * Hook in tabs. |
14 | 14 | */ |
15 | 15 | public function __construct() { |
16 | - add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 ); |
|
17 | - add_action( 'admin_menu', array( $this, 'add_customers_menu' ), 18 ); |
|
18 | - add_action( 'admin_menu', array( $this, 'add_subscriptions_menu' ), 40 ); |
|
19 | - add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 100 ); |
|
20 | - add_action( 'admin_menu', array( $this, 'add_settings_menu' ), 60 ); |
|
21 | - add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 ); |
|
22 | - add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) ); |
|
16 | + add_action('admin_menu', array($this, 'admin_menu'), 10); |
|
17 | + add_action('admin_menu', array($this, 'add_customers_menu'), 18); |
|
18 | + add_action('admin_menu', array($this, 'add_subscriptions_menu'), 40); |
|
19 | + add_action('admin_menu', array($this, 'add_addons_menu'), 100); |
|
20 | + add_action('admin_menu', array($this, 'add_settings_menu'), 60); |
|
21 | + add_action('admin_menu', array($this, 'remove_admin_submenus'), 10); |
|
22 | + add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes')); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | public function admin_menu() { |
26 | 26 | |
27 | - $capability = apply_filters( 'invoicing_capability', wpinv_get_capability() ); |
|
27 | + $capability = apply_filters('invoicing_capability', wpinv_get_capability()); |
|
28 | 28 | add_menu_page( |
29 | - __( 'GetPaid', 'invoicing' ), |
|
30 | - __( 'GetPaid', 'invoicing' ), |
|
29 | + __('GetPaid', 'invoicing'), |
|
30 | + __('GetPaid', 'invoicing'), |
|
31 | 31 | $capability, |
32 | 32 | 'wpinv', |
33 | 33 | null, |
34 | - 'data:image/svg+xml;base64,' . base64_encode( file_get_contents( WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg' ) ), |
|
34 | + 'data:image/svg+xml;base64,' . base64_encode(file_get_contents(WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg')), |
|
35 | 35 | '54.123460' |
36 | 36 | ); |
37 | 37 | |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | public function add_customers_menu() { |
44 | 44 | add_submenu_page( |
45 | 45 | 'wpinv', |
46 | - __( 'Customers', 'invoicing' ), |
|
47 | - __( 'Customers', 'invoicing' ), |
|
46 | + __('Customers', 'invoicing'), |
|
47 | + __('Customers', 'invoicing'), |
|
48 | 48 | wpinv_get_capability(), |
49 | 49 | 'wpinv-customers', |
50 | - array( $this, 'customers_page' ) |
|
50 | + array($this, 'customers_page') |
|
51 | 51 | ); |
52 | 52 | } |
53 | 53 | |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | public function add_subscriptions_menu() { |
58 | 58 | add_submenu_page( |
59 | 59 | 'wpinv', |
60 | - __( 'Subscriptions', 'invoicing' ), |
|
61 | - __( 'Subscriptions', 'invoicing' ), |
|
60 | + __('Subscriptions', 'invoicing'), |
|
61 | + __('Subscriptions', 'invoicing'), |
|
62 | 62 | wpinv_get_capability(), |
63 | 63 | 'wpinv-subscriptions', |
64 | 64 | 'wpinv_subscriptions_page' |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * Displays the customers page. |
70 | 70 | */ |
71 | 71 | public function customers_page() { |
72 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php' ); |
|
72 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php'); |
|
73 | 73 | ?> |
74 | 74 | <div class="wrap wpi-customers-wrap"> |
75 | 75 | <style> |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | width: 30%; |
78 | 78 | } |
79 | 79 | </style> |
80 | - <h1><?php echo esc_html( __( 'Customers', 'invoicing' ) ); ?></h1> |
|
80 | + <h1><?php echo esc_html(__('Customers', 'invoicing')); ?></h1> |
|
81 | 81 | <?php |
82 | 82 | $table = new WPInv_Customers_Table(); |
83 | 83 | $table->prepare_items(); |
@@ -93,16 +93,16 @@ discard block |
||
93 | 93 | public function add_settings_menu() { |
94 | 94 | add_submenu_page( |
95 | 95 | 'wpinv', |
96 | - __( 'Invoice Settings', 'invoicing' ), |
|
97 | - __( 'Settings', 'invoicing' ), |
|
98 | - apply_filters( 'invoicing_capability', wpinv_get_capability() ), |
|
96 | + __('Invoice Settings', 'invoicing'), |
|
97 | + __('Settings', 'invoicing'), |
|
98 | + apply_filters('invoicing_capability', wpinv_get_capability()), |
|
99 | 99 | 'wpinv-settings', |
100 | - array( $this, 'options_page' ) |
|
100 | + array($this, 'options_page') |
|
101 | 101 | ); |
102 | 102 | } |
103 | 103 | |
104 | - public function add_addons_menu(){ |
|
105 | - if ( !apply_filters( 'wpi_show_addons_page', true ) ) { |
|
104 | + public function add_addons_menu() { |
|
105 | + if (!apply_filters('wpi_show_addons_page', true)) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
@@ -112,78 +112,78 @@ discard block |
||
112 | 112 | __('Extensions', 'invoicing'), |
113 | 113 | 'manage_options', |
114 | 114 | 'wpi-addons', |
115 | - array( $this, 'addons_page' ) |
|
115 | + array($this, 'addons_page') |
|
116 | 116 | ); |
117 | 117 | } |
118 | 118 | |
119 | - public function addons_page(){ |
|
119 | + public function addons_page() { |
|
120 | 120 | $addon_obj = new WPInv_Admin_Addons(); |
121 | 121 | $addon_obj->output(); |
122 | 122 | } |
123 | 123 | |
124 | 124 | function options_page() { |
125 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
125 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
126 | 126 | |
127 | - if ( $page !== 'wpinv-settings' ) { |
|
127 | + if ($page !== 'wpinv-settings') { |
|
128 | 128 | return; |
129 | 129 | } |
130 | 130 | |
131 | 131 | $settings_tabs = wpinv_get_settings_tabs(); |
132 | 132 | $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs; |
133 | - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general'; |
|
134 | - $sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
133 | + $active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general'; |
|
134 | + $sections = wpinv_get_settings_tab_sections($active_tab); |
|
135 | 135 | $key = 'main'; |
136 | 136 | |
137 | - if ( is_array( $sections ) ) { |
|
138 | - $key = key( $sections ); |
|
137 | + if (is_array($sections)) { |
|
138 | + $key = key($sections); |
|
139 | 139 | } |
140 | 140 | |
141 | - $registered_sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
142 | - $section = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key; |
|
141 | + $registered_sections = wpinv_get_settings_tab_sections($active_tab); |
|
142 | + $section = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key; |
|
143 | 143 | ob_start(); |
144 | 144 | ?> |
145 | 145 | <div class="wrap"> |
146 | 146 | <h1 class="nav-tab-wrapper"> |
147 | 147 | <?php |
148 | - foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) { |
|
149 | - $tab_url = add_query_arg( array( |
|
148 | + foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) { |
|
149 | + $tab_url = add_query_arg(array( |
|
150 | 150 | 'settings-updated' => false, |
151 | 151 | 'tab' => $tab_id, |
152 | - ) ); |
|
152 | + )); |
|
153 | 153 | |
154 | 154 | // Remove the section from the tabs so we always end up at the main section |
155 | - $tab_url = remove_query_arg( 'section', $tab_url ); |
|
156 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
155 | + $tab_url = remove_query_arg('section', $tab_url); |
|
156 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
157 | 157 | |
158 | 158 | $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
159 | 159 | |
160 | - echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">'; |
|
161 | - echo esc_html( $tab_name ); |
|
160 | + echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">'; |
|
161 | + echo esc_html($tab_name); |
|
162 | 162 | echo '</a>'; |
163 | 163 | } |
164 | 164 | ?> |
165 | 165 | </h1> |
166 | 166 | <?php |
167 | - $number_of_sections = count( $sections ); |
|
167 | + $number_of_sections = count($sections); |
|
168 | 168 | $number = 0; |
169 | - if ( $number_of_sections > 1 ) { |
|
169 | + if ($number_of_sections > 1) { |
|
170 | 170 | echo '<div><ul class="subsubsub">'; |
171 | - foreach( $sections as $section_id => $section_name ) { |
|
171 | + foreach ($sections as $section_id => $section_name) { |
|
172 | 172 | echo '<li>'; |
173 | 173 | $number++; |
174 | - $tab_url = add_query_arg( array( |
|
174 | + $tab_url = add_query_arg(array( |
|
175 | 175 | 'settings-updated' => false, |
176 | 176 | 'tab' => $active_tab, |
177 | 177 | 'section' => $section_id |
178 | - ) ); |
|
179 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
178 | + )); |
|
179 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
180 | 180 | $class = ''; |
181 | - if ( $section == $section_id ) { |
|
181 | + if ($section == $section_id) { |
|
182 | 182 | $class = 'current'; |
183 | 183 | } |
184 | - echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>'; |
|
184 | + echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>'; |
|
185 | 185 | |
186 | - if ( $number != $number_of_sections ) { |
|
186 | + if ($number != $number_of_sections) { |
|
187 | 187 | echo ' | '; |
188 | 188 | } |
189 | 189 | echo '</li>'; |
@@ -195,20 +195,20 @@ discard block |
||
195 | 195 | <form method="post" action="options.php"> |
196 | 196 | <table class="form-table"> |
197 | 197 | <?php |
198 | - settings_fields( 'wpinv_settings' ); |
|
198 | + settings_fields('wpinv_settings'); |
|
199 | 199 | |
200 | - if ( 'main' === $section ) { |
|
201 | - do_action( 'wpinv_settings_tab_top', $active_tab ); |
|
200 | + if ('main' === $section) { |
|
201 | + do_action('wpinv_settings_tab_top', $active_tab); |
|
202 | 202 | } |
203 | 203 | |
204 | - do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
205 | - do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
206 | - do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
207 | - do_action( 'getpaid_settings_tab_bottom', $active_tab, $section ); |
|
204 | + do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section); |
|
205 | + do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section); |
|
206 | + do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section); |
|
207 | + do_action('getpaid_settings_tab_bottom', $active_tab, $section); |
|
208 | 208 | |
209 | 209 | // For backwards compatibility |
210 | - if ( 'main' === $section ) { |
|
211 | - do_action( 'wpinv_settings_tab_bottom', $active_tab ); |
|
210 | + if ('main' === $section) { |
|
211 | + do_action('wpinv_settings_tab_bottom', $active_tab); |
|
212 | 212 | } |
213 | 213 | ?> |
214 | 214 | </table> |
@@ -222,18 +222,18 @@ discard block |
||
222 | 222 | } |
223 | 223 | |
224 | 224 | public function remove_admin_submenus() { |
225 | - remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' ); |
|
225 | + remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice'); |
|
226 | 226 | } |
227 | 227 | |
228 | - public function add_nav_menu_meta_boxes(){ |
|
229 | - add_meta_box( 'wpinv_endpoints_nav_link', __( 'Invoicing Pages', 'invoicing' ), array( $this, 'nav_menu_links' ), 'nav-menus', 'side', 'low' ); |
|
228 | + public function add_nav_menu_meta_boxes() { |
|
229 | + add_meta_box('wpinv_endpoints_nav_link', __('Invoicing Pages', 'invoicing'), array($this, 'nav_menu_links'), 'nav-menus', 'side', 'low'); |
|
230 | 230 | } |
231 | 231 | |
232 | - public function nav_menu_links(){ |
|
232 | + public function nav_menu_links() { |
|
233 | 233 | $endpoints = $this->get_menu_items(); |
234 | 234 | ?> |
235 | 235 | <div id="invoicing-endpoints" class="posttypediv"> |
236 | - <?php if(!empty($endpoints['pages'])){ ?> |
|
236 | + <?php if (!empty($endpoints['pages'])) { ?> |
|
237 | 237 | <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active"> |
238 | 238 | <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear"> |
239 | 239 | <?php |
@@ -245,29 +245,29 @@ discard block |
||
245 | 245 | <?php } ?> |
246 | 246 | <p class="button-controls"> |
247 | 247 | <span class="list-controls"> |
248 | - <a href="<?php echo admin_url( 'nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints' ); ?>" class="select-all"><?php _e( 'Select all', 'invoicing' ); ?></a> |
|
248 | + <a href="<?php echo admin_url('nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints'); ?>" class="select-all"><?php _e('Select all', 'invoicing'); ?></a> |
|
249 | 249 | </span> |
250 | 250 | <span class="add-to-menu"> |
251 | - <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints"> |
|
251 | + <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints"> |
|
252 | 252 | <span class="spinner"></span> |
253 | 253 | </span> |
254 | 254 | </p> |
255 | 255 | <?php |
256 | 256 | } |
257 | 257 | |
258 | - public function get_menu_items(){ |
|
258 | + public function get_menu_items() { |
|
259 | 259 | $items = array(); |
260 | 260 | |
261 | - $wpinv_history_page_id = (int)wpinv_get_option( 'invoice_history_page' ); |
|
262 | - if($wpinv_history_page_id > 0){ |
|
261 | + $wpinv_history_page_id = (int) wpinv_get_option('invoice_history_page'); |
|
262 | + if ($wpinv_history_page_id > 0) { |
|
263 | 263 | $item = new stdClass(); |
264 | 264 | $item->object_id = $wpinv_history_page_id; |
265 | 265 | $item->db_id = 0; |
266 | - $item->object = 'page'; |
|
266 | + $item->object = 'page'; |
|
267 | 267 | $item->menu_item_parent = 0; |
268 | 268 | $item->type = 'post_type'; |
269 | - $item->title = __('Invoice History Page','invoicing'); |
|
270 | - $item->url = get_permalink( $wpinv_history_page_id ); |
|
269 | + $item->title = __('Invoice History Page', 'invoicing'); |
|
270 | + $item->url = get_permalink($wpinv_history_page_id); |
|
271 | 271 | $item->target = ''; |
272 | 272 | $item->attr_title = ''; |
273 | 273 | $item->classes = array('wpinv-menu-item'); |
@@ -276,16 +276,16 @@ discard block |
||
276 | 276 | $items['pages'][] = $item; |
277 | 277 | } |
278 | 278 | |
279 | - $wpinv_sub_history_page_id = (int)wpinv_get_option( 'invoice_subscription_page' ); |
|
280 | - if($wpinv_sub_history_page_id > 0){ |
|
279 | + $wpinv_sub_history_page_id = (int) wpinv_get_option('invoice_subscription_page'); |
|
280 | + if ($wpinv_sub_history_page_id > 0) { |
|
281 | 281 | $item = new stdClass(); |
282 | 282 | $item->object_id = $wpinv_sub_history_page_id; |
283 | 283 | $item->db_id = 0; |
284 | - $item->object = 'page'; |
|
284 | + $item->object = 'page'; |
|
285 | 285 | $item->menu_item_parent = 0; |
286 | 286 | $item->type = 'post_type'; |
287 | - $item->title = __('Invoice Subscriptions Page','invoicing'); |
|
288 | - $item->url = get_permalink( $wpinv_sub_history_page_id ); |
|
287 | + $item->title = __('Invoice Subscriptions Page', 'invoicing'); |
|
288 | + $item->url = get_permalink($wpinv_sub_history_page_id); |
|
289 | 289 | $item->target = ''; |
290 | 290 | $item->attr_title = ''; |
291 | 291 | $item->classes = array('wpinv-menu-item'); |
@@ -294,16 +294,16 @@ discard block |
||
294 | 294 | $items['pages'][] = $item; |
295 | 295 | } |
296 | 296 | |
297 | - $wpinv_checkout_page_id = (int)wpinv_get_option( 'checkout_page' ); |
|
298 | - if($wpinv_checkout_page_id > 0){ |
|
297 | + $wpinv_checkout_page_id = (int) wpinv_get_option('checkout_page'); |
|
298 | + if ($wpinv_checkout_page_id > 0) { |
|
299 | 299 | $item = new stdClass(); |
300 | 300 | $item->object_id = $wpinv_checkout_page_id; |
301 | 301 | $item->db_id = 0; |
302 | - $item->object = 'page'; |
|
302 | + $item->object = 'page'; |
|
303 | 303 | $item->menu_item_parent = 0; |
304 | 304 | $item->type = 'post_type'; |
305 | - $item->title = __('Checkout Page','invoicing'); |
|
306 | - $item->url = get_permalink( $wpinv_checkout_page_id ); |
|
305 | + $item->title = __('Checkout Page', 'invoicing'); |
|
306 | + $item->url = get_permalink($wpinv_checkout_page_id); |
|
307 | 307 | $item->target = ''; |
308 | 308 | $item->attr_title = ''; |
309 | 309 | $item->classes = array('wpinv-menu-item'); |
@@ -312,16 +312,16 @@ discard block |
||
312 | 312 | $items['pages'][] = $item; |
313 | 313 | } |
314 | 314 | |
315 | - $wpinv_tandc_page_id = (int)wpinv_get_option( 'tandc_page' ); |
|
316 | - if($wpinv_tandc_page_id > 0){ |
|
315 | + $wpinv_tandc_page_id = (int) wpinv_get_option('tandc_page'); |
|
316 | + if ($wpinv_tandc_page_id > 0) { |
|
317 | 317 | $item = new stdClass(); |
318 | 318 | $item->object_id = $wpinv_tandc_page_id; |
319 | 319 | $item->db_id = 0; |
320 | - $item->object = 'page'; |
|
320 | + $item->object = 'page'; |
|
321 | 321 | $item->menu_item_parent = 0; |
322 | 322 | $item->type = 'post_type'; |
323 | - $item->title = __('Terms & Conditions','invoicing'); |
|
324 | - $item->url = get_permalink( $wpinv_tandc_page_id ); |
|
323 | + $item->title = __('Terms & Conditions', 'invoicing'); |
|
324 | + $item->url = get_permalink($wpinv_tandc_page_id); |
|
325 | 325 | $item->target = ''; |
326 | 326 | $item->attr_title = ''; |
327 | 327 | $item->classes = array('wpinv-menu-item'); |
@@ -330,16 +330,16 @@ discard block |
||
330 | 330 | $items['pages'][] = $item; |
331 | 331 | } |
332 | 332 | |
333 | - $wpinv_success_page_id = (int)wpinv_get_option( 'success_page' ); |
|
334 | - if($wpinv_success_page_id > 0){ |
|
333 | + $wpinv_success_page_id = (int) wpinv_get_option('success_page'); |
|
334 | + if ($wpinv_success_page_id > 0) { |
|
335 | 335 | $item = new stdClass(); |
336 | 336 | $item->object_id = $wpinv_success_page_id; |
337 | 337 | $item->db_id = 0; |
338 | - $item->object = 'page'; |
|
338 | + $item->object = 'page'; |
|
339 | 339 | $item->menu_item_parent = 0; |
340 | 340 | $item->type = 'post_type'; |
341 | - $item->title = __('Success Page','invoicing'); |
|
342 | - $item->url = get_permalink( $wpinv_success_page_id ); |
|
341 | + $item->title = __('Success Page', 'invoicing'); |
|
342 | + $item->url = get_permalink($wpinv_success_page_id); |
|
343 | 343 | $item->target = ''; |
344 | 344 | $item->attr_title = ''; |
345 | 345 | $item->classes = array('wpinv-menu-item'); |
@@ -348,16 +348,16 @@ discard block |
||
348 | 348 | $items['pages'][] = $item; |
349 | 349 | } |
350 | 350 | |
351 | - $wpinv_failure_page_id = (int)wpinv_get_option( 'failure_page' ); |
|
352 | - if($wpinv_failure_page_id > 0){ |
|
351 | + $wpinv_failure_page_id = (int) wpinv_get_option('failure_page'); |
|
352 | + if ($wpinv_failure_page_id > 0) { |
|
353 | 353 | $item = new stdClass(); |
354 | 354 | $item->object_id = $wpinv_failure_page_id; |
355 | 355 | $item->db_id = 0; |
356 | - $item->object = 'page'; |
|
356 | + $item->object = 'page'; |
|
357 | 357 | $item->menu_item_parent = 0; |
358 | 358 | $item->type = 'post_type'; |
359 | - $item->title = __('Failed Transaction Page','invoicing'); |
|
360 | - $item->url = get_permalink( $wpinv_failure_page_id ); |
|
359 | + $item->title = __('Failed Transaction Page', 'invoicing'); |
|
360 | + $item->url = get_permalink($wpinv_failure_page_id); |
|
361 | 361 | $item->target = ''; |
362 | 362 | $item->attr_title = ''; |
363 | 363 | $item->classes = array('wpinv-menu-item'); |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | $items['pages'][] = $item; |
367 | 367 | } |
368 | 368 | |
369 | - return apply_filters( 'wpinv_menu_items', $items ); |
|
369 | + return apply_filters('wpinv_menu_items', $items); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
@@ -18,16 +18,16 @@ discard block |
||
18 | 18 | <?php |
19 | 19 | |
20 | 20 | // Fires when printing the header. |
21 | - do_action( 'getpaid_invoice_header', $invoice ); |
|
21 | + do_action('getpaid_invoice_header', $invoice); |
|
22 | 22 | |
23 | 23 | // Print the opening wrapper. |
24 | 24 | echo '<div class="container bg-white border mt-4 mb-4 p-4 position-relative flex-grow-1">'; |
25 | 25 | |
26 | 26 | // Fires when printing the invoice details. |
27 | - do_action( 'getpaid_invoice_details', $invoice ); |
|
27 | + do_action('getpaid_invoice_details', $invoice); |
|
28 | 28 | |
29 | 29 | // Fires when printing the invoice line items. |
30 | - do_action( 'getpaid_invoice_line_items', $invoice ); |
|
30 | + do_action('getpaid_invoice_line_items', $invoice); |
|
31 | 31 | |
32 | 32 | // Print notifications. |
33 | 33 | wpinv_print_errors(); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | echo '</div>'; |
37 | 37 | |
38 | 38 | // Fires when printing the invoice footer. |
39 | - do_action( 'getpaid_invoice_footer', $invoice ); |
|
39 | + do_action('getpaid_invoice_footer', $invoice); |
|
40 | 40 | |
41 | 41 | ?> |
42 | 42 |