@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | * Retrieves the transaction ID from the subscription |
371 | 371 | * |
372 | 372 | * @since 1.0.0 |
373 | - * @return bool |
|
373 | + * @return string |
|
374 | 374 | */ |
375 | 375 | public function get_transaction_id() { |
376 | 376 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | * Stores the transaction ID for the subscription purchase |
393 | 393 | * |
394 | 394 | * @since 1.0.0.4 |
395 | - * @return bool |
|
395 | + * @return boolean|null |
|
396 | 396 | */ |
397 | 397 | public function set_transaction_id( $txn_id = '' ) { |
398 | 398 | $this->update( array( 'transaction_id' => $txn_id ) ); |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | * Renews a subscription |
404 | 404 | * |
405 | 405 | * @since 1.0.0 |
406 | - * @return bool |
|
406 | + * @return boolean|null |
|
407 | 407 | */ |
408 | 408 | public function renew() { |
409 | 409 | |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | * |
493 | 493 | * @since 1.0.0 |
494 | 494 | * @param $check_expiration bool True if expiration date should be checked with merchant processor before expiring |
495 | - * @return void |
|
495 | + * @return false|null |
|
496 | 496 | */ |
497 | 497 | public function expire( $check_expiration = false ) { |
498 | 498 | |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | * Retrieves the subscription status |
745 | 745 | * |
746 | 746 | * @since 1.0.0 |
747 | - * @return int |
|
747 | + * @return string |
|
748 | 748 | */ |
749 | 749 | public function get_status() { |
750 | 750 |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | // Exit if accessed directly |
4 | 4 | if ( ! defined( 'ABSPATH' ) ) { |
5 | - exit; |
|
5 | + exit; |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -13,183 +13,183 @@ discard block |
||
13 | 13 | */ |
14 | 14 | class WPInv_Subscription { |
15 | 15 | |
16 | - private $subs_db; |
|
16 | + private $subs_db; |
|
17 | + |
|
18 | + public $id = 0; |
|
19 | + public $customer_id = 0; |
|
20 | + public $period = ''; |
|
21 | + public $initial_amount = ''; |
|
22 | + public $recurring_amount = ''; |
|
23 | + public $bill_times = 0; |
|
24 | + public $transaction_id = ''; |
|
25 | + public $parent_payment_id = 0; |
|
26 | + public $product_id = 0; |
|
27 | + public $created = '0000-00-00 00:00:00'; |
|
28 | + public $expiration = '0000-00-00 00:00:00'; |
|
29 | + public $trial_period = ''; |
|
30 | + public $status = 'pending'; |
|
31 | + public $profile_id = ''; |
|
32 | + public $gateway = ''; |
|
33 | + public $customer; |
|
17 | 34 | |
18 | - public $id = 0; |
|
19 | - public $customer_id = 0; |
|
20 | - public $period = ''; |
|
21 | - public $initial_amount = ''; |
|
22 | - public $recurring_amount = ''; |
|
23 | - public $bill_times = 0; |
|
24 | - public $transaction_id = ''; |
|
25 | - public $parent_payment_id = 0; |
|
26 | - public $product_id = 0; |
|
27 | - public $created = '0000-00-00 00:00:00'; |
|
28 | - public $expiration = '0000-00-00 00:00:00'; |
|
29 | - public $trial_period = ''; |
|
30 | - public $status = 'pending'; |
|
31 | - public $profile_id = ''; |
|
32 | - public $gateway = ''; |
|
33 | - public $customer; |
|
34 | - |
|
35 | - /** |
|
36 | - * Get us started |
|
37 | - * |
|
38 | - * @since 1.0.0 |
|
39 | - * @return void |
|
40 | - */ |
|
41 | - function __construct( $_id_or_object = 0, $_by_profile_id = false ) { |
|
35 | + /** |
|
36 | + * Get us started |
|
37 | + * |
|
38 | + * @since 1.0.0 |
|
39 | + * @return void |
|
40 | + */ |
|
41 | + function __construct( $_id_or_object = 0, $_by_profile_id = false ) { |
|
42 | 42 | |
43 | - $this->subs_db = new WPInv_Subscriptions_DB; |
|
43 | + $this->subs_db = new WPInv_Subscriptions_DB; |
|
44 | 44 | |
45 | - if( $_by_profile_id ) { |
|
45 | + if( $_by_profile_id ) { |
|
46 | 46 | |
47 | - $_sub = $this->subs_db->get_by( 'profile_id', $_id_or_object ); |
|
47 | + $_sub = $this->subs_db->get_by( 'profile_id', $_id_or_object ); |
|
48 | 48 | |
49 | - if( empty( $_sub ) ) { |
|
50 | - return false; |
|
51 | - } |
|
49 | + if( empty( $_sub ) ) { |
|
50 | + return false; |
|
51 | + } |
|
52 | 52 | |
53 | - $_id_or_object = $_sub; |
|
53 | + $_id_or_object = $_sub; |
|
54 | 54 | |
55 | - } |
|
55 | + } |
|
56 | 56 | |
57 | - return $this->setup_subscription( $_id_or_object ); |
|
58 | - } |
|
57 | + return $this->setup_subscription( $_id_or_object ); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Setup the subscription object |
|
62 | - * |
|
63 | - * @since 1.0.0 |
|
64 | - * @return void |
|
65 | - */ |
|
66 | - private function setup_subscription( $id_or_object = 0 ) { |
|
60 | + /** |
|
61 | + * Setup the subscription object |
|
62 | + * |
|
63 | + * @since 1.0.0 |
|
64 | + * @return void |
|
65 | + */ |
|
66 | + private function setup_subscription( $id_or_object = 0 ) { |
|
67 | 67 | |
68 | - if( empty( $id_or_object ) ) { |
|
69 | - return false; |
|
70 | - } |
|
68 | + if( empty( $id_or_object ) ) { |
|
69 | + return false; |
|
70 | + } |
|
71 | 71 | |
72 | - if( is_numeric( $id_or_object ) ) { |
|
72 | + if( is_numeric( $id_or_object ) ) { |
|
73 | 73 | |
74 | - $sub = $this->subs_db->get( $id_or_object ); |
|
74 | + $sub = $this->subs_db->get( $id_or_object ); |
|
75 | 75 | |
76 | - } elseif( is_object( $id_or_object ) ) { |
|
76 | + } elseif( is_object( $id_or_object ) ) { |
|
77 | 77 | |
78 | - $sub = $id_or_object; |
|
78 | + $sub = $id_or_object; |
|
79 | 79 | |
80 | - } |
|
80 | + } |
|
81 | 81 | |
82 | - if( empty( $sub ) ) { |
|
83 | - return false; |
|
84 | - } |
|
82 | + if( empty( $sub ) ) { |
|
83 | + return false; |
|
84 | + } |
|
85 | 85 | |
86 | - foreach( $sub as $key => $value ) { |
|
87 | - $this->$key = $value; |
|
88 | - } |
|
86 | + foreach( $sub as $key => $value ) { |
|
87 | + $this->$key = $value; |
|
88 | + } |
|
89 | 89 | |
90 | - $this->customer = get_userdata( $this->customer_id ); |
|
91 | - $this->gateway = wpinv_get_payment_gateway( $this->parent_payment_id ); |
|
90 | + $this->customer = get_userdata( $this->customer_id ); |
|
91 | + $this->gateway = wpinv_get_payment_gateway( $this->parent_payment_id ); |
|
92 | 92 | |
93 | - do_action( 'wpinv_recurring_setup_subscription', $this ); |
|
93 | + do_action( 'wpinv_recurring_setup_subscription', $this ); |
|
94 | 94 | |
95 | - return $this; |
|
96 | - } |
|
95 | + return $this; |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * Magic __get function to dispatch a call to retrieve a private property |
|
100 | - * |
|
101 | - * @since 1.0.0 |
|
102 | - */ |
|
103 | - public function __get( $key ) { |
|
98 | + /** |
|
99 | + * Magic __get function to dispatch a call to retrieve a private property |
|
100 | + * |
|
101 | + * @since 1.0.0 |
|
102 | + */ |
|
103 | + public function __get( $key ) { |
|
104 | 104 | |
105 | - if( method_exists( $this, 'get_' . $key ) ) { |
|
105 | + if( method_exists( $this, 'get_' . $key ) ) { |
|
106 | 106 | |
107 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
107 | + return call_user_func( array( $this, 'get_' . $key ) ); |
|
108 | 108 | |
109 | - } else { |
|
109 | + } else { |
|
110 | 110 | |
111 | - return new WP_Error( 'wpinv-subscription-invalid-property', sprintf( __( 'Can\'t get property %s', 'invoicing' ), $key ) ); |
|
111 | + return new WP_Error( 'wpinv-subscription-invalid-property', sprintf( __( 'Can\'t get property %s', 'invoicing' ), $key ) ); |
|
112 | 112 | |
113 | - } |
|
113 | + } |
|
114 | 114 | |
115 | - } |
|
115 | + } |
|
116 | 116 | |
117 | - /** |
|
118 | - * Creates a subscription |
|
119 | - * |
|
120 | - * @since 1.0.0 |
|
121 | - * @param array $data Array of attributes for a subscription |
|
122 | - * @return mixed false if data isn't passed and class not instantiated for creation |
|
123 | - */ |
|
124 | - public function create( $data = array() ) { |
|
117 | + /** |
|
118 | + * Creates a subscription |
|
119 | + * |
|
120 | + * @since 1.0.0 |
|
121 | + * @param array $data Array of attributes for a subscription |
|
122 | + * @return mixed false if data isn't passed and class not instantiated for creation |
|
123 | + */ |
|
124 | + public function create( $data = array() ) { |
|
125 | 125 | |
126 | - if ( $this->id != 0 ) { |
|
127 | - return false; |
|
128 | - } |
|
126 | + if ( $this->id != 0 ) { |
|
127 | + return false; |
|
128 | + } |
|
129 | 129 | |
130 | - $defaults = array( |
|
131 | - 'customer_id' => 0, |
|
132 | - 'frequency' => '', |
|
133 | - 'period' => '', |
|
134 | - 'initial_amount' => '', |
|
135 | - 'recurring_amount' => '', |
|
136 | - 'bill_times' => 0, |
|
137 | - 'parent_payment_id' => 0, |
|
138 | - 'product_id' => 0, |
|
139 | - 'created' => '', |
|
140 | - 'expiration' => '', |
|
141 | - 'status' => '', |
|
142 | - 'profile_id' => '', |
|
143 | - ); |
|
130 | + $defaults = array( |
|
131 | + 'customer_id' => 0, |
|
132 | + 'frequency' => '', |
|
133 | + 'period' => '', |
|
134 | + 'initial_amount' => '', |
|
135 | + 'recurring_amount' => '', |
|
136 | + 'bill_times' => 0, |
|
137 | + 'parent_payment_id' => 0, |
|
138 | + 'product_id' => 0, |
|
139 | + 'created' => '', |
|
140 | + 'expiration' => '', |
|
141 | + 'status' => '', |
|
142 | + 'profile_id' => '', |
|
143 | + ); |
|
144 | 144 | |
145 | - $args = wp_parse_args( $data, $defaults ); |
|
145 | + $args = wp_parse_args( $data, $defaults ); |
|
146 | 146 | |
147 | - if( $args['expiration'] && strtotime( 'NOW', current_time( 'timestamp' ) ) > strtotime( $args['expiration'], current_time( 'timestamp' ) ) ) { |
|
147 | + if( $args['expiration'] && strtotime( 'NOW', current_time( 'timestamp' ) ) > strtotime( $args['expiration'], current_time( 'timestamp' ) ) ) { |
|
148 | 148 | |
149 | - if( 'active' == $args['status'] || 'trialling' == $args['status'] ) { |
|
149 | + if( 'active' == $args['status'] || 'trialling' == $args['status'] ) { |
|
150 | 150 | |
151 | - // Force an active subscription to expired if expiration date is in the past |
|
152 | - $args['status'] = 'expired'; |
|
151 | + // Force an active subscription to expired if expiration date is in the past |
|
152 | + $args['status'] = 'expired'; |
|
153 | 153 | |
154 | - } |
|
155 | - } |
|
154 | + } |
|
155 | + } |
|
156 | 156 | |
157 | - do_action( 'wpinv_subscription_pre_create', $args ); |
|
157 | + do_action( 'wpinv_subscription_pre_create', $args ); |
|
158 | 158 | |
159 | - $id = $this->subs_db->insert( $args, 'subscription' ); |
|
159 | + $id = $this->subs_db->insert( $args, 'subscription' ); |
|
160 | 160 | |
161 | - do_action( 'wpinv_subscription_post_create', $id, $args ); |
|
161 | + do_action( 'wpinv_subscription_post_create', $id, $args ); |
|
162 | 162 | |
163 | - return $this->setup_subscription( $id ); |
|
163 | + return $this->setup_subscription( $id ); |
|
164 | 164 | |
165 | - } |
|
165 | + } |
|
166 | 166 | |
167 | - /** |
|
168 | - * Updates a subscription |
|
169 | - * |
|
170 | - * @since 1.0.0 |
|
171 | - * @param array $args Array of fields to update |
|
172 | - * @return bool |
|
173 | - */ |
|
174 | - public function update( $args = array() ) { |
|
167 | + /** |
|
168 | + * Updates a subscription |
|
169 | + * |
|
170 | + * @since 1.0.0 |
|
171 | + * @param array $args Array of fields to update |
|
172 | + * @return bool |
|
173 | + */ |
|
174 | + public function update( $args = array() ) { |
|
175 | 175 | |
176 | - $ret = $this->subs_db->update( $this->id, $args ); |
|
176 | + $ret = $this->subs_db->update( $this->id, $args ); |
|
177 | 177 | |
178 | - do_action( 'wpinv_recurring_update_subscription', $this->id, $args, $this ); |
|
178 | + do_action( 'wpinv_recurring_update_subscription', $this->id, $args, $this ); |
|
179 | 179 | |
180 | - return $ret; |
|
180 | + return $ret; |
|
181 | 181 | |
182 | - } |
|
182 | + } |
|
183 | 183 | |
184 | - /** |
|
185 | - * Delete the subscription |
|
186 | - * |
|
187 | - * @since 1.0.0 |
|
188 | - * @return bool |
|
189 | - */ |
|
190 | - public function delete() { |
|
191 | - return $this->subs_db->delete( $this->id ); |
|
192 | - } |
|
184 | + /** |
|
185 | + * Delete the subscription |
|
186 | + * |
|
187 | + * @since 1.0.0 |
|
188 | + * @return bool |
|
189 | + */ |
|
190 | + public function delete() { |
|
191 | + return $this->subs_db->delete( $this->id ); |
|
192 | + } |
|
193 | 193 | |
194 | 194 | /** |
195 | 195 | * Retrieves the parent payment ID |
@@ -366,185 +366,185 @@ discard block |
||
366 | 366 | return false; |
367 | 367 | } |
368 | 368 | |
369 | - /** |
|
370 | - * Retrieves the transaction ID from the subscription |
|
371 | - * |
|
372 | - * @since 1.0.0 |
|
373 | - * @return bool |
|
374 | - */ |
|
375 | - public function get_transaction_id() { |
|
369 | + /** |
|
370 | + * Retrieves the transaction ID from the subscription |
|
371 | + * |
|
372 | + * @since 1.0.0 |
|
373 | + * @return bool |
|
374 | + */ |
|
375 | + public function get_transaction_id() { |
|
376 | 376 | |
377 | - if( empty( $this->transaction_id ) ) { |
|
377 | + if( empty( $this->transaction_id ) ) { |
|
378 | 378 | |
379 | - $txn_id = wpinv_get_payment_transaction_id( $this->parent_payment_id ); |
|
379 | + $txn_id = wpinv_get_payment_transaction_id( $this->parent_payment_id ); |
|
380 | 380 | |
381 | - if( ! empty( $txn_id ) && (int) $this->parent_payment_id !== (int) $txn_id ) { |
|
382 | - $this->set_transaction_id( $txn_id ); |
|
383 | - } |
|
381 | + if( ! empty( $txn_id ) && (int) $this->parent_payment_id !== (int) $txn_id ) { |
|
382 | + $this->set_transaction_id( $txn_id ); |
|
383 | + } |
|
384 | 384 | |
385 | - } |
|
385 | + } |
|
386 | 386 | |
387 | - return $this->transaction_id; |
|
387 | + return $this->transaction_id; |
|
388 | 388 | |
389 | - } |
|
389 | + } |
|
390 | 390 | |
391 | - /** |
|
392 | - * Stores the transaction ID for the subscription purchase |
|
393 | - * |
|
394 | - * @since 1.0.0.4 |
|
395 | - * @return bool |
|
396 | - */ |
|
397 | - public function set_transaction_id( $txn_id = '' ) { |
|
398 | - $this->update( array( 'transaction_id' => $txn_id ) ); |
|
399 | - $this->transaction_id = $txn_id; |
|
400 | - } |
|
391 | + /** |
|
392 | + * Stores the transaction ID for the subscription purchase |
|
393 | + * |
|
394 | + * @since 1.0.0.4 |
|
395 | + * @return bool |
|
396 | + */ |
|
397 | + public function set_transaction_id( $txn_id = '' ) { |
|
398 | + $this->update( array( 'transaction_id' => $txn_id ) ); |
|
399 | + $this->transaction_id = $txn_id; |
|
400 | + } |
|
401 | 401 | |
402 | - /** |
|
403 | - * Renews a subscription |
|
404 | - * |
|
405 | - * @since 1.0.0 |
|
406 | - * @return bool |
|
407 | - */ |
|
408 | - public function renew() { |
|
402 | + /** |
|
403 | + * Renews a subscription |
|
404 | + * |
|
405 | + * @since 1.0.0 |
|
406 | + * @return bool |
|
407 | + */ |
|
408 | + public function renew() { |
|
409 | 409 | |
410 | - $expires = $this->get_expiration_time(); |
|
410 | + $expires = $this->get_expiration_time(); |
|
411 | 411 | |
412 | 412 | |
413 | - // Determine what date to use as the start for the new expiration calculation |
|
414 | - if( $expires > current_time( 'timestamp' ) && $this->is_active() ) { |
|
413 | + // Determine what date to use as the start for the new expiration calculation |
|
414 | + if( $expires > current_time( 'timestamp' ) && $this->is_active() ) { |
|
415 | 415 | |
416 | - $base_date = $expires; |
|
416 | + $base_date = $expires; |
|
417 | 417 | |
418 | - } else { |
|
418 | + } else { |
|
419 | 419 | |
420 | - $base_date = current_time( 'timestamp' ); |
|
420 | + $base_date = current_time( 'timestamp' ); |
|
421 | 421 | |
422 | - } |
|
422 | + } |
|
423 | 423 | |
424 | - $last_day = wpinv_cal_days_in_month( CAL_GREGORIAN, date( 'n', $base_date ), date( 'Y', $base_date ) ); |
|
424 | + $last_day = wpinv_cal_days_in_month( CAL_GREGORIAN, date( 'n', $base_date ), date( 'Y', $base_date ) ); |
|
425 | 425 | |
426 | 426 | |
427 | - $frequency = isset($this->frequency) ? $this->frequency : 1; |
|
428 | - $expiration = date( 'Y-m-d H:i:s', strtotime( '+' . $frequency . ' ' . $this->period . ' 23:59:59', $base_date ) ); |
|
427 | + $frequency = isset($this->frequency) ? $this->frequency : 1; |
|
428 | + $expiration = date( 'Y-m-d H:i:s', strtotime( '+' . $frequency . ' ' . $this->period . ' 23:59:59', $base_date ) ); |
|
429 | 429 | |
430 | - if( date( 'j', $base_date ) == $last_day && 'day' != $this->period ) { |
|
431 | - $expiration = date( 'Y-m-d H:i:s', strtotime( $expiration . ' +2 days' ) ); |
|
432 | - } |
|
430 | + if( date( 'j', $base_date ) == $last_day && 'day' != $this->period ) { |
|
431 | + $expiration = date( 'Y-m-d H:i:s', strtotime( $expiration . ' +2 days' ) ); |
|
432 | + } |
|
433 | 433 | |
434 | - $expiration = apply_filters( 'wpinv_subscription_renewal_expiration', $expiration, $this->id, $this ); |
|
434 | + $expiration = apply_filters( 'wpinv_subscription_renewal_expiration', $expiration, $this->id, $this ); |
|
435 | 435 | |
436 | - do_action( 'wpinv_subscription_pre_renew', $this->id, $expiration, $this ); |
|
436 | + do_action( 'wpinv_subscription_pre_renew', $this->id, $expiration, $this ); |
|
437 | 437 | |
438 | - $this->status = 'active'; |
|
439 | - $times_billed = $this->get_times_billed(); |
|
438 | + $this->status = 'active'; |
|
439 | + $times_billed = $this->get_times_billed(); |
|
440 | 440 | |
441 | - // Complete subscription if applicable |
|
442 | - if ( $this->bill_times > 0 && $times_billed >= $this->bill_times ) { |
|
443 | - $this->complete(); |
|
444 | - $this->status = 'completed'; |
|
445 | - } |
|
441 | + // Complete subscription if applicable |
|
442 | + if ( $this->bill_times > 0 && $times_billed >= $this->bill_times ) { |
|
443 | + $this->complete(); |
|
444 | + $this->status = 'completed'; |
|
445 | + } |
|
446 | 446 | |
447 | - $args = array( |
|
448 | - 'expiration' => $expiration, |
|
449 | - 'status' => $this->status, |
|
450 | - ); |
|
447 | + $args = array( |
|
448 | + 'expiration' => $expiration, |
|
449 | + 'status' => $this->status, |
|
450 | + ); |
|
451 | 451 | |
452 | 452 | $this->subs_db->update( $this->id, $args ); |
453 | 453 | |
454 | - do_action( 'wpinv_subscription_post_renew', $this->id, $expiration, $this ); |
|
455 | - do_action( 'wpinv_recurring_set_subscription_status', $this->id, $this->status, $this ); |
|
454 | + do_action( 'wpinv_subscription_post_renew', $this->id, $expiration, $this ); |
|
455 | + do_action( 'wpinv_recurring_set_subscription_status', $this->id, $this->status, $this ); |
|
456 | 456 | |
457 | - } |
|
457 | + } |
|
458 | 458 | |
459 | - /** |
|
460 | - * Marks a subscription as completed |
|
461 | - * |
|
462 | - * Subscription is completed when the number of payments matches the billing_times field |
|
463 | - * |
|
464 | - * @since 1.0.0 |
|
465 | - * @return void |
|
466 | - */ |
|
467 | - public function complete() { |
|
459 | + /** |
|
460 | + * Marks a subscription as completed |
|
461 | + * |
|
462 | + * Subscription is completed when the number of payments matches the billing_times field |
|
463 | + * |
|
464 | + * @since 1.0.0 |
|
465 | + * @return void |
|
466 | + */ |
|
467 | + public function complete() { |
|
468 | 468 | |
469 | - // Only mark a subscription as complete if it's not already cancelled. |
|
470 | - if ( 'cancelled' === $this->status ) { |
|
471 | - return; |
|
472 | - } |
|
469 | + // Only mark a subscription as complete if it's not already cancelled. |
|
470 | + if ( 'cancelled' === $this->status ) { |
|
471 | + return; |
|
472 | + } |
|
473 | 473 | |
474 | - $args = array( |
|
475 | - 'status' => 'completed' |
|
476 | - ); |
|
474 | + $args = array( |
|
475 | + 'status' => 'completed' |
|
476 | + ); |
|
477 | 477 | |
478 | - if( $this->subs_db->update( $this->id, $args ) ) { |
|
478 | + if( $this->subs_db->update( $this->id, $args ) ) { |
|
479 | 479 | |
480 | - $this->status = 'completed'; |
|
480 | + $this->status = 'completed'; |
|
481 | 481 | |
482 | - do_action( 'wpinv_subscription_completed', $this->id, $this ); |
|
482 | + do_action( 'wpinv_subscription_completed', $this->id, $this ); |
|
483 | 483 | |
484 | - } |
|
484 | + } |
|
485 | 485 | |
486 | - } |
|
486 | + } |
|
487 | 487 | |
488 | - /** |
|
489 | - * Marks a subscription as expired |
|
490 | - * |
|
491 | - * Subscription is completed when the billing times is reached |
|
492 | - * |
|
493 | - * @since 1.0.0 |
|
494 | - * @param $check_expiration bool True if expiration date should be checked with merchant processor before expiring |
|
495 | - * @return void |
|
496 | - */ |
|
497 | - public function expire( $check_expiration = false ) { |
|
488 | + /** |
|
489 | + * Marks a subscription as expired |
|
490 | + * |
|
491 | + * Subscription is completed when the billing times is reached |
|
492 | + * |
|
493 | + * @since 1.0.0 |
|
494 | + * @param $check_expiration bool True if expiration date should be checked with merchant processor before expiring |
|
495 | + * @return void |
|
496 | + */ |
|
497 | + public function expire( $check_expiration = false ) { |
|
498 | 498 | |
499 | - $expiration = $this->expiration; |
|
499 | + $expiration = $this->expiration; |
|
500 | 500 | |
501 | - if( $check_expiration ) { |
|
501 | + if( $check_expiration ) { |
|
502 | 502 | |
503 | - // check_expiration() updates $this->expiration so compare to $expiration above |
|
503 | + // check_expiration() updates $this->expiration so compare to $expiration above |
|
504 | 504 | |
505 | - if( $expiration < $this->get_expiration() && current_time( 'timestamp' ) < $this->get_expiration_time() ) { |
|
505 | + if( $expiration < $this->get_expiration() && current_time( 'timestamp' ) < $this->get_expiration_time() ) { |
|
506 | 506 | |
507 | - return false; // Do not mark as expired since real expiration date is in the future |
|
508 | - } |
|
507 | + return false; // Do not mark as expired since real expiration date is in the future |
|
508 | + } |
|
509 | 509 | |
510 | - } |
|
510 | + } |
|
511 | 511 | |
512 | - $args = array( |
|
513 | - 'status' => 'expired' |
|
514 | - ); |
|
512 | + $args = array( |
|
513 | + 'status' => 'expired' |
|
514 | + ); |
|
515 | 515 | |
516 | - if( $this->subs_db->update( $this->id, $args ) ) { |
|
516 | + if( $this->subs_db->update( $this->id, $args ) ) { |
|
517 | 517 | |
518 | - $this->status = 'expired'; |
|
518 | + $this->status = 'expired'; |
|
519 | 519 | |
520 | - do_action( 'wpinv_subscription_expired', $this->id, $this ); |
|
520 | + do_action( 'wpinv_subscription_expired', $this->id, $this ); |
|
521 | 521 | |
522 | - } |
|
522 | + } |
|
523 | 523 | |
524 | - } |
|
524 | + } |
|
525 | 525 | |
526 | - /** |
|
527 | - * Marks a subscription as failing |
|
528 | - * |
|
529 | - * @since 2.4.2 |
|
530 | - * @return void |
|
531 | - */ |
|
532 | - public function failing() { |
|
526 | + /** |
|
527 | + * Marks a subscription as failing |
|
528 | + * |
|
529 | + * @since 2.4.2 |
|
530 | + * @return void |
|
531 | + */ |
|
532 | + public function failing() { |
|
533 | 533 | |
534 | - $args = array( |
|
535 | - 'status' => 'failing' |
|
536 | - ); |
|
534 | + $args = array( |
|
535 | + 'status' => 'failing' |
|
536 | + ); |
|
537 | 537 | |
538 | - if( $this->subs_db->update( $this->id, $args ) ) { |
|
538 | + if( $this->subs_db->update( $this->id, $args ) ) { |
|
539 | 539 | |
540 | - $this->status = 'failing'; |
|
540 | + $this->status = 'failing'; |
|
541 | 541 | |
542 | - do_action( 'wpinv_subscription_failing', $this->id, $this ); |
|
542 | + do_action( 'wpinv_subscription_failing', $this->id, $this ); |
|
543 | 543 | |
544 | 544 | |
545 | - } |
|
545 | + } |
|
546 | 546 | |
547 | - } |
|
547 | + } |
|
548 | 548 | |
549 | 549 | /** |
550 | 550 | * Marks a subscription as cancelled |
@@ -578,22 +578,22 @@ discard block |
||
578 | 578 | } |
579 | 579 | } |
580 | 580 | |
581 | - /** |
|
582 | - * Determines if subscription can be cancelled |
|
583 | - * |
|
584 | - * This method is filtered by payment gateways in order to return true on subscriptions |
|
585 | - * that can be cancelled with a profile ID through the merchant processor |
|
586 | - * |
|
587 | - * @since 1.0.0 |
|
588 | - * @return bool |
|
589 | - */ |
|
590 | - public function can_cancel() { |
|
581 | + /** |
|
582 | + * Determines if subscription can be cancelled |
|
583 | + * |
|
584 | + * This method is filtered by payment gateways in order to return true on subscriptions |
|
585 | + * that can be cancelled with a profile ID through the merchant processor |
|
586 | + * |
|
587 | + * @since 1.0.0 |
|
588 | + * @return bool |
|
589 | + */ |
|
590 | + public function can_cancel() { |
|
591 | 591 | $ret = false; |
592 | - if( $this->gateway === 'manual' || in_array( $this->status, $this->get_cancellable_statuses() ) ) { |
|
592 | + if( $this->gateway === 'manual' || in_array( $this->status, $this->get_cancellable_statuses() ) ) { |
|
593 | 593 | $ret = true; |
594 | 594 | } |
595 | - return apply_filters( 'wpinv_subscription_can_cancel', $ret, $this ); |
|
596 | - } |
|
595 | + return apply_filters( 'wpinv_subscription_can_cancel', $ret, $this ); |
|
596 | + } |
|
597 | 597 | |
598 | 598 | /** |
599 | 599 | * Returns an array of subscription statuses that can be cancelled |
@@ -606,197 +606,197 @@ discard block |
||
606 | 606 | return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) ); |
607 | 607 | } |
608 | 608 | |
609 | - /** |
|
610 | - * Retrieves the URL to cancel subscription |
|
611 | - * |
|
612 | - * @since 1.0.0 |
|
613 | - * @return string |
|
614 | - */ |
|
615 | - public function get_cancel_url() { |
|
609 | + /** |
|
610 | + * Retrieves the URL to cancel subscription |
|
611 | + * |
|
612 | + * @since 1.0.0 |
|
613 | + * @return string |
|
614 | + */ |
|
615 | + public function get_cancel_url() { |
|
616 | 616 | |
617 | - $url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'cancel_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-cancel' ); |
|
617 | + $url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'cancel_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-cancel' ); |
|
618 | 618 | |
619 | - return apply_filters( 'wpinv_subscription_cancel_url', $url, $this ); |
|
620 | - } |
|
619 | + return apply_filters( 'wpinv_subscription_cancel_url', $url, $this ); |
|
620 | + } |
|
621 | 621 | |
622 | - /** |
|
623 | - * Determines if subscription can be manually renewed |
|
624 | - * |
|
625 | - * This method is filtered by payment gateways in order to return true on subscriptions |
|
626 | - * that can be renewed manually |
|
627 | - * |
|
628 | - * @since 2.5 |
|
629 | - * @return bool |
|
630 | - */ |
|
631 | - public function can_renew() { |
|
622 | + /** |
|
623 | + * Determines if subscription can be manually renewed |
|
624 | + * |
|
625 | + * This method is filtered by payment gateways in order to return true on subscriptions |
|
626 | + * that can be renewed manually |
|
627 | + * |
|
628 | + * @since 2.5 |
|
629 | + * @return bool |
|
630 | + */ |
|
631 | + public function can_renew() { |
|
632 | 632 | |
633 | - return apply_filters( 'wpinv_subscription_can_renew', true, $this ); |
|
634 | - } |
|
635 | - |
|
636 | - /** |
|
637 | - * Retrieves the URL to renew a subscription |
|
638 | - * |
|
639 | - * @since 2.5 |
|
640 | - * @return string |
|
641 | - */ |
|
642 | - public function get_renew_url() { |
|
643 | - |
|
644 | - $url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'renew_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-renew' ); |
|
645 | - |
|
646 | - return apply_filters( 'wpinv_subscription_renew_url', $url, $this ); |
|
647 | - } |
|
648 | - |
|
649 | - /** |
|
650 | - * Determines if subscription can have their payment method updated |
|
651 | - * |
|
652 | - * @since 1.0.0 |
|
653 | - * @return bool |
|
654 | - */ |
|
655 | - public function can_update() { |
|
656 | - return apply_filters( 'wpinv_subscription_can_update', false, $this ); |
|
657 | - } |
|
658 | - |
|
659 | - /** |
|
660 | - * Retrieves the URL to update subscription |
|
661 | - * |
|
662 | - * @since 1.0.0 |
|
663 | - * @return void |
|
664 | - */ |
|
665 | - public function get_update_url() { |
|
666 | - |
|
667 | - $url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->id ) ); |
|
668 | - |
|
669 | - return apply_filters( 'wpinv_subscription_update_url', $url, $this ); |
|
670 | - } |
|
671 | - |
|
672 | - /** |
|
673 | - * Determines if subscription is active |
|
674 | - * |
|
675 | - * @since 1.0.0 |
|
676 | - * @return void |
|
677 | - */ |
|
678 | - public function is_active() { |
|
679 | - |
|
680 | - $ret = false; |
|
681 | - |
|
682 | - if( ! $this->is_expired() && ( $this->status == 'active' || $this->status == 'cancelled' || $this->status == 'trialling' ) ) { |
|
683 | - $ret = true; |
|
684 | - } |
|
685 | - |
|
686 | - return apply_filters( 'wpinv_subscription_is_active', $ret, $this->id, $this ); |
|
687 | - |
|
688 | - } |
|
689 | - |
|
690 | - /** |
|
691 | - * Determines if subscription is expired |
|
692 | - * |
|
693 | - * @since 1.0.0 |
|
694 | - * @return void |
|
695 | - */ |
|
696 | - public function is_expired() { |
|
697 | - |
|
698 | - $ret = false; |
|
699 | - |
|
700 | - if ( $this->status == 'expired' ) { |
|
701 | - |
|
702 | - $ret = true; |
|
703 | - |
|
704 | - } elseif( 'active' === $this->status || 'cancelled' === $this->status || $this->status == 'trialling' ) { |
|
705 | - |
|
706 | - $ret = false; |
|
707 | - $expiration = $this->get_expiration_time(); |
|
708 | - |
|
709 | - if( $expiration && strtotime( 'NOW', current_time( 'timestamp' ) ) > $expiration ) { |
|
710 | - $ret = true; |
|
711 | - |
|
712 | - if ( 'active' === $this->status || $this->status == 'trialling' ) { |
|
713 | - $this->expire(); |
|
714 | - } |
|
715 | - } |
|
716 | - |
|
717 | - } |
|
718 | - |
|
719 | - return apply_filters( 'wpinv_subscription_is_expired', $ret, $this->id, $this ); |
|
720 | - |
|
721 | - } |
|
722 | - |
|
723 | - /** |
|
724 | - * Retrieves the expiration date |
|
725 | - * |
|
726 | - * @since 1.0.0 |
|
727 | - * @return string |
|
728 | - */ |
|
729 | - public function get_expiration() { |
|
730 | - return $this->expiration; |
|
731 | - } |
|
732 | - |
|
733 | - /** |
|
734 | - * Retrieves the expiration date in a timestamp |
|
735 | - * |
|
736 | - * @since 1.0.0 |
|
737 | - * @return int |
|
738 | - */ |
|
739 | - public function get_expiration_time() { |
|
740 | - return strtotime( $this->expiration, current_time( 'timestamp' ) ); |
|
741 | - } |
|
742 | - |
|
743 | - /** |
|
744 | - * Retrieves the subscription status |
|
745 | - * |
|
746 | - * @since 1.0.0 |
|
747 | - * @return int |
|
748 | - */ |
|
749 | - public function get_status() { |
|
750 | - |
|
751 | - // Monitor for page load delays on pages with large subscription lists (IE: Subscriptions table in admin) |
|
752 | - $this->is_expired(); |
|
753 | - return $this->status; |
|
754 | - } |
|
755 | - |
|
756 | - /** |
|
757 | - * Retrieves the subscription status label |
|
758 | - * |
|
759 | - * @since 1.0.0 |
|
760 | - * @return int |
|
761 | - */ |
|
762 | - public function get_status_label() { |
|
763 | - |
|
764 | - switch( $this->get_status() ) { |
|
765 | - case 'active' : |
|
766 | - $status = __( 'Active', 'invoicing' ); |
|
767 | - break; |
|
768 | - |
|
769 | - case 'cancelled' : |
|
770 | - $status = __( 'Cancelled', 'invoicing' ); |
|
771 | - break; |
|
772 | - |
|
773 | - case 'expired' : |
|
774 | - $status = __( 'Expired', 'invoicing' ); |
|
775 | - break; |
|
776 | - |
|
777 | - case 'pending' : |
|
778 | - $status = __( 'Pending', 'invoicing' ); |
|
779 | - break; |
|
780 | - |
|
781 | - case 'failing' : |
|
782 | - $status = __( 'Failing', 'invoicing' ); |
|
783 | - break; |
|
784 | - |
|
785 | - case 'trialling' : |
|
786 | - $status = __( 'Trialling', 'invoicing' ); |
|
787 | - break; |
|
788 | - |
|
789 | - case 'completed' : |
|
790 | - $status = __( 'Completed', 'invoicing' ); |
|
791 | - break; |
|
792 | - |
|
793 | - default: |
|
794 | - $status = ucfirst( $this->get_status() ); |
|
795 | - break; |
|
796 | - } |
|
797 | - |
|
798 | - return $status; |
|
799 | - } |
|
633 | + return apply_filters( 'wpinv_subscription_can_renew', true, $this ); |
|
634 | + } |
|
635 | + |
|
636 | + /** |
|
637 | + * Retrieves the URL to renew a subscription |
|
638 | + * |
|
639 | + * @since 2.5 |
|
640 | + * @return string |
|
641 | + */ |
|
642 | + public function get_renew_url() { |
|
643 | + |
|
644 | + $url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'renew_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-renew' ); |
|
645 | + |
|
646 | + return apply_filters( 'wpinv_subscription_renew_url', $url, $this ); |
|
647 | + } |
|
648 | + |
|
649 | + /** |
|
650 | + * Determines if subscription can have their payment method updated |
|
651 | + * |
|
652 | + * @since 1.0.0 |
|
653 | + * @return bool |
|
654 | + */ |
|
655 | + public function can_update() { |
|
656 | + return apply_filters( 'wpinv_subscription_can_update', false, $this ); |
|
657 | + } |
|
658 | + |
|
659 | + /** |
|
660 | + * Retrieves the URL to update subscription |
|
661 | + * |
|
662 | + * @since 1.0.0 |
|
663 | + * @return void |
|
664 | + */ |
|
665 | + public function get_update_url() { |
|
666 | + |
|
667 | + $url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->id ) ); |
|
668 | + |
|
669 | + return apply_filters( 'wpinv_subscription_update_url', $url, $this ); |
|
670 | + } |
|
671 | + |
|
672 | + /** |
|
673 | + * Determines if subscription is active |
|
674 | + * |
|
675 | + * @since 1.0.0 |
|
676 | + * @return void |
|
677 | + */ |
|
678 | + public function is_active() { |
|
679 | + |
|
680 | + $ret = false; |
|
681 | + |
|
682 | + if( ! $this->is_expired() && ( $this->status == 'active' || $this->status == 'cancelled' || $this->status == 'trialling' ) ) { |
|
683 | + $ret = true; |
|
684 | + } |
|
685 | + |
|
686 | + return apply_filters( 'wpinv_subscription_is_active', $ret, $this->id, $this ); |
|
687 | + |
|
688 | + } |
|
689 | + |
|
690 | + /** |
|
691 | + * Determines if subscription is expired |
|
692 | + * |
|
693 | + * @since 1.0.0 |
|
694 | + * @return void |
|
695 | + */ |
|
696 | + public function is_expired() { |
|
697 | + |
|
698 | + $ret = false; |
|
699 | + |
|
700 | + if ( $this->status == 'expired' ) { |
|
701 | + |
|
702 | + $ret = true; |
|
703 | + |
|
704 | + } elseif( 'active' === $this->status || 'cancelled' === $this->status || $this->status == 'trialling' ) { |
|
705 | + |
|
706 | + $ret = false; |
|
707 | + $expiration = $this->get_expiration_time(); |
|
708 | + |
|
709 | + if( $expiration && strtotime( 'NOW', current_time( 'timestamp' ) ) > $expiration ) { |
|
710 | + $ret = true; |
|
711 | + |
|
712 | + if ( 'active' === $this->status || $this->status == 'trialling' ) { |
|
713 | + $this->expire(); |
|
714 | + } |
|
715 | + } |
|
716 | + |
|
717 | + } |
|
718 | + |
|
719 | + return apply_filters( 'wpinv_subscription_is_expired', $ret, $this->id, $this ); |
|
720 | + |
|
721 | + } |
|
722 | + |
|
723 | + /** |
|
724 | + * Retrieves the expiration date |
|
725 | + * |
|
726 | + * @since 1.0.0 |
|
727 | + * @return string |
|
728 | + */ |
|
729 | + public function get_expiration() { |
|
730 | + return $this->expiration; |
|
731 | + } |
|
732 | + |
|
733 | + /** |
|
734 | + * Retrieves the expiration date in a timestamp |
|
735 | + * |
|
736 | + * @since 1.0.0 |
|
737 | + * @return int |
|
738 | + */ |
|
739 | + public function get_expiration_time() { |
|
740 | + return strtotime( $this->expiration, current_time( 'timestamp' ) ); |
|
741 | + } |
|
742 | + |
|
743 | + /** |
|
744 | + * Retrieves the subscription status |
|
745 | + * |
|
746 | + * @since 1.0.0 |
|
747 | + * @return int |
|
748 | + */ |
|
749 | + public function get_status() { |
|
750 | + |
|
751 | + // Monitor for page load delays on pages with large subscription lists (IE: Subscriptions table in admin) |
|
752 | + $this->is_expired(); |
|
753 | + return $this->status; |
|
754 | + } |
|
755 | + |
|
756 | + /** |
|
757 | + * Retrieves the subscription status label |
|
758 | + * |
|
759 | + * @since 1.0.0 |
|
760 | + * @return int |
|
761 | + */ |
|
762 | + public function get_status_label() { |
|
763 | + |
|
764 | + switch( $this->get_status() ) { |
|
765 | + case 'active' : |
|
766 | + $status = __( 'Active', 'invoicing' ); |
|
767 | + break; |
|
768 | + |
|
769 | + case 'cancelled' : |
|
770 | + $status = __( 'Cancelled', 'invoicing' ); |
|
771 | + break; |
|
772 | + |
|
773 | + case 'expired' : |
|
774 | + $status = __( 'Expired', 'invoicing' ); |
|
775 | + break; |
|
776 | + |
|
777 | + case 'pending' : |
|
778 | + $status = __( 'Pending', 'invoicing' ); |
|
779 | + break; |
|
780 | + |
|
781 | + case 'failing' : |
|
782 | + $status = __( 'Failing', 'invoicing' ); |
|
783 | + break; |
|
784 | + |
|
785 | + case 'trialling' : |
|
786 | + $status = __( 'Trialling', 'invoicing' ); |
|
787 | + break; |
|
788 | + |
|
789 | + case 'completed' : |
|
790 | + $status = __( 'Completed', 'invoicing' ); |
|
791 | + break; |
|
792 | + |
|
793 | + default: |
|
794 | + $status = ucfirst( $this->get_status() ); |
|
795 | + break; |
|
796 | + } |
|
797 | + |
|
798 | + return $status; |
|
799 | + } |
|
800 | 800 | |
801 | 801 | /** |
802 | 802 | * Retrieves the subscription status label |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Exit if accessed directly |
4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
4 | +if (!defined('ABSPATH')) { |
|
5 | 5 | exit; |
6 | 6 | } |
7 | 7 | |
@@ -38,15 +38,15 @@ discard block |
||
38 | 38 | * @since 1.0.0 |
39 | 39 | * @return void |
40 | 40 | */ |
41 | - function __construct( $_id_or_object = 0, $_by_profile_id = false ) { |
|
41 | + function __construct($_id_or_object = 0, $_by_profile_id = false) { |
|
42 | 42 | |
43 | 43 | $this->subs_db = new WPInv_Subscriptions_DB; |
44 | 44 | |
45 | - if( $_by_profile_id ) { |
|
45 | + if ($_by_profile_id) { |
|
46 | 46 | |
47 | - $_sub = $this->subs_db->get_by( 'profile_id', $_id_or_object ); |
|
47 | + $_sub = $this->subs_db->get_by('profile_id', $_id_or_object); |
|
48 | 48 | |
49 | - if( empty( $_sub ) ) { |
|
49 | + if (empty($_sub)) { |
|
50 | 50 | return false; |
51 | 51 | } |
52 | 52 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | } |
56 | 56 | |
57 | - return $this->setup_subscription( $_id_or_object ); |
|
57 | + return $this->setup_subscription($_id_or_object); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -63,34 +63,34 @@ discard block |
||
63 | 63 | * @since 1.0.0 |
64 | 64 | * @return void |
65 | 65 | */ |
66 | - private function setup_subscription( $id_or_object = 0 ) { |
|
66 | + private function setup_subscription($id_or_object = 0) { |
|
67 | 67 | |
68 | - if( empty( $id_or_object ) ) { |
|
68 | + if (empty($id_or_object)) { |
|
69 | 69 | return false; |
70 | 70 | } |
71 | 71 | |
72 | - if( is_numeric( $id_or_object ) ) { |
|
72 | + if (is_numeric($id_or_object)) { |
|
73 | 73 | |
74 | - $sub = $this->subs_db->get( $id_or_object ); |
|
74 | + $sub = $this->subs_db->get($id_or_object); |
|
75 | 75 | |
76 | - } elseif( is_object( $id_or_object ) ) { |
|
76 | + } elseif (is_object($id_or_object)) { |
|
77 | 77 | |
78 | 78 | $sub = $id_or_object; |
79 | 79 | |
80 | 80 | } |
81 | 81 | |
82 | - if( empty( $sub ) ) { |
|
82 | + if (empty($sub)) { |
|
83 | 83 | return false; |
84 | 84 | } |
85 | 85 | |
86 | - foreach( $sub as $key => $value ) { |
|
86 | + foreach ($sub as $key => $value) { |
|
87 | 87 | $this->$key = $value; |
88 | 88 | } |
89 | 89 | |
90 | - $this->customer = get_userdata( $this->customer_id ); |
|
91 | - $this->gateway = wpinv_get_payment_gateway( $this->parent_payment_id ); |
|
90 | + $this->customer = get_userdata($this->customer_id); |
|
91 | + $this->gateway = wpinv_get_payment_gateway($this->parent_payment_id); |
|
92 | 92 | |
93 | - do_action( 'wpinv_recurring_setup_subscription', $this ); |
|
93 | + do_action('wpinv_recurring_setup_subscription', $this); |
|
94 | 94 | |
95 | 95 | return $this; |
96 | 96 | } |
@@ -100,15 +100,15 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @since 1.0.0 |
102 | 102 | */ |
103 | - public function __get( $key ) { |
|
103 | + public function __get($key) { |
|
104 | 104 | |
105 | - if( method_exists( $this, 'get_' . $key ) ) { |
|
105 | + if (method_exists($this, 'get_' . $key)) { |
|
106 | 106 | |
107 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
107 | + return call_user_func(array($this, 'get_' . $key)); |
|
108 | 108 | |
109 | 109 | } else { |
110 | 110 | |
111 | - return new WP_Error( 'wpinv-subscription-invalid-property', sprintf( __( 'Can\'t get property %s', 'invoicing' ), $key ) ); |
|
111 | + return new WP_Error('wpinv-subscription-invalid-property', sprintf(__('Can\'t get property %s', 'invoicing'), $key)); |
|
112 | 112 | |
113 | 113 | } |
114 | 114 | |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | * @param array $data Array of attributes for a subscription |
122 | 122 | * @return mixed false if data isn't passed and class not instantiated for creation |
123 | 123 | */ |
124 | - public function create( $data = array() ) { |
|
124 | + public function create($data = array()) { |
|
125 | 125 | |
126 | - if ( $this->id != 0 ) { |
|
126 | + if ($this->id != 0) { |
|
127 | 127 | return false; |
128 | 128 | } |
129 | 129 | |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | 'profile_id' => '', |
143 | 143 | ); |
144 | 144 | |
145 | - $args = wp_parse_args( $data, $defaults ); |
|
145 | + $args = wp_parse_args($data, $defaults); |
|
146 | 146 | |
147 | - if( $args['expiration'] && strtotime( 'NOW', current_time( 'timestamp' ) ) > strtotime( $args['expiration'], current_time( 'timestamp' ) ) ) { |
|
147 | + if ($args['expiration'] && strtotime('NOW', current_time('timestamp')) > strtotime($args['expiration'], current_time('timestamp'))) { |
|
148 | 148 | |
149 | - if( 'active' == $args['status'] || 'trialling' == $args['status'] ) { |
|
149 | + if ('active' == $args['status'] || 'trialling' == $args['status']) { |
|
150 | 150 | |
151 | 151 | // Force an active subscription to expired if expiration date is in the past |
152 | 152 | $args['status'] = 'expired'; |
@@ -154,13 +154,13 @@ discard block |
||
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
157 | - do_action( 'wpinv_subscription_pre_create', $args ); |
|
157 | + do_action('wpinv_subscription_pre_create', $args); |
|
158 | 158 | |
159 | - $id = $this->subs_db->insert( $args, 'subscription' ); |
|
159 | + $id = $this->subs_db->insert($args, 'subscription'); |
|
160 | 160 | |
161 | - do_action( 'wpinv_subscription_post_create', $id, $args ); |
|
161 | + do_action('wpinv_subscription_post_create', $id, $args); |
|
162 | 162 | |
163 | - return $this->setup_subscription( $id ); |
|
163 | + return $this->setup_subscription($id); |
|
164 | 164 | |
165 | 165 | } |
166 | 166 | |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | * @param array $args Array of fields to update |
172 | 172 | * @return bool |
173 | 173 | */ |
174 | - public function update( $args = array() ) { |
|
174 | + public function update($args = array()) { |
|
175 | 175 | |
176 | - $ret = $this->subs_db->update( $this->id, $args ); |
|
176 | + $ret = $this->subs_db->update($this->id, $args); |
|
177 | 177 | |
178 | - do_action( 'wpinv_recurring_update_subscription', $this->id, $args, $this ); |
|
178 | + do_action('wpinv_recurring_update_subscription', $this->id, $args, $this); |
|
179 | 179 | |
180 | 180 | return $ret; |
181 | 181 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * @return bool |
189 | 189 | */ |
190 | 190 | public function delete() { |
191 | - return $this->subs_db->delete( $this->id ); |
|
191 | + return $this->subs_db->delete($this->id); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | * @return array |
209 | 209 | */ |
210 | 210 | public function get_child_payments() { |
211 | - $payments = get_posts( array( |
|
212 | - 'post_parent' => (int) $this->parent_payment_id, |
|
211 | + $payments = get_posts(array( |
|
212 | + 'post_parent' => (int)$this->parent_payment_id, |
|
213 | 213 | 'posts_per_page' => '999', |
214 | - 'post_status' => array( 'publish', 'wpi-processing', 'wpi-renewal' ), |
|
214 | + 'post_status' => array('publish', 'wpi-processing', 'wpi-renewal'), |
|
215 | 215 | 'orderby' => 'ID', |
216 | 216 | 'order' => 'DESC', |
217 | 217 | 'post_type' => 'wpi_invoice' |
218 | - ) ); |
|
218 | + )); |
|
219 | 219 | |
220 | 220 | return $payments; |
221 | 221 | } |
@@ -228,9 +228,9 @@ discard block |
||
228 | 228 | */ |
229 | 229 | public function get_total_payments() { |
230 | 230 | $child_payments = $this->get_child_payments(); |
231 | - $total_payments = !empty( $child_payments ) ? count( $child_payments ) : 0; |
|
231 | + $total_payments = !empty($child_payments) ? count($child_payments) : 0; |
|
232 | 232 | |
233 | - if ( 'pending' != $this->status ) { |
|
233 | + if ('pending' != $this->status) { |
|
234 | 234 | $total_payments++; |
235 | 235 | } |
236 | 236 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | public function get_times_billed() { |
247 | 247 | $times_billed = (int)$this->get_total_payments(); |
248 | 248 | |
249 | - if ( ! empty( $this->trial_period ) && $times_billed > 0 ) { |
|
249 | + if (!empty($this->trial_period) && $times_billed > 0) { |
|
250 | 250 | $times_billed--; |
251 | 251 | } |
252 | 252 | |
@@ -260,51 +260,51 @@ discard block |
||
260 | 260 | * @param array $args Array of values for the payment, including amount and transaction ID |
261 | 261 | * @return bool |
262 | 262 | */ |
263 | - public function add_payment( $args = array() ) { |
|
264 | - if ( ! $this->parent_payment_id ) { |
|
263 | + public function add_payment($args = array()) { |
|
264 | + if (!$this->parent_payment_id) { |
|
265 | 265 | return false; |
266 | 266 | } |
267 | 267 | |
268 | - $args = wp_parse_args( $args, array( |
|
268 | + $args = wp_parse_args($args, array( |
|
269 | 269 | 'amount' => '', |
270 | 270 | 'transaction_id' => '', |
271 | 271 | 'gateway' => '' |
272 | - ) ); |
|
272 | + )); |
|
273 | 273 | |
274 | - if ( empty( $args['transaction_id'] ) || $this->payment_exists( $args['transaction_id'] ) ) { |
|
274 | + if (empty($args['transaction_id']) || $this->payment_exists($args['transaction_id'])) { |
|
275 | 275 | return false; |
276 | 276 | } |
277 | 277 | |
278 | - $parent_invoice = wpinv_get_invoice( $this->parent_payment_id ); |
|
279 | - if ( empty( $parent_invoice->ID ) ) { |
|
278 | + $parent_invoice = wpinv_get_invoice($this->parent_payment_id); |
|
279 | + if (empty($parent_invoice->ID)) { |
|
280 | 280 | return false; |
281 | 281 | } |
282 | 282 | |
283 | 283 | $invoice = new WPInv_Invoice(); |
284 | - $invoice->set( 'post_type', 'wpi_invoice' ); |
|
285 | - $invoice->set( 'parent_invoice', $this->parent_payment_id ); |
|
286 | - $invoice->set( 'currency', $parent_invoice->get_currency() ); |
|
287 | - $invoice->set( 'transaction_id', $args['transaction_id'] ); |
|
288 | - $invoice->set( 'key', $parent_invoice->generate_key() ); |
|
289 | - $invoice->set( 'ip', $parent_invoice->ip ); |
|
290 | - $invoice->set( 'user_id', $parent_invoice->get_user_id() ); |
|
291 | - $invoice->set( 'first_name', $parent_invoice->get_first_name() ); |
|
292 | - $invoice->set( 'last_name', $parent_invoice->get_last_name() ); |
|
293 | - $invoice->set( 'phone', $parent_invoice->phone ); |
|
294 | - $invoice->set( 'address', $parent_invoice->address ); |
|
295 | - $invoice->set( 'city', $parent_invoice->city ); |
|
296 | - $invoice->set( 'country', $parent_invoice->country ); |
|
297 | - $invoice->set( 'state', $parent_invoice->state ); |
|
298 | - $invoice->set( 'zip', $parent_invoice->zip ); |
|
299 | - $invoice->set( 'company', $parent_invoice->company ); |
|
300 | - $invoice->set( 'vat_number', $parent_invoice->vat_number ); |
|
301 | - $invoice->set( 'vat_rate', $parent_invoice->vat_rate ); |
|
302 | - $invoice->set( 'adddress_confirmed', $parent_invoice->adddress_confirmed ); |
|
303 | - |
|
304 | - if ( empty( $args['gateway'] ) ) { |
|
305 | - $invoice->set( 'gateway', $parent_invoice->get_gateway() ); |
|
284 | + $invoice->set('post_type', 'wpi_invoice'); |
|
285 | + $invoice->set('parent_invoice', $this->parent_payment_id); |
|
286 | + $invoice->set('currency', $parent_invoice->get_currency()); |
|
287 | + $invoice->set('transaction_id', $args['transaction_id']); |
|
288 | + $invoice->set('key', $parent_invoice->generate_key()); |
|
289 | + $invoice->set('ip', $parent_invoice->ip); |
|
290 | + $invoice->set('user_id', $parent_invoice->get_user_id()); |
|
291 | + $invoice->set('first_name', $parent_invoice->get_first_name()); |
|
292 | + $invoice->set('last_name', $parent_invoice->get_last_name()); |
|
293 | + $invoice->set('phone', $parent_invoice->phone); |
|
294 | + $invoice->set('address', $parent_invoice->address); |
|
295 | + $invoice->set('city', $parent_invoice->city); |
|
296 | + $invoice->set('country', $parent_invoice->country); |
|
297 | + $invoice->set('state', $parent_invoice->state); |
|
298 | + $invoice->set('zip', $parent_invoice->zip); |
|
299 | + $invoice->set('company', $parent_invoice->company); |
|
300 | + $invoice->set('vat_number', $parent_invoice->vat_number); |
|
301 | + $invoice->set('vat_rate', $parent_invoice->vat_rate); |
|
302 | + $invoice->set('adddress_confirmed', $parent_invoice->adddress_confirmed); |
|
303 | + |
|
304 | + if (empty($args['gateway'])) { |
|
305 | + $invoice->set('gateway', $parent_invoice->get_gateway()); |
|
306 | 306 | } else { |
307 | - $invoice->set( 'gateway', $args['gateway'] ); |
|
307 | + $invoice->set('gateway', $args['gateway']); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | $recurring_details = $parent_invoice->get_recurring_details(); |
@@ -312,11 +312,11 @@ discard block |
||
312 | 312 | // increase the earnings for each item in the subscription |
313 | 313 | $items = $recurring_details['cart_details']; |
314 | 314 | |
315 | - if ( $items ) { |
|
315 | + if ($items) { |
|
316 | 316 | $add_items = array(); |
317 | 317 | $cart_details = array(); |
318 | 318 | |
319 | - foreach ( $items as $item ) { |
|
319 | + foreach ($items as $item) { |
|
320 | 320 | $add_item = array(); |
321 | 321 | $add_item['id'] = $item['id']; |
322 | 322 | $add_item['quantity'] = $item['quantity']; |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | break; |
327 | 327 | } |
328 | 328 | |
329 | - $invoice->set( 'items', $add_items ); |
|
329 | + $invoice->set('items', $add_items); |
|
330 | 330 | $invoice->cart_details = $cart_details; |
331 | 331 | } |
332 | 332 | |
@@ -336,29 +336,29 @@ discard block |
||
336 | 336 | $tax = $recurring_details['tax']; |
337 | 337 | $discount = $recurring_details['discount']; |
338 | 338 | |
339 | - if ( $discount > 0 ) { |
|
340 | - $invoice->set( 'discount_code', $parent_invoice->discount_code ); |
|
339 | + if ($discount > 0) { |
|
340 | + $invoice->set('discount_code', $parent_invoice->discount_code); |
|
341 | 341 | } |
342 | 342 | |
343 | - $invoice->subtotal = wpinv_round_amount( $subtotal ); |
|
344 | - $invoice->tax = wpinv_round_amount( $tax ); |
|
345 | - $invoice->discount = wpinv_round_amount( $discount ); |
|
346 | - $invoice->total = wpinv_round_amount( $total ); |
|
343 | + $invoice->subtotal = wpinv_round_amount($subtotal); |
|
344 | + $invoice->tax = wpinv_round_amount($tax); |
|
345 | + $invoice->discount = wpinv_round_amount($discount); |
|
346 | + $invoice->total = wpinv_round_amount($total); |
|
347 | 347 | |
348 | - $invoice = apply_filters( 'wpinv_subscription_add_payment_save', $invoice, $this, $args ); |
|
348 | + $invoice = apply_filters('wpinv_subscription_add_payment_save', $invoice, $this, $args); |
|
349 | 349 | |
350 | 350 | $invoice->save(); |
351 | - $invoice->update_meta( '_wpinv_subscription_id', $this->id ); |
|
351 | + $invoice->update_meta('_wpinv_subscription_id', $this->id); |
|
352 | 352 | |
353 | - if ( !empty( $invoice->ID ) ) { |
|
354 | - wpinv_update_payment_status( $invoice->ID, 'publish' ); |
|
353 | + if (!empty($invoice->ID)) { |
|
354 | + wpinv_update_payment_status($invoice->ID, 'publish'); |
|
355 | 355 | sleep(1); |
356 | - wpinv_update_payment_status( $invoice->ID, 'wpi-renewal' ); |
|
356 | + wpinv_update_payment_status($invoice->ID, 'wpi-renewal'); |
|
357 | 357 | |
358 | - $invoice = wpinv_get_invoice( $invoice->ID ); |
|
358 | + $invoice = wpinv_get_invoice($invoice->ID); |
|
359 | 359 | |
360 | - do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this ); |
|
361 | - do_action( 'wpinv_recurring_record_payment', $invoice->ID, $this->parent_payment_id, $args['amount'], $args['transaction_id'] ); |
|
360 | + do_action('wpinv_recurring_add_subscription_payment', $invoice, $this); |
|
361 | + do_action('wpinv_recurring_record_payment', $invoice->ID, $this->parent_payment_id, $args['amount'], $args['transaction_id']); |
|
362 | 362 | |
363 | 363 | return $invoice->ID; |
364 | 364 | } |
@@ -374,12 +374,12 @@ discard block |
||
374 | 374 | */ |
375 | 375 | public function get_transaction_id() { |
376 | 376 | |
377 | - if( empty( $this->transaction_id ) ) { |
|
377 | + if (empty($this->transaction_id)) { |
|
378 | 378 | |
379 | - $txn_id = wpinv_get_payment_transaction_id( $this->parent_payment_id ); |
|
379 | + $txn_id = wpinv_get_payment_transaction_id($this->parent_payment_id); |
|
380 | 380 | |
381 | - if( ! empty( $txn_id ) && (int) $this->parent_payment_id !== (int) $txn_id ) { |
|
382 | - $this->set_transaction_id( $txn_id ); |
|
381 | + if (!empty($txn_id) && (int)$this->parent_payment_id !== (int)$txn_id) { |
|
382 | + $this->set_transaction_id($txn_id); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | } |
@@ -394,8 +394,8 @@ discard block |
||
394 | 394 | * @since 1.0.0.4 |
395 | 395 | * @return bool |
396 | 396 | */ |
397 | - public function set_transaction_id( $txn_id = '' ) { |
|
398 | - $this->update( array( 'transaction_id' => $txn_id ) ); |
|
397 | + public function set_transaction_id($txn_id = '') { |
|
398 | + $this->update(array('transaction_id' => $txn_id)); |
|
399 | 399 | $this->transaction_id = $txn_id; |
400 | 400 | } |
401 | 401 | |
@@ -411,35 +411,35 @@ discard block |
||
411 | 411 | |
412 | 412 | |
413 | 413 | // Determine what date to use as the start for the new expiration calculation |
414 | - if( $expires > current_time( 'timestamp' ) && $this->is_active() ) { |
|
414 | + if ($expires > current_time('timestamp') && $this->is_active()) { |
|
415 | 415 | |
416 | - $base_date = $expires; |
|
416 | + $base_date = $expires; |
|
417 | 417 | |
418 | 418 | } else { |
419 | 419 | |
420 | - $base_date = current_time( 'timestamp' ); |
|
420 | + $base_date = current_time('timestamp'); |
|
421 | 421 | |
422 | 422 | } |
423 | 423 | |
424 | - $last_day = wpinv_cal_days_in_month( CAL_GREGORIAN, date( 'n', $base_date ), date( 'Y', $base_date ) ); |
|
424 | + $last_day = wpinv_cal_days_in_month(CAL_GREGORIAN, date('n', $base_date), date('Y', $base_date)); |
|
425 | 425 | |
426 | 426 | |
427 | 427 | $frequency = isset($this->frequency) ? $this->frequency : 1; |
428 | - $expiration = date( 'Y-m-d H:i:s', strtotime( '+' . $frequency . ' ' . $this->period . ' 23:59:59', $base_date ) ); |
|
428 | + $expiration = date('Y-m-d H:i:s', strtotime('+' . $frequency . ' ' . $this->period . ' 23:59:59', $base_date)); |
|
429 | 429 | |
430 | - if( date( 'j', $base_date ) == $last_day && 'day' != $this->period ) { |
|
431 | - $expiration = date( 'Y-m-d H:i:s', strtotime( $expiration . ' +2 days' ) ); |
|
430 | + if (date('j', $base_date) == $last_day && 'day' != $this->period) { |
|
431 | + $expiration = date('Y-m-d H:i:s', strtotime($expiration . ' +2 days')); |
|
432 | 432 | } |
433 | 433 | |
434 | - $expiration = apply_filters( 'wpinv_subscription_renewal_expiration', $expiration, $this->id, $this ); |
|
434 | + $expiration = apply_filters('wpinv_subscription_renewal_expiration', $expiration, $this->id, $this); |
|
435 | 435 | |
436 | - do_action( 'wpinv_subscription_pre_renew', $this->id, $expiration, $this ); |
|
436 | + do_action('wpinv_subscription_pre_renew', $this->id, $expiration, $this); |
|
437 | 437 | |
438 | 438 | $this->status = 'active'; |
439 | 439 | $times_billed = $this->get_times_billed(); |
440 | 440 | |
441 | 441 | // Complete subscription if applicable |
442 | - if ( $this->bill_times > 0 && $times_billed >= $this->bill_times ) { |
|
442 | + if ($this->bill_times > 0 && $times_billed >= $this->bill_times) { |
|
443 | 443 | $this->complete(); |
444 | 444 | $this->status = 'completed'; |
445 | 445 | } |
@@ -449,10 +449,10 @@ discard block |
||
449 | 449 | 'status' => $this->status, |
450 | 450 | ); |
451 | 451 | |
452 | - $this->subs_db->update( $this->id, $args ); |
|
452 | + $this->subs_db->update($this->id, $args); |
|
453 | 453 | |
454 | - do_action( 'wpinv_subscription_post_renew', $this->id, $expiration, $this ); |
|
455 | - do_action( 'wpinv_recurring_set_subscription_status', $this->id, $this->status, $this ); |
|
454 | + do_action('wpinv_subscription_post_renew', $this->id, $expiration, $this); |
|
455 | + do_action('wpinv_recurring_set_subscription_status', $this->id, $this->status, $this); |
|
456 | 456 | |
457 | 457 | } |
458 | 458 | |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | public function complete() { |
468 | 468 | |
469 | 469 | // Only mark a subscription as complete if it's not already cancelled. |
470 | - if ( 'cancelled' === $this->status ) { |
|
470 | + if ('cancelled' === $this->status) { |
|
471 | 471 | return; |
472 | 472 | } |
473 | 473 | |
@@ -475,11 +475,11 @@ discard block |
||
475 | 475 | 'status' => 'completed' |
476 | 476 | ); |
477 | 477 | |
478 | - if( $this->subs_db->update( $this->id, $args ) ) { |
|
478 | + if ($this->subs_db->update($this->id, $args)) { |
|
479 | 479 | |
480 | 480 | $this->status = 'completed'; |
481 | 481 | |
482 | - do_action( 'wpinv_subscription_completed', $this->id, $this ); |
|
482 | + do_action('wpinv_subscription_completed', $this->id, $this); |
|
483 | 483 | |
484 | 484 | } |
485 | 485 | |
@@ -494,15 +494,15 @@ discard block |
||
494 | 494 | * @param $check_expiration bool True if expiration date should be checked with merchant processor before expiring |
495 | 495 | * @return void |
496 | 496 | */ |
497 | - public function expire( $check_expiration = false ) { |
|
497 | + public function expire($check_expiration = false) { |
|
498 | 498 | |
499 | 499 | $expiration = $this->expiration; |
500 | 500 | |
501 | - if( $check_expiration ) { |
|
501 | + if ($check_expiration) { |
|
502 | 502 | |
503 | 503 | // check_expiration() updates $this->expiration so compare to $expiration above |
504 | 504 | |
505 | - if( $expiration < $this->get_expiration() && current_time( 'timestamp' ) < $this->get_expiration_time() ) { |
|
505 | + if ($expiration < $this->get_expiration() && current_time('timestamp') < $this->get_expiration_time()) { |
|
506 | 506 | |
507 | 507 | return false; // Do not mark as expired since real expiration date is in the future |
508 | 508 | } |
@@ -513,11 +513,11 @@ discard block |
||
513 | 513 | 'status' => 'expired' |
514 | 514 | ); |
515 | 515 | |
516 | - if( $this->subs_db->update( $this->id, $args ) ) { |
|
516 | + if ($this->subs_db->update($this->id, $args)) { |
|
517 | 517 | |
518 | 518 | $this->status = 'expired'; |
519 | 519 | |
520 | - do_action( 'wpinv_subscription_expired', $this->id, $this ); |
|
520 | + do_action('wpinv_subscription_expired', $this->id, $this); |
|
521 | 521 | |
522 | 522 | } |
523 | 523 | |
@@ -535,11 +535,11 @@ discard block |
||
535 | 535 | 'status' => 'failing' |
536 | 536 | ); |
537 | 537 | |
538 | - if( $this->subs_db->update( $this->id, $args ) ) { |
|
538 | + if ($this->subs_db->update($this->id, $args)) { |
|
539 | 539 | |
540 | 540 | $this->status = 'failing'; |
541 | 541 | |
542 | - do_action( 'wpinv_subscription_failing', $this->id, $this ); |
|
542 | + do_action('wpinv_subscription_failing', $this->id, $this); |
|
543 | 543 | |
544 | 544 | |
545 | 545 | } |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | * @return void |
554 | 554 | */ |
555 | 555 | public function cancel() { |
556 | - if ( 'cancelled' === $this->status ) { |
|
556 | + if ('cancelled' === $this->status) { |
|
557 | 557 | return; // Already cancelled |
558 | 558 | } |
559 | 559 | |
@@ -561,20 +561,20 @@ discard block |
||
561 | 561 | 'status' => 'cancelled' |
562 | 562 | ); |
563 | 563 | |
564 | - if ( $this->subs_db->update( $this->id, $args ) ) { |
|
565 | - if ( is_user_logged_in() ) { |
|
566 | - $userdata = get_userdata( get_current_user_id() ); |
|
564 | + if ($this->subs_db->update($this->id, $args)) { |
|
565 | + if (is_user_logged_in()) { |
|
566 | + $userdata = get_userdata(get_current_user_id()); |
|
567 | 567 | $user = $userdata->display_name; |
568 | 568 | } else { |
569 | - $user = __( 'gateway', 'invoicing' ); |
|
569 | + $user = __('gateway', 'invoicing'); |
|
570 | 570 | } |
571 | 571 | |
572 | - $note = sprintf( __( 'Subscription has been cancelled by %s', 'invoicing' ), $this->parent_payment_id, $user ); |
|
573 | - wpinv_insert_payment_note( $this->parent_payment_id, $note, '', '', true ); |
|
572 | + $note = sprintf(__('Subscription has been cancelled by %s', 'invoicing'), $this->parent_payment_id, $user); |
|
573 | + wpinv_insert_payment_note($this->parent_payment_id, $note, '', '', true); |
|
574 | 574 | |
575 | 575 | $this->status = 'cancelled'; |
576 | 576 | |
577 | - do_action( 'wpinv_subscription_cancelled', $this->id, $this ); |
|
577 | + do_action('wpinv_subscription_cancelled', $this->id, $this); |
|
578 | 578 | } |
579 | 579 | } |
580 | 580 | |
@@ -589,10 +589,10 @@ discard block |
||
589 | 589 | */ |
590 | 590 | public function can_cancel() { |
591 | 591 | $ret = false; |
592 | - if( $this->gateway === 'manual' || in_array( $this->status, $this->get_cancellable_statuses() ) ) { |
|
592 | + if ($this->gateway === 'manual' || in_array($this->status, $this->get_cancellable_statuses())) { |
|
593 | 593 | $ret = true; |
594 | 594 | } |
595 | - return apply_filters( 'wpinv_subscription_can_cancel', $ret, $this ); |
|
595 | + return apply_filters('wpinv_subscription_can_cancel', $ret, $this); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | /** |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | * @return array |
604 | 604 | */ |
605 | 605 | public function get_cancellable_statuses() { |
606 | - return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) ); |
|
606 | + return apply_filters('wpinv_recurring_cancellable_statuses', array('active', 'trialling', 'failing')); |
|
607 | 607 | } |
608 | 608 | |
609 | 609 | /** |
@@ -614,9 +614,9 @@ discard block |
||
614 | 614 | */ |
615 | 615 | public function get_cancel_url() { |
616 | 616 | |
617 | - $url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'cancel_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-cancel' ); |
|
617 | + $url = wp_nonce_url(add_query_arg(array('wpinv_action' => 'cancel_subscription', 'sub_id' => $this->id)), 'wpinv-recurring-cancel'); |
|
618 | 618 | |
619 | - return apply_filters( 'wpinv_subscription_cancel_url', $url, $this ); |
|
619 | + return apply_filters('wpinv_subscription_cancel_url', $url, $this); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | /** |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | */ |
631 | 631 | public function can_renew() { |
632 | 632 | |
633 | - return apply_filters( 'wpinv_subscription_can_renew', true, $this ); |
|
633 | + return apply_filters('wpinv_subscription_can_renew', true, $this); |
|
634 | 634 | } |
635 | 635 | |
636 | 636 | /** |
@@ -641,9 +641,9 @@ discard block |
||
641 | 641 | */ |
642 | 642 | public function get_renew_url() { |
643 | 643 | |
644 | - $url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'renew_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-renew' ); |
|
644 | + $url = wp_nonce_url(add_query_arg(array('wpinv_action' => 'renew_subscription', 'sub_id' => $this->id)), 'wpinv-recurring-renew'); |
|
645 | 645 | |
646 | - return apply_filters( 'wpinv_subscription_renew_url', $url, $this ); |
|
646 | + return apply_filters('wpinv_subscription_renew_url', $url, $this); |
|
647 | 647 | } |
648 | 648 | |
649 | 649 | /** |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | * @return bool |
654 | 654 | */ |
655 | 655 | public function can_update() { |
656 | - return apply_filters( 'wpinv_subscription_can_update', false, $this ); |
|
656 | + return apply_filters('wpinv_subscription_can_update', false, $this); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | /** |
@@ -664,9 +664,9 @@ discard block |
||
664 | 664 | */ |
665 | 665 | public function get_update_url() { |
666 | 666 | |
667 | - $url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->id ) ); |
|
667 | + $url = add_query_arg(array('action' => 'update', 'subscription_id' => $this->id)); |
|
668 | 668 | |
669 | - return apply_filters( 'wpinv_subscription_update_url', $url, $this ); |
|
669 | + return apply_filters('wpinv_subscription_update_url', $url, $this); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | /** |
@@ -679,11 +679,11 @@ discard block |
||
679 | 679 | |
680 | 680 | $ret = false; |
681 | 681 | |
682 | - if( ! $this->is_expired() && ( $this->status == 'active' || $this->status == 'cancelled' || $this->status == 'trialling' ) ) { |
|
682 | + if (!$this->is_expired() && ($this->status == 'active' || $this->status == 'cancelled' || $this->status == 'trialling')) { |
|
683 | 683 | $ret = true; |
684 | 684 | } |
685 | 685 | |
686 | - return apply_filters( 'wpinv_subscription_is_active', $ret, $this->id, $this ); |
|
686 | + return apply_filters('wpinv_subscription_is_active', $ret, $this->id, $this); |
|
687 | 687 | |
688 | 688 | } |
689 | 689 | |
@@ -697,26 +697,26 @@ discard block |
||
697 | 697 | |
698 | 698 | $ret = false; |
699 | 699 | |
700 | - if ( $this->status == 'expired' ) { |
|
700 | + if ($this->status == 'expired') { |
|
701 | 701 | |
702 | 702 | $ret = true; |
703 | 703 | |
704 | - } elseif( 'active' === $this->status || 'cancelled' === $this->status || $this->status == 'trialling' ) { |
|
704 | + } elseif ('active' === $this->status || 'cancelled' === $this->status || $this->status == 'trialling') { |
|
705 | 705 | |
706 | 706 | $ret = false; |
707 | 707 | $expiration = $this->get_expiration_time(); |
708 | 708 | |
709 | - if( $expiration && strtotime( 'NOW', current_time( 'timestamp' ) ) > $expiration ) { |
|
709 | + if ($expiration && strtotime('NOW', current_time('timestamp')) > $expiration) { |
|
710 | 710 | $ret = true; |
711 | 711 | |
712 | - if ( 'active' === $this->status || $this->status == 'trialling' ) { |
|
712 | + if ('active' === $this->status || $this->status == 'trialling') { |
|
713 | 713 | $this->expire(); |
714 | 714 | } |
715 | 715 | } |
716 | 716 | |
717 | 717 | } |
718 | 718 | |
719 | - return apply_filters( 'wpinv_subscription_is_expired', $ret, $this->id, $this ); |
|
719 | + return apply_filters('wpinv_subscription_is_expired', $ret, $this->id, $this); |
|
720 | 720 | |
721 | 721 | } |
722 | 722 | |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | * @return int |
738 | 738 | */ |
739 | 739 | public function get_expiration_time() { |
740 | - return strtotime( $this->expiration, current_time( 'timestamp' ) ); |
|
740 | + return strtotime($this->expiration, current_time('timestamp')); |
|
741 | 741 | } |
742 | 742 | |
743 | 743 | /** |
@@ -761,37 +761,37 @@ discard block |
||
761 | 761 | */ |
762 | 762 | public function get_status_label() { |
763 | 763 | |
764 | - switch( $this->get_status() ) { |
|
764 | + switch ($this->get_status()) { |
|
765 | 765 | case 'active' : |
766 | - $status = __( 'Active', 'invoicing' ); |
|
766 | + $status = __('Active', 'invoicing'); |
|
767 | 767 | break; |
768 | 768 | |
769 | 769 | case 'cancelled' : |
770 | - $status = __( 'Cancelled', 'invoicing' ); |
|
770 | + $status = __('Cancelled', 'invoicing'); |
|
771 | 771 | break; |
772 | 772 | |
773 | 773 | case 'expired' : |
774 | - $status = __( 'Expired', 'invoicing' ); |
|
774 | + $status = __('Expired', 'invoicing'); |
|
775 | 775 | break; |
776 | 776 | |
777 | 777 | case 'pending' : |
778 | - $status = __( 'Pending', 'invoicing' ); |
|
778 | + $status = __('Pending', 'invoicing'); |
|
779 | 779 | break; |
780 | 780 | |
781 | 781 | case 'failing' : |
782 | - $status = __( 'Failing', 'invoicing' ); |
|
782 | + $status = __('Failing', 'invoicing'); |
|
783 | 783 | break; |
784 | 784 | |
785 | 785 | case 'trialling' : |
786 | - $status = __( 'Trialling', 'invoicing' ); |
|
786 | + $status = __('Trialling', 'invoicing'); |
|
787 | 787 | break; |
788 | 788 | |
789 | 789 | case 'completed' : |
790 | - $status = __( 'Completed', 'invoicing' ); |
|
790 | + $status = __('Completed', 'invoicing'); |
|
791 | 791 | break; |
792 | 792 | |
793 | 793 | default: |
794 | - $status = ucfirst( $this->get_status() ); |
|
794 | + $status = ucfirst($this->get_status()); |
|
795 | 795 | break; |
796 | 796 | } |
797 | 797 | |
@@ -806,51 +806,51 @@ discard block |
||
806 | 806 | */ |
807 | 807 | public function get_status_label_html() { |
808 | 808 | |
809 | - switch( $get_status = $this->get_status() ) { |
|
809 | + switch ($get_status = $this->get_status()) { |
|
810 | 810 | case 'active' : |
811 | - $status = __( 'Active', 'invoicing' ); |
|
811 | + $status = __('Active', 'invoicing'); |
|
812 | 812 | $class = 'label-info'; |
813 | 813 | break; |
814 | 814 | |
815 | 815 | case 'cancelled' : |
816 | - $status = __( 'Cancelled', 'invoicing' ); |
|
816 | + $status = __('Cancelled', 'invoicing'); |
|
817 | 817 | $class = 'label-danger'; |
818 | 818 | break; |
819 | 819 | |
820 | 820 | case 'expired' : |
821 | - $status = __( 'Expired', 'invoicing' ); |
|
821 | + $status = __('Expired', 'invoicing'); |
|
822 | 822 | $class = 'label-default'; |
823 | 823 | break; |
824 | 824 | |
825 | 825 | case 'pending' : |
826 | - $status = __( 'Pending', 'invoicing' ); |
|
826 | + $status = __('Pending', 'invoicing'); |
|
827 | 827 | $class = 'label-primary'; |
828 | 828 | break; |
829 | 829 | |
830 | 830 | case 'failing' : |
831 | - $status = __( 'Failing', 'invoicing' ); |
|
831 | + $status = __('Failing', 'invoicing'); |
|
832 | 832 | $class = 'label-danger'; |
833 | 833 | break; |
834 | 834 | |
835 | 835 | case 'trialling' : |
836 | - $status = __( 'Trialling', 'invoicing' ); |
|
836 | + $status = __('Trialling', 'invoicing'); |
|
837 | 837 | $class = 'label-info'; |
838 | 838 | break; |
839 | 839 | |
840 | 840 | case 'completed' : |
841 | - $status = __( 'Completed', 'invoicing' ); |
|
841 | + $status = __('Completed', 'invoicing'); |
|
842 | 842 | $class = 'label-success'; |
843 | 843 | break; |
844 | 844 | |
845 | 845 | default: |
846 | - $status = ucfirst( $this->get_status() ); |
|
846 | + $status = ucfirst($this->get_status()); |
|
847 | 847 | $class = 'label-default'; |
848 | 848 | break; |
849 | 849 | } |
850 | 850 | |
851 | 851 | $label = '<span class="sub-status label label-sub-' . $get_status . ' ' . $class . '">' . $status . '</span>'; |
852 | 852 | |
853 | - return apply_filters( 'wpinv_subscription_status_label_html', $label, $get_status, $status ); |
|
853 | + return apply_filters('wpinv_subscription_status_label_html', $label, $get_status, $status); |
|
854 | 854 | } |
855 | 855 | |
856 | 856 | /** |
@@ -860,18 +860,18 @@ discard block |
||
860 | 860 | * @param string $txn_id The transaction ID from the merchant processor |
861 | 861 | * @return bool |
862 | 862 | */ |
863 | - public function payment_exists( $txn_id = '' ) { |
|
863 | + public function payment_exists($txn_id = '') { |
|
864 | 864 | global $wpdb; |
865 | 865 | |
866 | - if ( empty( $txn_id ) ) { |
|
866 | + if (empty($txn_id)) { |
|
867 | 867 | return false; |
868 | 868 | } |
869 | 869 | |
870 | - $txn_id = esc_sql( $txn_id ); |
|
870 | + $txn_id = esc_sql($txn_id); |
|
871 | 871 | |
872 | - $purchase = $wpdb->get_var( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = '{$txn_id}' LIMIT 1" ); |
|
872 | + $purchase = $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = '{$txn_id}' LIMIT 1"); |
|
873 | 873 | |
874 | - if ( $purchase != null ) { |
|
874 | + if ($purchase != null) { |
|
875 | 875 | return true; |
876 | 876 | } |
877 | 877 |
@@ -29,16 +29,16 @@ |
||
29 | 29 | <table class="table table-bordered table-hover table-responsive wpi-user-subscriptions"> |
30 | 30 | <thead> |
31 | 31 | <tr> |
32 | - <th class="sub-no"><span class="nobr"><?php _e( 'No.', 'invoicing' ); ?></span></th> |
|
33 | - <th class="sub-amount"><span class="nobr"><?php _e( 'Initial Amount', 'invoicing' ); ?></span></th> |
|
34 | - <th class="sub-cycle"><span class="nobr"><?php _e( 'Billing Cycle', 'invoicing' ); ?></span></th> |
|
35 | - <th class="sub-billed"><span class="nobr"><?php _e( 'Times Billed', 'invoicing' ); ?></span></th> |
|
36 | - <th class="sub-status"><span class="nobr"><?php _e( 'Status', 'invoicing' ); ?></span></th> |
|
37 | - <th class="sub-invoice"><span class="nobr"><?php _e( 'Invoice', 'invoicing' ); ?></span></th> |
|
38 | - <th class="sub-item"><span class="nobr"><?php _e( 'Item', 'invoicing' ); ?></span></th> |
|
39 | - <th class="sub-gateway"><span class="nobr"><?php _e( 'Gateway', 'invoicing' ); ?></span></th> |
|
40 | - <th class="sub-expiry"><span class="nobr"><?php _e( 'Expires On', 'invoicing' ); ?></span></th> |
|
41 | - <th class="sub-actions"><span class="nobr"><?php _e( 'Actions', 'invoicing' ); ?></span></th> |
|
32 | + <th class="sub-no"><span class="nobr"><?php _e('No.', 'invoicing'); ?></span></th> |
|
33 | + <th class="sub-amount"><span class="nobr"><?php _e('Initial Amount', 'invoicing'); ?></span></th> |
|
34 | + <th class="sub-cycle"><span class="nobr"><?php _e('Billing Cycle', 'invoicing'); ?></span></th> |
|
35 | + <th class="sub-billed"><span class="nobr"><?php _e('Times Billed', 'invoicing'); ?></span></th> |
|
36 | + <th class="sub-status"><span class="nobr"><?php _e('Status', 'invoicing'); ?></span></th> |
|
37 | + <th class="sub-invoice"><span class="nobr"><?php _e('Invoice', 'invoicing'); ?></span></th> |
|
38 | + <th class="sub-item"><span class="nobr"><?php _e('Item', 'invoicing'); ?></span></th> |
|
39 | + <th class="sub-gateway"><span class="nobr"><?php _e('Gateway', 'invoicing'); ?></span></th> |
|
40 | + <th class="sub-expiry"><span class="nobr"><?php _e('Expires On', 'invoicing'); ?></span></th> |
|
41 | + <th class="sub-actions"><span class="nobr"><?php _e('Actions', 'invoicing'); ?></span></th> |
|
42 | 42 | </tr> |
43 | 43 | </thead> |
44 | 44 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly |
4 | 4 | } |
5 | 5 | |
@@ -14,18 +14,18 @@ discard block |
||
14 | 14 | * Hook in methods. |
15 | 15 | */ |
16 | 16 | public static function init() { |
17 | - add_action( 'init', array( __CLASS__, 'init_hooks' ), 0 ); |
|
18 | - add_action( 'admin_notices', array( __CLASS__, 'notices' ) ); |
|
17 | + add_action('init', array(__CLASS__, 'init_hooks'), 0); |
|
18 | + add_action('admin_notices', array(__CLASS__, 'notices')); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | public static function init_hooks() { |
22 | - if ( false === ( $page_uris = get_transient( 'wpinv_cache_excluded_uris' ) ) ) { |
|
23 | - $checkout_page = wpinv_get_option( 'checkout_page', '' ); |
|
24 | - $success_page = wpinv_get_option( 'success_page', '' ); |
|
25 | - $failure_page = wpinv_get_option( 'failure_page', '' ); |
|
26 | - $history_page = wpinv_get_option( 'invoice_history_page', '' ); |
|
27 | - $subscr_page = wpinv_get_option( 'invoice_subscription_page', '' ); |
|
28 | - if ( empty( $checkout_page ) || empty( $success_page ) || empty( $failure_page ) || empty( $history_page ) || empty( $subscr_page ) ) { |
|
22 | + if (false === ($page_uris = get_transient('wpinv_cache_excluded_uris'))) { |
|
23 | + $checkout_page = wpinv_get_option('checkout_page', ''); |
|
24 | + $success_page = wpinv_get_option('success_page', ''); |
|
25 | + $failure_page = wpinv_get_option('failure_page', ''); |
|
26 | + $history_page = wpinv_get_option('invoice_history_page', ''); |
|
27 | + $subscr_page = wpinv_get_option('invoice_subscription_page', ''); |
|
28 | + if (empty($checkout_page) || empty($success_page) || empty($failure_page) || empty($history_page) || empty($subscr_page)) { |
|
29 | 29 | return; |
30 | 30 | } |
31 | 31 | |
@@ -39,34 +39,34 @@ discard block |
||
39 | 39 | $page_uris[] = 'p=' . $subscr_page; |
40 | 40 | |
41 | 41 | // Exclude permalinks |
42 | - $checkout_page = get_post( $checkout_page ); |
|
43 | - $success_page = get_post( $success_page ); |
|
44 | - $failure_page = get_post( $failure_page ); |
|
45 | - $history_page = get_post( $history_page ); |
|
46 | - $subscr_page = get_post( $subscr_page ); |
|
42 | + $checkout_page = get_post($checkout_page); |
|
43 | + $success_page = get_post($success_page); |
|
44 | + $failure_page = get_post($failure_page); |
|
45 | + $history_page = get_post($history_page); |
|
46 | + $subscr_page = get_post($subscr_page); |
|
47 | 47 | |
48 | - if ( ! is_null( $checkout_page ) ) { |
|
48 | + if (!is_null($checkout_page)) { |
|
49 | 49 | $page_uris[] = '/' . $checkout_page->post_name; |
50 | 50 | } |
51 | - if ( ! is_null( $success_page ) ) { |
|
51 | + if (!is_null($success_page)) { |
|
52 | 52 | $page_uris[] = '/' . $success_page->post_name; |
53 | 53 | } |
54 | - if ( ! is_null( $failure_page ) ) { |
|
54 | + if (!is_null($failure_page)) { |
|
55 | 55 | $page_uris[] = '/' . $failure_page->post_name; |
56 | 56 | } |
57 | - if ( ! is_null( $history_page ) ) { |
|
57 | + if (!is_null($history_page)) { |
|
58 | 58 | $page_uris[] = '/' . $history_page->post_name; |
59 | 59 | } |
60 | - if ( ! is_null( $subscr_page ) ) { |
|
60 | + if (!is_null($subscr_page)) { |
|
61 | 61 | $page_uris[] = '/' . $subscr_page->post_name; |
62 | 62 | } |
63 | 63 | |
64 | - set_transient( 'wpinv_cache_excluded_uris', $page_uris ); |
|
64 | + set_transient('wpinv_cache_excluded_uris', $page_uris); |
|
65 | 65 | } |
66 | 66 | |
67 | - if ( is_array( $page_uris ) ) { |
|
68 | - foreach( $page_uris as $uri ) { |
|
69 | - if ( strstr( $_SERVER['REQUEST_URI'], $uri ) ) { |
|
67 | + if (is_array($page_uris)) { |
|
68 | + foreach ($page_uris as $uri) { |
|
69 | + if (strstr($_SERVER['REQUEST_URI'], $uri)) { |
|
70 | 70 | self::nocache(); |
71 | 71 | break; |
72 | 72 | } |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | * @access private |
80 | 80 | */ |
81 | 81 | private static function nocache() { |
82 | - if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
|
83 | - define( "DONOTCACHEPAGE", true ); |
|
82 | + if (!defined('DONOTCACHEPAGE')) { |
|
83 | + define("DONOTCACHEPAGE", true); |
|
84 | 84 | } |
85 | - if ( ! defined( 'DONOTCACHEOBJECT' ) ) { |
|
86 | - define( "DONOTCACHEOBJECT", true ); |
|
85 | + if (!defined('DONOTCACHEOBJECT')) { |
|
86 | + define("DONOTCACHEOBJECT", true); |
|
87 | 87 | } |
88 | - if ( ! defined( 'DONOTCACHEDB' ) ) { |
|
89 | - define( "DONOTCACHEDB", true ); |
|
88 | + if (!defined('DONOTCACHEDB')) { |
|
89 | + define("DONOTCACHEDB", true); |
|
90 | 90 | } |
91 | 91 | nocache_headers(); |
92 | 92 | } |
@@ -95,18 +95,18 @@ discard block |
||
95 | 95 | * notices function. |
96 | 96 | */ |
97 | 97 | public static function notices() { |
98 | - if ( ! function_exists( 'w3tc_pgcache_flush' ) || ! function_exists( 'w3_instance' ) ) { |
|
98 | + if (!function_exists('w3tc_pgcache_flush') || !function_exists('w3_instance')) { |
|
99 | 99 | return; |
100 | 100 | } |
101 | 101 | |
102 | - $config = w3_instance( 'W3_Config' ); |
|
103 | - $enabled = $config->get_integer( 'dbcache.enabled' ); |
|
104 | - $settings = array_map( 'trim', $config->get_array( 'dbcache.reject.sql' ) ); |
|
102 | + $config = w3_instance('W3_Config'); |
|
103 | + $enabled = $config->get_integer('dbcache.enabled'); |
|
104 | + $settings = array_map('trim', $config->get_array('dbcache.reject.sql')); |
|
105 | 105 | |
106 | - if ( $enabled && ! in_array( '_wp_session_', $settings ) ) { |
|
106 | + if ($enabled && !in_array('_wp_session_', $settings)) { |
|
107 | 107 | ?> |
108 | 108 | <div class="error"> |
109 | - <p><?php printf( __( 'In order for <strong>database caching</strong> to work with Invoicing you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'invoicing' ), '<code>_wp_session_</code>', admin_url( 'admin.php?page=w3tc_dbcache' ) ); ?></p> |
|
109 | + <p><?php printf(__('In order for <strong>database caching</strong> to work with Invoicing you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'invoicing'), '<code>_wp_session_</code>', admin_url('admin.php?page=w3tc_dbcache')); ?></p> |
|
110 | 110 | </div> |
111 | 111 | <?php |
112 | 112 | } |
@@ -1,47 +1,47 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | class WPInv_Meta_Box_Items { |
8 | - public static function output( $post ) { |
|
8 | + public static function output($post) { |
|
9 | 9 | global $wpinv_euvat, $ajax_cart_details; |
10 | 10 | |
11 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
12 | - $invoice = new WPInv_Invoice( $post_id ); |
|
11 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
12 | + $invoice = new WPInv_Invoice($post_id); |
|
13 | 13 | $ajax_cart_details = $invoice->get_cart_details(); |
14 | - $subtotal = $invoice->get_subtotal( true ); |
|
14 | + $subtotal = $invoice->get_subtotal(true); |
|
15 | 15 | $discount_raw = $invoice->get_discount(); |
16 | - $discount = wpinv_price( $discount_raw, $invoice->get_currency() ); |
|
16 | + $discount = wpinv_price($discount_raw, $invoice->get_currency()); |
|
17 | 17 | $discounts = $discount_raw > 0 ? $invoice->get_discounts() : ''; |
18 | - $tax = $invoice->get_tax( true ); |
|
19 | - $total = $invoice->get_total( true ); |
|
18 | + $tax = $invoice->get_tax(true); |
|
19 | + $total = $invoice->get_total(true); |
|
20 | 20 | $item_quantities = wpinv_item_quantities_enabled(); |
21 | 21 | $use_taxes = wpinv_use_taxes(); |
22 | - if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) { |
|
22 | + if (!$use_taxes && (float)$invoice->get_tax() > 0) { |
|
23 | 23 | $use_taxes = true; |
24 | 24 | } |
25 | - $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post ); |
|
25 | + $item_types = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post); |
|
26 | 26 | $is_recurring = $invoice->is_recurring(); |
27 | 27 | $post_type_object = get_post_type_object($invoice->post_type); |
28 | 28 | $type_title = $post_type_object->labels->singular_name; |
29 | 29 | |
30 | 30 | $cols = 5; |
31 | - if ( $item_quantities ) { |
|
31 | + if ($item_quantities) { |
|
32 | 32 | $cols++; |
33 | 33 | } |
34 | - if ( $use_taxes ) { |
|
34 | + if ($use_taxes) { |
|
35 | 35 | $cols++; |
36 | 36 | } |
37 | 37 | $class = ''; |
38 | - if ( $invoice->is_paid() ) { |
|
38 | + if ($invoice->is_paid()) { |
|
39 | 39 | $class .= ' wpinv-paid'; |
40 | 40 | } |
41 | - if ( $invoice->is_refunded() ) { |
|
41 | + if ($invoice->is_refunded()) { |
|
42 | 42 | $class .= ' wpinv-refunded'; |
43 | 43 | } |
44 | - if ( $is_recurring ) { |
|
44 | + if ($is_recurring) { |
|
45 | 45 | $class .= ' wpi-recurring'; |
46 | 46 | } |
47 | 47 | ?> |
@@ -49,21 +49,21 @@ discard block |
||
49 | 49 | <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0"> |
50 | 50 | <thead> |
51 | 51 | <tr> |
52 | - <th class="id"><?php _e( 'ID', 'invoicing' );?></th> |
|
53 | - <th class="title"><?php _e( 'Item', 'invoicing' );?></th> |
|
54 | - <th class="price"><?php _e( 'Price', 'invoicing' );?></th> |
|
55 | - <?php if ( $item_quantities ) { ?> |
|
56 | - <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th> |
|
52 | + <th class="id"><?php _e('ID', 'invoicing'); ?></th> |
|
53 | + <th class="title"><?php _e('Item', 'invoicing'); ?></th> |
|
54 | + <th class="price"><?php _e('Price', 'invoicing'); ?></th> |
|
55 | + <?php if ($item_quantities) { ?> |
|
56 | + <th class="qty"><?php _e('Qty', 'invoicing'); ?></th> |
|
57 | 57 | <?php } ?> |
58 | - <th class="total"><?php _e( 'Total', 'invoicing' );?></th> |
|
59 | - <?php if ( $use_taxes ) { ?> |
|
60 | - <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th> |
|
58 | + <th class="total"><?php _e('Total', 'invoicing'); ?></th> |
|
59 | + <?php if ($use_taxes) { ?> |
|
60 | + <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th> |
|
61 | 61 | <?php } ?> |
62 | 62 | <th class="action"></th> |
63 | 63 | </tr> |
64 | 64 | </thead> |
65 | 65 | <tbody class="wpinv-line-items"> |
66 | - <?php echo wpinv_admin_get_line_items( $invoice ); ?> |
|
66 | + <?php echo wpinv_admin_get_line_items($invoice); ?> |
|
67 | 67 | </tbody> |
68 | 68 | <tfoot class="wpinv-totals"> |
69 | 69 | <tr> |
@@ -75,44 +75,44 @@ discard block |
||
75 | 75 | </td> |
76 | 76 | <td class="title"> |
77 | 77 | <input type="text" class="regular-text" placeholder="Item name" value="" name="_wpinv_quick[name]"> |
78 | - <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?> |
|
78 | + <?php if ($wpinv_euvat->allow_vat_rules()) { ?> |
|
79 | 79 | <div class="wp-clearfix"> |
80 | 80 | <label class="wpi-vat-rule"> |
81 | - <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span> |
|
81 | + <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span> |
|
82 | 82 | <span class="input-text-wrap"> |
83 | - <?php echo wpinv_html_select( array( |
|
83 | + <?php echo wpinv_html_select(array( |
|
84 | 84 | 'options' => $wpinv_euvat->get_rules(), |
85 | 85 | 'name' => '_wpinv_quick[vat_rule]', |
86 | 86 | 'id' => '_wpinv_quick_vat_rule', |
87 | 87 | 'show_option_all' => false, |
88 | 88 | 'show_option_none' => false, |
89 | 89 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-rule', |
90 | - ) ); ?> |
|
90 | + )); ?> |
|
91 | 91 | </span> |
92 | 92 | </label> |
93 | 93 | </div> |
94 | - <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?> |
|
94 | + <?php } if ($wpinv_euvat->allow_vat_classes()) { ?> |
|
95 | 95 | <div class="wp-clearfix"> |
96 | 96 | <label class="wpi-vat-class"> |
97 | - <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span> |
|
97 | + <span class="title"><?php _e('VAT class', 'invoicing'); ?></span> |
|
98 | 98 | <span class="input-text-wrap"> |
99 | - <?php echo wpinv_html_select( array( |
|
99 | + <?php echo wpinv_html_select(array( |
|
100 | 100 | 'options' => $wpinv_euvat->get_all_classes(), |
101 | 101 | 'name' => '_wpinv_quick[vat_class]', |
102 | 102 | 'id' => '_wpinv_quick_vat_class', |
103 | 103 | 'show_option_all' => false, |
104 | 104 | 'show_option_none' => false, |
105 | 105 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-class', |
106 | - ) ); ?> |
|
106 | + )); ?> |
|
107 | 107 | </span> |
108 | 108 | </label> |
109 | 109 | </div> |
110 | 110 | <?php } ?> |
111 | 111 | <div class="wp-clearfix"> |
112 | 112 | <label class="wpi-item-type"> |
113 | - <span class="title"><?php _e( 'Item type', 'invoicing' );?></span> |
|
113 | + <span class="title"><?php _e('Item type', 'invoicing'); ?></span> |
|
114 | 114 | <span class="input-text-wrap"> |
115 | - <?php echo wpinv_html_select( array( |
|
115 | + <?php echo wpinv_html_select(array( |
|
116 | 116 | 'options' => $item_types, |
117 | 117 | 'name' => '_wpinv_quick[type]', |
118 | 118 | 'id' => '_wpinv_quick_type', |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | 'show_option_all' => false, |
121 | 121 | 'show_option_none' => false, |
122 | 122 | 'class' => 'gdmbx2-text-medium wpinv-quick-type', |
123 | - ) ); ?> |
|
123 | + )); ?> |
|
124 | 124 | </span> |
125 | 125 | </label> |
126 | 126 | </div> |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | </div> |
134 | 134 | </td> |
135 | 135 | <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td> |
136 | - <?php if ( $item_quantities ) { ?> |
|
136 | + <?php if ($item_quantities) { ?> |
|
137 | 137 | <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td> |
138 | 138 | <?php } ?> |
139 | 139 | <td class="total"></td> |
140 | - <?php if ( $use_taxes ) { ?> |
|
140 | + <?php if ($use_taxes) { ?> |
|
141 | 141 | <td class="tax"></td> |
142 | 142 | <?php } ?> |
143 | 143 | <td class="action"></td> |
@@ -150,29 +150,29 @@ discard block |
||
150 | 150 | <td colspan="<?php echo $cols; ?>"></td> |
151 | 151 | </tr> |
152 | 152 | <tr class="totals"> |
153 | - <td colspan="<?php echo ( $cols - 4 ); ?>"></td> |
|
153 | + <td colspan="<?php echo ($cols - 4); ?>"></td> |
|
154 | 154 | <td colspan="4"> |
155 | 155 | <table cellspacing="0" cellpadding="0"> |
156 | 156 | <tr class="subtotal"> |
157 | - <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td> |
|
158 | - <td class="total"><?php echo $subtotal;?></td> |
|
157 | + <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td> |
|
158 | + <td class="total"><?php echo $subtotal; ?></td> |
|
159 | 159 | <td class="action"></td> |
160 | 160 | </tr> |
161 | 161 | <tr class="discount"> |
162 | - <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td> |
|
163 | - <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td> |
|
162 | + <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td> |
|
163 | + <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td> |
|
164 | 164 | <td class="action"></td> |
165 | 165 | </tr> |
166 | - <?php if ( $use_taxes ) { ?> |
|
166 | + <?php if ($use_taxes) { ?> |
|
167 | 167 | <tr class="tax"> |
168 | - <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td> |
|
169 | - <td class="total"><?php echo $tax;?></td> |
|
168 | + <td class="name"><?php _e('Tax:', 'invoicing'); ?></td> |
|
169 | + <td class="total"><?php echo $tax; ?></td> |
|
170 | 170 | <td class="action"></td> |
171 | 171 | </tr> |
172 | 172 | <?php } ?> |
173 | 173 | <tr class="total"> |
174 | - <td class="name"><?php echo apply_filters( 'wpinv_invoice_items_total_label', __( 'Invoice Total:', 'invoicing' ), $invoice );?></td> |
|
175 | - <td class="total"><?php echo $total;?></td> |
|
174 | + <td class="name"><?php echo apply_filters('wpinv_invoice_items_total_label', __('Invoice Total:', 'invoicing'), $invoice); ?></td> |
|
175 | + <td class="total"><?php echo $total; ?></td> |
|
176 | 176 | <td class="action"></td> |
177 | 177 | </tr> |
178 | 178 | </table> |
@@ -183,89 +183,89 @@ discard block |
||
183 | 183 | <div class="wpinv-actions"> |
184 | 184 | <?php ob_start(); ?> |
185 | 185 | <?php |
186 | - if ( !$invoice->is_paid() && !$invoice->is_refunded() ) { |
|
187 | - if ( !$invoice->is_recurring() ) { |
|
188 | - echo wpinv_item_dropdown( array( |
|
186 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
187 | + if (!$invoice->is_recurring()) { |
|
188 | + echo wpinv_item_dropdown(array( |
|
189 | 189 | 'name' => 'wpinv_invoice_item', |
190 | 190 | 'id' => 'wpinv_invoice_item', |
191 | 191 | 'show_recurring' => true, |
192 | - ) ); |
|
192 | + )); |
|
193 | 193 | ?> |
194 | - <input type="button" value="<?php echo sprintf(esc_attr__( 'Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e( 'Create new item', 'invoicing' );?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e( 'Recalculate Totals', 'invoicing' );?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals"> |
|
194 | + <input type="button" value="<?php echo sprintf(esc_attr__('Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e('Create new item', 'invoicing'); ?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e('Recalculate Totals', 'invoicing'); ?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals"> |
|
195 | 195 | <?php } ?> |
196 | - <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?> |
|
197 | - <?php $item_actions = ob_get_clean(); echo apply_filters( 'wpinv_invoice_items_actions_content', $item_actions, $invoice, $post ); ?> |
|
196 | + <?php do_action('wpinv_invoice_items_actions', $invoice); ?> |
|
197 | + <?php $item_actions = ob_get_clean(); echo apply_filters('wpinv_invoice_items_actions_content', $item_actions, $invoice, $post); ?> |
|
198 | 198 | </div> |
199 | 199 | </div> |
200 | 200 | <?php |
201 | 201 | } |
202 | 202 | |
203 | - public static function prices( $post ) { |
|
203 | + public static function prices($post) { |
|
204 | 204 | $symbol = wpinv_currency_symbol(); |
205 | 205 | $position = wpinv_currency_position(); |
206 | - $item = new WPInv_Item( $post->ID ); |
|
206 | + $item = new WPInv_Item($post->ID); |
|
207 | 207 | |
208 | 208 | $price = $item->get_price(); |
209 | 209 | $is_recurring = $item->is_recurring(); |
210 | 210 | $period = $item->get_recurring_period(); |
211 | - $interval = absint( $item->get_recurring_interval() ); |
|
212 | - $times = absint( $item->get_recurring_limit() ); |
|
211 | + $interval = absint($item->get_recurring_interval()); |
|
212 | + $times = absint($item->get_recurring_limit()); |
|
213 | 213 | $free_trial = $item->has_free_trial(); |
214 | 214 | $trial_interval = $item->get_trial_interval(); |
215 | 215 | $trial_period = $item->get_trial_period(); |
216 | 216 | |
217 | 217 | $intervals = array(); |
218 | - for ( $i = 1; $i <= 90; $i++ ) { |
|
218 | + for ($i = 1; $i <= 90; $i++) { |
|
219 | 219 | $intervals[$i] = $i; |
220 | 220 | } |
221 | 221 | |
222 | - $interval = $interval > 0 ? $interval : 1; |
|
222 | + $interval = $interval > 0 ? $interval : 1; |
|
223 | 223 | |
224 | 224 | $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n'; |
225 | 225 | ?> |
226 | - <p class="wpinv-row-prices"><?php echo ( $position != 'right' ? $symbol . ' ' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $price;?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled( $item->is_editable(), false ); ?> /><?php echo ( $position == 'right' ? ' ' . $symbol : '' );?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce( 'wpinv_item_meta_box_save' ) ;?>" /> |
|
227 | - <?php do_action( 'wpinv_prices_metabox_price', $item ); ?> |
|
226 | + <p class="wpinv-row-prices"><?php echo ($position != 'right' ? $symbol . ' ' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $price; ?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled($item->is_editable(), false); ?> /><?php echo ($position == 'right' ? ' ' . $symbol : ''); ?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce('wpinv_item_meta_box_save'); ?>" /> |
|
227 | + <?php do_action('wpinv_prices_metabox_price', $item); ?> |
|
228 | 228 | </p> |
229 | 229 | <p class="wpinv-row-is-recurring"> |
230 | 230 | <label for="wpinv_is_recurring"> |
231 | - <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> /> |
|
232 | - <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?> |
|
231 | + <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> /> |
|
232 | + <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?> |
|
233 | 233 | </label> |
234 | - <?php do_action( 'wpinv_prices_metabox_is_recurring_field', $item ); ?> |
|
234 | + <?php do_action('wpinv_prices_metabox_is_recurring_field', $item); ?> |
|
235 | 235 | </p> |
236 | - <p class="wpinv-row-recurring-fields <?php echo $class;?>"> |
|
237 | - <label class="wpinv-period" for="wpinv_recurring_period"><?php _e( 'Recurring', 'invoicing' );?> <select class="wpinv-select " id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e( 'day(s)', 'invoicing' ); ?>" <?php selected( 'D', $period );?>><?php _e( 'Daily', 'invoicing' ); ?></option><option value="W" data-text="<?php esc_attr_e( 'week(s)', 'invoicing' ); ?>" <?php selected( 'W', $period );?>><?php _e( 'Weekly', 'invoicing' ); ?></option><option value="M" data-text="<?php esc_attr_e( 'month(s)', 'invoicing' ); ?>" <?php selected( 'M', $period );?>><?php _e( 'Monthly', 'invoicing' ); ?></option><option value="Y" data-text="<?php esc_attr_e( 'year(s)', 'invoicing' ); ?>" <?php selected( 'Y', $period );?>><?php _e( 'Yearly', 'invoicing' ); ?></option></select></label> |
|
238 | - <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array( |
|
236 | + <p class="wpinv-row-recurring-fields <?php echo $class; ?>"> |
|
237 | + <label class="wpinv-period" for="wpinv_recurring_period"><?php _e('Recurring', 'invoicing'); ?> <select class="wpinv-select " id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e('day(s)', 'invoicing'); ?>" <?php selected('D', $period); ?>><?php _e('Daily', 'invoicing'); ?></option><option value="W" data-text="<?php esc_attr_e('week(s)', 'invoicing'); ?>" <?php selected('W', $period); ?>><?php _e('Weekly', 'invoicing'); ?></option><option value="M" data-text="<?php esc_attr_e('month(s)', 'invoicing'); ?>" <?php selected('M', $period); ?>><?php _e('Monthly', 'invoicing'); ?></option><option value="Y" data-text="<?php esc_attr_e('year(s)', 'invoicing'); ?>" <?php selected('Y', $period); ?>><?php _e('Yearly', 'invoicing'); ?></option></select></label> |
|
238 | + <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array( |
|
239 | 239 | 'options' => $intervals, |
240 | 240 | 'name' => 'wpinv_recurring_interval', |
241 | 241 | 'id' => 'wpinv_recurring_interval', |
242 | 242 | 'selected' => $interval, |
243 | 243 | 'show_option_all' => false, |
244 | 244 | 'show_option_none' => false |
245 | - ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label> |
|
246 | - <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e( 'for', 'invoicing' );?> <input class="small-text" type="number" value="<?php echo $times;?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e( 'time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing' );?></label> |
|
245 | + )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label> |
|
246 | + <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e('for', 'invoicing'); ?> <input class="small-text" type="number" value="<?php echo $times; ?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e('time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing'); ?></label> |
|
247 | 247 | <span class="clear wpi-trial-clr"></span> |
248 | 248 | <label class="wpinv-free-trial" for="wpinv_free_trial"> |
249 | - <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> |
|
250 | - <?php echo __( 'Offer free trial for', 'invoicing' ); ?> |
|
249 | + <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool)$free_trial); ?> /> |
|
250 | + <?php echo __('Offer free trial for', 'invoicing'); ?> |
|
251 | 251 | </label> |
252 | 252 | <label class="wpinv-trial-interval" for="wpinv_trial_interval"> |
253 | - <input class="small-text" type="number" value="<?php echo $trial_interval;?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected( 'D', $trial_period );?>><?php _e( 'day(s)', 'invoicing' ); ?></option><option value="W" <?php selected( 'W', $trial_period );?>><?php _e( 'week(s)', 'invoicing' ); ?></option><option value="M" <?php selected( 'M', $trial_period );?>><?php _e( 'month(s)', 'invoicing' ); ?></option><option value="Y" <?php selected( 'Y', $trial_period );?>><?php _e( 'year(s)', 'invoicing' ); ?></option></select> |
|
253 | + <input class="small-text" type="number" value="<?php echo $trial_interval; ?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected('D', $trial_period); ?>><?php _e('day(s)', 'invoicing'); ?></option><option value="W" <?php selected('W', $trial_period); ?>><?php _e('week(s)', 'invoicing'); ?></option><option value="M" <?php selected('M', $trial_period); ?>><?php _e('month(s)', 'invoicing'); ?></option><option value="Y" <?php selected('Y', $trial_period); ?>><?php _e('year(s)', 'invoicing'); ?></option></select> |
|
254 | 254 | </label> |
255 | - <?php do_action( 'wpinv_prices_metabox_recurring_fields', $item ); ?> |
|
255 | + <?php do_action('wpinv_prices_metabox_recurring_fields', $item); ?> |
|
256 | 256 | </p> |
257 | - <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" /> |
|
258 | - <?php do_action( 'wpinv_item_price_field', $post->ID ); ?> |
|
257 | + <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" /> |
|
258 | + <?php do_action('wpinv_item_price_field', $post->ID); ?> |
|
259 | 259 | <?php |
260 | 260 | } |
261 | 261 | |
262 | - public static function vat_rules( $post ) { |
|
262 | + public static function vat_rules($post) { |
|
263 | 263 | global $wpinv_euvat; |
264 | 264 | |
265 | - $rule_type = $wpinv_euvat->get_item_rule( $post->ID ); |
|
265 | + $rule_type = $wpinv_euvat->get_item_rule($post->ID); |
|
266 | 266 | ?> |
267 | - <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label> |
|
268 | - <?php echo wpinv_html_select( array( |
|
267 | + <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label> |
|
268 | + <?php echo wpinv_html_select(array( |
|
269 | 269 | 'options' => $wpinv_euvat->get_rules(), |
270 | 270 | 'name' => 'wpinv_vat_rules', |
271 | 271 | 'id' => 'wpinv_vat_rules', |
@@ -273,19 +273,19 @@ discard block |
||
273 | 273 | 'show_option_all' => false, |
274 | 274 | 'show_option_none' => false, |
275 | 275 | 'class' => 'gdmbx2-text-medium wpinv-vat-rules', |
276 | - ) ); ?> |
|
276 | + )); ?> |
|
277 | 277 | </p> |
278 | - <p class="wpi-m0"><?php _e( 'When you select physical product rules, only consumers and businesses in your country will be charged VAT. The VAT rate used will be the rate in your country.', 'invoicing' ); ?></p> |
|
279 | - <p class="wpi-m0"><?php _e( 'If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer. Only businesses in your country will be charged VAT.', 'invoicing' ); ?></p> |
|
278 | + <p class="wpi-m0"><?php _e('When you select physical product rules, only consumers and businesses in your country will be charged VAT. The VAT rate used will be the rate in your country.', 'invoicing'); ?></p> |
|
279 | + <p class="wpi-m0"><?php _e('If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer. Only businesses in your country will be charged VAT.', 'invoicing'); ?></p> |
|
280 | 280 | <?php |
281 | 281 | } |
282 | 282 | |
283 | - public static function vat_classes( $post ) { |
|
283 | + public static function vat_classes($post) { |
|
284 | 284 | global $wpinv_euvat; |
285 | 285 | |
286 | - $vat_class = $wpinv_euvat->get_item_class( $post->ID ); |
|
286 | + $vat_class = $wpinv_euvat->get_item_class($post->ID); |
|
287 | 287 | ?> |
288 | - <p><?php echo wpinv_html_select( array( |
|
288 | + <p><?php echo wpinv_html_select(array( |
|
289 | 289 | 'options' => $wpinv_euvat->get_all_classes(), |
290 | 290 | 'name' => 'wpinv_vat_class', |
291 | 291 | 'id' => 'wpinv_vat_class', |
@@ -293,18 +293,18 @@ discard block |
||
293 | 293 | 'show_option_all' => false, |
294 | 294 | 'show_option_none' => false, |
295 | 295 | 'class' => 'gdmbx2-text-medium wpinv-vat-class', |
296 | - ) ); ?> |
|
296 | + )); ?> |
|
297 | 297 | </p> |
298 | - <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p> |
|
298 | + <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p> |
|
299 | 299 | <?php |
300 | 300 | } |
301 | 301 | |
302 | - public static function item_info( $post ) { |
|
303 | - $item_type = wpinv_get_item_type( $post->ID ); |
|
304 | - do_action( 'wpinv_item_info_metabox_before', $post ); |
|
302 | + public static function item_info($post) { |
|
303 | + $item_type = wpinv_get_item_type($post->ID); |
|
304 | + do_action('wpinv_item_info_metabox_before', $post); |
|
305 | 305 | ?> |
306 | - <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label> |
|
307 | - <?php echo wpinv_html_select( array( |
|
306 | + <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label> |
|
307 | + <?php echo wpinv_html_select(array( |
|
308 | 308 | 'options' => wpinv_get_item_types(), |
309 | 309 | 'name' => 'wpinv_item_type', |
310 | 310 | 'id' => 'wpinv_item_type', |
@@ -312,114 +312,114 @@ discard block |
||
312 | 312 | 'show_option_all' => false, |
313 | 313 | 'show_option_none' => false, |
314 | 314 | 'class' => 'gdmbx2-text-medium wpinv-item-type', |
315 | - ) ); ?> |
|
315 | + )); ?> |
|
316 | 316 | </p> |
317 | - <p class="wpi-m0"><?php _e( 'Select item type.', 'invoicing' );?><br><?php _e( '<b>Standard:</b> Standard item type', 'invoicing' );?><br><?php _e( '<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing' );?></p> |
|
317 | + <p class="wpi-m0"><?php _e('Select item type.', 'invoicing'); ?><br><?php _e('<b>Standard:</b> Standard item type', 'invoicing'); ?><br><?php _e('<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing'); ?></p> |
|
318 | 318 | <?php |
319 | - do_action( 'wpinv_item_info_metabox_after', $post ); |
|
319 | + do_action('wpinv_item_info_metabox_after', $post); |
|
320 | 320 | } |
321 | 321 | |
322 | - public static function meta_values( $post ) { |
|
323 | - $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array( |
|
322 | + public static function meta_values($post) { |
|
323 | + $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array( |
|
324 | 324 | 'type', |
325 | 325 | 'custom_id' |
326 | - ) ); |
|
326 | + )); |
|
327 | 327 | |
328 | - if ( empty( $meta_keys ) ) { |
|
328 | + if (empty($meta_keys)) { |
|
329 | 329 | return; |
330 | 330 | } |
331 | 331 | |
332 | - do_action( 'wpinv_meta_values_metabox_before', $post ); |
|
332 | + do_action('wpinv_meta_values_metabox_before', $post); |
|
333 | 333 | |
334 | - foreach ( $meta_keys as $meta_key ) { |
|
334 | + foreach ($meta_keys as $meta_key) { |
|
335 | 335 | ?> |
336 | - <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p> |
|
336 | + <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p> |
|
337 | 337 | <?php |
338 | 338 | } |
339 | 339 | |
340 | - do_action( 'wpinv_meta_values_metabox_after', $post ); |
|
340 | + do_action('wpinv_meta_values_metabox_after', $post); |
|
341 | 341 | } |
342 | 342 | |
343 | - public static function save( $post_id, $data, $post ) { |
|
344 | - $invoice = new WPInv_Invoice( $post_id ); |
|
343 | + public static function save($post_id, $data, $post) { |
|
344 | + $invoice = new WPInv_Invoice($post_id); |
|
345 | 345 | |
346 | 346 | // Billing |
347 | - $first_name = sanitize_text_field( $data['wpinv_first_name'] ); |
|
348 | - $last_name = sanitize_text_field( $data['wpinv_last_name'] ); |
|
349 | - $company = sanitize_text_field( $data['wpinv_company'] ); |
|
350 | - $vat_number = sanitize_text_field( $data['wpinv_vat_number'] ); |
|
351 | - $phone = sanitize_text_field( $data['wpinv_phone'] ); |
|
352 | - $address = sanitize_text_field( $data['wpinv_address'] ); |
|
353 | - $city = sanitize_text_field( $data['wpinv_city'] ); |
|
354 | - $zip = sanitize_text_field( $data['wpinv_zip'] ); |
|
355 | - $country = sanitize_text_field( $data['wpinv_country'] ); |
|
356 | - $state = sanitize_text_field( $data['wpinv_state'] ); |
|
347 | + $first_name = sanitize_text_field($data['wpinv_first_name']); |
|
348 | + $last_name = sanitize_text_field($data['wpinv_last_name']); |
|
349 | + $company = sanitize_text_field($data['wpinv_company']); |
|
350 | + $vat_number = sanitize_text_field($data['wpinv_vat_number']); |
|
351 | + $phone = sanitize_text_field($data['wpinv_phone']); |
|
352 | + $address = sanitize_text_field($data['wpinv_address']); |
|
353 | + $city = sanitize_text_field($data['wpinv_city']); |
|
354 | + $zip = sanitize_text_field($data['wpinv_zip']); |
|
355 | + $country = sanitize_text_field($data['wpinv_country']); |
|
356 | + $state = sanitize_text_field($data['wpinv_state']); |
|
357 | 357 | |
358 | 358 | // Details |
359 | - $status = sanitize_text_field( $data['wpinv_status'] ); |
|
360 | - $old_status = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status; |
|
361 | - $number = sanitize_text_field( $data['wpinv_number'] ); |
|
362 | - $due_date = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : ''; |
|
359 | + $status = sanitize_text_field($data['wpinv_status']); |
|
360 | + $old_status = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status; |
|
361 | + $number = sanitize_text_field($data['wpinv_number']); |
|
362 | + $due_date = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : ''; |
|
363 | 363 | //$discounts = sanitize_text_field( $data['wpinv_discounts'] ); |
364 | 364 | //$discount = sanitize_text_field( $data['wpinv_discount'] ); |
365 | 365 | |
366 | - $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip(); |
|
366 | + $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip(); |
|
367 | 367 | |
368 | - $invoice->set( 'due_date', $due_date ); |
|
369 | - $invoice->set( 'first_name', $first_name ); |
|
370 | - $invoice->set( 'last_name', $last_name ); |
|
371 | - $invoice->set( 'company', $company ); |
|
372 | - $invoice->set( 'vat_number', $vat_number ); |
|
373 | - $invoice->set( 'phone', $phone ); |
|
374 | - $invoice->set( 'address', $address ); |
|
375 | - $invoice->set( 'city', $city ); |
|
376 | - $invoice->set( 'zip', $zip ); |
|
377 | - $invoice->set( 'country', $country ); |
|
378 | - $invoice->set( 'state', $state ); |
|
379 | - $invoice->set( 'status', $status ); |
|
368 | + $invoice->set('due_date', $due_date); |
|
369 | + $invoice->set('first_name', $first_name); |
|
370 | + $invoice->set('last_name', $last_name); |
|
371 | + $invoice->set('company', $company); |
|
372 | + $invoice->set('vat_number', $vat_number); |
|
373 | + $invoice->set('phone', $phone); |
|
374 | + $invoice->set('address', $address); |
|
375 | + $invoice->set('city', $city); |
|
376 | + $invoice->set('zip', $zip); |
|
377 | + $invoice->set('country', $country); |
|
378 | + $invoice->set('state', $state); |
|
379 | + $invoice->set('status', $status); |
|
380 | 380 | //$invoice->set( 'number', $number ); |
381 | 381 | //$invoice->set( 'discounts', $discounts ); |
382 | 382 | //$invoice->set( 'discount', $discount ); |
383 | - $invoice->set( 'ip', $ip ); |
|
383 | + $invoice->set('ip', $ip); |
|
384 | 384 | $invoice->old_status = $_POST['original_post_status']; |
385 | 385 | $invoice->currency = wpinv_get_currency(); |
386 | - if ( !empty( $data['wpinv_gateway'] ) ) { |
|
387 | - $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) ); |
|
386 | + if (!empty($data['wpinv_gateway'])) { |
|
387 | + $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway'])); |
|
388 | 388 | } |
389 | 389 | $saved = $invoice->save(); |
390 | 390 | |
391 | 391 | // Check for payment notes |
392 | - if ( !empty( $data['invoice_note'] ) ) { |
|
393 | - $note = wp_kses( $data['invoice_note'], array() ); |
|
394 | - $note_type = sanitize_text_field( $data['invoice_note_type'] ); |
|
392 | + if (!empty($data['invoice_note'])) { |
|
393 | + $note = wp_kses($data['invoice_note'], array()); |
|
394 | + $note_type = sanitize_text_field($data['invoice_note_type']); |
|
395 | 395 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
396 | 396 | |
397 | - wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note ); |
|
397 | + wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | // Update user address if empty. |
401 | - if ( $saved && !empty( $invoice ) ) { |
|
402 | - if ( $user_id = $invoice->get_user_id() ) { |
|
403 | - $user_address = wpinv_get_user_address( $user_id, false ); |
|
401 | + if ($saved && !empty($invoice)) { |
|
402 | + if ($user_id = $invoice->get_user_id()) { |
|
403 | + $user_address = wpinv_get_user_address($user_id, false); |
|
404 | 404 | |
405 | 405 | if (empty($user_address['first_name'])) { |
406 | - update_user_meta( $user_id, '_wpinv_first_name', $first_name ); |
|
407 | - update_user_meta( $user_id, '_wpinv_last_name', $last_name ); |
|
406 | + update_user_meta($user_id, '_wpinv_first_name', $first_name); |
|
407 | + update_user_meta($user_id, '_wpinv_last_name', $last_name); |
|
408 | 408 | } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) { |
409 | - update_user_meta( $user_id, '_wpinv_last_name', $last_name ); |
|
409 | + update_user_meta($user_id, '_wpinv_last_name', $last_name); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) { |
413 | - update_user_meta( $user_id, '_wpinv_address', $address ); |
|
414 | - update_user_meta( $user_id, '_wpinv_city', $city ); |
|
415 | - update_user_meta( $user_id, '_wpinv_state', $state ); |
|
416 | - update_user_meta( $user_id, '_wpinv_country', $country ); |
|
417 | - update_user_meta( $user_id, '_wpinv_zip', $zip ); |
|
418 | - update_user_meta( $user_id, '_wpinv_phone', $phone ); |
|
413 | + update_user_meta($user_id, '_wpinv_address', $address); |
|
414 | + update_user_meta($user_id, '_wpinv_city', $city); |
|
415 | + update_user_meta($user_id, '_wpinv_state', $state); |
|
416 | + update_user_meta($user_id, '_wpinv_country', $country); |
|
417 | + update_user_meta($user_id, '_wpinv_zip', $zip); |
|
418 | + update_user_meta($user_id, '_wpinv_phone', $phone); |
|
419 | 419 | } |
420 | 420 | } |
421 | 421 | |
422 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
422 | + do_action('wpinv_invoice_metabox_saved', $invoice); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | return $saved; |
@@ -180,8 +180,11 @@ discard block |
||
180 | 180 | <label for="tablecell"> |
181 | 181 | <?php if( 'trialling' == $sub->status ) : ?> |
182 | 182 | <?php _e( 'Trialling Until:', 'invoicing' ); ?> |
183 | - <?php else: ?> |
|
184 | - <?php _e( 'Expiration Date:', 'invoicing' ); ?> |
|
183 | + <?php else { |
|
184 | + : ?> |
|
185 | + <?php _e( 'Expiration Date:', 'invoicing' ); |
|
186 | +} |
|
187 | +?> |
|
185 | 188 | <?php endif; ?> |
186 | 189 | </label> |
187 | 190 | </td> |
@@ -251,7 +254,10 @@ discard block |
||
251 | 254 | </thead> |
252 | 255 | <tbody> |
253 | 256 | <?php if ( ! empty( $payments ) ) : ?> |
254 | - <?php foreach ( $payments as $payment ) : $invoice = wpinv_get_invoice( $payment->ID ); if ( empty( $invoice->ID ) ) continue; ?> |
|
257 | + <?php foreach ( $payments as $payment ) : $invoice = wpinv_get_invoice( $payment->ID ); if ( empty( $invoice->ID ) ) { |
|
258 | + continue; |
|
259 | +} |
|
260 | +?> |
|
255 | 261 | <tr> |
256 | 262 | <td><?php echo $payment->ID; ?></td> |
257 | 263 | <td><?php echo $invoice->get_total( true ); ?></td> |
@@ -268,9 +274,12 @@ discard block |
||
268 | 274 | </td> |
269 | 275 | </tr> |
270 | 276 | <?php endforeach; ?> |
271 | - <?php else: ?> |
|
277 | + <?php else { |
|
278 | + : ?> |
|
272 | 279 | <tr> |
273 | - <td colspan="5"><?php _e( 'No Invoices Found.', 'invoicing' ); ?></td> |
|
280 | + <td colspan="5"><?php _e( 'No Invoices Found.', 'invoicing' ); |
|
281 | +} |
|
282 | +?></td> |
|
274 | 283 | </tr> |
275 | 284 | <?php endif; ?> |
276 | 285 | </tbody> |
@@ -8,23 +8,23 @@ discard block |
||
8 | 8 | */ |
9 | 9 | function wpinv_subscriptions_page() { |
10 | 10 | |
11 | - if ( ! empty( $_GET['id'] ) ) { |
|
11 | + if ( ! empty( $_GET['id'] ) ) { |
|
12 | 12 | |
13 | 13 | wpinv_recurring_subscription_details(); |
14 | 14 | |
15 | - return; |
|
15 | + return; |
|
16 | 16 | |
17 | - } |
|
18 | - ?> |
|
17 | + } |
|
18 | + ?> |
|
19 | 19 | <div class="wrap"> |
20 | 20 | |
21 | 21 | <h1> |
22 | 22 | <?php _e( 'Subscriptions', 'invoicing' ); ?> |
23 | 23 | </h1> |
24 | 24 | <?php |
25 | - $subscribers_table = new WPInv_Subscription_Reports_Table(); |
|
26 | - $subscribers_table->prepare_items(); |
|
27 | - ?> |
|
25 | + $subscribers_table = new WPInv_Subscription_Reports_Table(); |
|
26 | + $subscribers_table->prepare_items(); |
|
27 | + ?> |
|
28 | 28 | |
29 | 29 | <form id="subscribers-filter" method="get"> |
30 | 30 | |
@@ -47,24 +47,24 @@ discard block |
||
47 | 47 | */ |
48 | 48 | function wpinv_recurring_subscription_details() { |
49 | 49 | |
50 | - $render = true; |
|
50 | + $render = true; |
|
51 | 51 | |
52 | - if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
53 | - die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
54 | - } |
|
52 | + if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
53 | + die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
54 | + } |
|
55 | 55 | |
56 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
56 | + if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
57 | 57 | die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
58 | - } |
|
58 | + } |
|
59 | 59 | |
60 | - $sub_id = (int) $_GET['id']; |
|
61 | - $sub = new WPInv_Subscription( $sub_id ); |
|
60 | + $sub_id = (int) $_GET['id']; |
|
61 | + $sub = new WPInv_Subscription( $sub_id ); |
|
62 | 62 | |
63 | - if ( empty( $sub ) ) { |
|
64 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
65 | - } |
|
63 | + if ( empty( $sub ) ) { |
|
64 | + die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
65 | + } |
|
66 | 66 | |
67 | - ?> |
|
67 | + ?> |
|
68 | 68 | <div class="wrap"> |
69 | 69 | <h2><?php _e( 'Subscription Details', 'invoicing' ); ?></h2> |
70 | 70 | |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | </td> |
89 | 89 | <td> |
90 | 90 | <?php |
91 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
92 | - $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
93 | - $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
94 | - printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
95 | - ?> |
|
91 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
92 | + $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
93 | + $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
94 | + printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
95 | + ?> |
|
96 | 96 | </td> |
97 | 97 | </tr> |
98 | 98 | <tr> |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | |
135 | 135 | ?> |
136 | 136 | <a href="<?php echo esc_url( add_query_arg( array( |
137 | - 'post' => $sub->product_id, |
|
138 | - 'action' => 'edit' |
|
139 | - ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
137 | + 'post' => $sub->product_id, |
|
138 | + 'action' => 'edit' |
|
139 | + ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
140 | 140 | </td> |
141 | 141 | </tr> |
142 | 142 | <tr> |
@@ -299,56 +299,56 @@ discard block |
||
299 | 299 | */ |
300 | 300 | function wpinv_recurring_process_subscription_update() { |
301 | 301 | |
302 | - if( empty( $_POST['sub_id'] ) ) { |
|
303 | - return; |
|
304 | - } |
|
302 | + if( empty( $_POST['sub_id'] ) ) { |
|
303 | + return; |
|
304 | + } |
|
305 | 305 | |
306 | - if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
307 | - return; |
|
308 | - } |
|
306 | + if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
307 | + return; |
|
308 | + } |
|
309 | 309 | |
310 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
311 | - return; |
|
312 | - } |
|
310 | + if( ! current_user_can( 'manage_invoicing') ) { |
|
311 | + return; |
|
312 | + } |
|
313 | 313 | |
314 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
315 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
316 | - } |
|
314 | + if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
315 | + wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
316 | + } |
|
317 | 317 | |
318 | - $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
319 | - $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
320 | - $product_id = absint( $_POST['product_id'] ); |
|
321 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
322 | - $subscription->update( array( |
|
323 | - 'status' => sanitize_text_field( $_POST['status'] ), |
|
324 | - 'profile_id' => $profile_id, |
|
325 | - 'product_id' => $product_id, |
|
326 | - 'transaction_id' => $transaction_id, |
|
327 | - ) ); |
|
318 | + $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
319 | + $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
320 | + $product_id = absint( $_POST['product_id'] ); |
|
321 | + $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
322 | + $subscription->update( array( |
|
323 | + 'status' => sanitize_text_field( $_POST['status'] ), |
|
324 | + 'profile_id' => $profile_id, |
|
325 | + 'product_id' => $product_id, |
|
326 | + 'transaction_id' => $transaction_id, |
|
327 | + ) ); |
|
328 | 328 | |
329 | - $status = sanitize_text_field( $_POST['status'] ); |
|
329 | + $status = sanitize_text_field( $_POST['status'] ); |
|
330 | 330 | |
331 | - switch( $status ) { |
|
331 | + switch( $status ) { |
|
332 | 332 | |
333 | - case 'cancelled' : |
|
333 | + case 'cancelled' : |
|
334 | 334 | |
335 | - $subscription->cancel(); |
|
336 | - break; |
|
335 | + $subscription->cancel(); |
|
336 | + break; |
|
337 | 337 | |
338 | - case 'expired' : |
|
338 | + case 'expired' : |
|
339 | 339 | |
340 | - $subscription->expire(); |
|
341 | - break; |
|
340 | + $subscription->expire(); |
|
341 | + break; |
|
342 | 342 | |
343 | - case 'completed' : |
|
343 | + case 'completed' : |
|
344 | 344 | |
345 | - $subscription->complete(); |
|
346 | - break; |
|
345 | + $subscription->complete(); |
|
346 | + break; |
|
347 | 347 | |
348 | - } |
|
348 | + } |
|
349 | 349 | |
350 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
351 | - exit; |
|
350 | + wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
351 | + exit; |
|
352 | 352 | |
353 | 353 | } |
354 | 354 | add_action( 'admin_init', 'wpinv_recurring_process_subscription_update', 1 ); |
@@ -362,30 +362,30 @@ discard block |
||
362 | 362 | */ |
363 | 363 | function wpinv_recurring_process_subscription_deletion() { |
364 | 364 | |
365 | - if( empty( $_POST['sub_id'] ) ) { |
|
366 | - return; |
|
367 | - } |
|
365 | + if( empty( $_POST['sub_id'] ) ) { |
|
366 | + return; |
|
367 | + } |
|
368 | 368 | |
369 | - if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
370 | - return; |
|
371 | - } |
|
369 | + if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
370 | + return; |
|
371 | + } |
|
372 | 372 | |
373 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
374 | - return; |
|
375 | - } |
|
373 | + if( ! current_user_can( 'manage_invoicing') ) { |
|
374 | + return; |
|
375 | + } |
|
376 | 376 | |
377 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
378 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
379 | - } |
|
377 | + if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
378 | + wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
379 | + } |
|
380 | 380 | |
381 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
381 | + $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
382 | 382 | |
383 | - delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
383 | + delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
384 | 384 | |
385 | - $subscription->delete(); |
|
385 | + $subscription->delete(); |
|
386 | 386 | |
387 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
388 | - exit; |
|
387 | + wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
388 | + exit; |
|
389 | 389 | |
390 | 390 | } |
391 | 391 | add_action( 'admin_init', 'wpinv_recurring_process_subscription_deletion', 2 ); |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | function wpinv_subscriptions_page() { |
10 | 10 | |
11 | - if ( ! empty( $_GET['id'] ) ) { |
|
11 | + if (!empty($_GET['id'])) { |
|
12 | 12 | |
13 | 13 | wpinv_recurring_subscription_details(); |
14 | 14 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | <div class="wrap"> |
20 | 20 | |
21 | 21 | <h1> |
22 | - <?php _e( 'Subscriptions', 'invoicing' ); ?> |
|
22 | + <?php _e('Subscriptions', 'invoicing'); ?> |
|
23 | 23 | </h1> |
24 | 24 | <?php |
25 | 25 | $subscribers_table = new WPInv_Subscription_Reports_Table(); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | <input type="hidden" name="post_type" value="download" /> |
32 | 32 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
33 | 33 | <?php $subscribers_table->views(); ?> |
34 | - <?php $subscribers_table->search_box( __( 'Search', 'wpinvoicing' ), 'subscriptions' ); ?> |
|
34 | + <?php $subscribers_table->search_box(__('Search', 'wpinvoicing'), 'subscriptions'); ?> |
|
35 | 35 | <?php $subscribers_table->display(); ?> |
36 | 36 | |
37 | 37 | </form> |
@@ -49,34 +49,34 @@ discard block |
||
49 | 49 | |
50 | 50 | $render = true; |
51 | 51 | |
52 | - if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
53 | - die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
52 | + if (!current_user_can('manage_invoicing')) { |
|
53 | + die(__('You are not permitted to view this data.', 'invoicing')); |
|
54 | 54 | } |
55 | 55 | |
56 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
57 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
56 | + if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { |
|
57 | + die(__('Invalid subscription ID Provided.', 'invoicing')); |
|
58 | 58 | } |
59 | 59 | |
60 | - $sub_id = (int) $_GET['id']; |
|
61 | - $sub = new WPInv_Subscription( $sub_id ); |
|
60 | + $sub_id = (int)$_GET['id']; |
|
61 | + $sub = new WPInv_Subscription($sub_id); |
|
62 | 62 | |
63 | - if ( empty( $sub ) ) { |
|
64 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
63 | + if (empty($sub)) { |
|
64 | + die(__('Invalid subscription ID Provided.', 'invoicing')); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | ?> |
68 | 68 | <div class="wrap"> |
69 | - <h2><?php _e( 'Subscription Details', 'invoicing' ); ?></h2> |
|
69 | + <h2><?php _e('Subscription Details', 'invoicing'); ?></h2> |
|
70 | 70 | |
71 | - <?php if ( $sub ) : ?> |
|
71 | + <?php if ($sub) : ?> |
|
72 | 72 | |
73 | 73 | <div id="wpinv-item-card-wrapper"> |
74 | 74 | |
75 | - <?php do_action( 'wpinv_subscription_card_top', $sub ); ?> |
|
75 | + <?php do_action('wpinv_subscription_card_top', $sub); ?> |
|
76 | 76 | |
77 | 77 | <div class="info-wrapper item-section"> |
78 | 78 | |
79 | - <form id="edit-item-info" method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $sub->id ); ?>"> |
|
79 | + <form id="edit-item-info" method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . $sub->id); ?>"> |
|
80 | 80 | |
81 | 81 | <div class="item-info"> |
82 | 82 | |
@@ -84,124 +84,124 @@ discard block |
||
84 | 84 | <tbody> |
85 | 85 | <tr> |
86 | 86 | <td class="row-title"> |
87 | - <label for="tablecell"><?php _e( 'Billing Cycle:', 'invoicing' ); ?></label> |
|
87 | + <label for="tablecell"><?php _e('Billing Cycle:', 'invoicing'); ?></label> |
|
88 | 88 | </td> |
89 | 89 | <td> |
90 | 90 | <?php |
91 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
92 | - $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
93 | - $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
94 | - printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
91 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($sub->period, $sub->frequency); |
|
92 | + $billing = wpinv_price(wpinv_format_amount($sub->recurring_amount), wpinv_get_invoice_currency_code($sub->parent_payment_id)) . ' / ' . $frequency; |
|
93 | + $initial = wpinv_price(wpinv_format_amount($sub->initial_amount), wpinv_get_invoice_currency_code($sub->parent_payment_id)); |
|
94 | + printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing); |
|
95 | 95 | ?> |
96 | 96 | </td> |
97 | 97 | </tr> |
98 | 98 | <tr> |
99 | 99 | <td class="row-title"> |
100 | - <label for="tablecell"><?php _e( 'Times Billed:', 'invoicing' ); ?></label> |
|
100 | + <label for="tablecell"><?php _e('Times Billed:', 'invoicing'); ?></label> |
|
101 | 101 | </td> |
102 | - <td><?php echo $sub->get_times_billed() . ' / ' . ( ( $sub->bill_times == 0 ) ? 'Until Cancelled' : $sub->bill_times ); ?></td> |
|
102 | + <td><?php echo $sub->get_times_billed() . ' / ' . (($sub->bill_times == 0) ? 'Until Cancelled' : $sub->bill_times); ?></td> |
|
103 | 103 | </tr> |
104 | 104 | <tr> |
105 | 105 | <td class="row-title"> |
106 | - <label for="tablecell"><?php _e( 'Customer:', 'invoicing' ); ?></label> |
|
106 | + <label for="tablecell"><?php _e('Customer:', 'invoicing'); ?></label> |
|
107 | 107 | </td> |
108 | 108 | <td> |
109 | - <?php $subscriber = get_userdata( $sub->customer_id ); ?> |
|
110 | - <a href="<?php echo esc_url( get_edit_user_link( $sub->customer_id ) ); ?>" target="_blank"><?php echo ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email; ?></a> |
|
109 | + <?php $subscriber = get_userdata($sub->customer_id); ?> |
|
110 | + <a href="<?php echo esc_url(get_edit_user_link($sub->customer_id)); ?>" target="_blank"><?php echo !empty($subscriber->display_name) ? $subscriber->display_name : $subscriber->user_email; ?></a> |
|
111 | 111 | </td> |
112 | 112 | </tr> |
113 | 113 | <tr> |
114 | 114 | <td class="row-title"> |
115 | - <label for="tablecell"><?php _e( 'Initial Invoice:', 'invoicing' ); ?></label> |
|
115 | + <label for="tablecell"><?php _e('Initial Invoice:', 'invoicing'); ?></label> |
|
116 | 116 | </td> |
117 | 117 | <td> |
118 | - <a target="_blank" title="<?php _e( 'View invoice', 'invoicing' ); ?>" href="<?php echo esc_url( get_permalink( $sub->parent_payment_id ) ); ?>"><?php echo wpinv_get_invoice_number( $sub->parent_payment_id ); ?></a> <?php echo wp_sprintf( __( '( ID: %s )', 'invoicing' ), '<a title="' . esc_attr( __( 'View invoice details', 'invoicing' ) ) . '" href="' . get_edit_post_link( $sub->parent_payment_id ) . '" target="_blank">' . $sub->parent_payment_id . '</a>' ); ?></td> |
|
118 | + <a target="_blank" title="<?php _e('View invoice', 'invoicing'); ?>" href="<?php echo esc_url(get_permalink($sub->parent_payment_id)); ?>"><?php echo wpinv_get_invoice_number($sub->parent_payment_id); ?></a> <?php echo wp_sprintf(__('( ID: %s )', 'invoicing'), '<a title="' . esc_attr(__('View invoice details', 'invoicing')) . '" href="' . get_edit_post_link($sub->parent_payment_id) . '" target="_blank">' . $sub->parent_payment_id . '</a>'); ?></td> |
|
119 | 119 | </tr> |
120 | 120 | <tr> |
121 | 121 | <td class="row-title"> |
122 | - <label for="tablecell"><?php _e( 'Item:', 'invoicing' ); ?></label> |
|
122 | + <label for="tablecell"><?php _e('Item:', 'invoicing'); ?></label> |
|
123 | 123 | </td> |
124 | 124 | <td> |
125 | 125 | <?php |
126 | - echo wpinv_item_dropdown( array( |
|
126 | + echo wpinv_item_dropdown(array( |
|
127 | 127 | 'name' => 'product_id', |
128 | 128 | 'id' => 'wpinv_invoice_item', |
129 | 129 | 'with_packages' => false, |
130 | 130 | 'show_recurring' => true, |
131 | 131 | 'selected' => $sub->product_id, |
132 | 132 | 'class' => 'wpinv-sub-product-id', |
133 | - ) ); |
|
133 | + )); |
|
134 | 134 | |
135 | 135 | ?> |
136 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
136 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
137 | 137 | 'post' => $sub->product_id, |
138 | 138 | 'action' => 'edit' |
139 | - ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
139 | + ), admin_url('post.php'))); ?>" target="_blank"><?php _e('View Item', 'invoicing'); ?></a> |
|
140 | 140 | </td> |
141 | 141 | </tr> |
142 | 142 | <tr> |
143 | 143 | <td class="row-title"> |
144 | - <label for="tablecell"><?php _e( 'Payment Method:', 'invoicing' ); ?></label> |
|
144 | + <label for="tablecell"><?php _e('Payment Method:', 'invoicing'); ?></label> |
|
145 | 145 | </td> |
146 | - <td><?php echo wpinv_get_gateway_admin_label( wpinv_get_payment_gateway( $sub->parent_payment_id ) ); ?></td> |
|
146 | + <td><?php echo wpinv_get_gateway_admin_label(wpinv_get_payment_gateway($sub->parent_payment_id)); ?></td> |
|
147 | 147 | </tr> |
148 | 148 | <tr> |
149 | 149 | <td class="row-title"> |
150 | - <label for="tablecell"><?php _e( 'Profile ID:', 'invoicing' ); ?></label> |
|
150 | + <label for="tablecell"><?php _e('Profile ID:', 'invoicing'); ?></label> |
|
151 | 151 | </td> |
152 | 152 | <td> |
153 | 153 | <span class="wpinv-sub-profile-id"> |
154 | - <?php echo apply_filters( 'wpinv_subscription_profile_link_' . $sub->gateway, $sub->profile_id, $sub ); ?> |
|
154 | + <?php echo apply_filters('wpinv_subscription_profile_link_' . $sub->gateway, $sub->profile_id, $sub); ?> |
|
155 | 155 | </span> |
156 | - <input type="text" name="profile_id" class="hidden wpinv-sub-profile-id" value="<?php echo esc_attr( $sub->profile_id ); ?>" /> |
|
156 | + <input type="text" name="profile_id" class="hidden wpinv-sub-profile-id" value="<?php echo esc_attr($sub->profile_id); ?>" /> |
|
157 | 157 | <span> – </span> |
158 | - <a href="#" class="wpinv-edit-sub-profile-id"><?php _e( 'Edit', 'invoicing' ); ?></a> |
|
158 | + <a href="#" class="wpinv-edit-sub-profile-id"><?php _e('Edit', 'invoicing'); ?></a> |
|
159 | 159 | </td> |
160 | 160 | </tr> |
161 | 161 | <tr> |
162 | 162 | <td class="row-title"> |
163 | - <label for="tablecell"><?php _e( 'Transaction ID:', 'invoicing' ); ?></label> |
|
163 | + <label for="tablecell"><?php _e('Transaction ID:', 'invoicing'); ?></label> |
|
164 | 164 | </td> |
165 | 165 | <td> |
166 | - <span class="wpinv-sub-transaction-id"><?php echo apply_filters( 'wpinv_subscription_transaction_link_' . $sub->gateway, $sub->get_transaction_id(), $sub ); ?></span> |
|
167 | - <input type="text" name="transaction_id" class="hidden wpinv-sub-transaction-id" value="<?php echo esc_attr( $sub->get_transaction_id() ); ?>" /> |
|
166 | + <span class="wpinv-sub-transaction-id"><?php echo apply_filters('wpinv_subscription_transaction_link_' . $sub->gateway, $sub->get_transaction_id(), $sub); ?></span> |
|
167 | + <input type="text" name="transaction_id" class="hidden wpinv-sub-transaction-id" value="<?php echo esc_attr($sub->get_transaction_id()); ?>" /> |
|
168 | 168 | <span> – </span> |
169 | - <a href="#" class="wpinv-edit-sub-transaction-id"><?php _e( 'Edit', 'invoicing' ); ?></a> |
|
169 | + <a href="#" class="wpinv-edit-sub-transaction-id"><?php _e('Edit', 'invoicing'); ?></a> |
|
170 | 170 | </td> |
171 | 171 | </tr> |
172 | 172 | <tr> |
173 | 173 | <td class="row-title"> |
174 | - <label for="tablecell"><?php _e( 'Date Created:', 'invoicing' ); ?></label> |
|
174 | + <label for="tablecell"><?php _e('Date Created:', 'invoicing'); ?></label> |
|
175 | 175 | </td> |
176 | - <td><?php echo date_i18n( get_option( 'date_format' ), strtotime( $sub->created, current_time( 'timestamp' ) ) ); ?></td> |
|
176 | + <td><?php echo date_i18n(get_option('date_format'), strtotime($sub->created, current_time('timestamp'))); ?></td> |
|
177 | 177 | </tr> |
178 | 178 | <tr> |
179 | 179 | <td class="row-title"> |
180 | 180 | <label for="tablecell"> |
181 | - <?php if( 'trialling' == $sub->status ) : ?> |
|
182 | - <?php _e( 'Trialling Until:', 'invoicing' ); ?> |
|
181 | + <?php if ('trialling' == $sub->status) : ?> |
|
182 | + <?php _e('Trialling Until:', 'invoicing'); ?> |
|
183 | 183 | <?php else: ?> |
184 | - <?php _e( 'Expiration Date:', 'invoicing' ); ?> |
|
184 | + <?php _e('Expiration Date:', 'invoicing'); ?> |
|
185 | 185 | <?php endif; ?> |
186 | 186 | </label> |
187 | 187 | </td> |
188 | 188 | <td> |
189 | - <span class="wpinv-sub-expiration"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $sub->expiration, current_time( 'timestamp' ) ) ); ?></span> |
|
189 | + <span class="wpinv-sub-expiration"><?php echo date_i18n(get_option('date_format'), strtotime($sub->expiration, current_time('timestamp'))); ?></span> |
|
190 | 190 | </td> |
191 | 191 | </tr> |
192 | 192 | <tr> |
193 | 193 | <td class="row-title"> |
194 | - <label for="tablecell"><?php _e( 'Subscription Status:', 'invoicing' ); ?></label> |
|
194 | + <label for="tablecell"><?php _e('Subscription Status:', 'invoicing'); ?></label> |
|
195 | 195 | </td> |
196 | 196 | <td> |
197 | 197 | <select name="status"> |
198 | - <option value="pending"<?php selected( 'pending', $sub->status ); ?>><?php _e( 'Pending', 'invoicing' ); ?></option> |
|
199 | - <option value="active"<?php selected( 'active', $sub->status ); ?>><?php _e( 'Active', 'invoicing' ); ?></option> |
|
200 | - <option value="cancelled"<?php selected( 'cancelled', $sub->status ); ?>><?php _e( 'Cancelled', 'invoicing' ); ?></option> |
|
201 | - <option value="expired"<?php selected( 'expired', $sub->status ); ?>><?php _e( 'Expired', 'invoicing' ); ?></option> |
|
202 | - <option value="trialling"<?php selected( 'trialling', $sub->status ); ?>><?php _e( 'Trialling', 'invoicing' ); ?></option> |
|
203 | - <option value="failing"<?php selected( 'failing', $sub->status ); ?>><?php _e( 'Failing', 'invoicing' ); ?></option> |
|
204 | - <option value="completed"<?php selected( 'completed', $sub->status ); ?>><?php _e( 'Completed', 'invoicing' ); ?></option> |
|
198 | + <option value="pending"<?php selected('pending', $sub->status); ?>><?php _e('Pending', 'invoicing'); ?></option> |
|
199 | + <option value="active"<?php selected('active', $sub->status); ?>><?php _e('Active', 'invoicing'); ?></option> |
|
200 | + <option value="cancelled"<?php selected('cancelled', $sub->status); ?>><?php _e('Cancelled', 'invoicing'); ?></option> |
|
201 | + <option value="expired"<?php selected('expired', $sub->status); ?>><?php _e('Expired', 'invoicing'); ?></option> |
|
202 | + <option value="trialling"<?php selected('trialling', $sub->status); ?>><?php _e('Trialling', 'invoicing'); ?></option> |
|
203 | + <option value="failing"<?php selected('failing', $sub->status); ?>><?php _e('Failing', 'invoicing'); ?></option> |
|
204 | + <option value="completed"<?php selected('completed', $sub->status); ?>><?php _e('Completed', 'invoicing'); ?></option> |
|
205 | 205 | </select> |
206 | 206 | </td> |
207 | 207 | </tr> |
@@ -209,79 +209,79 @@ discard block |
||
209 | 209 | </table> |
210 | 210 | </div> |
211 | 211 | <div id="wpinv-sub-notices"> |
212 | - <div class="notice notice-info inline hidden" id="wpinv-sub-product-update-notice"><p><?php _e( 'Changing the product assigned will not automatically adjust any pricing.', 'invoicing' ); ?></p></div> |
|
213 | - <div class="notice notice-warning inline hidden" id="wpinv-sub-profile-id-update-notice"><p><?php _e( 'Changing the profile ID can result in renewals not being processed. Do this with caution.', 'invoicing' ); ?></p></div> |
|
212 | + <div class="notice notice-info inline hidden" id="wpinv-sub-product-update-notice"><p><?php _e('Changing the product assigned will not automatically adjust any pricing.', 'invoicing'); ?></p></div> |
|
213 | + <div class="notice notice-warning inline hidden" id="wpinv-sub-profile-id-update-notice"><p><?php _e('Changing the profile ID can result in renewals not being processed. Do this with caution.', 'invoicing'); ?></p></div> |
|
214 | 214 | </div> |
215 | 215 | <div id="item-edit-actions" class="edit-item" style="float:right; margin: 10px 0 0; display: block;"> |
216 | - <?php wp_nonce_field( 'wpinv-recurring-update', 'wpinv-recurring-update-nonce', false, true ); ?> |
|
217 | - <input type="submit" name="wpinv_update_subscription" id="wpinv_update_subscription" class="button button-primary" value="<?php _e( 'Update Subscription', 'invoicing' ); ?>"/> |
|
218 | - <input type="hidden" name="sub_id" value="<?php echo absint( $sub->id ); ?>" /> |
|
219 | - <?php if( $sub->can_cancel() ) : ?> |
|
220 | - <a class="button button-primary" href="<?php echo $sub->get_cancel_url(); ?>" ><?php _e( 'Cancel Subscription', 'invoicing' ); ?></a> |
|
216 | + <?php wp_nonce_field('wpinv-recurring-update', 'wpinv-recurring-update-nonce', false, true); ?> |
|
217 | + <input type="submit" name="wpinv_update_subscription" id="wpinv_update_subscription" class="button button-primary" value="<?php _e('Update Subscription', 'invoicing'); ?>"/> |
|
218 | + <input type="hidden" name="sub_id" value="<?php echo absint($sub->id); ?>" /> |
|
219 | + <?php if ($sub->can_cancel()) : ?> |
|
220 | + <a class="button button-primary" href="<?php echo $sub->get_cancel_url(); ?>" ><?php _e('Cancel Subscription', 'invoicing'); ?></a> |
|
221 | 221 | <?php endif; ?> |
222 | - <input type="submit" name="wpinv_delete_subscription" class="wpinv-delete-subscription button" value="<?php _e( 'Delete Subscription', 'invoicing' ); ?>"/> |
|
222 | + <input type="submit" name="wpinv_delete_subscription" class="wpinv-delete-subscription button" value="<?php _e('Delete Subscription', 'invoicing'); ?>"/> |
|
223 | 223 | </div> |
224 | 224 | |
225 | 225 | </form> |
226 | 226 | </div> |
227 | 227 | |
228 | - <?php do_action( 'wpinv_subscription_before_stats', $sub ); ?> |
|
228 | + <?php do_action('wpinv_subscription_before_stats', $sub); ?> |
|
229 | 229 | |
230 | - <?php do_action( 'wpinv_subscription_before_tables_wrapper', $sub ); ?> |
|
230 | + <?php do_action('wpinv_subscription_before_tables_wrapper', $sub); ?> |
|
231 | 231 | |
232 | 232 | <div id="item-tables-wrapper" class="item-section"> |
233 | 233 | |
234 | - <?php do_action( 'wpinv_subscription_before_tables', $sub ); ?> |
|
234 | + <?php do_action('wpinv_subscription_before_tables', $sub); ?> |
|
235 | 235 | |
236 | - <h3><?php _e( 'Renewal Payments:', 'invoicing' ); ?></h3> |
|
236 | + <h3><?php _e('Renewal Payments:', 'invoicing'); ?></h3> |
|
237 | 237 | <?php $payments = $sub->get_child_payments(); ?> |
238 | - <?php if ( 'manual' == $sub->gateway ) : ?> |
|
239 | - <p><strong><?php _e( 'Note:', 'invoicing' ); ?></strong> <?php _e( 'Subscriptions purchased with the Test Payment gateway will not renew automatically.', 'invoicing' ); ?></p> |
|
238 | + <?php if ('manual' == $sub->gateway) : ?> |
|
239 | + <p><strong><?php _e('Note:', 'invoicing'); ?></strong> <?php _e('Subscriptions purchased with the Test Payment gateway will not renew automatically.', 'invoicing'); ?></p> |
|
240 | 240 | <?php endif; ?> |
241 | 241 | <table class="wp-list-table widefat striped payments"> |
242 | 242 | <thead> |
243 | 243 | <tr> |
244 | - <th><?php _e( 'ID', 'invoicing' ); ?></th> |
|
245 | - <th><?php _e( 'Amount', 'invoicing' ); ?></th> |
|
246 | - <th><?php _e( 'Date', 'invoicing' ); ?></th> |
|
247 | - <th><?php _e( 'Status', 'invoicing' ); ?></th> |
|
248 | - <th><?php _e( 'Invoice', 'invoicing' ); ?></th> |
|
249 | - <th class="column-wpi_actions"><?php _e( 'Actions', 'invoicing' ); ?></th> |
|
244 | + <th><?php _e('ID', 'invoicing'); ?></th> |
|
245 | + <th><?php _e('Amount', 'invoicing'); ?></th> |
|
246 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
247 | + <th><?php _e('Status', 'invoicing'); ?></th> |
|
248 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
249 | + <th class="column-wpi_actions"><?php _e('Actions', 'invoicing'); ?></th> |
|
250 | 250 | </tr> |
251 | 251 | </thead> |
252 | 252 | <tbody> |
253 | - <?php if ( ! empty( $payments ) ) : ?> |
|
254 | - <?php foreach ( $payments as $payment ) : $invoice = wpinv_get_invoice( $payment->ID ); if ( empty( $invoice->ID ) ) continue; ?> |
|
253 | + <?php if (!empty($payments)) : ?> |
|
254 | + <?php foreach ($payments as $payment) : $invoice = wpinv_get_invoice($payment->ID); if (empty($invoice->ID)) continue; ?> |
|
255 | 255 | <tr> |
256 | 256 | <td><?php echo $payment->ID; ?></td> |
257 | - <td><?php echo $invoice->get_total( true ); ?></td> |
|
257 | + <td><?php echo $invoice->get_total(true); ?></td> |
|
258 | 258 | <td><?php echo $invoice->get_invoice_date(); ?></td> |
259 | - <td><?php echo $invoice->get_status( true ); ?></td> |
|
259 | + <td><?php echo $invoice->get_status(true); ?></td> |
|
260 | 260 | <td> |
261 | - <a target="_blank" title="<?php _e( 'View invoice', 'invoicing' ); ?>" href="<?php echo esc_url( get_permalink( $payment->ID ) ); ?>"><?php echo $invoice->get_number(); ?></a> |
|
262 | - <?php do_action( 'wpinv_subscription_payments_actions', $sub, $payment ); ?> |
|
261 | + <a target="_blank" title="<?php _e('View invoice', 'invoicing'); ?>" href="<?php echo esc_url(get_permalink($payment->ID)); ?>"><?php echo $invoice->get_number(); ?></a> |
|
262 | + <?php do_action('wpinv_subscription_payments_actions', $sub, $payment); ?> |
|
263 | 263 | </td> |
264 | 264 | <td class="column-wpi_actions"> |
265 | - <a title="<?php echo esc_attr( wp_sprintf( __( 'View details for invoice: %s', 'invoicing' ), $invoice->get_number() ) ); ?>" href="<?php echo get_edit_post_link( $payment->ID ); ?>"><?php _e( 'View Details', 'invoicing' ); ?> |
|
265 | + <a title="<?php echo esc_attr(wp_sprintf(__('View details for invoice: %s', 'invoicing'), $invoice->get_number())); ?>" href="<?php echo get_edit_post_link($payment->ID); ?>"><?php _e('View Details', 'invoicing'); ?> |
|
266 | 266 | </a> |
267 | - <?php do_action( 'wpinv_subscription_payments_actions', $sub, $payment ); ?> |
|
267 | + <?php do_action('wpinv_subscription_payments_actions', $sub, $payment); ?> |
|
268 | 268 | </td> |
269 | 269 | </tr> |
270 | 270 | <?php endforeach; ?> |
271 | 271 | <?php else: ?> |
272 | 272 | <tr> |
273 | - <td colspan="5"><?php _e( 'No Invoices Found.', 'invoicing' ); ?></td> |
|
273 | + <td colspan="5"><?php _e('No Invoices Found.', 'invoicing'); ?></td> |
|
274 | 274 | </tr> |
275 | 275 | <?php endif; ?> |
276 | 276 | </tbody> |
277 | 277 | <tfoot></tfoot> |
278 | 278 | </table> |
279 | 279 | |
280 | - <?php do_action( 'wpinv_subscription_after_tables', $sub ); ?> |
|
280 | + <?php do_action('wpinv_subscription_after_tables', $sub); ?> |
|
281 | 281 | |
282 | 282 | </div> |
283 | 283 | |
284 | - <?php do_action( 'wpinv_subscription_card_bottom', $sub ); ?> |
|
284 | + <?php do_action('wpinv_subscription_card_bottom', $sub); ?> |
|
285 | 285 | </div> |
286 | 286 | |
287 | 287 | <?php endif; ?> |
@@ -299,36 +299,36 @@ discard block |
||
299 | 299 | */ |
300 | 300 | function wpinv_recurring_process_subscription_update() { |
301 | 301 | |
302 | - if( empty( $_POST['sub_id'] ) ) { |
|
302 | + if (empty($_POST['sub_id'])) { |
|
303 | 303 | return; |
304 | 304 | } |
305 | 305 | |
306 | - if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
306 | + if (empty($_POST['wpinv_update_subscription'])) { |
|
307 | 307 | return; |
308 | 308 | } |
309 | 309 | |
310 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
310 | + if (!current_user_can('manage_invoicing')) { |
|
311 | 311 | return; |
312 | 312 | } |
313 | 313 | |
314 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
315 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
314 | + if (!wp_verify_nonce($_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update')) { |
|
315 | + wp_die(__('Nonce verification failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
316 | 316 | } |
317 | 317 | |
318 | - $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
319 | - $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
320 | - $product_id = absint( $_POST['product_id'] ); |
|
321 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
322 | - $subscription->update( array( |
|
323 | - 'status' => sanitize_text_field( $_POST['status'] ), |
|
318 | + $profile_id = sanitize_text_field($_POST['profile_id']); |
|
319 | + $transaction_id = sanitize_text_field($_POST['transaction_id']); |
|
320 | + $product_id = absint($_POST['product_id']); |
|
321 | + $subscription = new WPInv_Subscription(absint($_POST['sub_id'])); |
|
322 | + $subscription->update(array( |
|
323 | + 'status' => sanitize_text_field($_POST['status']), |
|
324 | 324 | 'profile_id' => $profile_id, |
325 | 325 | 'product_id' => $product_id, |
326 | 326 | 'transaction_id' => $transaction_id, |
327 | - ) ); |
|
327 | + )); |
|
328 | 328 | |
329 | - $status = sanitize_text_field( $_POST['status'] ); |
|
329 | + $status = sanitize_text_field($_POST['status']); |
|
330 | 330 | |
331 | - switch( $status ) { |
|
331 | + switch ($status) { |
|
332 | 332 | |
333 | 333 | case 'cancelled' : |
334 | 334 | |
@@ -347,11 +347,11 @@ discard block |
||
347 | 347 | |
348 | 348 | } |
349 | 349 | |
350 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
350 | + wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id)); |
|
351 | 351 | exit; |
352 | 352 | |
353 | 353 | } |
354 | -add_action( 'admin_init', 'wpinv_recurring_process_subscription_update', 1 ); |
|
354 | +add_action('admin_init', 'wpinv_recurring_process_subscription_update', 1); |
|
355 | 355 | |
356 | 356 | /** |
357 | 357 | * Handles subscription deletion |
@@ -362,30 +362,30 @@ discard block |
||
362 | 362 | */ |
363 | 363 | function wpinv_recurring_process_subscription_deletion() { |
364 | 364 | |
365 | - if( empty( $_POST['sub_id'] ) ) { |
|
365 | + if (empty($_POST['sub_id'])) { |
|
366 | 366 | return; |
367 | 367 | } |
368 | 368 | |
369 | - if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
369 | + if (empty($_POST['wpinv_delete_subscription'])) { |
|
370 | 370 | return; |
371 | 371 | } |
372 | 372 | |
373 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
373 | + if (!current_user_can('manage_invoicing')) { |
|
374 | 374 | return; |
375 | 375 | } |
376 | 376 | |
377 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
378 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
377 | + if (!wp_verify_nonce($_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update')) { |
|
378 | + wp_die(__('Nonce verification failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
379 | 379 | } |
380 | 380 | |
381 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
381 | + $subscription = new WPInv_Subscription(absint($_POST['sub_id'])); |
|
382 | 382 | |
383 | - delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
383 | + delete_post_meta($subscription->parent_payment_id, '_wpinv_subscription_payment'); |
|
384 | 384 | |
385 | 385 | $subscription->delete(); |
386 | 386 | |
387 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
387 | + wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=deleted')); |
|
388 | 388 | exit; |
389 | 389 | |
390 | 390 | } |
391 | -add_action( 'admin_init', 'wpinv_recurring_process_subscription_deletion', 2 ); |
|
391 | +add_action('admin_init', 'wpinv_recurring_process_subscription_deletion', 2); |
@@ -1,65 +1,65 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | -function wpinv_add_meta_boxes( $post_type, $post ) { |
|
7 | +function wpinv_add_meta_boxes($post_type, $post) { |
|
8 | 8 | global $wpi_mb_invoice; |
9 | - if ( $post_type == 'wpi_invoice' && !empty( $post->ID ) ) { |
|
10 | - $wpi_mb_invoice = wpinv_get_invoice( $post->ID ); |
|
9 | + if ($post_type == 'wpi_invoice' && !empty($post->ID)) { |
|
10 | + $wpi_mb_invoice = wpinv_get_invoice($post->ID); |
|
11 | 11 | } |
12 | 12 | |
13 | - if ( !empty( $wpi_mb_invoice ) && !$wpi_mb_invoice->has_status( array( 'draft', 'auto-draft' ) ) ) { |
|
14 | - add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high' ); |
|
13 | + if (!empty($wpi_mb_invoice) && !$wpi_mb_invoice->has_status(array('draft', 'auto-draft'))) { |
|
14 | + add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high'); |
|
15 | 15 | } |
16 | 16 | |
17 | - if ( !empty( $wpi_mb_invoice ) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent() ) { |
|
18 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscriptions', 'invoicing' ), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high' ); |
|
17 | + if (!empty($wpi_mb_invoice) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent()) { |
|
18 | + add_meta_box('wpinv-mb-subscriptions', __('Subscriptions', 'invoicing'), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high'); |
|
19 | 19 | } |
20 | 20 | |
21 | - if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) { |
|
22 | - add_meta_box( 'wpinv-mb-renewals', __( 'Renewal Payment', 'invoicing' ), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high' ); |
|
21 | + if (wpinv_is_subscription_payment($wpi_mb_invoice)) { |
|
22 | + add_meta_box('wpinv-mb-renewals', __('Renewal Payment', 'invoicing'), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high'); |
|
23 | 23 | } |
24 | 24 | |
25 | - add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default' ); |
|
26 | - add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default' ); |
|
25 | + add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default'); |
|
26 | + add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default'); |
|
27 | 27 | |
28 | - add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' ); |
|
29 | - add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' ); |
|
30 | - add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' ); |
|
28 | + add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high'); |
|
29 | + add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high'); |
|
30 | + add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high'); |
|
31 | 31 | } |
32 | -add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 ); |
|
32 | +add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2); |
|
33 | 33 | |
34 | -function wpinv_save_meta_boxes( $post_id, $post, $update = false ) { |
|
35 | - remove_action( 'save_post', __FUNCTION__ ); |
|
34 | +function wpinv_save_meta_boxes($post_id, $post, $update = false) { |
|
35 | + remove_action('save_post', __FUNCTION__); |
|
36 | 36 | |
37 | 37 | // $post_id and $post are required |
38 | - if ( empty( $post_id ) || empty( $post ) ) { |
|
38 | + if (empty($post_id) || empty($post)) { |
|
39 | 39 | return; |
40 | 40 | } |
41 | 41 | |
42 | - if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) { |
|
42 | + if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) { |
|
43 | 43 | return; |
44 | 44 | } |
45 | 45 | |
46 | 46 | // Dont' save meta boxes for revisions or autosaves |
47 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
47 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
48 | 48 | return; |
49 | 49 | } |
50 | 50 | |
51 | - if ( $post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote' ) { |
|
52 | - if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
51 | + if ($post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote') { |
|
52 | + if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
56 | - if ( isset( $_POST['wpinv_save_invoice'] ) && wp_verify_nonce( $_POST['wpinv_save_invoice'], 'wpinv_save_invoice' ) ) { |
|
57 | - WPInv_Meta_Box_Items::save( $post_id, $_POST, $post ); |
|
56 | + if (isset($_POST['wpinv_save_invoice']) && wp_verify_nonce($_POST['wpinv_save_invoice'], 'wpinv_save_invoice')) { |
|
57 | + WPInv_Meta_Box_Items::save($post_id, $_POST, $post); |
|
58 | 58 | } |
59 | - } else if ( $post->post_type == 'wpi_item' ) { |
|
59 | + } else if ($post->post_type == 'wpi_item') { |
|
60 | 60 | // verify nonce |
61 | - if ( isset( $_POST['wpinv_vat_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save' ) ) { |
|
62 | - $fields = array(); |
|
61 | + if (isset($_POST['wpinv_vat_meta_box_nonce']) && wp_verify_nonce($_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save')) { |
|
62 | + $fields = array(); |
|
63 | 63 | $fields['_wpinv_price'] = 'wpinv_item_price'; |
64 | 64 | $fields['_wpinv_vat_class'] = 'wpinv_vat_class'; |
65 | 65 | $fields['_wpinv_vat_rule'] = 'wpinv_vat_rules'; |
@@ -72,92 +72,92 @@ discard block |
||
72 | 72 | $fields['_wpinv_trial_period'] = 'wpinv_trial_period'; |
73 | 73 | $fields['_wpinv_trial_interval'] = 'wpinv_trial_interval'; |
74 | 74 | |
75 | - if ( !isset( $_POST['wpinv_is_recurring'] ) ) { |
|
75 | + if (!isset($_POST['wpinv_is_recurring'])) { |
|
76 | 76 | $_POST['wpinv_is_recurring'] = 0; |
77 | 77 | } |
78 | 78 | |
79 | - if ( !isset( $_POST['wpinv_free_trial'] ) || empty( $_POST['wpinv_is_recurring'] ) ) { |
|
79 | + if (!isset($_POST['wpinv_free_trial']) || empty($_POST['wpinv_is_recurring'])) { |
|
80 | 80 | $_POST['wpinv_free_trial'] = 0; |
81 | 81 | } |
82 | 82 | |
83 | - foreach ( $fields as $field => $name ) { |
|
84 | - if ( isset( $_POST[ $name ] ) ) { |
|
85 | - $allowed = apply_filters( 'wpinv_item_allowed_save_meta_value', true, $field, $post_id ); |
|
83 | + foreach ($fields as $field => $name) { |
|
84 | + if (isset($_POST[$name])) { |
|
85 | + $allowed = apply_filters('wpinv_item_allowed_save_meta_value', true, $field, $post_id); |
|
86 | 86 | |
87 | - if ( !$allowed ) { |
|
87 | + if (!$allowed) { |
|
88 | 88 | continue; |
89 | 89 | } |
90 | 90 | |
91 | - if ( $field == '_wpinv_price' ) { |
|
92 | - $value = wpinv_sanitize_amount( $_POST[ $name ] ); |
|
91 | + if ($field == '_wpinv_price') { |
|
92 | + $value = wpinv_sanitize_amount($_POST[$name]); |
|
93 | 93 | } else { |
94 | - $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ]; |
|
94 | + $value = is_string($_POST[$name]) ? sanitize_text_field($_POST[$name]) : $_POST[$name]; |
|
95 | 95 | } |
96 | 96 | |
97 | - $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name ); |
|
98 | - update_post_meta( $post_id, $field, $value ); |
|
97 | + $value = apply_filters('wpinv_item_metabox_save_' . $field, $value, $name); |
|
98 | + update_post_meta($post_id, $field, $value); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | - if ( !get_post_meta( $post_id, '_wpinv_custom_id', true ) ) { |
|
103 | - update_post_meta( $post_id, '_wpinv_custom_id', $post_id ); |
|
102 | + if (!get_post_meta($post_id, '_wpinv_custom_id', true)) { |
|
103 | + update_post_meta($post_id, '_wpinv_custom_id', $post_id); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | } |
107 | 107 | } |
108 | -add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 ); |
|
108 | +add_action('save_post', 'wpinv_save_meta_boxes', 10, 3); |
|
109 | 109 | |
110 | 110 | function wpinv_register_item_meta_boxes() { |
111 | 111 | global $wpinv_euvat; |
112 | 112 | |
113 | - add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' ); |
|
113 | + add_meta_box('wpinv_field_prices', __('Item Price', 'invoicing'), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high'); |
|
114 | 114 | |
115 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
116 | - add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' ); |
|
115 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
116 | + add_meta_box('wpinv_field_vat_rules', __('VAT rules type to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high'); |
|
117 | 117 | } |
118 | 118 | |
119 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
120 | - add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' ); |
|
119 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
120 | + add_meta_box('wpinv_field_vat_classes', __('VAT rates class to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high'); |
|
121 | 121 | } |
122 | 122 | |
123 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' ); |
|
124 | - add_meta_box( 'wpinv_field_meta_values', __( 'Item Meta Values', 'invoicing' ), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core' ); |
|
123 | + add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core'); |
|
124 | + add_meta_box('wpinv_field_meta_values', __('Item Meta Values', 'invoicing'), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core'); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | function wpinv_register_discount_meta_boxes() { |
128 | - add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' ); |
|
128 | + add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high'); |
|
129 | 129 | } |
130 | 130 | |
131 | -function wpinv_discount_metabox_details( $post ) { |
|
131 | +function wpinv_discount_metabox_details($post) { |
|
132 | 132 | $discount_id = $post->ID; |
133 | - $discount = wpinv_get_discount( $discount_id ); |
|
133 | + $discount = wpinv_get_discount($discount_id); |
|
134 | 134 | |
135 | - $type = wpinv_get_discount_type( $discount_id ); |
|
136 | - $item_reqs = wpinv_get_discount_item_reqs( $discount_id ); |
|
137 | - $excluded_items = wpinv_get_discount_excluded_items( $discount_id ); |
|
138 | - $min_total = wpinv_get_discount_min_total( $discount_id ); |
|
139 | - $max_total = wpinv_get_discount_max_total( $discount_id ); |
|
140 | - $max_uses = wpinv_get_discount_max_uses( $discount_id ); |
|
141 | - $single_use = wpinv_discount_is_single_use( $discount_id ); |
|
142 | - $recurring = (bool)wpinv_discount_is_recurring( $discount_id ); |
|
143 | - $start_date = wpinv_get_discount_start_date( $discount_id ); |
|
144 | - $expiration_date = wpinv_get_discount_expiration( $discount_id ); |
|
135 | + $type = wpinv_get_discount_type($discount_id); |
|
136 | + $item_reqs = wpinv_get_discount_item_reqs($discount_id); |
|
137 | + $excluded_items = wpinv_get_discount_excluded_items($discount_id); |
|
138 | + $min_total = wpinv_get_discount_min_total($discount_id); |
|
139 | + $max_total = wpinv_get_discount_max_total($discount_id); |
|
140 | + $max_uses = wpinv_get_discount_max_uses($discount_id); |
|
141 | + $single_use = wpinv_discount_is_single_use($discount_id); |
|
142 | + $recurring = (bool)wpinv_discount_is_recurring($discount_id); |
|
143 | + $start_date = wpinv_get_discount_start_date($discount_id); |
|
144 | + $expiration_date = wpinv_get_discount_expiration($discount_id); |
|
145 | 145 | |
146 | - if ( ! empty( $start_date ) && strpos( $start_date, '0000' ) === false ) { |
|
147 | - $start_time = strtotime( $start_date ); |
|
148 | - $start_h = date_i18n( 'H', $start_time ); |
|
149 | - $start_m = date_i18n( 'i', $start_time ); |
|
150 | - $start_date = date_i18n( 'Y-m-d', $start_time ); |
|
146 | + if (!empty($start_date) && strpos($start_date, '0000') === false) { |
|
147 | + $start_time = strtotime($start_date); |
|
148 | + $start_h = date_i18n('H', $start_time); |
|
149 | + $start_m = date_i18n('i', $start_time); |
|
150 | + $start_date = date_i18n('Y-m-d', $start_time); |
|
151 | 151 | } else { |
152 | 152 | $start_h = '00'; |
153 | 153 | $start_m = '00'; |
154 | 154 | } |
155 | 155 | |
156 | - if ( ! empty( $expiration_date ) && strpos( $expiration_date, '0000' ) === false ) { |
|
157 | - $expiration_time = strtotime( $expiration_date ); |
|
158 | - $expiration_h = date_i18n( 'H', $expiration_time ); |
|
159 | - $expiration_m = date_i18n( 'i', $expiration_time ); |
|
160 | - $expiration_date = date_i18n( 'Y-m-d', $expiration_time ); |
|
156 | + if (!empty($expiration_date) && strpos($expiration_date, '0000') === false) { |
|
157 | + $expiration_time = strtotime($expiration_date); |
|
158 | + $expiration_h = date_i18n('H', $expiration_time); |
|
159 | + $expiration_m = date_i18n('i', $expiration_time); |
|
160 | + $expiration_date = date_i18n('Y-m-d', $expiration_time); |
|
161 | 161 | } else { |
162 | 162 | $expiration_h = '23'; |
163 | 163 | $expiration_m = '59'; |
@@ -167,207 +167,207 @@ discard block |
||
167 | 167 | $max_total = $max_total > 0 ? $max_total : ''; |
168 | 168 | $max_uses = $max_uses > 0 ? $max_uses : ''; |
169 | 169 | ?> |
170 | -<?php do_action( 'wpinv_discount_form_top', $post ); ?> |
|
171 | -<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?> |
|
170 | +<?php do_action('wpinv_discount_form_top', $post); ?> |
|
171 | +<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?> |
|
172 | 172 | <table class="form-table wpi-form-table"> |
173 | 173 | <tbody> |
174 | - <?php do_action( 'wpinv_discount_form_first', $post ); ?> |
|
175 | - <?php do_action( 'wpinv_discount_form_before_code', $post ); ?> |
|
174 | + <?php do_action('wpinv_discount_form_first', $post); ?> |
|
175 | + <?php do_action('wpinv_discount_form_before_code', $post); ?> |
|
176 | 176 | <tr> |
177 | 177 | <th valign="top" scope="row"> |
178 | - <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label> |
|
178 | + <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label> |
|
179 | 179 | </th> |
180 | 180 | <td> |
181 | - <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required> |
|
182 | - <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p> |
|
181 | + <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required> |
|
182 | + <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p> |
|
183 | 183 | </td> |
184 | 184 | </tr> |
185 | - <?php do_action( 'wpinv_discount_form_before_type', $post ); ?> |
|
185 | + <?php do_action('wpinv_discount_form_before_type', $post); ?> |
|
186 | 186 | <tr> |
187 | 187 | <th valign="top" scope="row"> |
188 | - <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label> |
|
188 | + <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label> |
|
189 | 189 | </th> |
190 | 190 | <td> |
191 | 191 | <select id="wpinv_discount_type" name="type" class="medium-text"> |
192 | - <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?> |
|
193 | - <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option> |
|
192 | + <?php foreach (wpinv_get_discount_types() as $value => $label) { ?> |
|
193 | + <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option> |
|
194 | 194 | <?php } ?> |
195 | 195 | </select> |
196 | - <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p> |
|
196 | + <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p> |
|
197 | 197 | </td> |
198 | 198 | </tr> |
199 | - <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?> |
|
199 | + <?php do_action('wpinv_discount_form_before_amount', $post); ?> |
|
200 | 200 | <tr> |
201 | 201 | <th valign="top" scope="row"> |
202 | - <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label> |
|
202 | + <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label> |
|
203 | 203 | </th> |
204 | 204 | <td> |
205 | - <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr( wpinv_get_discount_amount( $discount_id ) ); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol() ;?></font> |
|
206 | - <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p> |
|
207 | - <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p> |
|
205 | + <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr(wpinv_get_discount_amount($discount_id)); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol(); ?></font> |
|
206 | + <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p> |
|
207 | + <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p> |
|
208 | 208 | </td> |
209 | 209 | </tr> |
210 | - <?php do_action( 'wpinv_discount_form_before_items', $post ); ?> |
|
210 | + <?php do_action('wpinv_discount_form_before_items', $post); ?> |
|
211 | 211 | <tr> |
212 | 212 | <th valign="top" scope="row"> |
213 | - <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label> |
|
213 | + <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label> |
|
214 | 214 | </th> |
215 | 215 | <td> |
216 | - <p><?php echo wpinv_item_dropdown( array( |
|
216 | + <p><?php echo wpinv_item_dropdown(array( |
|
217 | 217 | 'name' => 'items[]', |
218 | 218 | 'id' => 'items', |
219 | 219 | 'selected' => $item_reqs, |
220 | 220 | 'multiple' => true, |
221 | 221 | 'class' => 'medium-text', |
222 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
222 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
223 | 223 | 'show_recurring' => true, |
224 | - ) ); ?> |
|
224 | + )); ?> |
|
225 | 225 | </p> |
226 | - <p class="description"><?php _e( 'Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing' ); ?></p> |
|
226 | + <p class="description"><?php _e('Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing'); ?></p> |
|
227 | 227 | </td> |
228 | 228 | </tr> |
229 | - <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?> |
|
229 | + <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?> |
|
230 | 230 | <tr> |
231 | 231 | <th valign="top" scope="row"> |
232 | - <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label> |
|
232 | + <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label> |
|
233 | 233 | </th> |
234 | 234 | <td> |
235 | - <p><?php echo wpinv_item_dropdown( array( |
|
235 | + <p><?php echo wpinv_item_dropdown(array( |
|
236 | 236 | 'name' => 'excluded_items[]', |
237 | 237 | 'id' => 'excluded_items', |
238 | 238 | 'selected' => $excluded_items, |
239 | 239 | 'multiple' => true, |
240 | 240 | 'class' => 'medium-text', |
241 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
241 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
242 | 242 | 'show_recurring' => true, |
243 | - ) ); ?> |
|
243 | + )); ?> |
|
244 | 244 | </p> |
245 | - <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p> |
|
245 | + <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p> |
|
246 | 246 | </td> |
247 | 247 | </tr> |
248 | - <?php do_action( 'wpinv_discount_form_before_start', $post ); ?> |
|
248 | + <?php do_action('wpinv_discount_form_before_start', $post); ?> |
|
249 | 249 | <tr> |
250 | 250 | <th valign="top" scope="row"> |
251 | - <label for="wpinv_discount_start"><?php _e( 'Start Date', 'invoicing' ); ?></label> |
|
251 | + <label for="wpinv_discount_start"><?php _e('Start Date', 'invoicing'); ?></label> |
|
252 | 252 | </th> |
253 | 253 | <td> |
254 | - <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( $start_date ); ?>"> @ <select id="wpinv_discount_start_h" name="start_h"> |
|
255 | - <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
256 | - <option value="<?php echo $value;?>" <?php selected( $value, $start_h ); ?>><?php echo $value;?></option> |
|
254 | + <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr($start_date); ?>"> @ <select id="wpinv_discount_start_h" name="start_h"> |
|
255 | + <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
256 | + <option value="<?php echo $value; ?>" <?php selected($value, $start_h); ?>><?php echo $value; ?></option> |
|
257 | 257 | <?php } ?> |
258 | 258 | </select> : <select id="wpinv_discount_start_m" name="start_m"> |
259 | - <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
260 | - <option value="<?php echo $value;?>" <?php selected( $value, $start_m ); ?>><?php echo $value;?></option> |
|
259 | + <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
260 | + <option value="<?php echo $value; ?>" <?php selected($value, $start_m); ?>><?php echo $value; ?></option> |
|
261 | 261 | <?php } ?> |
262 | 262 | </select> |
263 | - <p class="description"><?php _e( 'Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?></p> |
|
263 | + <p class="description"><?php _e('Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?></p> |
|
264 | 264 | </td> |
265 | 265 | </tr> |
266 | - <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?> |
|
266 | + <?php do_action('wpinv_discount_form_before_expiration', $post); ?> |
|
267 | 267 | <tr> |
268 | 268 | <th valign="top" scope="row"> |
269 | - <label for="wpinv_discount_expiration"><?php _e( 'Expiration Date', 'invoicing' ); ?></label> |
|
269 | + <label for="wpinv_discount_expiration"><?php _e('Expiration Date', 'invoicing'); ?></label> |
|
270 | 270 | </th> |
271 | 271 | <td> |
272 | - <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( $expiration_date ); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h"> |
|
273 | - <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
274 | - <option value="<?php echo $value;?>" <?php selected( $value, $expiration_h ); ?>><?php echo $value;?></option> |
|
272 | + <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr($expiration_date); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h"> |
|
273 | + <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
274 | + <option value="<?php echo $value; ?>" <?php selected($value, $expiration_h); ?>><?php echo $value; ?></option> |
|
275 | 275 | <?php } ?> |
276 | 276 | </select> : <select id="wpinv_discount_expiration_m" name="expiration_m"> |
277 | - <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
278 | - <option value="<?php echo $value;?>" <?php selected( $value, $expiration_m ); ?>><?php echo $value;?></option> |
|
277 | + <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
278 | + <option value="<?php echo $value; ?>" <?php selected($value, $expiration_m); ?>><?php echo $value; ?></option> |
|
279 | 279 | <?php } ?> |
280 | 280 | </select> |
281 | - <p class="description"><?php _e( 'Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing' ); ?></p> |
|
281 | + <p class="description"><?php _e('Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing'); ?></p> |
|
282 | 282 | </td> |
283 | 283 | </tr> |
284 | - <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?> |
|
284 | + <?php do_action('wpinv_discount_form_before_min_total', $post); ?> |
|
285 | 285 | <tr> |
286 | 286 | <th valign="top" scope="row"> |
287 | - <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label> |
|
287 | + <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label> |
|
288 | 288 | </th> |
289 | 289 | <td> |
290 | 290 | <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>"> |
291 | - <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
291 | + <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
292 | 292 | </td> |
293 | 293 | </tr> |
294 | - <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?> |
|
294 | + <?php do_action('wpinv_discount_form_before_max_total', $post); ?> |
|
295 | 295 | <tr> |
296 | 296 | <th valign="top" scope="row"> |
297 | - <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label> |
|
297 | + <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label> |
|
298 | 298 | </th> |
299 | 299 | <td> |
300 | 300 | <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>"> |
301 | - <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
301 | + <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
302 | 302 | </td> |
303 | 303 | </tr> |
304 | - <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?> |
|
304 | + <?php do_action('wpinv_discount_form_before_recurring', $post); ?> |
|
305 | 305 | <tr> |
306 | 306 | <th valign="top" scope="row"> |
307 | - <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label> |
|
307 | + <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label> |
|
308 | 308 | </th> |
309 | 309 | <td> |
310 | 310 | <select id="wpinv_discount_recurring" name="recurring" class="medium-text"> |
311 | - <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option> |
|
312 | - <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option> |
|
311 | + <option value="0" <?php selected(false, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option> |
|
312 | + <option value="1" <?php selected(true, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option> |
|
313 | 313 | </select> |
314 | - <p class="description"><?php _e( '<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing' ); ?></p> |
|
314 | + <p class="description"><?php _e('<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing'); ?></p> |
|
315 | 315 | </td> |
316 | 316 | </tr> |
317 | - <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?> |
|
317 | + <?php do_action('wpinv_discount_form_before_max_uses', $post); ?> |
|
318 | 318 | <tr> |
319 | 319 | <th valign="top" scope="row"> |
320 | - <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label> |
|
320 | + <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label> |
|
321 | 321 | </th> |
322 | 322 | <td> |
323 | 323 | <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>"> |
324 | - <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p> |
|
324 | + <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p> |
|
325 | 325 | </td> |
326 | 326 | </tr> |
327 | - <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?> |
|
327 | + <?php do_action('wpinv_discount_form_before_single_use', $post); ?> |
|
328 | 328 | <tr> |
329 | 329 | <th valign="top" scope="row"> |
330 | - <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label> |
|
330 | + <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label> |
|
331 | 331 | </th> |
332 | 332 | <td> |
333 | - <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>> |
|
334 | - <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span> |
|
333 | + <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>> |
|
334 | + <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span> |
|
335 | 335 | </td> |
336 | 336 | </tr> |
337 | - <?php do_action( 'wpinv_discount_form_last', $post ); ?> |
|
337 | + <?php do_action('wpinv_discount_form_last', $post); ?> |
|
338 | 338 | </tbody> |
339 | 339 | </table> |
340 | -<?php do_action( 'wpinv_discount_form_bottom', $post ); ?> |
|
340 | +<?php do_action('wpinv_discount_form_bottom', $post); ?> |
|
341 | 341 | <?php |
342 | 342 | } |
343 | 343 | |
344 | -function wpinv_discount_metabox_save( $post_id, $post, $update = false ) { |
|
345 | - $post_type = !empty( $post ) ? $post->post_type : ''; |
|
344 | +function wpinv_discount_metabox_save($post_id, $post, $update = false) { |
|
345 | + $post_type = !empty($post) ? $post->post_type : ''; |
|
346 | 346 | |
347 | - if ( $post_type != 'wpi_discount' ) { |
|
347 | + if ($post_type != 'wpi_discount') { |
|
348 | 348 | return; |
349 | 349 | } |
350 | 350 | |
351 | - if ( !isset( $_POST['wpinv_discount_metabox_nonce'] ) || ( isset( $_POST['wpinv_discount_metabox_nonce'] ) && !wp_verify_nonce( $_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce' ) ) ) { |
|
351 | + if (!isset($_POST['wpinv_discount_metabox_nonce']) || (isset($_POST['wpinv_discount_metabox_nonce']) && !wp_verify_nonce($_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce'))) { |
|
352 | 352 | return; |
353 | 353 | } |
354 | 354 | |
355 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
355 | + if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
356 | 356 | return; |
357 | 357 | } |
358 | 358 | |
359 | - if ( !current_user_can( 'manage_options', $post_id ) ) { |
|
359 | + if (!current_user_can('manage_options', $post_id)) { |
|
360 | 360 | return; |
361 | 361 | } |
362 | 362 | |
363 | - if ( !empty( $_POST['start'] ) && isset( $_POST['start_h'] ) && isset( $_POST['start_m'] ) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '' ) { |
|
363 | + if (!empty($_POST['start']) && isset($_POST['start_h']) && isset($_POST['start_m']) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '') { |
|
364 | 364 | $_POST['start'] = $_POST['start'] . ' ' . $_POST['start_h'] . ':' . $_POST['start_m']; |
365 | 365 | } |
366 | 366 | |
367 | - if ( !empty( $_POST['expiration'] ) && isset( $_POST['expiration_h'] ) && isset( $_POST['expiration_m'] ) ) { |
|
367 | + if (!empty($_POST['expiration']) && isset($_POST['expiration_h']) && isset($_POST['expiration_m'])) { |
|
368 | 368 | $_POST['expiration'] = $_POST['expiration'] . ' ' . $_POST['expiration_h'] . ':' . $_POST['expiration_m']; |
369 | 369 | } |
370 | 370 | |
371 | - return wpinv_store_discount( $post_id, $_POST, $post, $update ); |
|
371 | + return wpinv_store_discount($post_id, $_POST, $post, $update); |
|
372 | 372 | } |
373 | -add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 ); |
|
374 | 373 | \ No newline at end of file |
374 | +add_action('save_post', 'wpinv_discount_metabox_save', 10, 3); |
|
375 | 375 | \ No newline at end of file |
@@ -176,69 +176,69 @@ discard block |
||
176 | 176 | } |
177 | 177 | |
178 | 178 | function wpinv_admin_messages() { |
179 | - global $wpinv_options, $pagenow, $post; |
|
179 | + global $wpinv_options, $pagenow, $post; |
|
180 | 180 | |
181 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
182 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
183 | - } |
|
181 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
182 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
183 | + } |
|
184 | 184 | |
185 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
186 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
187 | - } |
|
185 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
186 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
187 | + } |
|
188 | 188 | |
189 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
190 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
191 | - } |
|
189 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
190 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
191 | + } |
|
192 | 192 | |
193 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
194 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
195 | - } |
|
193 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
194 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
195 | + } |
|
196 | 196 | |
197 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
198 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
199 | - } |
|
197 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
198 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
199 | + } |
|
200 | 200 | |
201 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
202 | - add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
203 | - } |
|
201 | + if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
202 | + add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
203 | + } |
|
204 | 204 | |
205 | - if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
206 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' ); |
|
207 | - } |
|
205 | + if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
206 | + add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' ); |
|
207 | + } |
|
208 | 208 | |
209 | - if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
210 | - add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
209 | + if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
210 | + add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
214 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
214 | + add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
218 | 218 | add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' ); |
219 | 219 | } |
220 | 220 | |
221 | - if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
222 | - add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
223 | - } |
|
221 | + if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
222 | + add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
223 | + } |
|
224 | 224 | |
225 | - if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
226 | - add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
227 | - } |
|
225 | + if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
226 | + add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
227 | + } |
|
228 | 228 | |
229 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
230 | - add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
231 | - } |
|
229 | + if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
230 | + add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
231 | + } |
|
232 | 232 | |
233 | - if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
234 | - $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
233 | + if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
234 | + $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
235 | 235 | |
236 | - if ( !empty( $message ) ) { |
|
237 | - add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
238 | - } |
|
239 | - } |
|
236 | + if ( !empty( $message ) ) { |
|
237 | + add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
238 | + } |
|
239 | + } |
|
240 | 240 | |
241 | - settings_errors( 'wpinv-notices' ); |
|
241 | + settings_errors( 'wpinv-notices' ); |
|
242 | 242 | } |
243 | 243 | add_action( 'admin_notices', 'wpinv_admin_messages' ); |
244 | 244 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | break; |
302 | 302 | case 'id' : |
303 | 303 | echo $post->ID; |
304 | - echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
|
304 | + echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
|
305 | 305 | <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>'; |
306 | 306 | if ( $wpinv_euvat->allow_vat_rules() ) { |
307 | 307 | echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>'; |
@@ -7,262 +7,262 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | -function wpinv_columns( $columns ) { |
|
14 | +function wpinv_columns($columns) { |
|
15 | 15 | $columns = array( |
16 | 16 | 'cb' => $columns['cb'], |
17 | - 'number' => __( 'Number', 'invoicing' ), |
|
18 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
19 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
20 | - 'invoice_date' => __( 'Created Date', 'invoicing' ), |
|
21 | - 'payment_date' => __( 'Payment Date', 'invoicing' ), |
|
22 | - 'status' => __( 'Status', 'invoicing' ), |
|
23 | - 'ID' => __( 'ID', 'invoicing' ), |
|
24 | - 'wpi_actions' => __( 'Actions', 'invoicing' ), |
|
17 | + 'number' => __('Number', 'invoicing'), |
|
18 | + 'customer' => __('Customer', 'invoicing'), |
|
19 | + 'amount' => __('Amount', 'invoicing'), |
|
20 | + 'invoice_date' => __('Created Date', 'invoicing'), |
|
21 | + 'payment_date' => __('Payment Date', 'invoicing'), |
|
22 | + 'status' => __('Status', 'invoicing'), |
|
23 | + 'ID' => __('ID', 'invoicing'), |
|
24 | + 'wpi_actions' => __('Actions', 'invoicing'), |
|
25 | 25 | ); |
26 | 26 | |
27 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
27 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
28 | 28 | } |
29 | -add_filter( 'manage_wpi_invoice_posts_columns', 'wpinv_columns' ); |
|
29 | +add_filter('manage_wpi_invoice_posts_columns', 'wpinv_columns'); |
|
30 | 30 | |
31 | -function wpinv_bulk_actions( $actions ) { |
|
32 | - if ( isset( $actions['edit'] ) ) { |
|
33 | - unset( $actions['edit'] ); |
|
31 | +function wpinv_bulk_actions($actions) { |
|
32 | + if (isset($actions['edit'])) { |
|
33 | + unset($actions['edit']); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | return $actions; |
37 | 37 | } |
38 | -add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' ); |
|
39 | -add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' ); |
|
38 | +add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions'); |
|
39 | +add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions'); |
|
40 | 40 | |
41 | -function wpinv_sortable_columns( $columns ) { |
|
41 | +function wpinv_sortable_columns($columns) { |
|
42 | 42 | $columns = array( |
43 | - 'ID' => array( 'ID', true ), |
|
44 | - 'number' => array( 'number', false ), |
|
45 | - 'amount' => array( 'amount', false ), |
|
46 | - 'invoice_date' => array( 'date', false ), |
|
47 | - 'payment_date' => array( 'payment_date', true ), |
|
48 | - 'customer' => array( 'customer', false ), |
|
49 | - 'status' => array( 'status', false ), |
|
43 | + 'ID' => array('ID', true), |
|
44 | + 'number' => array('number', false), |
|
45 | + 'amount' => array('amount', false), |
|
46 | + 'invoice_date' => array('date', false), |
|
47 | + 'payment_date' => array('payment_date', true), |
|
48 | + 'customer' => array('customer', false), |
|
49 | + 'status' => array('status', false), |
|
50 | 50 | ); |
51 | 51 | |
52 | - return apply_filters( 'wpi_invoice_table_sortable_columns', $columns ); |
|
52 | + return apply_filters('wpi_invoice_table_sortable_columns', $columns); |
|
53 | 53 | } |
54 | -add_filter( 'manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns' ); |
|
54 | +add_filter('manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns'); |
|
55 | 55 | |
56 | -add_action( 'manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
57 | -function wpinv_posts_custom_column( $column_name, $post_id = 0 ) { |
|
56 | +add_action('manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
57 | +function wpinv_posts_custom_column($column_name, $post_id = 0) { |
|
58 | 58 | global $post, $wpi_invoice; |
59 | 59 | |
60 | - if ( empty( $wpi_invoice ) || ( !empty( $wpi_invoice ) && $post->ID != $wpi_invoice->ID ) ) { |
|
61 | - $wpi_invoice = new WPInv_Invoice( $post->ID ); |
|
60 | + if (empty($wpi_invoice) || (!empty($wpi_invoice) && $post->ID != $wpi_invoice->ID)) { |
|
61 | + $wpi_invoice = new WPInv_Invoice($post->ID); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | $value = NULL; |
65 | 65 | |
66 | - switch ( $column_name ) { |
|
66 | + switch ($column_name) { |
|
67 | 67 | case 'email' : |
68 | - $value = $wpi_invoice->get_email(); |
|
68 | + $value = $wpi_invoice->get_email(); |
|
69 | 69 | break; |
70 | 70 | case 'customer' : |
71 | 71 | $customer_name = $wpi_invoice->get_user_full_name(); |
72 | - $customer_name = $customer_name != '' ? $customer_name : __( 'Customer', 'invoicing' ); |
|
73 | - $value = '<a href="' . esc_url( get_edit_user_link( $wpi_invoice->get_user_id() ) ) . '">' . $customer_name . '</a>'; |
|
74 | - if ( $email = $wpi_invoice->get_email() ) { |
|
72 | + $customer_name = $customer_name != '' ? $customer_name : __('Customer', 'invoicing'); |
|
73 | + $value = '<a href="' . esc_url(get_edit_user_link($wpi_invoice->get_user_id())) . '">' . $customer_name . '</a>'; |
|
74 | + if ($email = $wpi_invoice->get_email()) { |
|
75 | 75 | $value .= '<br><a class="email" href="mailto:' . $email . '">' . $email . '</a>'; |
76 | 76 | } |
77 | 77 | break; |
78 | 78 | case 'amount' : |
79 | - echo $wpi_invoice->get_total( true ); |
|
79 | + echo $wpi_invoice->get_total(true); |
|
80 | 80 | break; |
81 | 81 | case 'invoice_date' : |
82 | - $date_format = get_option( 'date_format' ); |
|
83 | - $time_format = get_option( 'time_format' ); |
|
84 | - $date_time_format = $date_format . ' '. $time_format; |
|
82 | + $date_format = get_option('date_format'); |
|
83 | + $time_format = get_option('time_format'); |
|
84 | + $date_time_format = $date_format . ' ' . $time_format; |
|
85 | 85 | |
86 | 86 | $m_time = $post->post_date; |
87 | - $h_time = mysql2date( $date_format, $m_time ); |
|
87 | + $h_time = mysql2date($date_format, $m_time); |
|
88 | 88 | |
89 | - $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>'; |
|
89 | + $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>'; |
|
90 | 90 | break; |
91 | 91 | case 'payment_date' : |
92 | - if ( $date_completed = $wpi_invoice->get_meta( '_wpinv_completed_date', true ) ) { |
|
93 | - $date_format = get_option( 'date_format' ); |
|
94 | - $time_format = get_option( 'time_format' ); |
|
95 | - $date_time_format = $date_format . ' '. $time_format; |
|
92 | + if ($date_completed = $wpi_invoice->get_meta('_wpinv_completed_date', true)) { |
|
93 | + $date_format = get_option('date_format'); |
|
94 | + $time_format = get_option('time_format'); |
|
95 | + $date_time_format = $date_format . ' ' . $time_format; |
|
96 | 96 | |
97 | 97 | $m_time = $date_completed; |
98 | - $h_time = mysql2date( $date_format, $m_time ); |
|
98 | + $h_time = mysql2date($date_format, $m_time); |
|
99 | 99 | |
100 | - $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>'; |
|
100 | + $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>'; |
|
101 | 101 | } else { |
102 | 102 | $value = '-'; |
103 | 103 | } |
104 | 104 | break; |
105 | 105 | case 'status' : |
106 | - $value = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' ); |
|
107 | - $is_viewed = wpinv_is_invoice_viewed( $wpi_invoice->ID ); |
|
108 | - if ( 1 == $is_viewed ) { |
|
109 | - $value .= ' <i class="fa fa-eye" title="'.__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
106 | + $value = $wpi_invoice->get_status(true) . ($wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : ''); |
|
107 | + $is_viewed = wpinv_is_invoice_viewed($wpi_invoice->ID); |
|
108 | + if (1 == $is_viewed) { |
|
109 | + $value .= ' <i class="fa fa-eye" title="' . __('Viewed by Customer', 'invoicing') . '"></i>'; |
|
110 | 110 | } |
111 | - if ( ( $wpi_invoice->is_paid() || $wpi_invoice->is_refunded() ) && ( $gateway_title = wpinv_get_gateway_admin_label( $wpi_invoice->get_gateway() ) ) ) { |
|
112 | - $value .= '<br><small class="meta gateway">' . wp_sprintf( __( 'Via %s', 'invoicing' ), $gateway_title ) . '</small>'; |
|
111 | + if (($wpi_invoice->is_paid() || $wpi_invoice->is_refunded()) && ($gateway_title = wpinv_get_gateway_admin_label($wpi_invoice->get_gateway()))) { |
|
112 | + $value .= '<br><small class="meta gateway">' . wp_sprintf(__('Via %s', 'invoicing'), $gateway_title) . '</small>'; |
|
113 | 113 | } |
114 | 114 | break; |
115 | 115 | case 'number' : |
116 | - $edit_link = get_edit_post_link( $post->ID ); |
|
117 | - $value = '<a title="' . esc_attr__( 'View Invoice Details', 'invoicing' ) . '" href="' . esc_url( $edit_link ) . '">' . $wpi_invoice->get_number() . '</a>'; |
|
116 | + $edit_link = get_edit_post_link($post->ID); |
|
117 | + $value = '<a title="' . esc_attr__('View Invoice Details', 'invoicing') . '" href="' . esc_url($edit_link) . '">' . $wpi_invoice->get_number() . '</a>'; |
|
118 | 118 | break; |
119 | 119 | case 'wpi_actions' : |
120 | 120 | $value = ''; |
121 | - if ( !empty( $post->post_name ) ) { |
|
122 | - $value .= '<a title="' . esc_attr__( 'Print invoice', 'invoicing' ) . '" href="' . esc_url( get_permalink( $post->ID ) ) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
121 | + if (!empty($post->post_name)) { |
|
122 | + $value .= '<a title="' . esc_attr__('Print invoice', 'invoicing') . '" href="' . esc_url(get_permalink($post->ID)) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
123 | 123 | } |
124 | 124 | |
125 | - if ( $email = $wpi_invoice->get_email() ) { |
|
126 | - $value .= '<a title="' . esc_attr__( 'Send invoice to customer', 'invoicing' ) . '" href="' . esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
125 | + if ($email = $wpi_invoice->get_email()) { |
|
126 | + $value .= '<a title="' . esc_attr__('Send invoice to customer', 'invoicing') . '" href="' . esc_url(add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | break; |
130 | 130 | default: |
131 | - $value = isset( $post->$column_name ) ? $post->$column_name : ''; |
|
131 | + $value = isset($post->$column_name) ? $post->$column_name : ''; |
|
132 | 132 | break; |
133 | 133 | |
134 | 134 | } |
135 | - $value = apply_filters( 'wpinv_payments_table_column', $value, $post->ID, $column_name ); |
|
135 | + $value = apply_filters('wpinv_payments_table_column', $value, $post->ID, $column_name); |
|
136 | 136 | |
137 | - if ( $value !== NULL ) { |
|
137 | + if ($value !== NULL) { |
|
138 | 138 | echo $value; |
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
142 | -function wpinv_admin_post_id( $id = 0 ) { |
|
142 | +function wpinv_admin_post_id($id = 0) { |
|
143 | 143 | global $post; |
144 | 144 | |
145 | - if ( isset( $id ) && ! empty( $id ) ) { |
|
145 | + if (isset($id) && !empty($id)) { |
|
146 | 146 | return (int)$id; |
147 | - } else if ( get_the_ID() ) { |
|
148 | - return (int) get_the_ID(); |
|
149 | - } else if ( isset( $post->ID ) && !empty( $post->ID ) ) { |
|
150 | - return (int) $post->ID; |
|
151 | - } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) { |
|
152 | - return (int) $_GET['post']; |
|
153 | - } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) { |
|
154 | - return (int) $_GET['id']; |
|
155 | - } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) { |
|
156 | - return (int) $_POST['id']; |
|
147 | + } else if (get_the_ID()) { |
|
148 | + return (int)get_the_ID(); |
|
149 | + } else if (isset($post->ID) && !empty($post->ID)) { |
|
150 | + return (int)$post->ID; |
|
151 | + } else if (isset($_GET['post']) && !empty($_GET['post'])) { |
|
152 | + return (int)$_GET['post']; |
|
153 | + } else if (isset($_GET['id']) && !empty($_GET['id'])) { |
|
154 | + return (int)$_GET['id']; |
|
155 | + } else if (isset($_POST['id']) && !empty($_POST['id'])) { |
|
156 | + return (int)$_POST['id']; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | return null; |
160 | 160 | } |
161 | 161 | |
162 | -function wpinv_admin_post_type( $id = 0 ) { |
|
163 | - if ( !$id ) { |
|
162 | +function wpinv_admin_post_type($id = 0) { |
|
163 | + if (!$id) { |
|
164 | 164 | $id = wpinv_admin_post_id(); |
165 | 165 | } |
166 | 166 | |
167 | - $type = get_post_type( $id ); |
|
167 | + $type = get_post_type($id); |
|
168 | 168 | |
169 | - if ( !$type ) { |
|
170 | - $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null; |
|
169 | + if (!$type) { |
|
170 | + $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null; |
|
171 | 171 | } |
172 | 172 | |
173 | - return apply_filters( 'wpinv_admin_post_type', $type, $id ); |
|
173 | + return apply_filters('wpinv_admin_post_type', $type, $id); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | function wpinv_admin_messages() { |
177 | 177 | global $wpinv_options, $pagenow, $post; |
178 | 178 | |
179 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
180 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
179 | + if (isset($_GET['wpinv-message']) && 'discount_added' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
180 | + add_settings_error('wpinv-notices', 'wpinv-discount-added', __('Discount code added.', 'invoicing'), 'updated'); |
|
181 | 181 | } |
182 | 182 | |
183 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
184 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
183 | + if (isset($_GET['wpinv-message']) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
184 | + add_settings_error('wpinv-notices', 'wpinv-discount-add-fail', __('There was a problem adding your discount code, please try again.', 'invoicing'), 'error'); |
|
185 | 185 | } |
186 | 186 | |
187 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
188 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
187 | + if (isset($_GET['wpinv-message']) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
188 | + add_settings_error('wpinv-notices', 'wpinv-discount-exists', __('A discount with that code already exists, please use a different code.', 'invoicing'), 'error'); |
|
189 | 189 | } |
190 | 190 | |
191 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
192 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
191 | + if (isset($_GET['wpinv-message']) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
192 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated', __('Discount code updated.', 'invoicing'), 'updated'); |
|
193 | 193 | } |
194 | 194 | |
195 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
196 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
195 | + if (isset($_GET['wpinv-message']) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
196 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated-fail', __('There was a problem updating your discount code, please try again.', 'invoicing'), 'error'); |
|
197 | 197 | } |
198 | 198 | |
199 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
200 | - add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
199 | + if (isset($_GET['wpinv-message']) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
200 | + add_settings_error('wpinv-notices', 'wpinv-deleted', __('The invoice has been deleted.', 'invoicing'), 'updated'); |
|
201 | 201 | } |
202 | 202 | |
203 | - if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
204 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' ); |
|
203 | + if (isset($_GET['wpinv-message']) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
204 | + add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Email notification is disabled. Please check settings.', 'invoicing'), 'error'); |
|
205 | 205 | } |
206 | 206 | |
207 | - if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
208 | - add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
207 | + if (isset($_GET['wpinv-message']) && 'email_sent' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
208 | + add_settings_error('wpinv-notices', 'wpinv-sent', __('The email has been sent to customer.', 'invoicing'), 'updated'); |
|
209 | 209 | } |
210 | 210 | |
211 | - if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
212 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
211 | + if (isset($_GET['wpinv-message']) && 'email_fail' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
212 | + add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Fail to send email to the customer.', 'invoicing'), 'error'); |
|
213 | 213 | } |
214 | 214 | |
215 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
216 | - add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' ); |
|
215 | + if (isset($_GET['wpinv-message']) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
216 | + add_settings_error('wpinv-notices', 'wpinv-note-deleted', __('The invoice note has been deleted.', 'invoicing'), 'updated'); |
|
217 | 217 | } |
218 | 218 | |
219 | - if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
220 | - add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
219 | + if (isset($_GET['wpinv-message']) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
220 | + add_settings_error('wpinv-notices', 'wpinv-settings-imported', __('The settings have been imported.', 'invoicing'), 'updated'); |
|
221 | 221 | } |
222 | 222 | |
223 | - if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
224 | - add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
223 | + if (isset($_GET['wpinv-message']) && 'note-added' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
224 | + add_settings_error('wpinv-notices', 'wpinv-note-added', __('The invoice note has been added successfully.', 'invoicing'), 'updated'); |
|
225 | 225 | } |
226 | 226 | |
227 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
228 | - add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
227 | + if (isset($_GET['wpinv-message']) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
228 | + add_settings_error('wpinv-notices', 'wpinv-updated', __('The invoice has been successfully updated.', 'invoicing'), 'updated'); |
|
229 | 229 | } |
230 | 230 | |
231 | - if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
232 | - $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
231 | + if ($pagenow == 'post.php' && !empty($post->post_type) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable($post)) { |
|
232 | + $message = apply_filters('wpinv_item_non_editable_message', __('This item in not editable.', 'invoicing'), $post->ID); |
|
233 | 233 | |
234 | - if ( !empty( $message ) ) { |
|
235 | - add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
234 | + if (!empty($message)) { |
|
235 | + add_settings_error('wpinv-notices', 'wpinv-edit-n', $message, 'updated'); |
|
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
239 | - settings_errors( 'wpinv-notices' ); |
|
239 | + settings_errors('wpinv-notices'); |
|
240 | 240 | } |
241 | -add_action( 'admin_notices', 'wpinv_admin_messages' ); |
|
241 | +add_action('admin_notices', 'wpinv_admin_messages'); |
|
242 | 242 | |
243 | -function wpinv_items_columns( $existing_columns ) { |
|
243 | +function wpinv_items_columns($existing_columns) { |
|
244 | 244 | global $wpinv_euvat; |
245 | 245 | |
246 | 246 | $columns = array(); |
247 | 247 | $columns['cb'] = $existing_columns['cb']; |
248 | - $columns['title'] = __( 'Title', 'invoicing' ); |
|
249 | - $columns['price'] = __( 'Price', 'invoicing' ); |
|
250 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
251 | - $columns['vat_rule'] = __( 'VAT rule type', 'invoicing' ); |
|
248 | + $columns['title'] = __('Title', 'invoicing'); |
|
249 | + $columns['price'] = __('Price', 'invoicing'); |
|
250 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
251 | + $columns['vat_rule'] = __('VAT rule type', 'invoicing'); |
|
252 | 252 | } |
253 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
254 | - $columns['vat_class'] = __( 'VAT class', 'invoicing' ); |
|
253 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
254 | + $columns['vat_class'] = __('VAT class', 'invoicing'); |
|
255 | 255 | } |
256 | - $columns['type'] = __( 'Type', 'invoicing' ); |
|
257 | - $columns['recurring'] = __( 'Recurring', 'invoicing' ); |
|
258 | - $columns['date'] = __( 'Date', 'invoicing' ); |
|
259 | - $columns['id'] = __( 'ID', 'invoicing' ); |
|
256 | + $columns['type'] = __('Type', 'invoicing'); |
|
257 | + $columns['recurring'] = __('Recurring', 'invoicing'); |
|
258 | + $columns['date'] = __('Date', 'invoicing'); |
|
259 | + $columns['id'] = __('ID', 'invoicing'); |
|
260 | 260 | |
261 | - return apply_filters( 'wpinv_items_columns', $columns ); |
|
261 | + return apply_filters('wpinv_items_columns', $columns); |
|
262 | 262 | } |
263 | -add_filter( 'manage_wpi_item_posts_columns', 'wpinv_items_columns' ); |
|
263 | +add_filter('manage_wpi_item_posts_columns', 'wpinv_items_columns'); |
|
264 | 264 | |
265 | -function wpinv_items_sortable_columns( $columns ) { |
|
265 | +function wpinv_items_sortable_columns($columns) { |
|
266 | 266 | $columns['price'] = 'price'; |
267 | 267 | $columns['vat_rule'] = 'vat_rule'; |
268 | 268 | $columns['vat_class'] = 'vat_class'; |
@@ -272,151 +272,151 @@ discard block |
||
272 | 272 | |
273 | 273 | return $columns; |
274 | 274 | } |
275 | -add_filter( 'manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns' ); |
|
275 | +add_filter('manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns'); |
|
276 | 276 | |
277 | -function wpinv_items_table_custom_column( $column ) { |
|
277 | +function wpinv_items_table_custom_column($column) { |
|
278 | 278 | global $wpinv_euvat, $post, $wpi_item; |
279 | 279 | |
280 | - if ( empty( $wpi_item ) || ( !empty( $wpi_item ) && $post->ID != $wpi_item->ID ) ) { |
|
281 | - $wpi_item = new WPInv_Item( $post->ID ); |
|
280 | + if (empty($wpi_item) || (!empty($wpi_item) && $post->ID != $wpi_item->ID)) { |
|
281 | + $wpi_item = new WPInv_Item($post->ID); |
|
282 | 282 | } |
283 | 283 | |
284 | - switch ( $column ) { |
|
284 | + switch ($column) { |
|
285 | 285 | case 'price' : |
286 | - echo wpinv_item_price( $post->ID ); |
|
286 | + echo wpinv_item_price($post->ID); |
|
287 | 287 | break; |
288 | 288 | case 'vat_rule' : |
289 | - echo $wpinv_euvat->item_rule_label( $post->ID ); |
|
289 | + echo $wpinv_euvat->item_rule_label($post->ID); |
|
290 | 290 | break; |
291 | 291 | case 'vat_class' : |
292 | - echo $wpinv_euvat->item_class_label( $post->ID ); |
|
292 | + echo $wpinv_euvat->item_class_label($post->ID); |
|
293 | 293 | break; |
294 | 294 | case 'type' : |
295 | - echo wpinv_item_type( $post->ID ) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
295 | + echo wpinv_item_type($post->ID) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
296 | 296 | break; |
297 | 297 | case 'recurring' : |
298 | - echo ( wpinv_is_recurring_item( $post->ID ) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>' ); |
|
298 | + echo (wpinv_is_recurring_item($post->ID) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>'); |
|
299 | 299 | break; |
300 | 300 | case 'id' : |
301 | 301 | echo $post->ID; |
302 | 302 | echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
303 | - <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>'; |
|
304 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
305 | - echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>'; |
|
303 | + <div class="price">' . wpinv_get_item_price($post->ID) . '</div>'; |
|
304 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
305 | + echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule($post->ID) . '</div>'; |
|
306 | 306 | } |
307 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
308 | - echo '<div class="vat_class">' . $wpinv_euvat->get_item_class( $post->ID ) . '</div>'; |
|
307 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
308 | + echo '<div class="vat_class">' . $wpinv_euvat->get_item_class($post->ID) . '</div>'; |
|
309 | 309 | } |
310 | - echo '<div class="type">' . wpinv_get_item_type( $post->ID ) . '</div> |
|
310 | + echo '<div class="type">' . wpinv_get_item_type($post->ID) . '</div> |
|
311 | 311 | </div>'; |
312 | 312 | break; |
313 | 313 | } |
314 | 314 | |
315 | - do_action( 'wpinv_items_table_column_item_' . $column, $wpi_item, $post ); |
|
315 | + do_action('wpinv_items_table_column_item_' . $column, $wpi_item, $post); |
|
316 | 316 | } |
317 | -add_action( 'manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column' ); |
|
317 | +add_action('manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column'); |
|
318 | 318 | |
319 | 319 | function wpinv_add_items_filters() { |
320 | 320 | global $wpinv_euvat, $typenow; |
321 | 321 | |
322 | 322 | // Checks if the current post type is 'item' |
323 | - if ( $typenow == 'wpi_item') { |
|
324 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
325 | - echo wpinv_html_select( array( |
|
326 | - 'options' => array_merge( array( '' => __( 'All VAT rules', 'invoicing' ) ), $wpinv_euvat->get_rules() ), |
|
323 | + if ($typenow == 'wpi_item') { |
|
324 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
325 | + echo wpinv_html_select(array( |
|
326 | + 'options' => array_merge(array('' => __('All VAT rules', 'invoicing')), $wpinv_euvat->get_rules()), |
|
327 | 327 | 'name' => 'vat_rule', |
328 | 328 | 'id' => 'vat_rule', |
329 | - 'selected' => ( isset( $_GET['vat_rule'] ) ? $_GET['vat_rule'] : '' ), |
|
329 | + 'selected' => (isset($_GET['vat_rule']) ? $_GET['vat_rule'] : ''), |
|
330 | 330 | 'show_option_all' => false, |
331 | 331 | 'show_option_none' => false, |
332 | 332 | 'class' => 'gdmbx2-text-medium', |
333 | - ) ); |
|
333 | + )); |
|
334 | 334 | } |
335 | 335 | |
336 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
337 | - echo wpinv_html_select( array( |
|
338 | - 'options' => array_merge( array( '' => __( 'All VAT classes', 'invoicing' ) ), $wpinv_euvat->get_all_classes() ), |
|
336 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
337 | + echo wpinv_html_select(array( |
|
338 | + 'options' => array_merge(array('' => __('All VAT classes', 'invoicing')), $wpinv_euvat->get_all_classes()), |
|
339 | 339 | 'name' => 'vat_class', |
340 | 340 | 'id' => 'vat_class', |
341 | - 'selected' => ( isset( $_GET['vat_class'] ) ? $_GET['vat_class'] : '' ), |
|
341 | + 'selected' => (isset($_GET['vat_class']) ? $_GET['vat_class'] : ''), |
|
342 | 342 | 'show_option_all' => false, |
343 | 343 | 'show_option_none' => false, |
344 | 344 | 'class' => 'gdmbx2-text-medium', |
345 | - ) ); |
|
345 | + )); |
|
346 | 346 | } |
347 | 347 | |
348 | - echo wpinv_html_select( array( |
|
349 | - 'options' => array_merge( array( '' => __( 'All item types', 'invoicing' ) ), wpinv_get_item_types() ), |
|
348 | + echo wpinv_html_select(array( |
|
349 | + 'options' => array_merge(array('' => __('All item types', 'invoicing')), wpinv_get_item_types()), |
|
350 | 350 | 'name' => 'type', |
351 | 351 | 'id' => 'type', |
352 | - 'selected' => ( isset( $_GET['type'] ) ? $_GET['type'] : '' ), |
|
352 | + 'selected' => (isset($_GET['type']) ? $_GET['type'] : ''), |
|
353 | 353 | 'show_option_all' => false, |
354 | 354 | 'show_option_none' => false, |
355 | 355 | 'class' => 'gdmbx2-text-medium', |
356 | - ) ); |
|
356 | + )); |
|
357 | 357 | |
358 | - if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) { |
|
358 | + if (isset($_REQUEST['all_posts']) && '1' === $_REQUEST['all_posts']) { |
|
359 | 359 | echo '<input type="hidden" name="all_posts" value="1" />'; |
360 | 360 | } |
361 | 361 | } |
362 | 362 | } |
363 | -add_action( 'restrict_manage_posts', 'wpinv_add_items_filters', 100 ); |
|
363 | +add_action('restrict_manage_posts', 'wpinv_add_items_filters', 100); |
|
364 | 364 | |
365 | -function wpinv_send_invoice_after_save( $invoice ) { |
|
366 | - if ( empty( $_POST['wpi_save_send'] ) ) { |
|
365 | +function wpinv_send_invoice_after_save($invoice) { |
|
366 | + if (empty($_POST['wpi_save_send'])) { |
|
367 | 367 | return; |
368 | 368 | } |
369 | 369 | |
370 | - if ( !empty( $invoice->ID ) && !empty( $invoice->post_type ) && 'wpi_invoice' == $invoice->post_type ) { |
|
371 | - wpinv_user_invoice_notification( $invoice->ID ); |
|
370 | + if (!empty($invoice->ID) && !empty($invoice->post_type) && 'wpi_invoice' == $invoice->post_type) { |
|
371 | + wpinv_user_invoice_notification($invoice->ID); |
|
372 | 372 | } |
373 | 373 | } |
374 | -add_action( 'wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1 ); |
|
374 | +add_action('wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1); |
|
375 | 375 | |
376 | -function wpinv_send_register_new_user( $data, $postarr ) { |
|
377 | - if ( current_user_can( 'manage_options' ) && !empty( $data['post_type'] ) && ( 'wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'] ) ) { |
|
378 | - $is_new_user = !empty( $postarr['wpinv_new_user'] ) ? true : false; |
|
379 | - $email = !empty( $postarr['wpinv_email'] ) && $postarr['wpinv_email'] && is_email( $postarr['wpinv_email'] ) ? $postarr['wpinv_email'] : NULL; |
|
376 | +function wpinv_send_register_new_user($data, $postarr) { |
|
377 | + if (current_user_can('manage_options') && !empty($data['post_type']) && ('wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'])) { |
|
378 | + $is_new_user = !empty($postarr['wpinv_new_user']) ? true : false; |
|
379 | + $email = !empty($postarr['wpinv_email']) && $postarr['wpinv_email'] && is_email($postarr['wpinv_email']) ? $postarr['wpinv_email'] : NULL; |
|
380 | 380 | |
381 | - if ( $is_new_user && $email && !email_exists( $email ) ) { |
|
382 | - $first_name = !empty( $postarr['wpinv_first_name'] ) ? sanitize_text_field( $postarr['wpinv_first_name'] ) : ''; |
|
383 | - $last_name = !empty( $postarr['wpinv_last_name'] ) ? sanitize_text_field( $postarr['wpinv_last_name'] ) : ''; |
|
384 | - $display_name = $first_name || $last_name ? trim( $first_name . ' ' . $last_name ) : ''; |
|
385 | - $user_nicename = $display_name ? trim( $display_name ) : $email; |
|
386 | - $user_company = !empty( $postarr['wpinv_company'] ) ? sanitize_text_field( $postarr['wpinv_company'] ) : ''; |
|
381 | + if ($is_new_user && $email && !email_exists($email)) { |
|
382 | + $first_name = !empty($postarr['wpinv_first_name']) ? sanitize_text_field($postarr['wpinv_first_name']) : ''; |
|
383 | + $last_name = !empty($postarr['wpinv_last_name']) ? sanitize_text_field($postarr['wpinv_last_name']) : ''; |
|
384 | + $display_name = $first_name || $last_name ? trim($first_name . ' ' . $last_name) : ''; |
|
385 | + $user_nicename = $display_name ? trim($display_name) : $email; |
|
386 | + $user_company = !empty($postarr['wpinv_company']) ? sanitize_text_field($postarr['wpinv_company']) : ''; |
|
387 | 387 | |
388 | - $user_login = sanitize_user( str_replace( ' ', '', $display_name ), true ); |
|
389 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
388 | + $user_login = sanitize_user(str_replace(' ', '', $display_name), true); |
|
389 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
390 | 390 | $new_user_login = strstr($email, '@', true); |
391 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
392 | - $user_login = sanitize_user($new_user_login, true ); |
|
391 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
392 | + $user_login = sanitize_user($new_user_login, true); |
|
393 | 393 | } |
394 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
395 | - $user_append_text = rand(10,1000); |
|
396 | - $user_login = sanitize_user($new_user_login.$user_append_text, true ); |
|
394 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
395 | + $user_append_text = rand(10, 1000); |
|
396 | + $user_login = sanitize_user($new_user_login . $user_append_text, true); |
|
397 | 397 | } |
398 | 398 | |
399 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
399 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
400 | 400 | $user_login = $email; |
401 | 401 | } |
402 | 402 | } |
403 | 403 | |
404 | 404 | $userdata = array( |
405 | 405 | 'user_login' => $user_login, |
406 | - 'user_pass' => wp_generate_password( 12, false ), |
|
407 | - 'user_email' => sanitize_text_field( $email ), |
|
406 | + 'user_pass' => wp_generate_password(12, false), |
|
407 | + 'user_email' => sanitize_text_field($email), |
|
408 | 408 | 'first_name' => $first_name, |
409 | 409 | 'last_name' => $last_name, |
410 | - 'user_nicename' => wpinv_utf8_substr( $user_nicename, 0, 50 ), |
|
410 | + 'user_nicename' => wpinv_utf8_substr($user_nicename, 0, 50), |
|
411 | 411 | 'nickname' => $display_name, |
412 | 412 | 'display_name' => $display_name, |
413 | 413 | ); |
414 | 414 | |
415 | - $userdata = apply_filters( 'wpinv_register_new_user_data', $userdata ); |
|
415 | + $userdata = apply_filters('wpinv_register_new_user_data', $userdata); |
|
416 | 416 | |
417 | - $new_user_id = wp_insert_user( $userdata ); |
|
417 | + $new_user_id = wp_insert_user($userdata); |
|
418 | 418 | |
419 | - if ( !is_wp_error( $new_user_id ) ) { |
|
419 | + if (!is_wp_error($new_user_id)) { |
|
420 | 420 | $data['post_author'] = $new_user_id; |
421 | 421 | $_POST['post_author'] = $new_user_id; |
422 | 422 | $_POST['post_author_override'] = $new_user_id; |
@@ -437,69 +437,69 @@ discard block |
||
437 | 437 | |
438 | 438 | $meta = array(); |
439 | 439 | ///$meta['_wpinv_user_id'] = $new_user_id; |
440 | - foreach ( $meta_fields as $field ) { |
|
441 | - $meta['_wpinv_' . $field] = isset( $postarr['wpinv_' . $field] ) ? sanitize_text_field( $postarr['wpinv_' . $field] ) : ''; |
|
440 | + foreach ($meta_fields as $field) { |
|
441 | + $meta['_wpinv_' . $field] = isset($postarr['wpinv_' . $field]) ? sanitize_text_field($postarr['wpinv_' . $field]) : ''; |
|
442 | 442 | } |
443 | 443 | |
444 | - $meta = apply_filters( 'wpinv_register_new_user_meta', $meta, $new_user_id ); |
|
444 | + $meta = apply_filters('wpinv_register_new_user_meta', $meta, $new_user_id); |
|
445 | 445 | |
446 | 446 | // Update user meta. |
447 | - foreach ( $meta as $key => $value ) { |
|
448 | - update_user_meta( $new_user_id, $key, $value ); |
|
447 | + foreach ($meta as $key => $value) { |
|
448 | + update_user_meta($new_user_id, $key, $value); |
|
449 | 449 | } |
450 | 450 | |
451 | - if ( function_exists( 'wp_send_new_user_notifications' ) ) { |
|
451 | + if (function_exists('wp_send_new_user_notifications')) { |
|
452 | 452 | // Send email notifications related to the creation of new user. |
453 | - wp_send_new_user_notifications( $new_user_id, 'user' ); |
|
453 | + wp_send_new_user_notifications($new_user_id, 'user'); |
|
454 | 454 | } |
455 | 455 | } else { |
456 | - wpinv_error_log( $new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__ ); |
|
456 | + wpinv_error_log($new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__); |
|
457 | 457 | } |
458 | 458 | } |
459 | 459 | } |
460 | 460 | |
461 | 461 | return $data; |
462 | 462 | } |
463 | -add_filter( 'wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2 ); |
|
463 | +add_filter('wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2); |
|
464 | 464 | |
465 | -function wpinv_show_recurring_supported_gateways( $item_ID ) { |
|
465 | +function wpinv_show_recurring_supported_gateways($item_ID) { |
|
466 | 466 | $all_gateways = wpinv_get_payment_gateways(); |
467 | 467 | |
468 | - if ( !empty( $all_gateways ) ) { |
|
468 | + if (!empty($all_gateways)) { |
|
469 | 469 | $gateways = array(); |
470 | 470 | |
471 | - foreach ( $all_gateways as $key => $gateway ) { |
|
472 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
471 | + foreach ($all_gateways as $key => $gateway) { |
|
472 | + if (wpinv_gateway_support_subscription($key)) { |
|
473 | 473 | $gateways[] = $gateway['admin_label']; |
474 | 474 | } |
475 | 475 | } |
476 | 476 | |
477 | - if ( !empty( $gateways ) ) { |
|
477 | + if (!empty($gateways)) { |
|
478 | 478 | ?> |
479 | - <span class="description"><?php echo wp_sprintf( __( 'Recurring payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ); ?></span> |
|
479 | + <span class="description"><?php echo wp_sprintf(__('Recurring payments only supported by: %s', 'invoicing'), implode(', ', $gateways)); ?></span> |
|
480 | 480 | <?php |
481 | 481 | } |
482 | 482 | } |
483 | 483 | } |
484 | -add_action( 'wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1 ); |
|
484 | +add_action('wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1); |
|
485 | 485 | |
486 | -function wpinv_post_updated_messages( $messages ) { |
|
486 | +function wpinv_post_updated_messages($messages) { |
|
487 | 487 | global $post, $post_ID; |
488 | 488 | |
489 | 489 | $messages['wpi_discount'] = array( |
490 | 490 | 0 => '', |
491 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
492 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
493 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
494 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
495 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
496 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
497 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
498 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
499 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
500 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
491 | + 1 => __('Discount updated.', 'invoicing'), |
|
492 | + 2 => __('Custom field updated.', 'invoicing'), |
|
493 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
494 | + 4 => __('Discount updated.', 'invoicing'), |
|
495 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int)$_GET['revision'], false)) : false, |
|
496 | + 6 => __('Discount updated.', 'invoicing'), |
|
497 | + 7 => __('Discount saved.', 'invoicing'), |
|
498 | + 8 => __('Discount submitted.', 'invoicing'), |
|
499 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
500 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
501 | 501 | ); |
502 | 502 | |
503 | 503 | return $messages; |
504 | 504 | } |
505 | -add_filter( 'post_updated_messages', 'wpinv_post_updated_messages', 10, 1 ); |
|
506 | 505 | \ No newline at end of file |
506 | +add_filter('post_updated_messages', 'wpinv_post_updated_messages', 10, 1); |
|
507 | 507 | \ No newline at end of file |
@@ -10,19 +10,19 @@ |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // MUST have WordPress. |
13 | -if ( !defined( 'WPINC' ) ) { |
|
14 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
13 | +if (!defined('WPINC')) { |
|
14 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
15 | 15 | } |
16 | 16 | |
17 | -if ( !defined( 'WPINV_VERSION' ) ) { |
|
18 | - define( 'WPINV_VERSION', '1.0.4' ); |
|
17 | +if (!defined('WPINV_VERSION')) { |
|
18 | + define('WPINV_VERSION', '1.0.4'); |
|
19 | 19 | } |
20 | 20 | |
21 | -if ( !defined( 'WPINV_PLUGIN_FILE' ) ) { |
|
22 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
21 | +if (!defined('WPINV_PLUGIN_FILE')) { |
|
22 | + define('WPINV_PLUGIN_FILE', __FILE__); |
|
23 | 23 | } |
24 | 24 | |
25 | -require plugin_dir_path( __FILE__ ) . 'includes/class-wpinv.php'; |
|
25 | +require plugin_dir_path(__FILE__) . 'includes/class-wpinv.php'; |
|
26 | 26 | |
27 | 27 | function wpinv_run() { |
28 | 28 | global $invoicing; |
@@ -7,15 +7,15 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | class WPInv_Plugin { |
15 | 15 | private static $instance; |
16 | 16 | |
17 | 17 | public static function run() { |
18 | - if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) { |
|
18 | + if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) { |
|
19 | 19 | self::$instance = new WPInv_Plugin; |
20 | 20 | self::$instance->includes(); |
21 | 21 | self::$instance->actions(); |
@@ -31,31 +31,31 @@ discard block |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | public function define_constants() { |
34 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
35 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
34 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
35 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | private function actions() { |
39 | 39 | /* Internationalize the text strings used. */ |
40 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
40 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
41 | 41 | |
42 | 42 | /* Perform actions on admin initialization. */ |
43 | - add_action( 'admin_init', array( &$this, 'admin_init') ); |
|
44 | - add_action( 'init', array( &$this, 'init' ), 3 ); |
|
45 | - add_action( 'init', array( 'WPInv_Shortcodes', 'init' ) ); |
|
46 | - add_action( 'init', array( &$this, 'wpinv_actions' ) ); |
|
43 | + add_action('admin_init', array(&$this, 'admin_init')); |
|
44 | + add_action('init', array(&$this, 'init'), 3); |
|
45 | + add_action('init', array('WPInv_Shortcodes', 'init')); |
|
46 | + add_action('init', array(&$this, 'wpinv_actions')); |
|
47 | 47 | |
48 | - if ( class_exists( 'BuddyPress' ) ) { |
|
49 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
48 | + if (class_exists('BuddyPress')) { |
|
49 | + add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
|
50 | 50 | } |
51 | 51 | |
52 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
52 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
53 | 53 | |
54 | - if ( is_admin() ) { |
|
55 | - add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) ); |
|
56 | - add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) ); |
|
54 | + if (is_admin()) { |
|
55 | + add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts')); |
|
56 | + add_action('admin_body_class', array(&$this, 'admin_body_class')); |
|
57 | 57 | } else { |
58 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
58 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -65,16 +65,16 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference. |
67 | 67 | */ |
68 | - do_action_ref_array( 'wpinv_actions', array( &$this ) ); |
|
68 | + do_action_ref_array('wpinv_actions', array(&$this)); |
|
69 | 69 | |
70 | - add_action( 'admin_init', array( &$this, 'activation_redirect') ); |
|
70 | + add_action('admin_init', array(&$this, 'activation_redirect')); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | public function plugins_loaded() { |
74 | 74 | /* Internationalize the text strings used. */ |
75 | 75 | $this->load_textdomain(); |
76 | 76 | |
77 | - do_action( 'wpinv_loaded' ); |
|
77 | + do_action('wpinv_loaded'); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -82,209 +82,209 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @since 1.0 |
84 | 84 | */ |
85 | - public function load_textdomain( $locale = NULL ) { |
|
86 | - if ( empty( $locale ) ) { |
|
87 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
85 | + public function load_textdomain($locale = NULL) { |
|
86 | + if (empty($locale)) { |
|
87 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
88 | 88 | } |
89 | 89 | |
90 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
90 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
91 | 91 | |
92 | - unload_textdomain( 'invoicing' ); |
|
93 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
94 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
92 | + unload_textdomain('invoicing'); |
|
93 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
94 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
95 | 95 | |
96 | 96 | /** |
97 | 97 | * Define language constants. |
98 | 98 | */ |
99 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
99 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | public function includes() { |
103 | 103 | global $wpinv_options; |
104 | 104 | |
105 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
105 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
106 | 106 | $wpinv_options = wpinv_get_settings(); |
107 | 107 | |
108 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' ); |
|
109 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
110 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
111 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
112 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
113 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
114 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
115 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' ); |
|
116 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
117 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
118 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
119 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
120 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
121 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' ); |
|
122 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' ); |
|
123 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' ); |
|
124 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' ); |
|
125 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php' ); |
|
126 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
127 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
128 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
129 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' ); |
|
130 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
131 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
132 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
133 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
134 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' ); |
|
135 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
136 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' ); |
|
137 | - if ( !class_exists( 'WPInv_EUVat' ) ) { |
|
138 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
108 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php'); |
|
109 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
110 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
111 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
112 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
113 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
114 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
115 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php'); |
|
116 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
117 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
118 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
119 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
120 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
121 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php'); |
|
122 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php'); |
|
123 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php'); |
|
124 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php'); |
|
125 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php'); |
|
126 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
127 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
128 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
129 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php'); |
|
130 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
131 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
132 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
133 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
134 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php'); |
|
135 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
136 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php'); |
|
137 | + if (!class_exists('WPInv_EUVat')) { |
|
138 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
139 | 139 | } |
140 | 140 | |
141 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
142 | - if ( !empty( $gateways ) ) { |
|
143 | - foreach ( $gateways as $gateway ) { |
|
144 | - if ( $gateway == 'manual' ) { |
|
141 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
142 | + if (!empty($gateways)) { |
|
143 | + foreach ($gateways as $gateway) { |
|
144 | + if ($gateway == 'manual') { |
|
145 | 145 | continue; |
146 | 146 | } |
147 | 147 | |
148 | 148 | $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; |
149 | 149 | |
150 | - if ( file_exists( $gateway_file ) ) { |
|
151 | - require_once( $gateway_file ); |
|
150 | + if (file_exists($gateway_file)) { |
|
151 | + require_once($gateway_file); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | } |
155 | - require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' ); |
|
155 | + require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php'); |
|
156 | 156 | |
157 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
158 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
159 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
160 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' ); |
|
157 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
158 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
159 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
160 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php'); |
|
161 | 161 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' ); |
162 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' ); |
|
163 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' ); |
|
164 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
165 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' ); |
|
166 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
162 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php'); |
|
163 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php'); |
|
164 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
165 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php'); |
|
166 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
167 | 167 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
168 | 168 | } |
169 | 169 | |
170 | 170 | // include css inliner |
171 | - if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { |
|
172 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
171 | + if (!class_exists('Emogrifier') && class_exists('DOMDocument')) { |
|
172 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
173 | 173 | } |
174 | 174 | |
175 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
175 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | public function init() { |
179 | 179 | } |
180 | 180 | |
181 | 181 | public function admin_init() { |
182 | - if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) { |
|
182 | + if (!(defined('DOING_AJAX') && DOING_AJAX)) { |
|
183 | 183 | } |
184 | 184 | |
185 | - add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) ); |
|
185 | + add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php')); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | public function activation_redirect() { |
189 | 189 | // Bail if no activation redirect |
190 | - if ( !get_transient( '_wpinv_activation_redirect' ) ) { |
|
190 | + if (!get_transient('_wpinv_activation_redirect')) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | |
194 | 194 | // Delete the redirect transient |
195 | - delete_transient( '_wpinv_activation_redirect' ); |
|
195 | + delete_transient('_wpinv_activation_redirect'); |
|
196 | 196 | |
197 | 197 | // Bail if activating from network, or bulk |
198 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
198 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
199 | 199 | return; |
200 | 200 | } |
201 | 201 | |
202 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
202 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
203 | 203 | exit; |
204 | 204 | } |
205 | 205 | |
206 | 206 | public function enqueue_scripts() { |
207 | - $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
207 | + $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
208 | 208 | |
209 | - wp_deregister_style( 'font-awesome' ); |
|
210 | - wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' ); |
|
211 | - wp_enqueue_style( 'font-awesome' ); |
|
209 | + wp_deregister_style('font-awesome'); |
|
210 | + wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0'); |
|
211 | + wp_enqueue_style('font-awesome'); |
|
212 | 212 | |
213 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION ); |
|
214 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
213 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION); |
|
214 | + wp_enqueue_style('wpinv_front_style'); |
|
215 | 215 | |
216 | 216 | // Register scripts |
217 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
218 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array( 'jquery', 'wpinv-vat-script' ), WPINV_VERSION ); |
|
217 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
218 | + wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array('jquery', 'wpinv-vat-script'), WPINV_VERSION); |
|
219 | 219 | |
220 | 220 | $localize = array(); |
221 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
222 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
221 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
222 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
223 | 223 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
224 | 224 | $localize['currency_pos'] = wpinv_currency_position(); |
225 | 225 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
226 | 226 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
227 | 227 | $localize['decimals'] = wpinv_decimals(); |
228 | - $localize['txtComplete'] = __( 'Complete', 'invoicing' ); |
|
228 | + $localize['txtComplete'] = __('Complete', 'invoicing'); |
|
229 | 229 | |
230 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
230 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
231 | 231 | |
232 | - wp_enqueue_script( 'jquery-blockui' ); |
|
232 | + wp_enqueue_script('jquery-blockui'); |
|
233 | 233 | $autofill_api = wpinv_get_option('address_autofill_api'); |
234 | 234 | $autofill_active = wpinv_get_option('address_autofill_active'); |
235 | - if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { |
|
236 | - if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { |
|
237 | - wp_dequeue_script( 'google-maps-api' ); |
|
235 | + if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { |
|
236 | + if (wp_script_is('google-maps-api', 'enqueued')) { |
|
237 | + wp_dequeue_script('google-maps-api'); |
|
238 | 238 | } |
239 | - wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); |
|
240 | - wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); |
|
239 | + wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); |
|
240 | + wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true); |
|
241 | 241 | } |
242 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
243 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
242 | + wp_enqueue_script('wpinv-front-script'); |
|
243 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | public function admin_enqueue_scripts() { |
247 | 247 | global $post, $pagenow; |
248 | 248 | |
249 | 249 | $post_type = wpinv_admin_post_type(); |
250 | - $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
251 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : ''; |
|
250 | + $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
251 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : ''; |
|
252 | 252 | |
253 | - wp_deregister_style( 'font-awesome' ); |
|
254 | - wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' ); |
|
255 | - wp_enqueue_style( 'font-awesome' ); |
|
253 | + wp_deregister_style('font-awesome'); |
|
254 | + wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0'); |
|
255 | + wp_enqueue_style('font-awesome'); |
|
256 | 256 | |
257 | 257 | $jquery_ui_css = false; |
258 | - if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) { |
|
258 | + if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
|
259 | 259 | $jquery_ui_css = true; |
260 | - } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) { |
|
260 | + } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') { |
|
261 | 261 | $jquery_ui_css = true; |
262 | 262 | } |
263 | - if ( $jquery_ui_css ) { |
|
264 | - wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); |
|
265 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
263 | + if ($jquery_ui_css) { |
|
264 | + wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16'); |
|
265 | + wp_enqueue_style('jquery-ui-css'); |
|
266 | 266 | } |
267 | 267 | |
268 | - wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
|
269 | - wp_enqueue_style( 'wpinv_meta_box_style' ); |
|
268 | + wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
269 | + wp_enqueue_style('wpinv_meta_box_style'); |
|
270 | 270 | |
271 | - wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION ); |
|
272 | - wp_enqueue_style( 'wpinv_admin_style' ); |
|
271 | + wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION); |
|
272 | + wp_enqueue_style('wpinv_admin_style'); |
|
273 | 273 | |
274 | - $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ); |
|
275 | - if ( $page == 'wpinv-subscriptions' ) { |
|
276 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
274 | + $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')); |
|
275 | + if ($page == 'wpinv-subscriptions') { |
|
276 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
277 | 277 | } |
278 | - $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ); |
|
278 | + $enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue); |
|
279 | 279 | |
280 | - if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) { |
|
281 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
280 | + if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) { |
|
281 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
282 | 282 | } |
283 | 283 | |
284 | - wp_enqueue_style( 'wp-color-picker' ); |
|
285 | - wp_enqueue_script( 'wp-color-picker' ); |
|
284 | + wp_enqueue_style('wp-color-picker'); |
|
285 | + wp_enqueue_script('wp-color-picker'); |
|
286 | 286 | |
287 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
287 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
288 | 288 | |
289 | 289 | if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
290 | 290 | $autofill_api = wpinv_get_option('address_autofill_api'); |
@@ -295,17 +295,17 @@ discard block |
||
295 | 295 | } |
296 | 296 | } |
297 | 297 | |
298 | - wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ), WPINV_VERSION ); |
|
299 | - wp_enqueue_script( 'wpinv-admin-script' ); |
|
298 | + wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION); |
|
299 | + wp_enqueue_script('wpinv-admin-script'); |
|
300 | 300 | |
301 | 301 | $localize = array(); |
302 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
303 | - $localize['post_ID'] = isset( $post->ID ) ? $post->ID : ''; |
|
304 | - $localize['wpinv_nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
305 | - $localize['add_invoice_note_nonce'] = wp_create_nonce( 'add-invoice-note' ); |
|
306 | - $localize['delete_invoice_note_nonce'] = wp_create_nonce( 'delete-invoice-note' ); |
|
307 | - $localize['invoice_item_nonce'] = wp_create_nonce( 'invoice-item' ); |
|
308 | - $localize['billing_details_nonce'] = wp_create_nonce( 'get-billing-details' ); |
|
302 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
303 | + $localize['post_ID'] = isset($post->ID) ? $post->ID : ''; |
|
304 | + $localize['wpinv_nonce'] = wp_create_nonce('wpinv-nonce'); |
|
305 | + $localize['add_invoice_note_nonce'] = wp_create_nonce('add-invoice-note'); |
|
306 | + $localize['delete_invoice_note_nonce'] = wp_create_nonce('delete-invoice-note'); |
|
307 | + $localize['invoice_item_nonce'] = wp_create_nonce('invoice-item'); |
|
308 | + $localize['billing_details_nonce'] = wp_create_nonce('get-billing-details'); |
|
309 | 309 | $localize['tax'] = wpinv_tax_amount(); |
310 | 310 | $localize['discount'] = wpinv_discount_amount(); |
311 | 311 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
@@ -313,69 +313,69 @@ discard block |
||
313 | 313 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
314 | 314 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
315 | 315 | $localize['decimals'] = wpinv_decimals(); |
316 | - $localize['save_invoice'] = __( 'Save Invoice', 'invoicing' ); |
|
317 | - $localize['status_publish'] = wpinv_status_nicename( 'publish' ); |
|
318 | - $localize['status_pending'] = wpinv_status_nicename( 'wpi-pending' ); |
|
319 | - $localize['delete_tax_rate'] = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ); |
|
320 | - $localize['OneItemMin'] = __( 'Invoice must contain at least one item', 'invoicing' ); |
|
321 | - $localize['DeleteInvoiceItem'] = __( 'Are you sure you wish to delete this item?', 'invoicing' ); |
|
322 | - $localize['FillBillingDetails'] = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ); |
|
323 | - $localize['confirmCalcTotals'] = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ); |
|
324 | - $localize['AreYouSure'] = __( 'Are you sure?', 'invoicing' ); |
|
325 | - $localize['emptyInvoice'] = __( 'Add at least one item to save invoice!', 'invoicing' ); |
|
326 | - $localize['errDeleteItem'] = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ); |
|
327 | - $localize['delete_subscription'] = __( 'Are you sure you want to delete this subscription?', 'invoicing' ); |
|
328 | - $localize['action_edit'] = __( 'Edit', 'invoicing' ); |
|
329 | - $localize['action_cancel'] = __( 'Cancel', 'invoicing' ); |
|
316 | + $localize['save_invoice'] = __('Save Invoice', 'invoicing'); |
|
317 | + $localize['status_publish'] = wpinv_status_nicename('publish'); |
|
318 | + $localize['status_pending'] = wpinv_status_nicename('wpi-pending'); |
|
319 | + $localize['delete_tax_rate'] = __('Are you sure you wish to delete this tax rate?', 'invoicing'); |
|
320 | + $localize['OneItemMin'] = __('Invoice must contain at least one item', 'invoicing'); |
|
321 | + $localize['DeleteInvoiceItem'] = __('Are you sure you wish to delete this item?', 'invoicing'); |
|
322 | + $localize['FillBillingDetails'] = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'); |
|
323 | + $localize['confirmCalcTotals'] = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'); |
|
324 | + $localize['AreYouSure'] = __('Are you sure?', 'invoicing'); |
|
325 | + $localize['emptyInvoice'] = __('Add at least one item to save invoice!', 'invoicing'); |
|
326 | + $localize['errDeleteItem'] = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'); |
|
327 | + $localize['delete_subscription'] = __('Are you sure you want to delete this subscription?', 'invoicing'); |
|
328 | + $localize['action_edit'] = __('Edit', 'invoicing'); |
|
329 | + $localize['action_cancel'] = __('Cancel', 'invoicing'); |
|
330 | 330 | |
331 | - $localize = apply_filters( 'wpinv_admin_js_localize', $localize ); |
|
331 | + $localize = apply_filters('wpinv_admin_js_localize', $localize); |
|
332 | 332 | |
333 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize ); |
|
333 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize); |
|
334 | 334 | |
335 | - if ( $page == 'wpinv-subscriptions' ) { |
|
336 | - wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions' . $suffix . '.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
337 | - wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
335 | + if ($page == 'wpinv-subscriptions') { |
|
336 | + wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions' . $suffix . '.js', array('wpinv-admin-script'), WPINV_VERSION); |
|
337 | + wp_enqueue_script('wpinv-sub-admin-script'); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | |
341 | - public function admin_body_class( $classes ) { |
|
341 | + public function admin_body_class($classes) { |
|
342 | 342 | global $pagenow, $post, $current_screen; |
343 | 343 | |
344 | - if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) { |
|
344 | + if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) { |
|
345 | 345 | $classes .= ' wpinv-cpt'; |
346 | 346 | } |
347 | 347 | |
348 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
348 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
349 | 349 | |
350 | - $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false; |
|
351 | - if ( $add_class ) { |
|
352 | - $classes .= ' wpi-' . wpinv_sanitize_key( $page ); |
|
350 | + $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false; |
|
351 | + if ($add_class) { |
|
352 | + $classes .= ' wpi-' . wpinv_sanitize_key($page); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | $settings_class = array(); |
356 | - if ( $page == 'wpinv-settings' ) { |
|
357 | - if ( !empty( $_REQUEST['tab'] ) ) { |
|
358 | - $settings_class[] = sanitize_text_field( $_REQUEST['tab'] ); |
|
356 | + if ($page == 'wpinv-settings') { |
|
357 | + if (!empty($_REQUEST['tab'])) { |
|
358 | + $settings_class[] = sanitize_text_field($_REQUEST['tab']); |
|
359 | 359 | } |
360 | 360 | |
361 | - if ( !empty( $_REQUEST['section'] ) ) { |
|
362 | - $settings_class[] = sanitize_text_field( $_REQUEST['section'] ); |
|
361 | + if (!empty($_REQUEST['section'])) { |
|
362 | + $settings_class[] = sanitize_text_field($_REQUEST['section']); |
|
363 | 363 | } |
364 | 364 | |
365 | - $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main'; |
|
365 | + $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main'; |
|
366 | 366 | } |
367 | 367 | |
368 | - if ( !empty( $settings_class ) ) { |
|
369 | - $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) ); |
|
368 | + if (!empty($settings_class)) { |
|
369 | + $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-')); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | $post_type = wpinv_admin_post_type(); |
373 | 373 | |
374 | - if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) { |
|
374 | + if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) { |
|
375 | 375 | return $classes .= ' wpinv'; |
376 | 376 | } |
377 | 377 | |
378 | - if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) { |
|
378 | + if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) { |
|
379 | 379 | $classes .= ' wpi-editable-n'; |
380 | 380 | } |
381 | 381 | |
@@ -387,20 +387,20 @@ discard block |
||
387 | 387 | } |
388 | 388 | |
389 | 389 | public function wpinv_actions() { |
390 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
391 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
390 | + if (isset($_REQUEST['wpi_action'])) { |
|
391 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
392 | 392 | } |
393 | 393 | } |
394 | 394 | |
395 | - public function pre_get_posts( $wp_query ) { |
|
396 | - if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
397 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
395 | + public function pre_get_posts($wp_query) { |
|
396 | + if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
397 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | return $wp_query; |
401 | 401 | } |
402 | 402 | |
403 | 403 | public function bp_invoicing_init() { |
404 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
404 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
405 | 405 | } |
406 | 406 | } |
407 | 407 | \ No newline at end of file |