@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
9 | - exit; // Exit if accessed directly |
|
9 | + exit; // Exit if accessed directly |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | /** |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | class GetPaid_Meta_Box_Resend_Invoice { |
16 | 16 | |
17 | 17 | /** |
18 | - * Output the metabox. |
|
19 | - * |
|
20 | - * @param WP_Post $post |
|
21 | - */ |
|
18 | + * Output the metabox. |
|
19 | + * |
|
20 | + * @param WP_Post $post |
|
21 | + */ |
|
22 | 22 | public static function output( $post ) { |
23 | 23 | |
24 | 24 | // Fetch the invoice. |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * |
6 | 6 | */ |
7 | 7 | |
8 | -if ( ! defined( 'ABSPATH' ) ) { |
|
8 | +if (!defined('ABSPATH')) { |
|
9 | 9 | exit; // Exit if accessed directly |
10 | 10 | } |
11 | 11 | |
@@ -19,12 +19,12 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @param WP_Post $post |
21 | 21 | */ |
22 | - public static function output( $post ) { |
|
22 | + public static function output($post) { |
|
23 | 23 | |
24 | 24 | // Fetch the invoice. |
25 | - $invoice = new WPInv_Invoice( $post ); |
|
25 | + $invoice = new WPInv_Invoice($post); |
|
26 | 26 | |
27 | - do_action( 'wpinv_metabox_resend_invoice_before', $invoice ); |
|
27 | + do_action('wpinv_metabox_resend_invoice_before', $invoice); |
|
28 | 28 | |
29 | 29 | $email_url = esc_url( |
30 | 30 | add_query_arg( |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | ); |
51 | 51 | |
52 | 52 | ?> |
53 | - <p class="wpi-meta-row wpi-resend-info"><?php _e( "This will send a copy of the invoice to the customer's email address.", 'invoicing' ); ?></p> |
|
54 | - <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo $email_url; ?>" class="button button-secondary"><?php _e( 'Resend Invoice', 'invoicing' ); ?></a></p> |
|
55 | - <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e( 'Send overdue reminder notification to customer', 'invoicing' ); ?>" href="<?php echo $reminder_url; ?>" class="button button-secondary"><?php esc_attr_e( 'Send Reminder', 'invoicing' ); ?></a></p> |
|
53 | + <p class="wpi-meta-row wpi-resend-info"><?php _e("This will send a copy of the invoice to the customer's email address.", 'invoicing'); ?></p> |
|
54 | + <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo $email_url; ?>" class="button button-secondary"><?php _e('Resend Invoice', 'invoicing'); ?></a></p> |
|
55 | + <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e('Send overdue reminder notification to customer', 'invoicing'); ?>" href="<?php echo $reminder_url; ?>" class="button button-secondary"><?php esc_attr_e('Send Reminder', 'invoicing'); ?></a></p> |
|
56 | 56 | <?php |
57 | 57 | |
58 | - do_action( 'wpinv_metabox_resend_invoice_after', $invoice ); |
|
58 | + do_action('wpinv_metabox_resend_invoice_after', $invoice); |
|
59 | 59 | |
60 | 60 | } |
61 | 61 |
@@ -1,39 +1,39 @@ |
||
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_Notes { |
8 | - public static function output( $post ) { |
|
8 | + public static function output($post) { |
|
9 | 9 | global $post; |
10 | 10 | |
11 | - $notes = wpinv_get_invoice_notes( $post->ID ); |
|
11 | + $notes = wpinv_get_invoice_notes($post->ID); |
|
12 | 12 | |
13 | 13 | echo '<ul class="invoice_notes">'; |
14 | 14 | |
15 | - if ( $notes ) { |
|
16 | - foreach( $notes as $note ) { |
|
17 | - wpinv_get_invoice_note_line_item( $note ); |
|
15 | + if ($notes) { |
|
16 | + foreach ($notes as $note) { |
|
17 | + wpinv_get_invoice_note_line_item($note); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | } else { |
21 | - echo '<li>' . __( 'There are no notes yet.', 'invoicing' ) . '</li>'; |
|
21 | + echo '<li>' . __('There are no notes yet.', 'invoicing') . '</li>'; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | echo '</ul>'; |
25 | 25 | ?> |
26 | 26 | <div class="add_note"> |
27 | - <h4><?php _e( 'Add note', 'invoicing' ); ?></h4> |
|
27 | + <h4><?php _e('Add note', 'invoicing'); ?></h4> |
|
28 | 28 | <p> |
29 | 29 | <textarea type="text" name="invoice_note" id="add_invoice_note" class="input-text" cols="20" rows="5"></textarea> |
30 | 30 | </p> |
31 | 31 | <p> |
32 | 32 | <select name="invoice_note_type" id="invoice_note_type" class="regular-text"> |
33 | - <option value=""><?php _e( 'Private note', 'invoicing' ); ?></option> |
|
34 | - <option value="customer"><?php _e( 'Note to customer', 'invoicing' ); ?></option> |
|
33 | + <option value=""><?php _e('Private note', 'invoicing'); ?></option> |
|
34 | + <option value="customer"><?php _e('Note to customer', 'invoicing'); ?></option> |
|
35 | 35 | </select> |
36 | - <a href="#" class="add_note button"><?php _e( 'Add', 'invoicing' ); ?></a> <span class="description"><?php _e( 'Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing' ); ?></span> |
|
36 | + <a href="#" class="add_note button"><?php _e('Add', 'invoicing'); ?></a> <span class="description"><?php _e('Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing'); ?></span> |
|
37 | 37 | </p> |
38 | 38 | </div> |
39 | 39 | <?php |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
11 | - exit; // Exit if accessed directly |
|
11 | + exit; // Exit if accessed directly |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | class GetPaid_Meta_Box_Item_Details { |
18 | 18 | |
19 | 19 | /** |
20 | - * Output the metabox. |
|
21 | - * |
|
22 | - * @param WP_Post $post |
|
23 | - */ |
|
20 | + * Output the metabox. |
|
21 | + * |
|
22 | + * @param WP_Post $post |
|
23 | + */ |
|
24 | 24 | public static function output( $post ) { |
25 | 25 | |
26 | 26 | // Prepare the item. |
@@ -289,35 +289,35 @@ discard block |
||
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
292 | - * Save meta box data. |
|
293 | - * |
|
294 | - * @param int $post_id |
|
295 | - */ |
|
296 | - public static function save( $post_id ) { |
|
292 | + * Save meta box data. |
|
293 | + * |
|
294 | + * @param int $post_id |
|
295 | + */ |
|
296 | + public static function save( $post_id ) { |
|
297 | 297 | |
298 | 298 | // Prepare the item. |
299 | 299 | $item = new WPInv_Item( $post_id ); |
300 | 300 | |
301 | 301 | // Load new data. |
302 | 302 | $item->set_props( |
303 | - array( |
|
304 | - 'price' => isset( $_POST['wpinv_item_price'] ) ? (float) $_POST['wpinv_item_price'] : null, |
|
305 | - 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, |
|
306 | - 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, |
|
307 | - 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, |
|
308 | - 'is_dynamic_pricing' => isset( $_POST['wpinv_name_your_price'] ), |
|
303 | + array( |
|
304 | + 'price' => isset( $_POST['wpinv_item_price'] ) ? (float) $_POST['wpinv_item_price'] : null, |
|
305 | + 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, |
|
306 | + 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, |
|
307 | + 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, |
|
308 | + 'is_dynamic_pricing' => isset( $_POST['wpinv_name_your_price'] ), |
|
309 | 309 | 'minimum_price' => isset( $_POST['wpinv_minimum_price'] ) ? (float) $_POST['wpinv_minimum_price'] : null, |
310 | - 'is_recurring' => isset( $_POST['wpinv_is_recurring'] ), |
|
311 | - 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, |
|
312 | - 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : null, |
|
313 | - 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
314 | - 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, |
|
315 | - 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, |
|
316 | - 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
317 | - ) |
|
310 | + 'is_recurring' => isset( $_POST['wpinv_is_recurring'] ), |
|
311 | + 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, |
|
312 | + 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : null, |
|
313 | + 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
314 | + 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, |
|
315 | + 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, |
|
316 | + 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
317 | + ) |
|
318 | 318 | ); |
319 | 319 | |
320 | - $item->save(); |
|
321 | - do_action( 'getpaid_item_metabox_save', $post_id, $item ); |
|
322 | - } |
|
320 | + $item->save(); |
|
321 | + do_action( 'getpaid_item_metabox_save', $post_id, $item ); |
|
322 | + } |
|
323 | 323 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,27 +21,27 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the item. |
27 | - $item = new WPInv_Item( $post ); |
|
27 | + $item = new WPInv_Item($post); |
|
28 | 28 | |
29 | 29 | // Nonce field. |
30 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
30 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
31 | 31 | |
32 | 32 | // Set the currency position. |
33 | 33 | $position = wpinv_currency_position(); |
34 | 34 | |
35 | - if ( $position == 'left_space' ) { |
|
35 | + if ($position == 'left_space') { |
|
36 | 36 | $position = 'left'; |
37 | 37 | } |
38 | 38 | |
39 | - if ( $position == 'right_space' ) { |
|
39 | + if ($position == 'right_space') { |
|
40 | 40 | $position = 'right'; |
41 | 41 | } |
42 | 42 | |
43 | 43 | ?> |
44 | - <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr( $item->get_type( 'edit' ) ); ?>" /> |
|
44 | + <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr($item->get_type('edit')); ?>" /> |
|
45 | 45 | <style> |
46 | 46 | #poststuff .input-group-text, |
47 | 47 | #poststuff .form-control { |
@@ -55,21 +55,21 @@ discard block |
||
55 | 55 | </style> |
56 | 56 | <div class='bsui' style='max-width: 600px;padding-top: 10px;'> |
57 | 57 | |
58 | - <?php do_action( 'wpinv_item_details_metabox_before_price', $item ); ?> |
|
58 | + <?php do_action('wpinv_item_details_metabox_before_price', $item); ?> |
|
59 | 59 | <div class="form-group row"> |
60 | - <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e( 'Item Price', 'invoicing' )?></span></label> |
|
60 | + <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e('Item Price', 'invoicing')?></span></label> |
|
61 | 61 | <div class="col-sm-8"> |
62 | 62 | <div class="row"> |
63 | 63 | <div class="col-sm-4 getpaid-price-input"> |
64 | 64 | <div class="input-group input-group-sm"> |
65 | - <?php if( 'left' == $position ) : ?> |
|
65 | + <?php if ('left' == $position) : ?> |
|
66 | 66 | <div class="input-group-prepend"> |
67 | 67 | <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
68 | 68 | </div> |
69 | 69 | <?php endif; ?> |
70 | - <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr( $item->get_price( 'edit' ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control"> |
|
70 | + <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr($item->get_price('edit')); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control"> |
|
71 | 71 | |
72 | - <?php if( 'left' != $position ) : ?> |
|
72 | + <?php if ('left' != $position) : ?> |
|
73 | 73 | <div class="input-group-append"> |
74 | 74 | <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
75 | 75 | </div> |
@@ -83,25 +83,25 @@ discard block |
||
83 | 83 | array( |
84 | 84 | 'id' => 'wpinv_recurring_interval', |
85 | 85 | 'name' => 'wpinv_recurring_interval', |
86 | - 'label' => __( 'Interval', 'invoicing' ), |
|
87 | - 'placeholder' => __( 'Select Interval', 'invoicing' ), |
|
88 | - 'value' => $item->get_recurring_interval( 'edit' ), |
|
86 | + 'label' => __('Interval', 'invoicing'), |
|
87 | + 'placeholder' => __('Select Interval', 'invoicing'), |
|
88 | + 'value' => $item->get_recurring_interval('edit'), |
|
89 | 89 | 'select2' => true, |
90 | 90 | 'data-allow-clear' => 'false', |
91 | 91 | 'options' => array( |
92 | - '1' => __( 'every', 'invoicing' ), |
|
93 | - '2' => __( 'every 2nd', 'invoicing' ), |
|
94 | - '3' => __( 'every 3rd', 'invoicing' ), |
|
95 | - '4' => __( 'every 4th', 'invoicing' ), |
|
96 | - '5' => __( 'every 5th', 'invoicing' ), |
|
97 | - '6' => __( 'every 6th', 'invoicing' ), |
|
98 | - '8' => __( 'every 8th', 'invoicing' ), |
|
99 | - '9' => __( 'every 9th', 'invoicing' ), |
|
100 | - '10' => __( 'every 10th', 'invoicing' ), |
|
101 | - '11' => __( 'every 11th', 'invoicing' ), |
|
102 | - '12' => __( 'every 12th', 'invoicing' ), |
|
103 | - '13' => __( 'every 13th', 'invoicing' ), |
|
104 | - '14' => __( 'every 14th', 'invoicing' ), |
|
92 | + '1' => __('every', 'invoicing'), |
|
93 | + '2' => __('every 2nd', 'invoicing'), |
|
94 | + '3' => __('every 3rd', 'invoicing'), |
|
95 | + '4' => __('every 4th', 'invoicing'), |
|
96 | + '5' => __('every 5th', 'invoicing'), |
|
97 | + '6' => __('every 6th', 'invoicing'), |
|
98 | + '8' => __('every 8th', 'invoicing'), |
|
99 | + '9' => __('every 9th', 'invoicing'), |
|
100 | + '10' => __('every 10th', 'invoicing'), |
|
101 | + '11' => __('every 11th', 'invoicing'), |
|
102 | + '12' => __('every 12th', 'invoicing'), |
|
103 | + '13' => __('every 13th', 'invoicing'), |
|
104 | + '14' => __('every 14th', 'invoicing'), |
|
105 | 105 | ) |
106 | 106 | ) |
107 | 107 | ); |
@@ -113,16 +113,16 @@ discard block |
||
113 | 113 | array( |
114 | 114 | 'id' => 'wpinv_recurring_period', |
115 | 115 | 'name' => 'wpinv_recurring_period', |
116 | - 'label' => __( 'Period', 'invoicing' ), |
|
117 | - 'placeholder' => __( 'Select Period', 'invoicing' ), |
|
118 | - 'value' => $item->get_recurring_period( 'edit' ), |
|
116 | + 'label' => __('Period', 'invoicing'), |
|
117 | + 'placeholder' => __('Select Period', 'invoicing'), |
|
118 | + 'value' => $item->get_recurring_period('edit'), |
|
119 | 119 | 'select2' => true, |
120 | 120 | 'data-allow-clear' => 'false', |
121 | 121 | 'options' => array( |
122 | - 'D' => __( 'day', 'invoicing' ), |
|
123 | - 'W' => __( 'week', 'invoicing' ), |
|
124 | - 'M' => __( 'month', 'invoicing' ), |
|
125 | - 'Y' => __( 'year', 'invoicing' ), |
|
122 | + 'D' => __('day', 'invoicing'), |
|
123 | + 'W' => __('week', 'invoicing'), |
|
124 | + 'M' => __('month', 'invoicing'), |
|
125 | + 'Y' => __('year', 'invoicing'), |
|
126 | 126 | ) |
127 | 127 | ) |
128 | 128 | ); |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | <?php |
135 | 135 | |
136 | 136 | // Dynamic pricing. |
137 | - if( $item->supports_dynamic_pricing() ) { |
|
137 | + if ($item->supports_dynamic_pricing()) { |
|
138 | 138 | |
139 | - do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item ); |
|
139 | + do_action('wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item); |
|
140 | 140 | |
141 | 141 | // NYP toggle. |
142 | 142 | echo aui()->input( |
@@ -144,31 +144,31 @@ discard block |
||
144 | 144 | 'id' => 'wpinv_name_your_price', |
145 | 145 | 'name' => 'wpinv_name_your_price', |
146 | 146 | 'type' => 'checkbox', |
147 | - 'label' => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ), |
|
147 | + 'label' => apply_filters('wpinv_name_your_price_toggle_text', __('Let customers name their price', 'invoicing')), |
|
148 | 148 | 'value' => '1', |
149 | 149 | 'checked' => $item->user_can_set_their_price(), |
150 | 150 | 'no_wrap' => true, |
151 | 151 | ) |
152 | 152 | ); |
153 | 153 | |
154 | - do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item ); |
|
154 | + do_action('wpinv_item_details_metabox_dynamic_pricing_checkbox', $item); |
|
155 | 155 | |
156 | 156 | } |
157 | 157 | |
158 | 158 | // Subscriptions. |
159 | - do_action( 'wpinv_item_details_metabox_before_subscription_checkbox', $item ); |
|
159 | + do_action('wpinv_item_details_metabox_before_subscription_checkbox', $item); |
|
160 | 160 | echo aui()->input( |
161 | 161 | array( |
162 | 162 | 'id' => 'wpinv_is_recurring', |
163 | 163 | 'name' => 'wpinv_is_recurring', |
164 | 164 | 'type' => 'checkbox', |
165 | - 'label' => apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Charge customers a recurring amount for this item', 'invoicing' ) ), |
|
165 | + 'label' => apply_filters('wpinv_is_recurring_toggle_text', __('Charge customers a recurring amount for this item', 'invoicing')), |
|
166 | 166 | 'value' => '1', |
167 | 167 | 'checked' => $item->is_recurring(), |
168 | 168 | 'no_wrap' => true, |
169 | 169 | ) |
170 | 170 | ); |
171 | - do_action( 'wpinv_item_details_metabox_subscription_checkbox', $item ); |
|
171 | + do_action('wpinv_item_details_metabox_subscription_checkbox', $item); |
|
172 | 172 | |
173 | 173 | ?> |
174 | 174 | <div class="wpinv_show_if_recurring"> |
@@ -178,30 +178,30 @@ discard block |
||
178 | 178 | </div> |
179 | 179 | </div> |
180 | 180 | <div class="col-sm-1 pt-2 pl-0"> |
181 | - <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e( 'Set the subscription price, billing interval and period.', 'invoicing' ); ?>"></span> |
|
181 | + <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e('Set the subscription price, billing interval and period.', 'invoicing'); ?>"></span> |
|
182 | 182 | </div> |
183 | 183 | </div> |
184 | - <?php do_action( 'wpinv_item_details_metabox_after_price', $item ); ?> |
|
184 | + <?php do_action('wpinv_item_details_metabox_after_price', $item); ?> |
|
185 | 185 | |
186 | - <?php if( $item->supports_dynamic_pricing() ) : ?> |
|
187 | - <?php do_action( 'wpinv_item_details_metabox_before_minimum_price', $item ); ?> |
|
186 | + <?php if ($item->supports_dynamic_pricing()) : ?> |
|
187 | + <?php do_action('wpinv_item_details_metabox_before_minimum_price', $item); ?> |
|
188 | 188 | <div class="wpinv_show_if_dynamic wpinv_minimum_price"> |
189 | 189 | |
190 | 190 | <div class="form-group row"> |
191 | 191 | <label for="wpinv_minimum_price" class="col-sm-3 col-form-label"> |
192 | - <?php _e( 'Minimum Price', 'invoicing' );?> |
|
192 | + <?php _e('Minimum Price', 'invoicing'); ?> |
|
193 | 193 | </label> |
194 | 194 | <div class="col-sm-8"> |
195 | 195 | <div class="input-group input-group-sm"> |
196 | - <?php if( 'left' == $position ) : ?> |
|
196 | + <?php if ('left' == $position) : ?> |
|
197 | 197 | <div class="input-group-prepend"> |
198 | 198 | <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
199 | 199 | </div> |
200 | 200 | <?php endif; ?> |
201 | 201 | |
202 | - <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr( $item->get_minimum_price( 'edit' ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control"> |
|
202 | + <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr($item->get_minimum_price('edit')); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control"> |
|
203 | 203 | |
204 | - <?php if( 'left' != $position ) : ?> |
|
204 | + <?php if ('left' != $position) : ?> |
|
205 | 205 | <div class="input-group-append"> |
206 | 206 | <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
207 | 207 | </div> |
@@ -210,45 +210,45 @@ discard block |
||
210 | 210 | </div> |
211 | 211 | |
212 | 212 | <div class="col-sm-1 pt-2 pl-0"> |
213 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the minimum amount that users are allowed to set', 'invoicing' ); ?>"></span> |
|
213 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the minimum amount that users are allowed to set', 'invoicing'); ?>"></span> |
|
214 | 214 | </div> |
215 | 215 | </div> |
216 | 216 | |
217 | 217 | </div> |
218 | - <?php do_action( 'wpinv_item_details_metabox_minimum_price', $item ); ?> |
|
218 | + <?php do_action('wpinv_item_details_metabox_minimum_price', $item); ?> |
|
219 | 219 | <?php endif; ?> |
220 | 220 | |
221 | - <?php do_action( 'wpinv_item_details_metabox_before_maximum_renewals', $item ); ?> |
|
221 | + <?php do_action('wpinv_item_details_metabox_before_maximum_renewals', $item); ?> |
|
222 | 222 | <div class="wpinv_show_if_recurring wpinv_maximum_renewals"> |
223 | 223 | |
224 | 224 | <div class="form-group row"> |
225 | 225 | <label for="wpinv_recurring_limit" class="col-sm-3 col-form-label"> |
226 | - <?php _e( 'Maximum Renewals', 'invoicing' );?> |
|
226 | + <?php _e('Maximum Renewals', 'invoicing'); ?> |
|
227 | 227 | </label> |
228 | 228 | <div class="col-sm-8"> |
229 | - <input type="number" value="<?php echo esc_attr( $item->get_recurring_limit( 'edit' ) ); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" /> |
|
229 | + <input type="number" value="<?php echo esc_attr($item->get_recurring_limit('edit')); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" /> |
|
230 | 230 | </div> |
231 | 231 | <div class="col-sm-1 pt-2 pl-0"> |
232 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing' ); ?>"></span> |
|
232 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing'); ?>"></span> |
|
233 | 233 | </div> |
234 | 234 | </div> |
235 | 235 | |
236 | 236 | </div> |
237 | - <?php do_action( 'wpinv_item_details_metabox_maximum_renewals', $item ); ?> |
|
237 | + <?php do_action('wpinv_item_details_metabox_maximum_renewals', $item); ?> |
|
238 | 238 | |
239 | - <?php do_action( 'wpinv_item_details_metabox_before_free_trial', $item ); ?> |
|
239 | + <?php do_action('wpinv_item_details_metabox_before_free_trial', $item); ?> |
|
240 | 240 | <div class="wpinv_show_if_recurring wpinv_free_trial"> |
241 | 241 | |
242 | 242 | <div class="form-group row"> |
243 | - <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php _e( 'Free Trial', 'invoicing' )?></label> |
|
243 | + <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php _e('Free Trial', 'invoicing')?></label> |
|
244 | 244 | |
245 | 245 | <div class="col-sm-8"> |
246 | 246 | <div class="row"> |
247 | 247 | <div class="col-sm-6"> |
248 | - <?php $value = $item->has_free_trial() ? $item->get_trial_interval( 'edit' ) : 0;?> |
|
248 | + <?php $value = $item->has_free_trial() ? $item->get_trial_interval('edit') : 0; ?> |
|
249 | 249 | |
250 | 250 | <div> |
251 | - <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr( $value ); ?>" > |
|
251 | + <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr($value); ?>" > |
|
252 | 252 | </div> |
253 | 253 | </div> |
254 | 254 | <div class="col-sm-6"> |
@@ -257,17 +257,17 @@ discard block |
||
257 | 257 | array( |
258 | 258 | 'id' => 'wpinv_trial_period', |
259 | 259 | 'name' => 'wpinv_trial_period', |
260 | - 'label' => __( 'Trial Period', 'invoicing' ), |
|
261 | - 'placeholder' => __( 'Trial Period', 'invoicing' ), |
|
262 | - 'value' => $item->get_recurring_period( 'edit' ), |
|
260 | + 'label' => __('Trial Period', 'invoicing'), |
|
261 | + 'placeholder' => __('Trial Period', 'invoicing'), |
|
262 | + 'value' => $item->get_recurring_period('edit'), |
|
263 | 263 | 'select2' => true, |
264 | 264 | 'data-allow-clear' => 'false', |
265 | 265 | 'no_wrap' => true, |
266 | 266 | 'options' => array( |
267 | - 'D' => __( 'day(s)', 'invoicing' ), |
|
268 | - 'W' => __( 'week(s)', 'invoicing' ), |
|
269 | - 'M' => __( 'month(s)', 'invoicing' ), |
|
270 | - 'Y' => __( 'year(s)', 'invoicing' ), |
|
267 | + 'D' => __('day(s)', 'invoicing'), |
|
268 | + 'W' => __('week(s)', 'invoicing'), |
|
269 | + 'M' => __('month(s)', 'invoicing'), |
|
270 | + 'Y' => __('year(s)', 'invoicing'), |
|
271 | 271 | ) |
272 | 272 | ) |
273 | 273 | ); |
@@ -278,15 +278,15 @@ discard block |
||
278 | 278 | </div> |
279 | 279 | |
280 | 280 | <div class="col-sm-1 pt-2 pl-0"> |
281 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'An optional period of time to wait before charging the first recurring payment.', 'invoicing' ); ?>"></span> |
|
281 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('An optional period of time to wait before charging the first recurring payment.', 'invoicing'); ?>"></span> |
|
282 | 282 | </div> |
283 | 283 | |
284 | 284 | </div> |
285 | 285 | |
286 | 286 | </div> |
287 | - <?php do_action( 'wpinv_item_details_metabox__free_trial', $item ); ?> |
|
287 | + <?php do_action('wpinv_item_details_metabox__free_trial', $item); ?> |
|
288 | 288 | |
289 | - <?php do_action( 'wpinv_item_details_metabox_item_details', $item ); ?> |
|
289 | + <?php do_action('wpinv_item_details_metabox_item_details', $item); ?> |
|
290 | 290 | </div> |
291 | 291 | <?php |
292 | 292 | |
@@ -297,31 +297,31 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @param int $post_id |
299 | 299 | */ |
300 | - public static function save( $post_id ) { |
|
300 | + public static function save($post_id) { |
|
301 | 301 | |
302 | 302 | // Prepare the item. |
303 | - $item = new WPInv_Item( $post_id ); |
|
303 | + $item = new WPInv_Item($post_id); |
|
304 | 304 | |
305 | 305 | // Load new data. |
306 | 306 | $item->set_props( |
307 | 307 | array( |
308 | - 'price' => isset( $_POST['wpinv_item_price'] ) ? (float) $_POST['wpinv_item_price'] : null, |
|
309 | - 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, |
|
310 | - 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, |
|
311 | - 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, |
|
312 | - 'is_dynamic_pricing' => isset( $_POST['wpinv_name_your_price'] ), |
|
313 | - 'minimum_price' => isset( $_POST['wpinv_minimum_price'] ) ? (float) $_POST['wpinv_minimum_price'] : null, |
|
314 | - 'is_recurring' => isset( $_POST['wpinv_is_recurring'] ), |
|
315 | - 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, |
|
316 | - 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : null, |
|
317 | - 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
318 | - 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, |
|
319 | - 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, |
|
320 | - 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
308 | + 'price' => isset($_POST['wpinv_item_price']) ? (float) $_POST['wpinv_item_price'] : null, |
|
309 | + 'vat_rule' => isset($_POST['wpinv_vat_rules']) ? wpinv_clean($_POST['wpinv_vat_rules']) : null, |
|
310 | + 'vat_class' => isset($_POST['wpinv_vat_class']) ? wpinv_clean($_POST['wpinv_vat_class']) : null, |
|
311 | + 'type' => isset($_POST['wpinv_item_type']) ? wpinv_clean($_POST['wpinv_item_type']) : null, |
|
312 | + 'is_dynamic_pricing' => isset($_POST['wpinv_name_your_price']), |
|
313 | + 'minimum_price' => isset($_POST['wpinv_minimum_price']) ? (float) $_POST['wpinv_minimum_price'] : null, |
|
314 | + 'is_recurring' => isset($_POST['wpinv_is_recurring']), |
|
315 | + 'recurring_period' => isset($_POST['wpinv_recurring_period']) ? wpinv_clean($_POST['wpinv_recurring_period']) : null, |
|
316 | + 'recurring_interval' => isset($_POST['wpinv_recurring_interval']) ? (int) $_POST['wpinv_recurring_interval'] : null, |
|
317 | + 'recurring_limit' => isset($_POST['wpinv_recurring_limit']) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
318 | + 'is_free_trial' => isset($_POST['wpinv_trial_interval']) ? (0 != (int) $_POST['wpinv_trial_interval']) : null, |
|
319 | + 'trial_period' => isset($_POST['wpinv_trial_period']) ? wpinv_clean($_POST['wpinv_trial_period']) : null, |
|
320 | + 'trial_interval' => isset($_POST['wpinv_trial_interval']) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
321 | 321 | ) |
322 | 322 | ); |
323 | 323 | |
324 | 324 | $item->save(); |
325 | - do_action( 'getpaid_item_metabox_save', $post_id, $item ); |
|
325 | + do_action('getpaid_item_metabox_save', $post_id, $item); |
|
326 | 326 | } |
327 | 327 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
11 | - exit; // Exit if accessed directly |
|
11 | + exit; // Exit if accessed directly |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | class GetPaid_Meta_Box_Invoice_Address { |
18 | 18 | |
19 | 19 | /** |
20 | - * Output the metabox. |
|
21 | - * |
|
22 | - * @param WP_Post $post |
|
23 | - */ |
|
20 | + * Output the metabox. |
|
21 | + * |
|
22 | + * @param WP_Post $post |
|
23 | + */ |
|
24 | 24 | public static function output( $post ) { |
25 | 25 | |
26 | 26 | // Prepare the invoice. |
@@ -300,18 +300,18 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
303 | - * Save meta box data. |
|
304 | - * |
|
305 | - * @param int $post_id |
|
306 | - */ |
|
307 | - public static function save( $post_id ) { |
|
303 | + * Save meta box data. |
|
304 | + * |
|
305 | + * @param int $post_id |
|
306 | + */ |
|
307 | + public static function save( $post_id ) { |
|
308 | 308 | |
309 | 309 | // Prepare the invoice. |
310 | 310 | $invoice = new WPInv_Invoice( $post_id ); |
311 | 311 | |
312 | 312 | // Load new data. |
313 | 313 | $invoice->set_props( |
314 | - array( |
|
314 | + array( |
|
315 | 315 | 'template' => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null, |
316 | 316 | 'email_cc' => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null, |
317 | 317 | 'disable_taxes' => isset( $_POST['disable_taxes'] ), |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | 'due_date' => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null, |
333 | 333 | 'number' => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null, |
334 | 334 | 'status' => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null, |
335 | - ) |
|
335 | + ) |
|
336 | 336 | ); |
337 | 337 | |
338 | 338 | // Recalculate totals. |
@@ -362,6 +362,6 @@ discard block |
||
362 | 362 | } |
363 | 363 | |
364 | 364 | // Fires after an invoice is saved. |
365 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
366 | - } |
|
365 | + do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
366 | + } |
|
367 | 367 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the invoice. |
27 | - $invoice = new WPInv_Invoice( $post ); |
|
27 | + $invoice = new WPInv_Invoice($post); |
|
28 | 28 | |
29 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
29 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
30 | 30 | |
31 | 31 | ?> |
32 | 32 | |
@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | <div class="col-12 col-sm-6"> |
42 | 42 | <div id="getpaid-invoice-user-id-wrapper" class="form-group"> |
43 | 43 | <div> |
44 | - <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label> |
|
44 | + <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label> |
|
45 | 45 | </div> |
46 | 46 | <?php |
47 | 47 | wpinv_dropdown_users( |
48 | 48 | array( |
49 | 49 | 'name' => 'post_author_override', |
50 | - 'selected' => $invoice->get_id() ? $invoice->get_user_id( 'edit' ) : get_current_user_id(), |
|
50 | + 'selected' => $invoice->get_id() ? $invoice->get_user_id('edit') : get_current_user_id(), |
|
51 | 51 | 'include_selected' => true, |
52 | 52 | 'show' => 'display_name_with_login', |
53 | 53 | 'orderby' => 'user_email', |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | 'type' => 'text', |
66 | 66 | 'id' => 'getpaid-invoice-new-user-email', |
67 | 67 | 'name' => 'wpinv_email', |
68 | - 'label' => __( 'Email', 'invoicing' ) . '<span class="required">*</span>', |
|
68 | + 'label' => __('Email', 'invoicing') . '<span class="required">*</span>', |
|
69 | 69 | 'label_type' => 'vertical', |
70 | 70 | 'placeholder' => '[email protected]', |
71 | 71 | 'class' => 'form-control-sm', |
@@ -75,18 +75,18 @@ discard block |
||
75 | 75 | </div> |
76 | 76 | </div> |
77 | 77 | <div class="col-12 col-sm-6 form-group mt-sm-4"> |
78 | - <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?> |
|
78 | + <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?> |
|
79 | 79 | <a id="getpaid-invoice-fill-user-details" class="button button-small button-secondary" href="javascript:void(0)"> |
80 | 80 | <i aria-hidden="true" class="fa fa-refresh"></i> |
81 | - <?php _e( 'Fill User Details', 'invoicing' );?> |
|
81 | + <?php _e('Fill User Details', 'invoicing'); ?> |
|
82 | 82 | </a> |
83 | 83 | <a id="getpaid-invoice-create-new-user-button" class="button button-small button-secondary" href="javascript:void(0)"> |
84 | 84 | <i aria-hidden="true" class="fa fa-plus"></i> |
85 | - <?php _e( 'Add New User', 'invoicing' );?> |
|
85 | + <?php _e('Add New User', 'invoicing'); ?> |
|
86 | 86 | </a> |
87 | 87 | <a id="getpaid-invoice-cancel-create-new-user" class="button button-small button-secondary d-none" href="javascript:void(0)"> |
88 | 88 | <i aria-hidden="true" class="fa fa-close"></i> |
89 | - <?php _e( 'Cancel', 'invoicing' );?> |
|
89 | + <?php _e('Cancel', 'invoicing'); ?> |
|
90 | 90 | </a> |
91 | 91 | <?php endif; ?> |
92 | 92 | </div> |
@@ -99,11 +99,11 @@ discard block |
||
99 | 99 | 'type' => 'text', |
100 | 100 | 'id' => 'wpinv_first_name', |
101 | 101 | 'name' => 'wpinv_first_name', |
102 | - 'label' => __( 'First Name', 'invoicing' ), |
|
102 | + 'label' => __('First Name', 'invoicing'), |
|
103 | 103 | 'label_type' => 'vertical', |
104 | 104 | 'placeholder' => 'Jane', |
105 | 105 | 'class' => 'form-control-sm', |
106 | - 'value' => $invoice->get_first_name( 'edit' ), |
|
106 | + 'value' => $invoice->get_first_name('edit'), |
|
107 | 107 | ) |
108 | 108 | ); |
109 | 109 | ?> |
@@ -115,11 +115,11 @@ discard block |
||
115 | 115 | 'type' => 'text', |
116 | 116 | 'id' => 'wpinv_last_name', |
117 | 117 | 'name' => 'wpinv_last_name', |
118 | - 'label' => __( 'Last Name', 'invoicing' ), |
|
118 | + 'label' => __('Last Name', 'invoicing'), |
|
119 | 119 | 'label_type' => 'vertical', |
120 | 120 | 'placeholder' => 'Doe', |
121 | 121 | 'class' => 'form-control-sm', |
122 | - 'value' => $invoice->get_last_name( 'edit' ), |
|
122 | + 'value' => $invoice->get_last_name('edit'), |
|
123 | 123 | ) |
124 | 124 | ); |
125 | 125 | ?> |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | 'type' => 'text', |
135 | 135 | 'id' => 'wpinv_company', |
136 | 136 | 'name' => 'wpinv_company', |
137 | - 'label' => __( 'Company', 'invoicing' ), |
|
137 | + 'label' => __('Company', 'invoicing'), |
|
138 | 138 | 'label_type' => 'vertical', |
139 | 139 | 'placeholder' => 'Acme Corporation', |
140 | 140 | 'class' => 'form-control-sm', |
141 | - 'value' => $invoice->get_company( 'edit' ), |
|
141 | + 'value' => $invoice->get_company('edit'), |
|
142 | 142 | ) |
143 | 143 | ); |
144 | 144 | ?> |
@@ -150,11 +150,11 @@ discard block |
||
150 | 150 | 'type' => 'text', |
151 | 151 | 'id' => 'wpinv_vat_number', |
152 | 152 | 'name' => 'wpinv_vat_number', |
153 | - 'label' => __( 'Vat Number', 'invoicing' ), |
|
153 | + 'label' => __('Vat Number', 'invoicing'), |
|
154 | 154 | 'label_type' => 'vertical', |
155 | 155 | 'placeholder' => '1234567890', |
156 | 156 | 'class' => 'form-control-sm', |
157 | - 'value' => $invoice->get_vat_number( 'edit' ), |
|
157 | + 'value' => $invoice->get_vat_number('edit'), |
|
158 | 158 | ) |
159 | 159 | ); |
160 | 160 | ?> |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | 'type' => 'text', |
170 | 170 | 'id' => 'wpinv_address', |
171 | 171 | 'name' => 'wpinv_address', |
172 | - 'label' => __( 'Address', 'invoicing' ), |
|
172 | + 'label' => __('Address', 'invoicing'), |
|
173 | 173 | 'label_type' => 'vertical', |
174 | 174 | 'placeholder' => 'Blekersdijk 295', |
175 | 175 | 'class' => 'form-control-sm', |
176 | - 'value' => $invoice->get_address( 'edit' ), |
|
176 | + 'value' => $invoice->get_address('edit'), |
|
177 | 177 | ) |
178 | 178 | ); |
179 | 179 | ?> |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | 'type' => 'text', |
186 | 186 | 'id' => 'wpinv_city', |
187 | 187 | 'name' => 'wpinv_city', |
188 | - 'label' => __( 'City', 'invoicing' ), |
|
188 | + 'label' => __('City', 'invoicing'), |
|
189 | 189 | 'label_type' => 'vertical', |
190 | 190 | 'placeholder' => 'Dolembreux', |
191 | 191 | 'class' => 'form-control-sm', |
192 | - 'value' => $invoice->get_vat_number( 'edit' ), |
|
192 | + 'value' => $invoice->get_vat_number('edit'), |
|
193 | 193 | ) |
194 | 194 | ); |
195 | 195 | ?> |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | array( |
204 | 204 | 'id' => 'wpinv_country', |
205 | 205 | 'name' => 'wpinv_country', |
206 | - 'label' => __( 'Country', 'invoicing' ), |
|
206 | + 'label' => __('Country', 'invoicing'), |
|
207 | 207 | 'label_type' => 'vertical', |
208 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
208 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
209 | 209 | 'class' => 'form-control-sm', |
210 | - 'value' => $invoice->get_country( 'edit' ), |
|
210 | + 'value' => $invoice->get_country('edit'), |
|
211 | 211 | 'options' => wpinv_get_country_list(), |
212 | 212 | 'data-allow-clear' => 'false', |
213 | 213 | 'select2' => true, |
@@ -218,20 +218,20 @@ discard block |
||
218 | 218 | <div class="col-12 col-sm-6"> |
219 | 219 | <?php |
220 | 220 | |
221 | - $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) ); |
|
221 | + $states = wpinv_get_country_states($invoice->get_country('edit')); |
|
222 | 222 | |
223 | - if ( empty( $states ) ) { |
|
223 | + if (empty($states)) { |
|
224 | 224 | |
225 | 225 | echo aui()->input( |
226 | 226 | array( |
227 | 227 | 'type' => 'text', |
228 | 228 | 'id' => 'wpinv_state', |
229 | 229 | 'name' => 'wpinv_state', |
230 | - 'label' => __( 'State', 'invoicing' ), |
|
230 | + 'label' => __('State', 'invoicing'), |
|
231 | 231 | 'label_type' => 'vertical', |
232 | 232 | 'placeholder' => 'Liège', |
233 | 233 | 'class' => 'form-control-sm', |
234 | - 'value' => $invoice->get_state( 'edit' ), |
|
234 | + 'value' => $invoice->get_state('edit'), |
|
235 | 235 | ) |
236 | 236 | ); |
237 | 237 | |
@@ -241,11 +241,11 @@ discard block |
||
241 | 241 | array( |
242 | 242 | 'id' => 'wpinv_state', |
243 | 243 | 'name' => 'wpinv_state', |
244 | - 'label' => __( 'State', 'invoicing' ), |
|
244 | + 'label' => __('State', 'invoicing'), |
|
245 | 245 | 'label_type' => 'vertical', |
246 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
246 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
247 | 247 | 'class' => 'form-control-sm', |
248 | - 'value' => $invoice->get_state( 'edit' ), |
|
248 | + 'value' => $invoice->get_state('edit'), |
|
249 | 249 | 'options' => $states, |
250 | 250 | 'data-allow-clear' => 'false', |
251 | 251 | 'select2' => true, |
@@ -266,11 +266,11 @@ discard block |
||
266 | 266 | 'type' => 'text', |
267 | 267 | 'id' => 'wpinv_zip', |
268 | 268 | 'name' => 'wpinv_zip', |
269 | - 'label' => __( 'Zip / Postal Code', 'invoicing' ), |
|
269 | + 'label' => __('Zip / Postal Code', 'invoicing'), |
|
270 | 270 | 'label_type' => 'vertical', |
271 | 271 | 'placeholder' => '4140', |
272 | 272 | 'class' => 'form-control-sm', |
273 | - 'value' => $invoice->get_zip( 'edit' ), |
|
273 | + 'value' => $invoice->get_zip('edit'), |
|
274 | 274 | ) |
275 | 275 | ); |
276 | 276 | ?> |
@@ -282,11 +282,11 @@ discard block |
||
282 | 282 | 'type' => 'text', |
283 | 283 | 'id' => 'wpinv_phone', |
284 | 284 | 'name' => 'wpinv_phone', |
285 | - 'label' => __( 'Phone', 'invoicing' ), |
|
285 | + 'label' => __('Phone', 'invoicing'), |
|
286 | 286 | 'label_type' => 'vertical', |
287 | 287 | 'placeholder' => '0493 18 45822', |
288 | 288 | 'class' => 'form-control-sm', |
289 | - 'value' => $invoice->get_phone( 'edit' ), |
|
289 | + 'value' => $invoice->get_phone('edit'), |
|
290 | 290 | ) |
291 | 291 | ); |
292 | 292 | ?> |
@@ -302,34 +302,34 @@ discard block |
||
302 | 302 | * |
303 | 303 | * @param int $post_id |
304 | 304 | */ |
305 | - public static function save( $post_id ) { |
|
305 | + public static function save($post_id) { |
|
306 | 306 | |
307 | 307 | // Prepare the invoice. |
308 | - $invoice = new WPInv_Invoice( $post_id ); |
|
308 | + $invoice = new WPInv_Invoice($post_id); |
|
309 | 309 | |
310 | 310 | // Load new data. |
311 | 311 | $invoice->set_props( |
312 | 312 | array( |
313 | - 'template' => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null, |
|
314 | - 'email_cc' => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null, |
|
315 | - 'disable_taxes' => isset( $_POST['disable_taxes'] ), |
|
316 | - 'currency' => isset( $_POST['wpinv_currency'] ) ? wpinv_clean( $_POST['wpinv_currency'] ) : null, |
|
317 | - 'gateway' => isset( $_POST['wpinv_gateway'] ) ? wpinv_clean( $_POST['wpinv_gateway'] ) : null, |
|
318 | - 'address' => isset( $_POST['wpinv_address'] ) ? wpinv_clean( $_POST['wpinv_address'] ) : null, |
|
319 | - 'vat_number' => isset( $_POST['wpinv_vat_number'] ) ? wpinv_clean( $_POST['wpinv_vat_number'] ) : null, |
|
320 | - 'company' => isset( $_POST['wpinv_company'] ) ? wpinv_clean( $_POST['wpinv_company'] ) : null, |
|
321 | - 'zip' => isset( $_POST['wpinv_zip'] ) ? wpinv_clean( $_POST['wpinv_zip'] ) : null, |
|
322 | - 'state' => isset( $_POST['wpinv_state'] ) ? wpinv_clean( $_POST['wpinv_state'] ) : null, |
|
323 | - 'city' => isset( $_POST['wpinv_city'] ) ? wpinv_clean( $_POST['wpinv_city'] ) : null, |
|
324 | - 'country' => isset( $_POST['wpinv_country'] ) ? wpinv_clean( $_POST['wpinv_country'] ) : null, |
|
325 | - 'phone' => isset( $_POST['wpinv_phone'] ) ? wpinv_clean( $_POST['wpinv_phone'] ) : null, |
|
326 | - 'first_name' => isset( $_POST['wpinv_first_name'] ) ? wpinv_clean( $_POST['wpinv_first_name'] ) : null, |
|
327 | - 'last_name' => isset( $_POST['wpinv_last_name'] ) ? wpinv_clean( $_POST['wpinv_last_name'] ) : null, |
|
328 | - 'author' => isset( $_POST['post_author_override'] ) ? wpinv_clean( $_POST['post_author_override'] ) : null, |
|
329 | - 'date_created' => isset( $_POST['date_created'] ) ? wpinv_clean( $_POST['date_created'] ) : null, |
|
330 | - 'due_date' => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null, |
|
331 | - 'number' => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null, |
|
332 | - 'status' => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null, |
|
313 | + 'template' => isset($_POST['wpinv_template']) ? wpinv_clean($_POST['wpinv_template']) : null, |
|
314 | + 'email_cc' => isset($_POST['wpinv_cc']) ? wpinv_clean($_POST['wpinv_cc']) : null, |
|
315 | + 'disable_taxes' => isset($_POST['disable_taxes']), |
|
316 | + 'currency' => isset($_POST['wpinv_currency']) ? wpinv_clean($_POST['wpinv_currency']) : null, |
|
317 | + 'gateway' => isset($_POST['wpinv_gateway']) ? wpinv_clean($_POST['wpinv_gateway']) : null, |
|
318 | + 'address' => isset($_POST['wpinv_address']) ? wpinv_clean($_POST['wpinv_address']) : null, |
|
319 | + 'vat_number' => isset($_POST['wpinv_vat_number']) ? wpinv_clean($_POST['wpinv_vat_number']) : null, |
|
320 | + 'company' => isset($_POST['wpinv_company']) ? wpinv_clean($_POST['wpinv_company']) : null, |
|
321 | + 'zip' => isset($_POST['wpinv_zip']) ? wpinv_clean($_POST['wpinv_zip']) : null, |
|
322 | + 'state' => isset($_POST['wpinv_state']) ? wpinv_clean($_POST['wpinv_state']) : null, |
|
323 | + 'city' => isset($_POST['wpinv_city']) ? wpinv_clean($_POST['wpinv_city']) : null, |
|
324 | + 'country' => isset($_POST['wpinv_country']) ? wpinv_clean($_POST['wpinv_country']) : null, |
|
325 | + 'phone' => isset($_POST['wpinv_phone']) ? wpinv_clean($_POST['wpinv_phone']) : null, |
|
326 | + 'first_name' => isset($_POST['wpinv_first_name']) ? wpinv_clean($_POST['wpinv_first_name']) : null, |
|
327 | + 'last_name' => isset($_POST['wpinv_last_name']) ? wpinv_clean($_POST['wpinv_last_name']) : null, |
|
328 | + 'author' => isset($_POST['post_author_override']) ? wpinv_clean($_POST['post_author_override']) : null, |
|
329 | + 'date_created' => isset($_POST['date_created']) ? wpinv_clean($_POST['date_created']) : null, |
|
330 | + 'due_date' => isset($_POST['wpinv_due_date']) ? wpinv_clean($_POST['wpinv_due_date']) : null, |
|
331 | + 'number' => isset($_POST['wpinv_number']) ? wpinv_clean($_POST['wpinv_number']) : null, |
|
332 | + 'status' => isset($_POST['wpinv_status']) ? wpinv_clean($_POST['wpinv_status']) : null, |
|
333 | 333 | ) |
334 | 334 | ); |
335 | 335 | |
@@ -337,17 +337,17 @@ discard block |
||
337 | 337 | $invoice->recalculate_total(); |
338 | 338 | |
339 | 339 | // If we're creating a new user... |
340 | - if ( ! empty( $_POST['wpinv_new_user'] ) && is_email( $_POST['wpinv_email'] ) ) { |
|
340 | + if (!empty($_POST['wpinv_new_user']) && is_email($_POST['wpinv_email'])) { |
|
341 | 341 | |
342 | 342 | // Attempt to create the user. |
343 | - $user = wpinv_create_user( sanitize_email( $_POST['wpinv_email'] ) ); |
|
343 | + $user = wpinv_create_user(sanitize_email($_POST['wpinv_email'])); |
|
344 | 344 | |
345 | 345 | |
346 | 346 | // If successful, update the invoice author. |
347 | - if ( is_numeric( $user ) ) { |
|
348 | - $invoice->set_author( $user ); |
|
347 | + if (is_numeric($user)) { |
|
348 | + $invoice->set_author($user); |
|
349 | 349 | } else { |
350 | - wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ ); |
|
350 | + wpinv_error_log($user->get_error_message(), __('Invoice add new user', 'invoicing'), __FILE__, __LINE__); |
|
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
@@ -355,11 +355,11 @@ discard block |
||
355 | 355 | $invoice->save(); |
356 | 356 | |
357 | 357 | // (Maybe) send new user notification. |
358 | - if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', true ) ) { |
|
359 | - wp_send_new_user_notifications( $user, 'user' ); |
|
358 | + if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', true)) { |
|
359 | + wp_send_new_user_notifications($user, 'user'); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | // Fires after an invoice is saved. |
363 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
363 | + do_action('wpinv_invoice_metabox_saved', $invoice); |
|
364 | 364 | } |
365 | 365 | } |
@@ -7,10 +7,10 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -$invoice = new WPInv_Invoice( $invoice ); |
|
13 | -$address_row = wpinv_get_invoice_address_markup( $invoice->get_user_info() ); |
|
12 | +$invoice = new WPInv_Invoice($invoice); |
|
13 | +$address_row = wpinv_get_invoice_address_markup($invoice->get_user_info()); |
|
14 | 14 | $phone = $invoice->get_phone(); |
15 | 15 | $email = $invoice->get_email(); |
16 | 16 | |
@@ -21,36 +21,36 @@ discard block |
||
21 | 21 | |
22 | 22 | |
23 | 23 | <div class="invoice-billing-address-label col-2"> |
24 | - <strong><?php _e( 'To:', 'invoicing' ) ?></strong> |
|
24 | + <strong><?php _e('To:', 'invoicing') ?></strong> |
|
25 | 25 | </div> |
26 | 26 | |
27 | 27 | |
28 | 28 | <div class="invoice-billing-address-value col-10"> |
29 | 29 | |
30 | - <?php do_action( 'getpaid_billing_address_top' ); ?> |
|
30 | + <?php do_action('getpaid_billing_address_top'); ?> |
|
31 | 31 | |
32 | - <?php if ( ! empty( $address_row ) ) : ?> |
|
32 | + <?php if (!empty($address_row)) : ?> |
|
33 | 33 | <div class="billing-address"> |
34 | 34 | <?php echo $address_row; ?> |
35 | 35 | </div> |
36 | 36 | <?php endif; ?> |
37 | 37 | |
38 | 38 | |
39 | - <?php if ( ! empty( $phone ) ) : ?> |
|
39 | + <?php if (!empty($phone)) : ?> |
|
40 | 40 | <div class="billing-phone"> |
41 | - <?php echo wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ); ?> |
|
41 | + <?php echo wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)); ?> |
|
42 | 42 | </div> |
43 | 43 | <?php endif; ?> |
44 | 44 | |
45 | 45 | |
46 | - <?php if ( ! empty( $email ) ) : ?> |
|
46 | + <?php if (!empty($email)) : ?> |
|
47 | 47 | <div class="billing-email"> |
48 | - <?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), sanitize_email( $email ) ); ?> |
|
48 | + <?php echo wp_sprintf(__('Email: %s', 'invoicing'), sanitize_email($email)); ?> |
|
49 | 49 | </div> |
50 | 50 | <?php endif; ?> |
51 | 51 | |
52 | 52 | |
53 | - <?php do_action( 'getpaid_billing_address_bottom' ); ?> |
|
53 | + <?php do_action('getpaid_billing_address_bottom'); ?> |
|
54 | 54 | |
55 | 55 | </div> |
56 | 56 |
@@ -7,26 +7,26 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
14 | - <?php do_action( 'getpaid_before_invoice_details_main', $invoice ); ?> |
|
14 | + <?php do_action('getpaid_before_invoice_details_main', $invoice); ?> |
|
15 | 15 | |
16 | 16 | <div class="getpaid-invoice-details mt-3 mb-3"> |
17 | 17 | <div class="row"> |
18 | 18 | |
19 | 19 | <div class="col-12 col-sm-6"> |
20 | - <?php do_action( 'getpaid_invoice_details_left', $invoice ); ?> |
|
20 | + <?php do_action('getpaid_invoice_details_left', $invoice); ?> |
|
21 | 21 | </div> |
22 | 22 | |
23 | 23 | <div class="col-12 col-sm-6"> |
24 | - <?php do_action( 'getpaid_invoice_details_right', $invoice ); ?> |
|
24 | + <?php do_action('getpaid_invoice_details_right', $invoice); ?> |
|
25 | 25 | </div> |
26 | 26 | |
27 | 27 | </div> |
28 | 28 | </div> |
29 | 29 | |
30 | - <?php do_action( 'getpaid_after_invoice_details_main', $invoice ); ?> |
|
30 | + <?php do_action('getpaid_after_invoice_details_main', $invoice); ?> |
|
31 | 31 | |
32 | 32 | <?php |
@@ -7,13 +7,13 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -if ( empty( $text ) ) { |
|
13 | - $text = __( 'Total to pay:', 'invoicing' ); |
|
12 | +if (empty($text)) { |
|
13 | + $text = __('Total to pay:', 'invoicing'); |
|
14 | 14 | } |
15 | 15 | ?> |
16 | 16 | <div class="form-group mt-4"> |
17 | - <strong><?php echo sanitize_text_field( $text ); ?></strong> |
|
17 | + <strong><?php echo sanitize_text_field($text); ?></strong> |
|
18 | 18 | <span class="getpaid-checkout-total-payable"></span> |
19 | 19 | </div> |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @deprecated |
247 | 247 | */ |
248 | 248 | function wpinv_get_payment_key( $invoice = 0 ) { |
249 | - $invoice = new WPInv_Invoice( $invoice ); |
|
249 | + $invoice = new WPInv_Invoice( $invoice ); |
|
250 | 250 | return $invoice->get_key(); |
251 | 251 | } |
252 | 252 | |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @deprecated |
425 | 425 | */ |
426 | 426 | function wpinv_get_checkout_session() { |
427 | - return false; |
|
427 | + return false; |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | /** |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * @deprecated |
@@ -19,48 +19,48 @@ discard block |
||
19 | 19 | * @deprecated |
20 | 20 | */ |
21 | 21 | function wpinv_get_invoice_cart() { |
22 | - return wpinv_get_invoice( getpaid_get_current_invoice_id() ); |
|
22 | + return wpinv_get_invoice(getpaid_get_current_invoice_id()); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @deprecated |
27 | 27 | */ |
28 | -function wpinv_get_invoice_description( $invoice ) { |
|
29 | - $invoice = new WPInv_Invoice( $invoice ); |
|
28 | +function wpinv_get_invoice_description($invoice) { |
|
29 | + $invoice = new WPInv_Invoice($invoice); |
|
30 | 30 | return $invoice->get_description(); |
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
34 | 34 | * @deprecated |
35 | 35 | */ |
36 | -function wpinv_get_invoice_currency_code( $invoice ) { |
|
37 | - $invoice = new WPInv_Invoice( $invoice ); |
|
36 | +function wpinv_get_invoice_currency_code($invoice) { |
|
37 | + $invoice = new WPInv_Invoice($invoice); |
|
38 | 38 | return $invoice->get_currency(); |
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @deprecated |
43 | 43 | */ |
44 | -function wpinv_get_payment_user_email( $invoice ) { |
|
45 | - $invoice = new WPInv_Invoice( $invoice ); |
|
44 | +function wpinv_get_payment_user_email($invoice) { |
|
45 | + $invoice = new WPInv_Invoice($invoice); |
|
46 | 46 | return $invoice->get_email(); |
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @deprecated |
51 | 51 | */ |
52 | -function wpinv_get_user_id( $invoice ) { |
|
53 | - $invoice = new WPInv_Invoice( $invoice ); |
|
52 | +function wpinv_get_user_id($invoice) { |
|
53 | + $invoice = new WPInv_Invoice($invoice); |
|
54 | 54 | return $invoice->get_user_id(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @deprecated |
59 | 59 | */ |
60 | -function wpinv_get_invoice_status( $invoice, $return_label = false ) { |
|
61 | - $invoice = new WPInv_Invoice( $invoice ); |
|
60 | +function wpinv_get_invoice_status($invoice, $return_label = false) { |
|
61 | + $invoice = new WPInv_Invoice($invoice); |
|
62 | 62 | |
63 | - if ( $return_label ) { |
|
63 | + if ($return_label) { |
|
64 | 64 | return $invoice->get_status_nicename(); |
65 | 65 | } |
66 | 66 | |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | /** |
71 | 71 | * @deprecated |
72 | 72 | */ |
73 | -function wpinv_get_payment_gateway( $invoice, $return_label = false ) { |
|
74 | - $invoice = new WPInv_Invoice( $invoice ); |
|
73 | +function wpinv_get_payment_gateway($invoice, $return_label = false) { |
|
74 | + $invoice = new WPInv_Invoice($invoice); |
|
75 | 75 | |
76 | - if ( $return_label ) { |
|
76 | + if ($return_label) { |
|
77 | 77 | return $invoice->get_gateway_title(); |
78 | 78 | } |
79 | 79 | |
@@ -83,75 +83,75 @@ discard block |
||
83 | 83 | /** |
84 | 84 | * @deprecated |
85 | 85 | */ |
86 | -function wpinv_get_payment_gateway_name( $invoice ) { |
|
87 | - return wpinv_get_payment_gateway( $invoice, true ); |
|
86 | +function wpinv_get_payment_gateway_name($invoice) { |
|
87 | + return wpinv_get_payment_gateway($invoice, true); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
91 | 91 | * @deprecated |
92 | 92 | */ |
93 | -function wpinv_get_payment_transaction_id( $invoice ) { |
|
94 | - $invoice = new WPInv_Invoice( $invoice ); |
|
93 | +function wpinv_get_payment_transaction_id($invoice) { |
|
94 | + $invoice = new WPInv_Invoice($invoice); |
|
95 | 95 | return $invoice->get_transaction_id(); |
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | 99 | * @deprecated |
100 | 100 | */ |
101 | -function wpinv_get_invoice_meta( $invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true ) { |
|
102 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
103 | - return $invoice->get_meta( $meta_key, $single ); |
|
101 | +function wpinv_get_invoice_meta($invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true) { |
|
102 | + $invoice = new WPInv_Invoice($invoice_id); |
|
103 | + return $invoice->get_meta($meta_key, $single); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
107 | 107 | * @deprecated |
108 | 108 | */ |
109 | -function wpinv_update_invoice_meta( $invoice_id = 0, $meta_key = '', $meta_value = '' ) { |
|
110 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
111 | - return $invoice->update_meta_data( $meta_key, $meta_value ); |
|
109 | +function wpinv_update_invoice_meta($invoice_id = 0, $meta_key = '', $meta_value = '') { |
|
110 | + $invoice = new WPInv_Invoice($invoice_id); |
|
111 | + return $invoice->update_meta_data($meta_key, $meta_value); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
115 | 115 | * @deprecated |
116 | 116 | */ |
117 | -function wpinv_get_items( $invoice = 0 ) { |
|
118 | - $invoice = new WPInv_Invoice( $invoice ); |
|
117 | +function wpinv_get_items($invoice = 0) { |
|
118 | + $invoice = new WPInv_Invoice($invoice); |
|
119 | 119 | return $invoice->get_items(); |
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
123 | 123 | * @deprecated |
124 | 124 | */ |
125 | -function wpinv_get_fees( $invoice = 0 ) { |
|
126 | - $invoice = new WPInv_Invoice( $invoice ); |
|
125 | +function wpinv_get_fees($invoice = 0) { |
|
126 | + $invoice = new WPInv_Invoice($invoice); |
|
127 | 127 | return $invoice->get_fees(); |
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | 131 | * @deprecated |
132 | 132 | */ |
133 | -function wpinv_get_invoice_ip( $invoice ) { |
|
134 | - $invoice = new WPInv_Invoice( $invoice ); |
|
133 | +function wpinv_get_invoice_ip($invoice) { |
|
134 | + $invoice = new WPInv_Invoice($invoice); |
|
135 | 135 | return $invoice->get_ip(); |
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
139 | 139 | * @deprecated |
140 | 140 | */ |
141 | -function wpinv_get_invoice_user_info( $invoice ) { |
|
142 | - $invoice = new WPInv_Invoice( $invoice ); |
|
141 | +function wpinv_get_invoice_user_info($invoice) { |
|
142 | + $invoice = new WPInv_Invoice($invoice); |
|
143 | 143 | return $invoice->get_user_info(); |
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
147 | 147 | * @deprecated |
148 | 148 | */ |
149 | -function wpinv_subtotal( $invoice = 0, $currency = false ) { |
|
150 | - $invoice = new WPInv_Invoice( $invoice ); |
|
149 | +function wpinv_subtotal($invoice = 0, $currency = false) { |
|
150 | + $invoice = new WPInv_Invoice($invoice); |
|
151 | 151 | $subtotal = $invoice->get_subtotal(); |
152 | 152 | |
153 | - if ( $currency ) { |
|
154 | - return wpinv_price( wpinv_format_amount( $subtotal ), $invoice->get_currency() ); |
|
153 | + if ($currency) { |
|
154 | + return wpinv_price(wpinv_format_amount($subtotal), $invoice->get_currency()); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | return $subtotal; |
@@ -160,12 +160,12 @@ discard block |
||
160 | 160 | /** |
161 | 161 | * @deprecated |
162 | 162 | */ |
163 | -function wpinv_tax( $invoice = 0, $currency = false ) { |
|
164 | - $invoice = new WPInv_Invoice( $invoice ); |
|
163 | +function wpinv_tax($invoice = 0, $currency = false) { |
|
164 | + $invoice = new WPInv_Invoice($invoice); |
|
165 | 165 | $tax = $invoice->get_total_tax(); |
166 | 166 | |
167 | - if ( $currency ) { |
|
168 | - return wpinv_price( wpinv_format_amount( $tax ), $invoice->get_currency() ); |
|
167 | + if ($currency) { |
|
168 | + return wpinv_price(wpinv_format_amount($tax), $invoice->get_currency()); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | return $tax; |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | /** |
175 | 175 | * @deprecated |
176 | 176 | */ |
177 | -function wpinv_discount( $invoice = 0, $currency = false, $deprecated ) { |
|
178 | - $invoice = new WPInv_Invoice( $invoice ); |
|
177 | +function wpinv_discount($invoice = 0, $currency = false, $deprecated) { |
|
178 | + $invoice = new WPInv_Invoice($invoice); |
|
179 | 179 | $discount = $invoice->get_total_discount(); |
180 | 180 | |
181 | - if ( $currency ) { |
|
182 | - return wpinv_price( wpinv_format_amount( $discount ), $invoice->get_currency() ); |
|
181 | + if ($currency) { |
|
182 | + return wpinv_price(wpinv_format_amount($discount), $invoice->get_currency()); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | return $discount; |
@@ -188,20 +188,20 @@ discard block |
||
188 | 188 | /** |
189 | 189 | * @deprecated |
190 | 190 | */ |
191 | -function wpinv_discount_code( $invoice = 0 ) { |
|
192 | - $invoice = new WPInv_Invoice( $invoice ); |
|
191 | +function wpinv_discount_code($invoice = 0) { |
|
192 | + $invoice = new WPInv_Invoice($invoice); |
|
193 | 193 | return $invoice->get_discount_code(); |
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
197 | 197 | * @deprecated |
198 | 198 | */ |
199 | -function wpinv_payment_total( $invoice = 0, $currency = false ) { |
|
200 | - $invoice = new WPInv_Invoice( $invoice ); |
|
199 | +function wpinv_payment_total($invoice = 0, $currency = false) { |
|
200 | + $invoice = new WPInv_Invoice($invoice); |
|
201 | 201 | $total = $invoice->get_total(); |
202 | 202 | |
203 | - if ( $currency ) { |
|
204 | - return wpinv_price( wpinv_format_amount( $total ), $invoice->get_currency() ); |
|
203 | + if ($currency) { |
|
204 | + return wpinv_price(wpinv_format_amount($total), $invoice->get_currency()); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | return $total; |
@@ -210,51 +210,51 @@ discard block |
||
210 | 210 | /** |
211 | 211 | * @deprecated |
212 | 212 | */ |
213 | -function wpinv_get_date_created( $invoice = 0, $format = '' ) { |
|
214 | - $invoice = new WPInv_Invoice( $invoice ); |
|
213 | +function wpinv_get_date_created($invoice = 0, $format = '') { |
|
214 | + $invoice = new WPInv_Invoice($invoice); |
|
215 | 215 | |
216 | - $format = ! empty( $format ) ? $format : get_option( 'date_format' ); |
|
216 | + $format = !empty($format) ? $format : get_option('date_format'); |
|
217 | 217 | $date_created = $invoice->get_created_date(); |
218 | 218 | |
219 | - return empty( $date_created ) ? date_i18n( $format, strtotime( $date_created ) ) : ''; |
|
219 | + return empty($date_created) ? date_i18n($format, strtotime($date_created)) : ''; |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
223 | 223 | * @deprecated |
224 | 224 | */ |
225 | -function wpinv_get_invoice_date( $invoice = 0, $format = '' ) { |
|
226 | - wpinv_get_date_created( $invoice, $format ); |
|
225 | +function wpinv_get_invoice_date($invoice = 0, $format = '') { |
|
226 | + wpinv_get_date_created($invoice, $format); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
230 | 230 | * @deprecated |
231 | 231 | */ |
232 | -function wpinv_get_invoice_vat_number( $invoice = 0 ) { |
|
233 | - $invoice = new WPInv_Invoice( $invoice ); |
|
232 | +function wpinv_get_invoice_vat_number($invoice = 0) { |
|
233 | + $invoice = new WPInv_Invoice($invoice); |
|
234 | 234 | return $invoice->get_vat_number(); |
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
238 | 238 | * @deprecated |
239 | 239 | */ |
240 | -function wpinv_insert_payment_note( $invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false ) { |
|
241 | - $invoice = new WPInv_Invoice( $invoice ); |
|
242 | - return $invoice->add_note( $note, $user_type, $added_by_user, $system ); |
|
240 | +function wpinv_insert_payment_note($invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false) { |
|
241 | + $invoice = new WPInv_Invoice($invoice); |
|
242 | + return $invoice->add_note($note, $user_type, $added_by_user, $system); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
246 | 246 | * @deprecated |
247 | 247 | */ |
248 | -function wpinv_get_payment_key( $invoice = 0 ) { |
|
249 | - $invoice = new WPInv_Invoice( $invoice ); |
|
248 | +function wpinv_get_payment_key($invoice = 0) { |
|
249 | + $invoice = new WPInv_Invoice($invoice); |
|
250 | 250 | return $invoice->get_key(); |
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
254 | 254 | * @deprecated |
255 | 255 | */ |
256 | -function wpinv_get_invoice_number( $invoice = 0 ) { |
|
257 | - $invoice = new WPInv_Invoice( $invoice ); |
|
256 | +function wpinv_get_invoice_number($invoice = 0) { |
|
257 | + $invoice = new WPInv_Invoice($invoice); |
|
258 | 258 | return $invoice->get_number(); |
259 | 259 | } |
260 | 260 | |
@@ -401,9 +401,9 @@ discard block |
||
401 | 401 | /** |
402 | 402 | * @deprecated |
403 | 403 | */ |
404 | -function wpinv_update_payment_status( $invoice, $new_status = 'publish' ) { |
|
405 | - $invoice = new WPInv_Invoice( $invoice ); |
|
406 | - return $invoice->update_status( $new_status ); |
|
404 | +function wpinv_update_payment_status($invoice, $new_status = 'publish') { |
|
405 | + $invoice = new WPInv_Invoice($invoice); |
|
406 | + return $invoice->update_status($new_status); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -456,22 +456,22 @@ discard block |
||
456 | 456 | /** |
457 | 457 | * @deprecated |
458 | 458 | */ |
459 | -function wpinv_set_payment_transaction_id( $invoice_id = 0, $transaction_id = '' ) { |
|
459 | +function wpinv_set_payment_transaction_id($invoice_id = 0, $transaction_id = '') { |
|
460 | 460 | |
461 | 461 | // Fetch the invoice. |
462 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
462 | + $invoice = new WPInv_Invoice($invoice_id); |
|
463 | 463 | |
464 | - if ( 0 == $invoice->get_id() ) { |
|
464 | + if (0 == $invoice->get_id()) { |
|
465 | 465 | return false; |
466 | 466 | } |
467 | 467 | |
468 | 468 | // Prepare the transaction id. |
469 | - if ( empty( $transaction_id ) ) { |
|
469 | + if (empty($transaction_id)) { |
|
470 | 470 | $transaction_id = $invoice_id; |
471 | 471 | } |
472 | 472 | |
473 | 473 | // Set the transaction id; |
474 | - $invoice->set_transaction_id( apply_filters( 'wpinv_set_payment_transaction_id', $transaction_id, $invoice ) ); |
|
474 | + $invoice->set_transaction_id(apply_filters('wpinv_set_payment_transaction_id', $transaction_id, $invoice)); |
|
475 | 475 | |
476 | 476 | // Save the invoice. |
477 | 477 | return $invoice->save(); |
@@ -484,12 +484,12 @@ discard block |
||
484 | 484 | * @param WPInv_Invoice $invoice |
485 | 485 | * @param string $gateway |
486 | 486 | */ |
487 | -function wpinv_send_to_gateway( $gateway, $invoice ) { |
|
487 | +function wpinv_send_to_gateway($gateway, $invoice) { |
|
488 | 488 | |
489 | 489 | $payment_data = array( |
490 | 490 | 'invoice_id' => $invoice->get_id(), |
491 | 491 | 'items' => $invoice->get_cart_details(), |
492 | - 'cart_discounts' => array( $invoice->get_discount_code() ), |
|
492 | + 'cart_discounts' => array($invoice->get_discount_code()), |
|
493 | 493 | 'fees' => $invoice->get_total_fees(), |
494 | 494 | 'subtotal' => $invoice->get_subtotal(), |
495 | 495 | 'discount' => $invoice->get_total_discount(), |
@@ -497,16 +497,16 @@ discard block |
||
497 | 497 | 'price' => $invoice->get_total(), |
498 | 498 | 'invoice_key' => $invoice->get_key(), |
499 | 499 | 'user_email' => $invoice->get_email(), |
500 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
500 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
501 | 501 | 'user_info' => $invoice->get_user_info(), |
502 | - 'post_data' => stripslashes_deep( $_POST ), |
|
502 | + 'post_data' => stripslashes_deep($_POST), |
|
503 | 503 | 'cart_details' => $invoice->get_cart_details(), |
504 | 504 | 'gateway' => $gateway, |
505 | 505 | 'card_info' => array(), |
506 | 506 | 'gateway_nonce' => wp_create_nonce('wpi-gateway'), |
507 | 507 | ); |
508 | 508 | |
509 | - do_action( 'wpinv_gateway_' . $gateway, $payment_data ); |
|
509 | + do_action('wpinv_gateway_' . $gateway, $payment_data); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | /** |
@@ -519,10 +519,10 @@ discard block |
||
519 | 519 | /** |
520 | 520 | * @deprecated |
521 | 521 | */ |
522 | -function wpinv_die( $message = '', $title = '', $status = 400 ) { |
|
523 | - add_filter( 'wp_die_ajax_handler', 'wpinv_die_handler', 10, 3 ); |
|
524 | - add_filter( 'wp_die_handler', 'wpinv_die_handler', 10, 3 ); |
|
525 | - wp_die( $message, $title, array( 'response' => $status )); |
|
522 | +function wpinv_die($message = '', $title = '', $status = 400) { |
|
523 | + add_filter('wp_die_ajax_handler', 'wpinv_die_handler', 10, 3); |
|
524 | + add_filter('wp_die_handler', 'wpinv_die_handler', 10, 3); |
|
525 | + wp_die($message, $title, array('response' => $status)); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
@@ -640,14 +640,14 @@ discard block |
||
640 | 640 | /** |
641 | 641 | * @deprecated |
642 | 642 | */ |
643 | -function wpinv_invoice_status_label( $status, $status_display = '' ) { |
|
644 | - return empty( $status_display ) ? sanitize_text_field( $status ) : sanitize_text_field( $status_display ); |
|
643 | +function wpinv_invoice_status_label($status, $status_display = '') { |
|
644 | + return empty($status_display) ? sanitize_text_field($status) : sanitize_text_field($status_display); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | /** |
648 | 648 | * @deprecated |
649 | 649 | */ |
650 | -function wpinv_clean_invoice_number( $number ) { |
|
650 | +function wpinv_clean_invoice_number($number) { |
|
651 | 651 | return $number; |
652 | 652 | } |
653 | 653 | |
@@ -852,12 +852,12 @@ discard block |
||
852 | 852 | /** |
853 | 853 | * @deprecated |
854 | 854 | */ |
855 | -function wpinv_item_show_price( $item_id = 0, $echo = true ) { |
|
855 | +function wpinv_item_show_price($item_id = 0, $echo = true) { |
|
856 | 856 | |
857 | - if ( $echo ) { |
|
858 | - echo wpinv_item_price( $item_id ); |
|
857 | + if ($echo) { |
|
858 | + echo wpinv_item_price($item_id); |
|
859 | 859 | } else { |
860 | - return wpinv_item_price( $item_id ); |
|
860 | + return wpinv_item_price($item_id); |
|
861 | 861 | } |
862 | 862 | |
863 | 863 | } |
@@ -67,7 +67,7 @@ |
||
67 | 67 | * Checks if the current user cna view an invoice receipt. |
68 | 68 | */ |
69 | 69 | function wpinv_can_view_receipt( $invoice ) { |
70 | - return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice ); |
|
70 | + return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice ); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Retrieves the current invoice. |
@@ -14,15 +14,15 @@ discard block |
||
14 | 14 | function getpaid_get_current_invoice_id() { |
15 | 15 | |
16 | 16 | // Ensure that we have an invoice key. |
17 | - if ( empty( $_GET['invoice_key'] ) ) { |
|
17 | + if (empty($_GET['invoice_key'])) { |
|
18 | 18 | return 0; |
19 | 19 | } |
20 | 20 | |
21 | 21 | // Retrieve an invoice using the key. |
22 | - $invoice = new WPInv_Invoice( $_GET['invoice_key'] ); |
|
22 | + $invoice = new WPInv_Invoice($_GET['invoice_key']); |
|
23 | 23 | |
24 | 24 | // Compare the invoice key and the parsed key. |
25 | - if ( $invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key'] ) { |
|
25 | + if ($invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key']) { |
|
26 | 26 | return $invoice->get_id(); |
27 | 27 | } |
28 | 28 | |
@@ -32,42 +32,42 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * Checks if the current user cna view an invoice. |
34 | 34 | */ |
35 | -function wpinv_user_can_view_invoice( $invoice ) { |
|
36 | - $invoice = new WPInv_Invoice( $invoice ); |
|
35 | +function wpinv_user_can_view_invoice($invoice) { |
|
36 | + $invoice = new WPInv_Invoice($invoice); |
|
37 | 37 | |
38 | 38 | // Abort if the invoice does not exist. |
39 | - if ( 0 == $invoice->get_id() ) { |
|
39 | + if (0 == $invoice->get_id()) { |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | 43 | // Don't allow trash, draft status |
44 | - if ( $invoice->is_draft() ) { |
|
44 | + if ($invoice->is_draft()) { |
|
45 | 45 | return false; |
46 | 46 | } |
47 | 47 | |
48 | 48 | // If users are not required to login to check out, compare the invoice keys. |
49 | - if ( ! wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && trim( $_GET['invoice_key'] ) == $invoice->get_key() ) { |
|
49 | + if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && trim($_GET['invoice_key']) == $invoice->get_key()) { |
|
50 | 50 | return true; |
51 | 51 | } |
52 | 52 | |
53 | 53 | // Always enable for admins.. |
54 | - if ( wpinv_current_user_can_manage_invoicing() || current_user_can( 'view_invoices', $invoice->get_id() ) ) { // Admin user |
|
54 | + if (wpinv_current_user_can_manage_invoicing() || current_user_can('view_invoices', $invoice->get_id())) { // Admin user |
|
55 | 55 | return true; |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Else, ensure that this is their invoice. |
59 | - if ( is_user_logged_in() && $invoice->get_user_id() == get_current_user_id() ) { |
|
59 | + if (is_user_logged_in() && $invoice->get_user_id() == get_current_user_id()) { |
|
60 | 60 | return true; |
61 | 61 | } |
62 | 62 | |
63 | - return apply_filters( 'wpinv_current_user_can_view_invoice', false, $invoice ); |
|
63 | + return apply_filters('wpinv_current_user_can_view_invoice', false, $invoice); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Checks if the current user cna view an invoice receipt. |
68 | 68 | */ |
69 | -function wpinv_can_view_receipt( $invoice ) { |
|
70 | - return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice ); |
|
69 | +function wpinv_can_view_receipt($invoice) { |
|
70 | + return (bool) apply_filters('wpinv_can_view_receipt', wpinv_user_can_view_invoice($invoice), $invoice); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | */ |
78 | 78 | function getpaid_get_invoice_post_types() { |
79 | 79 | $post_types = array( |
80 | - 'wpi_quote' => __( 'Quote', 'invoicing' ), |
|
81 | - 'wpi_invoice' => __( 'Invoice', 'invoicing' ), |
|
80 | + 'wpi_quote' => __('Quote', 'invoicing'), |
|
81 | + 'wpi_invoice' => __('Invoice', 'invoicing'), |
|
82 | 82 | ); |
83 | 83 | |
84 | - return apply_filters( 'getpaid_invoice_post_types', $post_types ); |
|
84 | + return apply_filters('getpaid_invoice_post_types', $post_types); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @param string $post_type The post type to check for. |
92 | 92 | */ |
93 | -function getpaid_is_invoice_post_type( $post_type ) { |
|
94 | - return ! empty( $post_type ) && array_key_exists( $post_type, getpaid_get_invoice_post_types() ); |
|
93 | +function getpaid_is_invoice_post_type($post_type) { |
|
94 | + return !empty($post_type) && array_key_exists($post_type, getpaid_get_invoice_post_types()); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
102 | 102 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
103 | 103 | */ |
104 | -function wpinv_create_invoice( $data = array(), $deprecated = null, $wp_error = false ) { |
|
105 | - $data[ 'invoice_id' ] = 0; |
|
106 | - return wpinv_insert_invoice( $data, $wp_error ); |
|
104 | +function wpinv_create_invoice($data = array(), $deprecated = null, $wp_error = false) { |
|
105 | + $data['invoice_id'] = 0; |
|
106 | + return wpinv_insert_invoice($data, $wp_error); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -113,36 +113,36 @@ discard block |
||
113 | 113 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
114 | 114 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
115 | 115 | */ |
116 | -function wpinv_update_invoice( $data = array(), $wp_error = false ) { |
|
116 | +function wpinv_update_invoice($data = array(), $wp_error = false) { |
|
117 | 117 | |
118 | 118 | // Backwards compatibility. |
119 | - if ( ! empty( $data['ID'] ) ) { |
|
119 | + if (!empty($data['ID'])) { |
|
120 | 120 | $data['invoice_id'] = $data['ID']; |
121 | 121 | } |
122 | 122 | |
123 | 123 | // Do we have an invoice id? |
124 | - if ( empty( $data['invoice_id'] ) ) { |
|
125 | - return $wp_error ? new WP_Error( 'invalid_invoice_id', __( 'Invalid invoice ID.', 'invoicing' ) ) : 0; |
|
124 | + if (empty($data['invoice_id'])) { |
|
125 | + return $wp_error ? new WP_Error('invalid_invoice_id', __('Invalid invoice ID.', 'invoicing')) : 0; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | // Retrieve the invoice. |
129 | - $invoice = wpinv_get_invoice( $data['invoice_id'] ); |
|
129 | + $invoice = wpinv_get_invoice($data['invoice_id']); |
|
130 | 130 | |
131 | 131 | // And abort if it does not exist. |
132 | - if ( empty( $invoice ) ) { |
|
133 | - return $wp_error ? new WP_Error( 'missing_invoice', __( 'Invoice not found.', 'invoicing' ) ) : 0; |
|
132 | + if (empty($invoice)) { |
|
133 | + return $wp_error ? new WP_Error('missing_invoice', __('Invoice not found.', 'invoicing')) : 0; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | // Do not update totals for paid / refunded invoices. |
137 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
137 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
138 | 138 | |
139 | - if ( ! empty( $data['items'] ) || ! empty( $data['cart_details'] ) ) { |
|
140 | - return $wp_error ? new WP_Error( 'paid_invoice', __( 'You can not update cart items for invoices that have already been paid for.', 'invoicing' ) ) : 0; |
|
139 | + if (!empty($data['items']) || !empty($data['cart_details'])) { |
|
140 | + return $wp_error ? new WP_Error('paid_invoice', __('You can not update cart items for invoices that have already been paid for.', 'invoicing')) : 0; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | } |
144 | 144 | |
145 | - return wpinv_insert_invoice( $data, $wp_error ); |
|
145 | + return wpinv_insert_invoice($data, $wp_error); |
|
146 | 146 | |
147 | 147 | } |
148 | 148 | |
@@ -153,34 +153,34 @@ discard block |
||
153 | 153 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
154 | 154 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
155 | 155 | */ |
156 | -function wpinv_insert_invoice( $data = array(), $wp_error = false ) { |
|
156 | +function wpinv_insert_invoice($data = array(), $wp_error = false) { |
|
157 | 157 | |
158 | 158 | // Ensure that we have invoice data. |
159 | - if ( empty( $data ) ) { |
|
159 | + if (empty($data)) { |
|
160 | 160 | return false; |
161 | 161 | } |
162 | 162 | |
163 | 163 | // The invoice id will be provided when updating an invoice. |
164 | - $data['invoice_id'] = ! empty( $data['invoice_id'] ) ? (int) $data['invoice_id'] : false; |
|
164 | + $data['invoice_id'] = !empty($data['invoice_id']) ? (int) $data['invoice_id'] : false; |
|
165 | 165 | |
166 | 166 | // Retrieve the invoice. |
167 | - $invoice = new WPInv_Invoice( $data['invoice_id'] ); |
|
167 | + $invoice = new WPInv_Invoice($data['invoice_id']); |
|
168 | 168 | |
169 | 169 | // Do we have an error? |
170 | - if ( ! empty( $invoice->last_error ) ) { |
|
171 | - return $wp_error ? new WP_Error( 'invalid_invoice_id', $invoice->last_error ) : 0; |
|
170 | + if (!empty($invoice->last_error)) { |
|
171 | + return $wp_error ? new WP_Error('invalid_invoice_id', $invoice->last_error) : 0; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // Backwards compatibility (billing address). |
175 | - if ( ! empty( $data['user_info'] ) ) { |
|
175 | + if (!empty($data['user_info'])) { |
|
176 | 176 | |
177 | - foreach ( $data['user_info'] as $key => $value ) { |
|
177 | + foreach ($data['user_info'] as $key => $value) { |
|
178 | 178 | |
179 | - if ( $key == 'discounts' ) { |
|
179 | + if ($key == 'discounts') { |
|
180 | 180 | $value = (array) $value; |
181 | - $data[ 'discount_code' ] = empty( $value ) ? null : $value[0]; |
|
181 | + $data['discount_code'] = empty($value) ? null : $value[0]; |
|
182 | 182 | } else { |
183 | - $data[ $key ] = $value; |
|
183 | + $data[$key] = $value; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | } |
@@ -188,30 +188,30 @@ discard block |
||
188 | 188 | } |
189 | 189 | |
190 | 190 | // Backwards compatibility. |
191 | - if ( ! empty( $data['payment_details'] ) ) { |
|
191 | + if (!empty($data['payment_details'])) { |
|
192 | 192 | |
193 | - foreach ( $data['payment_details'] as $key => $value ) { |
|
194 | - $data[ $key ] = $value; |
|
193 | + foreach ($data['payment_details'] as $key => $value) { |
|
194 | + $data[$key] = $value; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | } |
198 | 198 | |
199 | 199 | // Set up the owner of the invoice. |
200 | - $user_id = ! empty( $data['user_id'] ) ? wpinv_clean( $data['user_id'] ) : get_current_user_id(); |
|
200 | + $user_id = !empty($data['user_id']) ? wpinv_clean($data['user_id']) : get_current_user_id(); |
|
201 | 201 | |
202 | 202 | // Make sure the user exists. |
203 | - if ( ! get_userdata( $user_id ) ) { |
|
204 | - return $wp_error ? new WP_Error( 'wpinv_invalid_user', __( 'There is no user with that ID.', 'invoicing' ) ) : 0; |
|
203 | + if (!get_userdata($user_id)) { |
|
204 | + return $wp_error ? new WP_Error('wpinv_invalid_user', __('There is no user with that ID.', 'invoicing')) : 0; |
|
205 | 205 | } |
206 | 206 | |
207 | - $address = wpinv_get_user_address( $user_id ); |
|
207 | + $address = wpinv_get_user_address($user_id); |
|
208 | 208 | |
209 | - foreach ( $address as $key => $value ) { |
|
209 | + foreach ($address as $key => $value) { |
|
210 | 210 | |
211 | - if ( $value == '' ) { |
|
212 | - $address[ $key ] = null; |
|
211 | + if ($value == '') { |
|
212 | + $address[$key] = null; |
|
213 | 213 | } else { |
214 | - $address[ $key ] = wpinv_clean( $value ); |
|
214 | + $address[$key] = wpinv_clean($value); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | } |
@@ -222,103 +222,103 @@ discard block |
||
222 | 222 | array( |
223 | 223 | |
224 | 224 | // Basic info. |
225 | - 'template' => isset( $data['template'] ) ? wpinv_clean( $data['template'] ) : null, |
|
226 | - 'email_cc' => isset( $data['email_cc'] ) ? wpinv_clean( $data['email_cc'] ) : null, |
|
227 | - 'date_created' => isset( $data['created_date'] ) ? wpinv_clean( $data['created_date'] ) : null, |
|
228 | - 'due_date' => isset( $data['due_date'] ) ? wpinv_clean( $data['due_date'] ) : null, |
|
229 | - 'date_completed' => isset( $data['date_completed'] ) ? wpinv_clean( $data['date_completed'] ) : null, |
|
230 | - 'number' => isset( $data['number'] ) ? wpinv_clean( $data['number'] ) : null, |
|
231 | - 'key' => isset( $data['key'] ) ? wpinv_clean( $data['key'] ) : null, |
|
232 | - 'status' => isset( $data['status'] ) ? wpinv_clean( $data['status'] ) : null, |
|
233 | - 'post_type' => isset( $data['post_type'] ) ? wpinv_clean( $data['post_type'] ) : null, |
|
234 | - 'user_ip' => isset( $data['ip'] ) ? wpinv_clean( $data['ip'] ) : wpinv_get_ip(), |
|
235 | - 'parent_id' => isset( $data['parent'] ) ? intval( $data['parent'] ) : null, |
|
236 | - 'mode' => isset( $data['mode'] ) ? wpinv_clean( $data['mode'] ) : null, |
|
237 | - 'description' => isset( $data['description'] ) ? wp_kses_post( $data['description'] ) : null, |
|
225 | + 'template' => isset($data['template']) ? wpinv_clean($data['template']) : null, |
|
226 | + 'email_cc' => isset($data['email_cc']) ? wpinv_clean($data['email_cc']) : null, |
|
227 | + 'date_created' => isset($data['created_date']) ? wpinv_clean($data['created_date']) : null, |
|
228 | + 'due_date' => isset($data['due_date']) ? wpinv_clean($data['due_date']) : null, |
|
229 | + 'date_completed' => isset($data['date_completed']) ? wpinv_clean($data['date_completed']) : null, |
|
230 | + 'number' => isset($data['number']) ? wpinv_clean($data['number']) : null, |
|
231 | + 'key' => isset($data['key']) ? wpinv_clean($data['key']) : null, |
|
232 | + 'status' => isset($data['status']) ? wpinv_clean($data['status']) : null, |
|
233 | + 'post_type' => isset($data['post_type']) ? wpinv_clean($data['post_type']) : null, |
|
234 | + 'user_ip' => isset($data['ip']) ? wpinv_clean($data['ip']) : wpinv_get_ip(), |
|
235 | + 'parent_id' => isset($data['parent']) ? intval($data['parent']) : null, |
|
236 | + 'mode' => isset($data['mode']) ? wpinv_clean($data['mode']) : null, |
|
237 | + 'description' => isset($data['description']) ? wp_kses_post($data['description']) : null, |
|
238 | 238 | |
239 | 239 | // Payment info. |
240 | - 'disable_taxes' => ! empty( $data['disable_taxes'] ), |
|
241 | - 'currency' => isset( $data['currency'] ) ? wpinv_clean( $data['currency'] ) : wpinv_get_currency(), |
|
242 | - 'gateway' => isset( $data['gateway'] ) ? wpinv_clean( $data['gateway'] ) : null, |
|
243 | - 'transaction_id' => isset( $data['transaction_id'] ) ? wpinv_clean( $data['transaction_id'] ) : null, |
|
244 | - 'discount_code' => isset( $data['discount_code'] ) ? wpinv_clean( $data['discount_code'] ) : null, |
|
245 | - 'payment_form' => isset( $data['payment_form'] ) ? intval( $data['payment_form'] ) : null, |
|
246 | - 'submission_id' => isset( $data['submission_id'] ) ? wpinv_clean( $data['submission_id'] ) : null, |
|
247 | - 'subscription_id' => isset( $data['subscription_id'] ) ? wpinv_clean( $data['subscription_id'] ) : null, |
|
248 | - 'is_viewed' => isset( $data['is_viewed'] ) ? wpinv_clean( $data['is_viewed'] ) : null, |
|
249 | - 'fees' => isset( $data['fees'] ) ? wpinv_clean( $data['fees'] ) : null, |
|
250 | - 'discounts' => isset( $data['discounts'] ) ? wpinv_clean( $data['discounts'] ) : null, |
|
251 | - 'taxes' => isset( $data['taxes'] ) ? wpinv_clean( $data['taxes'] ) : null, |
|
240 | + 'disable_taxes' => !empty($data['disable_taxes']), |
|
241 | + 'currency' => isset($data['currency']) ? wpinv_clean($data['currency']) : wpinv_get_currency(), |
|
242 | + 'gateway' => isset($data['gateway']) ? wpinv_clean($data['gateway']) : null, |
|
243 | + 'transaction_id' => isset($data['transaction_id']) ? wpinv_clean($data['transaction_id']) : null, |
|
244 | + 'discount_code' => isset($data['discount_code']) ? wpinv_clean($data['discount_code']) : null, |
|
245 | + 'payment_form' => isset($data['payment_form']) ? intval($data['payment_form']) : null, |
|
246 | + 'submission_id' => isset($data['submission_id']) ? wpinv_clean($data['submission_id']) : null, |
|
247 | + 'subscription_id' => isset($data['subscription_id']) ? wpinv_clean($data['subscription_id']) : null, |
|
248 | + 'is_viewed' => isset($data['is_viewed']) ? wpinv_clean($data['is_viewed']) : null, |
|
249 | + 'fees' => isset($data['fees']) ? wpinv_clean($data['fees']) : null, |
|
250 | + 'discounts' => isset($data['discounts']) ? wpinv_clean($data['discounts']) : null, |
|
251 | + 'taxes' => isset($data['taxes']) ? wpinv_clean($data['taxes']) : null, |
|
252 | 252 | |
253 | 253 | |
254 | 254 | // Billing details. |
255 | 255 | 'user_id' => $data['user_id'], |
256 | - 'first_name' => isset( $data['first_name'] ) ? wpinv_clean( $data['first_name'] ) : $address['first_name'], |
|
257 | - 'last_name' => isset( $data['last_name'] ) ? wpinv_clean( $data['last_name'] ) : $address['last_name'], |
|
258 | - 'address' => isset( $data['address'] ) ? wpinv_clean( $data['address'] ) : $address['address'] , |
|
259 | - 'vat_number' => isset( $data['vat_number'] ) ? wpinv_clean( $data['vat_number'] ) : $address['vat_number'], |
|
260 | - 'company' => isset( $data['company'] ) ? wpinv_clean( $data['company'] ) : $address['company'], |
|
261 | - 'zip' => isset( $data['zip'] ) ? wpinv_clean( $data['zip'] ) : $address['zip'], |
|
262 | - 'state' => isset( $data['state'] ) ? wpinv_clean( $data['state'] ) : $address['state'], |
|
263 | - 'city' => isset( $data['city'] ) ? wpinv_clean( $data['city'] ) : $address['city'], |
|
264 | - 'country' => isset( $data['country'] ) ? wpinv_clean( $data['country'] ) : $address['country'], |
|
265 | - 'phone' => isset( $data['phone'] ) ? wpinv_clean( $data['phone'] ) : $address['phone'], |
|
266 | - 'address_confirmed' => ! empty( $data['address_confirmed'] ), |
|
256 | + 'first_name' => isset($data['first_name']) ? wpinv_clean($data['first_name']) : $address['first_name'], |
|
257 | + 'last_name' => isset($data['last_name']) ? wpinv_clean($data['last_name']) : $address['last_name'], |
|
258 | + 'address' => isset($data['address']) ? wpinv_clean($data['address']) : $address['address'], |
|
259 | + 'vat_number' => isset($data['vat_number']) ? wpinv_clean($data['vat_number']) : $address['vat_number'], |
|
260 | + 'company' => isset($data['company']) ? wpinv_clean($data['company']) : $address['company'], |
|
261 | + 'zip' => isset($data['zip']) ? wpinv_clean($data['zip']) : $address['zip'], |
|
262 | + 'state' => isset($data['state']) ? wpinv_clean($data['state']) : $address['state'], |
|
263 | + 'city' => isset($data['city']) ? wpinv_clean($data['city']) : $address['city'], |
|
264 | + 'country' => isset($data['country']) ? wpinv_clean($data['country']) : $address['country'], |
|
265 | + 'phone' => isset($data['phone']) ? wpinv_clean($data['phone']) : $address['phone'], |
|
266 | + 'address_confirmed' => !empty($data['address_confirmed']), |
|
267 | 267 | |
268 | 268 | ) |
269 | 269 | |
270 | 270 | ); |
271 | 271 | |
272 | 272 | // Backwards compatibililty. |
273 | - if ( ! empty( $data['cart_details'] ) && is_array( $data['cart_details'] ) ) { |
|
273 | + if (!empty($data['cart_details']) && is_array($data['cart_details'])) { |
|
274 | 274 | $data['items'] = array(); |
275 | 275 | |
276 | - foreach( $data['cart_details'] as $_item ) { |
|
276 | + foreach ($data['cart_details'] as $_item) { |
|
277 | 277 | |
278 | 278 | // Ensure that we have an item id. |
279 | - if ( empty( $_item['id'] ) ) { |
|
279 | + if (empty($_item['id'])) { |
|
280 | 280 | continue; |
281 | 281 | } |
282 | 282 | |
283 | 283 | // Retrieve the item. |
284 | - $item = new GetPaid_Form_Item( $_item['id'] ); |
|
284 | + $item = new GetPaid_Form_Item($_item['id']); |
|
285 | 285 | |
286 | 286 | // Ensure that it is purchasable. |
287 | - if ( ! $item->can_purchase() ) { |
|
287 | + if (!$item->can_purchase()) { |
|
288 | 288 | continue; |
289 | 289 | } |
290 | 290 | |
291 | 291 | // Set quantity. |
292 | - if ( ! empty( $_item['quantity'] ) && is_numeric( $_item['quantity'] ) ) { |
|
293 | - $item->set_quantity( $_item['quantity'] ); |
|
292 | + if (!empty($_item['quantity']) && is_numeric($_item['quantity'])) { |
|
293 | + $item->set_quantity($_item['quantity']); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | // Set price. |
297 | - if ( isset( $_item['item_price'] ) ) { |
|
298 | - $item->set_price( $_item['item_price'] ); |
|
297 | + if (isset($_item['item_price'])) { |
|
298 | + $item->set_price($_item['item_price']); |
|
299 | 299 | } |
300 | 300 | |
301 | - if ( isset( $_item['custom_price'] ) ) { |
|
302 | - $item->set_price( $_item['custom_price'] ); |
|
301 | + if (isset($_item['custom_price'])) { |
|
302 | + $item->set_price($_item['custom_price']); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | // Set name. |
306 | - if ( ! empty( $_item['name'] ) ) { |
|
307 | - $item->set_name( $_item['name'] ); |
|
306 | + if (!empty($_item['name'])) { |
|
307 | + $item->set_name($_item['name']); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | // Set description. |
311 | - if ( isset( $_item['description'] ) ) { |
|
312 | - $item->set_custom_description( $_item['description'] ); |
|
311 | + if (isset($_item['description'])) { |
|
312 | + $item->set_custom_description($_item['description']); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | // Set meta. |
316 | - if ( isset( $_item['meta'] ) && is_array( $_item['meta'] ) ) { |
|
316 | + if (isset($_item['meta']) && is_array($_item['meta'])) { |
|
317 | 317 | |
318 | - $item->set_item_meta( $_item['meta'] ); |
|
318 | + $item->set_item_meta($_item['meta']); |
|
319 | 319 | |
320 | - if ( isset( $_item['meta']['description'] ) ) { |
|
321 | - $item->set_custom_description( $_item['meta']['description'] ); |
|
320 | + if (isset($_item['meta']['description'])) { |
|
321 | + $item->set_custom_description($_item['meta']['description']); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | } |
@@ -329,14 +329,14 @@ discard block |
||
329 | 329 | } |
330 | 330 | |
331 | 331 | // Add invoice items. |
332 | - if ( ! empty( $data['items'] ) && is_array( $data['items'] ) ) { |
|
332 | + if (!empty($data['items']) && is_array($data['items'])) { |
|
333 | 333 | |
334 | - $invoice->set_items( array() ); |
|
334 | + $invoice->set_items(array()); |
|
335 | 335 | |
336 | - foreach ( $data['items'] as $item ) { |
|
336 | + foreach ($data['items'] as $item) { |
|
337 | 337 | |
338 | - if ( is_object( $item ) && is_a( $item, 'GetPaid_Form_Item' ) && $item->can_purchase() ) { |
|
339 | - $invoice->add_item( $item ); |
|
338 | + if (is_object($item) && is_a($item, 'GetPaid_Form_Item') && $item->can_purchase()) { |
|
339 | + $invoice->add_item($item); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | } |
@@ -347,30 +347,30 @@ discard block |
||
347 | 347 | $invoice->recalculate_total(); |
348 | 348 | $invoice->save(); |
349 | 349 | |
350 | - if ( ! $invoice->get_id() ) { |
|
351 | - return $wp_error ? new WP_Error( 'wpinv_insert_invoice_error', __( 'An error occured when saving your invoice.', 'invoicing' ) ) : 0; |
|
350 | + if (!$invoice->get_id()) { |
|
351 | + return $wp_error ? new WP_Error('wpinv_insert_invoice_error', __('An error occured when saving your invoice.', 'invoicing')) : 0; |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | // Add private note. |
355 | - if ( ! empty( $data['private_note'] ) ) { |
|
356 | - $invoice->add_note( $data['private_note'] ); |
|
355 | + if (!empty($data['private_note'])) { |
|
356 | + $invoice->add_note($data['private_note']); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | // User notes. |
360 | - if ( !empty( $data['user_note'] ) ) { |
|
361 | - $invoice->add_note( $data['user_note'], true ); |
|
360 | + if (!empty($data['user_note'])) { |
|
361 | + $invoice->add_note($data['user_note'], true); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | // Created via. |
365 | - if ( isset( $data['created_via'] ) ) { |
|
366 | - update_post_meta( $invoice->get_id(), 'wpinv_created_via', $data['created_via'] ); |
|
365 | + if (isset($data['created_via'])) { |
|
366 | + update_post_meta($invoice->get_id(), 'wpinv_created_via', $data['created_via']); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | // Backwards compatiblity. |
370 | - if ( $invoice->is_quote() ) { |
|
370 | + if ($invoice->is_quote()) { |
|
371 | 371 | |
372 | - if ( isset( $data['valid_until'] ) ) { |
|
373 | - update_post_meta( $invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until'] ); |
|
372 | + if (isset($data['valid_until'])) { |
|
373 | + update_post_meta($invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until']); |
|
374 | 374 | } |
375 | 375 | return $invoice; |
376 | 376 | |
@@ -385,18 +385,18 @@ discard block |
||
385 | 385 | * @param $bool $deprecated |
386 | 386 | * @return WPInv_Invoice|null |
387 | 387 | */ |
388 | -function wpinv_get_invoice( $invoice = 0, $deprecated = false ) { |
|
388 | +function wpinv_get_invoice($invoice = 0, $deprecated = false) { |
|
389 | 389 | |
390 | 390 | // If we are retrieving the invoice from the cart... |
391 | - if ( $deprecated && empty( $invoice ) ) { |
|
391 | + if ($deprecated && empty($invoice)) { |
|
392 | 392 | $invoice = (int) getpaid_get_current_invoice_id(); |
393 | 393 | } |
394 | 394 | |
395 | 395 | // Retrieve the invoice. |
396 | - $invoice = new WPInv_Invoice( $invoice ); |
|
396 | + $invoice = new WPInv_Invoice($invoice); |
|
397 | 397 | |
398 | 398 | // Check if it exists. |
399 | - if ( $invoice->get_id() != 0 ) { |
|
399 | + if ($invoice->get_id() != 0) { |
|
400 | 400 | return $invoice; |
401 | 401 | } |
402 | 402 | |
@@ -409,15 +409,15 @@ discard block |
||
409 | 409 | * @param array $args Args to search for. |
410 | 410 | * @return WPInv_Invoice[]|int[]|object |
411 | 411 | */ |
412 | -function wpinv_get_invoices( $args ) { |
|
412 | +function wpinv_get_invoices($args) { |
|
413 | 413 | |
414 | 414 | // Prepare args. |
415 | 415 | $args = wp_parse_args( |
416 | 416 | $args, |
417 | 417 | array( |
418 | - 'status' => array_keys( wpinv_get_invoice_statuses() ), |
|
418 | + 'status' => array_keys(wpinv_get_invoice_statuses()), |
|
419 | 419 | 'type' => 'wpi_invoice', |
420 | - 'limit' => get_option( 'posts_per_page' ), |
|
420 | + 'limit' => get_option('posts_per_page'), |
|
421 | 421 | 'return' => 'objects', |
422 | 422 | ) |
423 | 423 | ); |
@@ -435,24 +435,24 @@ discard block |
||
435 | 435 | 'post__in' => 'include', |
436 | 436 | ); |
437 | 437 | |
438 | - foreach ( $map_legacy as $to => $from ) { |
|
439 | - if ( isset( $args[ $from ] ) ) { |
|
440 | - $args[ $to ] = $args[ $from ]; |
|
441 | - unset( $args[ $from ] ); |
|
438 | + foreach ($map_legacy as $to => $from) { |
|
439 | + if (isset($args[$from])) { |
|
440 | + $args[$to] = $args[$from]; |
|
441 | + unset($args[$from]); |
|
442 | 442 | } |
443 | 443 | } |
444 | 444 | |
445 | 445 | // Backwards compatibility. |
446 | - if ( ! empty( $args['email'] ) && empty( $args['user'] ) ) { |
|
446 | + if (!empty($args['email']) && empty($args['user'])) { |
|
447 | 447 | $args['user'] = $args['email']; |
448 | - unset( $args['email'] ); |
|
448 | + unset($args['email']); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | // Handle cases where the user is set as an email. |
452 | - if ( ! empty( $args['author'] ) && is_email( $args['author'] ) ) { |
|
453 | - $user = get_user_by( 'email', $args['user'] ); |
|
452 | + if (!empty($args['author']) && is_email($args['author'])) { |
|
453 | + $user = get_user_by('email', $args['user']); |
|
454 | 454 | |
455 | - if ( $user ) { |
|
455 | + if ($user) { |
|
456 | 456 | $args['author'] = $user->user_email; |
457 | 457 | } |
458 | 458 | |
@@ -463,31 +463,31 @@ discard block |
||
463 | 463 | |
464 | 464 | // Show all posts. |
465 | 465 | $paginate = true; |
466 | - if ( isset( $args['paginate'] ) ) { |
|
466 | + if (isset($args['paginate'])) { |
|
467 | 467 | |
468 | 468 | $paginate = $args['paginate']; |
469 | - $args['no_found_rows'] = empty( $args['paginate'] ); |
|
470 | - unset( $args['paginate'] ); |
|
469 | + $args['no_found_rows'] = empty($args['paginate']); |
|
470 | + unset($args['paginate']); |
|
471 | 471 | |
472 | 472 | } |
473 | 473 | |
474 | 474 | // Whether to return objects or fields. |
475 | 475 | $return = $args['return']; |
476 | - unset( $args['return'] ); |
|
476 | + unset($args['return']); |
|
477 | 477 | |
478 | 478 | // Get invoices. |
479 | - $invoices = new WP_Query( apply_filters( 'wpinv_get_invoices_args', $args ) ); |
|
479 | + $invoices = new WP_Query(apply_filters('wpinv_get_invoices_args', $args)); |
|
480 | 480 | |
481 | 481 | // Prepare the results. |
482 | - if ( 'objects' === $return ) { |
|
483 | - $results = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
484 | - } elseif ( 'self' === $return ) { |
|
482 | + if ('objects' === $return) { |
|
483 | + $results = array_map('wpinv_get_invoice', $invoices->posts); |
|
484 | + } elseif ('self' === $return) { |
|
485 | 485 | return $invoices; |
486 | 486 | } else { |
487 | 487 | $results = $invoices->posts; |
488 | 488 | } |
489 | 489 | |
490 | - if ( $paginate ) { |
|
490 | + if ($paginate) { |
|
491 | 491 | return (object) array( |
492 | 492 | 'invoices' => $results, |
493 | 493 | 'total' => $invoices->found_posts, |
@@ -505,8 +505,8 @@ discard block |
||
505 | 505 | * @param string $transaction_id The transaction id to check. |
506 | 506 | * @return int Invoice id on success or 0 on failure |
507 | 507 | */ |
508 | -function wpinv_get_id_by_transaction_id( $transaction_id ) { |
|
509 | - return WPInv_Invoice::get_invoice_id_by_field( $transaction_id, 'transaction_id' ); |
|
508 | +function wpinv_get_id_by_transaction_id($transaction_id) { |
|
509 | + return WPInv_Invoice::get_invoice_id_by_field($transaction_id, 'transaction_id'); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | /** |
@@ -515,8 +515,8 @@ discard block |
||
515 | 515 | * @param string $invoice_number The invoice number to check. |
516 | 516 | * @return int Invoice id on success or 0 on failure |
517 | 517 | */ |
518 | -function wpinv_get_id_by_invoice_number( $invoice_number ) { |
|
519 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_number, 'number' ); |
|
518 | +function wpinv_get_id_by_invoice_number($invoice_number) { |
|
519 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_number, 'number'); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | /** |
@@ -525,8 +525,8 @@ discard block |
||
525 | 525 | * @param string $invoice_key The invoice key to check. |
526 | 526 | * @return int Invoice id on success or 0 on failure |
527 | 527 | */ |
528 | -function wpinv_get_invoice_id_by_key( $invoice_key ) { |
|
529 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_key, 'key' ); |
|
528 | +function wpinv_get_invoice_id_by_key($invoice_key) { |
|
529 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_key, 'key'); |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | /** |
@@ -536,19 +536,19 @@ discard block |
||
536 | 536 | * @param string $type Optionally filter by type i.e customer|system |
537 | 537 | * @return array|null |
538 | 538 | */ |
539 | -function wpinv_get_invoice_notes( $invoice = 0, $type = '' ) { |
|
539 | +function wpinv_get_invoice_notes($invoice = 0, $type = '') { |
|
540 | 540 | |
541 | 541 | // Prepare the invoice. |
542 | - $invoice = wpinv_get_invoice( $invoice ); |
|
543 | - if ( empty( $invoice ) ) { |
|
542 | + $invoice = wpinv_get_invoice($invoice); |
|
543 | + if (empty($invoice)) { |
|
544 | 544 | return NULL; |
545 | 545 | } |
546 | 546 | |
547 | 547 | // Fetch notes. |
548 | - $notes = getpaid_notes()->get_invoice_notes( $invoice->get_id(), $type ); |
|
548 | + $notes = getpaid_notes()->get_invoice_notes($invoice->get_id(), $type); |
|
549 | 549 | |
550 | 550 | // Filter the notes. |
551 | - return apply_filters( 'wpinv_invoice_notes', $notes, $invoice->get_id(), $type ); |
|
551 | + return apply_filters('wpinv_invoice_notes', $notes, $invoice->get_id(), $type); |
|
552 | 552 | } |
553 | 553 | |
554 | 554 | /** |
@@ -556,10 +556,10 @@ discard block |
||
556 | 556 | * |
557 | 557 | * @param string $post_type |
558 | 558 | */ |
559 | -function wpinv_get_user_invoices_columns( $post_type = 'wpi_invoice' ) { |
|
559 | +function wpinv_get_user_invoices_columns($post_type = 'wpi_invoice') { |
|
560 | 560 | |
561 | - $label = getpaid_get_post_type_label( $post_type, false ); |
|
562 | - $label = empty( $label ) ? __( 'Invoice', 'invoicing' ) : sanitize_text_field( $label ); |
|
561 | + $label = getpaid_get_post_type_label($post_type, false); |
|
562 | + $label = empty($label) ? __('Invoice', 'invoicing') : sanitize_text_field($label); |
|
563 | 563 | $columns = array( |
564 | 564 | |
565 | 565 | 'invoice-number' => array( |
@@ -568,22 +568,22 @@ discard block |
||
568 | 568 | ), |
569 | 569 | |
570 | 570 | 'created-date' => array( |
571 | - 'title' => __( 'Created Date', 'invoicing' ), |
|
571 | + 'title' => __('Created Date', 'invoicing'), |
|
572 | 572 | 'class' => 'text-left' |
573 | 573 | ), |
574 | 574 | |
575 | 575 | 'payment-date' => array( |
576 | - 'title' => __( 'Payment Date', 'invoicing' ), |
|
576 | + 'title' => __('Payment Date', 'invoicing'), |
|
577 | 577 | 'class' => 'text-left' |
578 | 578 | ), |
579 | 579 | |
580 | 580 | 'invoice-status' => array( |
581 | - 'title' => __( 'Status', 'invoicing' ), |
|
581 | + 'title' => __('Status', 'invoicing'), |
|
582 | 582 | 'class' => 'text-center' |
583 | 583 | ), |
584 | 584 | |
585 | 585 | 'invoice-total' => array( |
586 | - 'title' => __( 'Total', 'invoicing' ), |
|
586 | + 'title' => __('Total', 'invoicing'), |
|
587 | 587 | 'class' => 'text-right' |
588 | 588 | ), |
589 | 589 | |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | |
595 | 595 | ); |
596 | 596 | |
597 | - return apply_filters( 'wpinv_user_invoices_columns', $columns, $post_type ); |
|
597 | + return apply_filters('wpinv_user_invoices_columns', $columns, $post_type); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | /** |
@@ -604,59 +604,59 @@ discard block |
||
604 | 604 | |
605 | 605 | // Find the invoice. |
606 | 606 | $invoice_id = getpaid_get_current_invoice_id(); |
607 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
607 | + $invoice = new WPInv_Invoice($invoice_id); |
|
608 | 608 | |
609 | 609 | // Abort if non was found. |
610 | - if ( empty( $invoice_id ) || $invoice->is_draft() ) { |
|
610 | + if (empty($invoice_id) || $invoice->is_draft()) { |
|
611 | 611 | |
612 | 612 | return aui()->alert( |
613 | 613 | array( |
614 | 614 | 'type' => 'warning', |
615 | - 'content' => __( 'We could not find your invoice', 'invoicing' ), |
|
615 | + 'content' => __('We could not find your invoice', 'invoicing'), |
|
616 | 616 | ) |
617 | 617 | ); |
618 | 618 | |
619 | 619 | } |
620 | 620 | |
621 | 621 | // Can the user view this invoice? |
622 | - if ( ! wpinv_can_view_receipt( $invoice_id ) ) { |
|
622 | + if (!wpinv_can_view_receipt($invoice_id)) { |
|
623 | 623 | |
624 | 624 | return aui()->alert( |
625 | 625 | array( |
626 | 626 | 'type' => 'warning', |
627 | - 'content' => __( 'You are not allowed to view this receipt', 'invoicing' ), |
|
627 | + 'content' => __('You are not allowed to view this receipt', 'invoicing'), |
|
628 | 628 | ) |
629 | 629 | ); |
630 | 630 | |
631 | 631 | } |
632 | 632 | |
633 | 633 | // Load the template. |
634 | - return wpinv_get_template_html( 'invoice-receipt.php', compact( 'invoice' ) ); |
|
634 | + return wpinv_get_template_html('invoice-receipt.php', compact('invoice')); |
|
635 | 635 | |
636 | 636 | } |
637 | 637 | |
638 | 638 | /** |
639 | 639 | * Displays the invoice history. |
640 | 640 | */ |
641 | -function getpaid_invoice_history( $user_id = 0, $post_type = 'wpi_invoice' ) { |
|
641 | +function getpaid_invoice_history($user_id = 0, $post_type = 'wpi_invoice') { |
|
642 | 642 | |
643 | 643 | // Ensure that we have a user id. |
644 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
644 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
645 | 645 | $user_id = get_current_user_id(); |
646 | 646 | } |
647 | 647 | |
648 | - $label = getpaid_get_post_type_label( $post_type ); |
|
649 | - $label = empty( $label ) ? __( 'Invoices', 'invoicing' ) : sanitize_text_field( $label ); |
|
648 | + $label = getpaid_get_post_type_label($post_type); |
|
649 | + $label = empty($label) ? __('Invoices', 'invoicing') : sanitize_text_field($label); |
|
650 | 650 | |
651 | 651 | // View user id. |
652 | - if ( empty( $user_id ) ) { |
|
652 | + if (empty($user_id)) { |
|
653 | 653 | |
654 | 654 | return aui()->alert( |
655 | 655 | array( |
656 | 656 | 'type' => 'warning', |
657 | 657 | 'content' => sprintf( |
658 | - __( 'You must be logged in to view your %s.', 'invoicing' ), |
|
659 | - strtolower( $label ) |
|
658 | + __('You must be logged in to view your %s.', 'invoicing'), |
|
659 | + strtolower($label) |
|
660 | 660 | ) |
661 | 661 | ) |
662 | 662 | ); |
@@ -667,23 +667,23 @@ discard block |
||
667 | 667 | $invoices = wpinv_get_invoices( |
668 | 668 | |
669 | 669 | array( |
670 | - 'page' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
670 | + 'page' => (get_query_var('paged')) ? absint(get_query_var('paged')) : 1, |
|
671 | 671 | 'user' => $user_id, |
672 | 672 | 'paginate' => true, |
673 | 673 | 'type' => $post_type, |
674 | - 'status' => array_keys( wpinv_get_invoice_statuses( false, false, $post_type ) ), |
|
674 | + 'status' => array_keys(wpinv_get_invoice_statuses(false, false, $post_type)), |
|
675 | 675 | ) |
676 | 676 | |
677 | 677 | ); |
678 | 678 | |
679 | - if ( empty( $invoices->total ) ) { |
|
679 | + if (empty($invoices->total)) { |
|
680 | 680 | |
681 | 681 | return aui()->alert( |
682 | 682 | array( |
683 | 683 | 'type' => 'info', |
684 | 684 | 'content' => sprintf( |
685 | - __( 'No %s found.', 'invoicing' ), |
|
686 | - strtolower( $label ) |
|
685 | + __('No %s found.', 'invoicing'), |
|
686 | + strtolower($label) |
|
687 | 687 | ) |
688 | 688 | ) |
689 | 689 | ); |
@@ -691,38 +691,38 @@ discard block |
||
691 | 691 | } |
692 | 692 | |
693 | 693 | // Load the template. |
694 | - return wpinv_get_template_html( 'invoice-history.php', compact( 'invoices', 'post_type' ) ); |
|
694 | + return wpinv_get_template_html('invoice-history.php', compact('invoices', 'post_type')); |
|
695 | 695 | |
696 | 696 | } |
697 | 697 | |
698 | 698 | /** |
699 | 699 | * Formats an invoice number given an invoice type. |
700 | 700 | */ |
701 | -function wpinv_format_invoice_number( $number, $type = '' ) { |
|
701 | +function wpinv_format_invoice_number($number, $type = '') { |
|
702 | 702 | |
703 | 703 | // Allow other plugins to overide this. |
704 | - $check = apply_filters( 'wpinv_pre_format_invoice_number', null, $number, $type ); |
|
705 | - if ( null !== $check ) { |
|
704 | + $check = apply_filters('wpinv_pre_format_invoice_number', null, $number, $type); |
|
705 | + if (null !== $check) { |
|
706 | 706 | return $check; |
707 | 707 | } |
708 | 708 | |
709 | 709 | // Ensure that we have a numeric number. |
710 | - if ( ! is_numeric( $number ) ) { |
|
710 | + if (!is_numeric($number)) { |
|
711 | 711 | return $number; |
712 | 712 | } |
713 | 713 | |
714 | 714 | // Format the number. |
715 | - $padd = absint( (int) wpinv_get_option( 'invoice_number_padd' ) ); |
|
716 | - $prefix = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_prefix', 'INV-' ) ); |
|
717 | - $prefix = sanitize_text_field( apply_filters( 'getpaid_invoice_type_prefix', $prefix, $type ) ); |
|
718 | - $postfix = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_postfix' ) ); |
|
719 | - $postfix = sanitize_text_field( apply_filters( 'getpaid_invoice_type_postfix', $postfix, $type ) ); |
|
720 | - $formatted_number = zeroise( absint( $number ), $padd ); |
|
715 | + $padd = absint((int) wpinv_get_option('invoice_number_padd')); |
|
716 | + $prefix = sanitize_text_field((string) wpinv_get_option('invoice_number_prefix', 'INV-')); |
|
717 | + $prefix = sanitize_text_field(apply_filters('getpaid_invoice_type_prefix', $prefix, $type)); |
|
718 | + $postfix = sanitize_text_field((string) wpinv_get_option('invoice_number_postfix')); |
|
719 | + $postfix = sanitize_text_field(apply_filters('getpaid_invoice_type_postfix', $postfix, $type)); |
|
720 | + $formatted_number = zeroise(absint($number), $padd); |
|
721 | 721 | |
722 | 722 | // Add the prefix and post fix. |
723 | 723 | $formatted_number = $prefix . $formatted_number . $postfix; |
724 | 724 | |
725 | - return apply_filters( 'wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd ); |
|
725 | + return apply_filters('wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd); |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | /** |
@@ -731,58 +731,58 @@ discard block |
||
731 | 731 | * @param string $type. |
732 | 732 | * @return int|null|bool |
733 | 733 | */ |
734 | -function wpinv_get_next_invoice_number( $type = '' ) { |
|
734 | +function wpinv_get_next_invoice_number($type = '') { |
|
735 | 735 | |
736 | 736 | // Allow plugins to overide this. |
737 | - $check = apply_filters( 'wpinv_get_pre_next_invoice_number', null, $type ); |
|
738 | - if ( null !== $check ) { |
|
737 | + $check = apply_filters('wpinv_get_pre_next_invoice_number', null, $type); |
|
738 | + if (null !== $check) { |
|
739 | 739 | return $check; |
740 | 740 | } |
741 | 741 | |
742 | 742 | // Ensure sequential invoice numbers is active. |
743 | - if ( ! wpinv_sequential_number_active() ) { |
|
743 | + if (!wpinv_sequential_number_active()) { |
|
744 | 744 | return false; |
745 | 745 | } |
746 | 746 | |
747 | 747 | // Retrieve the current number and the start number. |
748 | - $number = (int) get_option( 'wpinv_last_invoice_number', 0 ); |
|
749 | - $start = absint( (int) wpinv_get_option( 'invoice_sequence_start', 1 ) ); |
|
748 | + $number = (int) get_option('wpinv_last_invoice_number', 0); |
|
749 | + $start = absint((int) wpinv_get_option('invoice_sequence_start', 1)); |
|
750 | 750 | |
751 | 751 | // Ensure that we are starting at a positive integer. |
752 | - $start = max( $start, 1 ); |
|
752 | + $start = max($start, 1); |
|
753 | 753 | |
754 | 754 | // If this is the first invoice, use the start number. |
755 | - $number = max( $start, $number ); |
|
755 | + $number = max($start, $number); |
|
756 | 756 | |
757 | 757 | // Format the invoice number. |
758 | - $formatted_number = wpinv_format_invoice_number( $number, $type ); |
|
758 | + $formatted_number = wpinv_format_invoice_number($number, $type); |
|
759 | 759 | |
760 | 760 | // Ensure that this number is unique. |
761 | - $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $formatted_number, 'number' ); |
|
761 | + $invoice_id = WPInv_Invoice::get_invoice_id_by_field($formatted_number, 'number'); |
|
762 | 762 | |
763 | 763 | // We found a match. Nice. |
764 | - if ( empty( $invoice_id ) ) { |
|
765 | - update_option( 'wpinv_last_invoice_number', $number ); |
|
766 | - return apply_filters( 'wpinv_get_next_invoice_number', $number ); |
|
764 | + if (empty($invoice_id)) { |
|
765 | + update_option('wpinv_last_invoice_number', $number); |
|
766 | + return apply_filters('wpinv_get_next_invoice_number', $number); |
|
767 | 767 | } |
768 | 768 | |
769 | - update_option( 'wpinv_last_invoice_number', $number + 1 ); |
|
770 | - return wpinv_get_next_invoice_number( $type ); |
|
769 | + update_option('wpinv_last_invoice_number', $number + 1); |
|
770 | + return wpinv_get_next_invoice_number($type); |
|
771 | 771 | |
772 | 772 | } |
773 | 773 | |
774 | 774 | /** |
775 | 775 | * The prefix used for invoice paths. |
776 | 776 | */ |
777 | -function wpinv_post_name_prefix( $post_type = 'wpi_invoice' ) { |
|
778 | - return apply_filters( 'wpinv_post_name_prefix', 'inv-', $post_type ); |
|
777 | +function wpinv_post_name_prefix($post_type = 'wpi_invoice') { |
|
778 | + return apply_filters('wpinv_post_name_prefix', 'inv-', $post_type); |
|
779 | 779 | } |
780 | 780 | |
781 | -function wpinv_generate_post_name( $post_ID ) { |
|
782 | - $prefix = wpinv_post_name_prefix( get_post_type( $post_ID ) ); |
|
783 | - $post_name = sanitize_title( $prefix . $post_ID ); |
|
781 | +function wpinv_generate_post_name($post_ID) { |
|
782 | + $prefix = wpinv_post_name_prefix(get_post_type($post_ID)); |
|
783 | + $post_name = sanitize_title($prefix . $post_ID); |
|
784 | 784 | |
785 | - return apply_filters( 'wpinv_generate_post_name', $post_name, $post_ID, $prefix ); |
|
785 | + return apply_filters('wpinv_generate_post_name', $post_name, $post_ID, $prefix); |
|
786 | 786 | } |
787 | 787 | |
788 | 788 | /** |
@@ -790,8 +790,8 @@ discard block |
||
790 | 790 | * |
791 | 791 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
792 | 792 | */ |
793 | -function wpinv_is_invoice_viewed( $invoice ) { |
|
794 | - $invoice = new WPInv_Invoice( $invoice ); |
|
793 | +function wpinv_is_invoice_viewed($invoice) { |
|
794 | + $invoice = new WPInv_Invoice($invoice); |
|
795 | 795 | return (bool) $invoice->get_is_viewed(); |
796 | 796 | } |
797 | 797 | |
@@ -800,17 +800,17 @@ discard block |
||
800 | 800 | * |
801 | 801 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
802 | 802 | */ |
803 | -function getpaid_maybe_mark_invoice_as_viewed( $invoice ) { |
|
804 | - $invoice = new WPInv_Invoice( $invoice ); |
|
803 | +function getpaid_maybe_mark_invoice_as_viewed($invoice) { |
|
804 | + $invoice = new WPInv_Invoice($invoice); |
|
805 | 805 | |
806 | - if ( get_current_user_id() == $invoice->get_user_id() && ! $invoice->get_is_viewed() ) { |
|
807 | - $invoice->set_is_viewed( true ); |
|
806 | + if (get_current_user_id() == $invoice->get_user_id() && !$invoice->get_is_viewed()) { |
|
807 | + $invoice->set_is_viewed(true); |
|
808 | 808 | $invoice->save(); |
809 | 809 | } |
810 | 810 | |
811 | 811 | } |
812 | -add_action( 'wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
813 | -add_action( 'wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
812 | +add_action('wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
813 | +add_action('wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
814 | 814 | |
815 | 815 | /** |
816 | 816 | * Processes an invoice refund. |
@@ -819,27 +819,27 @@ discard block |
||
819 | 819 | * @param array $status_transition |
820 | 820 | * @todo: descrease customer/store earnings |
821 | 821 | */ |
822 | -function getpaid_maybe_process_refund( $invoice, $status_transition ) { |
|
822 | +function getpaid_maybe_process_refund($invoice, $status_transition) { |
|
823 | 823 | |
824 | - if ( empty( $status_transition['from'] ) || ! in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ) ) ) { |
|
824 | + if (empty($status_transition['from']) || !in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'))) { |
|
825 | 825 | return; |
826 | 826 | } |
827 | 827 | |
828 | 828 | $discount_code = $invoice->get_discount_code(); |
829 | - if ( ! empty( $discount_code ) ) { |
|
830 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
829 | + if (!empty($discount_code)) { |
|
830 | + $discount = wpinv_get_discount_obj($discount_code); |
|
831 | 831 | |
832 | - if ( $discount->exists() ) { |
|
832 | + if ($discount->exists()) { |
|
833 | 833 | $discount->increase_usage( -1 ); |
834 | 834 | } |
835 | 835 | |
836 | 836 | } |
837 | 837 | |
838 | - do_action( 'wpinv_pre_refund_invoice', $invoice, $invoice->get_id() ); |
|
839 | - do_action( 'wpinv_refund_invoice', $invoice, $invoice->get_id() ); |
|
840 | - do_action( 'wpinv_post_refund_invoice', $invoice, $invoice->get_id() ); |
|
838 | + do_action('wpinv_pre_refund_invoice', $invoice, $invoice->get_id()); |
|
839 | + do_action('wpinv_refund_invoice', $invoice, $invoice->get_id()); |
|
840 | + do_action('wpinv_post_refund_invoice', $invoice, $invoice->get_id()); |
|
841 | 841 | } |
842 | -add_action( 'getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2 ); |
|
842 | +add_action('getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2); |
|
843 | 843 | |
844 | 844 | |
845 | 845 | /** |
@@ -847,48 +847,48 @@ discard block |
||
847 | 847 | * |
848 | 848 | * @param int $invoice_id |
849 | 849 | */ |
850 | -function getpaid_process_invoice_payment( $invoice_id ) { |
|
850 | +function getpaid_process_invoice_payment($invoice_id) { |
|
851 | 851 | |
852 | 852 | // Fetch the invoice. |
853 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
853 | + $invoice = new WPInv_Invoice($invoice_id); |
|
854 | 854 | |
855 | 855 | // We only want to do this once. |
856 | - if ( 1 == get_post_meta( $invoice->get_id(), 'wpinv_processed_payment', true ) ) { |
|
856 | + if (1 == get_post_meta($invoice->get_id(), 'wpinv_processed_payment', true)) { |
|
857 | 857 | return; |
858 | 858 | } |
859 | 859 | |
860 | - update_post_meta( $invoice->get_id(), 'wpinv_processed_payment', 1 ); |
|
860 | + update_post_meta($invoice->get_id(), 'wpinv_processed_payment', 1); |
|
861 | 861 | |
862 | 862 | // Fires when processing a payment. |
863 | - do_action( 'getpaid_process_payment', $invoice ); |
|
863 | + do_action('getpaid_process_payment', $invoice); |
|
864 | 864 | |
865 | 865 | // Fire an action for each invoice item. |
866 | - foreach( $invoice->get_items() as $item ) { |
|
867 | - do_action( 'getpaid_process_item_payment', $item, $invoice ); |
|
866 | + foreach ($invoice->get_items() as $item) { |
|
867 | + do_action('getpaid_process_item_payment', $item, $invoice); |
|
868 | 868 | } |
869 | 869 | |
870 | 870 | // Increase discount usage. |
871 | 871 | $discount_code = $invoice->get_discount_code(); |
872 | - if ( ! empty( $discount_code ) && ! $invoice->is_renewal() ) { |
|
873 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
872 | + if (!empty($discount_code) && !$invoice->is_renewal()) { |
|
873 | + $discount = wpinv_get_discount_obj($discount_code); |
|
874 | 874 | |
875 | - if ( $discount->exists() ) { |
|
875 | + if ($discount->exists()) { |
|
876 | 876 | $discount->increase_usage(); |
877 | 877 | } |
878 | 878 | |
879 | 879 | } |
880 | 880 | |
881 | 881 | // Record reverse vat. |
882 | - if ( 'invoice' == $invoice->get_type() && wpinv_use_taxes() && ! $invoice->get_disable_taxes() ) { |
|
882 | + if ('invoice' == $invoice->get_type() && wpinv_use_taxes() && !$invoice->get_disable_taxes()) { |
|
883 | 883 | |
884 | - if ( wpinv_same_country_exempt_vat() && wpinv_is_base_country( $invoice->get_country() ) ) { |
|
885 | - $invoice->add_note( __( 'VAT was reverse charged', 'invoicing' ), false, false, true ); |
|
884 | + if (wpinv_same_country_exempt_vat() && wpinv_is_base_country($invoice->get_country())) { |
|
885 | + $invoice->add_note(__('VAT was reverse charged', 'invoicing'), false, false, true); |
|
886 | 886 | } |
887 | 887 | |
888 | 888 | } |
889 | 889 | |
890 | 890 | } |
891 | -add_action( 'getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment' ); |
|
891 | +add_action('getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment'); |
|
892 | 892 | |
893 | 893 | /** |
894 | 894 | * Returns an array of invoice item columns |
@@ -896,13 +896,13 @@ discard block |
||
896 | 896 | * @param int|WPInv_Invoice $invoice |
897 | 897 | * @return array |
898 | 898 | */ |
899 | -function getpaid_invoice_item_columns( $invoice ) { |
|
899 | +function getpaid_invoice_item_columns($invoice) { |
|
900 | 900 | |
901 | 901 | // Prepare the invoice. |
902 | - $invoice = new WPInv_Invoice( $invoice ); |
|
902 | + $invoice = new WPInv_Invoice($invoice); |
|
903 | 903 | |
904 | 904 | // Abort if there is no invoice. |
905 | - if ( 0 == $invoice->get_id() ) { |
|
905 | + if (0 == $invoice->get_id()) { |
|
906 | 906 | return array(); |
907 | 907 | } |
908 | 908 | |
@@ -910,47 +910,47 @@ discard block |
||
910 | 910 | $columns = apply_filters( |
911 | 911 | 'getpaid_invoice_item_columns', |
912 | 912 | array( |
913 | - 'name' => __( 'Item', 'invoicing' ), |
|
914 | - 'price' => __( 'Price', 'invoicing' ), |
|
915 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
916 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
913 | + 'name' => __('Item', 'invoicing'), |
|
914 | + 'price' => __('Price', 'invoicing'), |
|
915 | + 'quantity' => __('Quantity', 'invoicing'), |
|
916 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
917 | 917 | ), |
918 | 918 | $invoice |
919 | 919 | ); |
920 | 920 | |
921 | 921 | // Quantities. |
922 | - if ( isset( $columns[ 'quantity' ] ) ) { |
|
922 | + if (isset($columns['quantity'])) { |
|
923 | 923 | |
924 | - if ( 'hours' == $invoice->get_template() ) { |
|
925 | - $columns[ 'quantity' ] = __( 'Hours', 'invoicing' ); |
|
924 | + if ('hours' == $invoice->get_template()) { |
|
925 | + $columns['quantity'] = __('Hours', 'invoicing'); |
|
926 | 926 | } |
927 | 927 | |
928 | - if ( ! wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template() ) { |
|
929 | - unset( $columns[ 'quantity' ] ); |
|
928 | + if (!wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template()) { |
|
929 | + unset($columns['quantity']); |
|
930 | 930 | } |
931 | 931 | |
932 | 932 | } |
933 | 933 | |
934 | 934 | |
935 | 935 | // Price. |
936 | - if ( isset( $columns[ 'price' ] ) ) { |
|
936 | + if (isset($columns['price'])) { |
|
937 | 937 | |
938 | - if ( 'amount' == $invoice->get_template() ) { |
|
939 | - $columns[ 'price' ] = __( 'Amount', 'invoicing' ); |
|
938 | + if ('amount' == $invoice->get_template()) { |
|
939 | + $columns['price'] = __('Amount', 'invoicing'); |
|
940 | 940 | } |
941 | 941 | |
942 | - if ( 'hours' == $invoice->get_template() ) { |
|
943 | - $columns[ 'price' ] = __( 'Rate', 'invoicing' ); |
|
942 | + if ('hours' == $invoice->get_template()) { |
|
943 | + $columns['price'] = __('Rate', 'invoicing'); |
|
944 | 944 | } |
945 | 945 | |
946 | 946 | } |
947 | 947 | |
948 | 948 | |
949 | 949 | // Sub total. |
950 | - if ( isset( $columns[ 'subtotal' ] ) ) { |
|
950 | + if (isset($columns['subtotal'])) { |
|
951 | 951 | |
952 | - if ( 'amount' == $invoice->get_template() ) { |
|
953 | - unset( $columns[ 'subtotal' ] ); |
|
952 | + if ('amount' == $invoice->get_template()) { |
|
953 | + unset($columns['subtotal']); |
|
954 | 954 | } |
955 | 955 | |
956 | 956 | } |
@@ -964,30 +964,30 @@ discard block |
||
964 | 964 | * @param int|WPInv_Invoice $invoice |
965 | 965 | * @return array |
966 | 966 | */ |
967 | -function getpaid_invoice_totals_rows( $invoice ) { |
|
967 | +function getpaid_invoice_totals_rows($invoice) { |
|
968 | 968 | |
969 | 969 | // Prepare the invoice. |
970 | - $invoice = new WPInv_Invoice( $invoice ); |
|
970 | + $invoice = new WPInv_Invoice($invoice); |
|
971 | 971 | |
972 | 972 | // Abort if there is no invoice. |
973 | - if ( 0 == $invoice->get_id() ) { |
|
973 | + if (0 == $invoice->get_id()) { |
|
974 | 974 | return array(); |
975 | 975 | } |
976 | 976 | |
977 | 977 | $totals = apply_filters( |
978 | 978 | 'getpaid_invoice_totals_rows', |
979 | 979 | array( |
980 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
981 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
982 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
983 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
984 | - 'total' => __( 'Total', 'invoicing' ), |
|
980 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
981 | + 'tax' => __('Tax', 'invoicing'), |
|
982 | + 'fee' => __('Fee', 'invoicing'), |
|
983 | + 'discount' => __('Discount', 'invoicing'), |
|
984 | + 'total' => __('Total', 'invoicing'), |
|
985 | 985 | ), |
986 | 986 | $invoice |
987 | 987 | ); |
988 | 988 | |
989 | - if ( ( $invoice->get_disable_taxes() || ! wpinv_use_taxes() ) && isset( $totals['tax'] ) ) { |
|
990 | - unset( $totals['tax'] ); |
|
989 | + if (($invoice->get_disable_taxes() || !wpinv_use_taxes()) && isset($totals['tax'])) { |
|
990 | + unset($totals['tax']); |
|
991 | 991 | } |
992 | 992 | |
993 | 993 | return $totals; |
@@ -998,47 +998,47 @@ discard block |
||
998 | 998 | * |
999 | 999 | * @param WPInv_Invoice $invoice |
1000 | 1000 | */ |
1001 | -function getpaid_new_invoice( $invoice ) { |
|
1001 | +function getpaid_new_invoice($invoice) { |
|
1002 | 1002 | |
1003 | - if ( ! $invoice->get_status() ) { |
|
1003 | + if (!$invoice->get_status()) { |
|
1004 | 1004 | return; |
1005 | 1005 | } |
1006 | 1006 | |
1007 | 1007 | // Add an invoice created note. |
1008 | 1008 | $invoice->add_note( |
1009 | 1009 | sprintf( |
1010 | - __( '%s created with the status "%s".', 'invoicing' ), |
|
1011 | - ucfirst( $invoice->get_type() ), |
|
1012 | - wpinv_status_nicename( $invoice->get_status(), $invoice ) |
|
1010 | + __('%s created with the status "%s".', 'invoicing'), |
|
1011 | + ucfirst($invoice->get_type()), |
|
1012 | + wpinv_status_nicename($invoice->get_status(), $invoice) |
|
1013 | 1013 | ) |
1014 | 1014 | ); |
1015 | 1015 | |
1016 | 1016 | } |
1017 | -add_action( 'getpaid_new_invoice', 'getpaid_new_invoice' ); |
|
1017 | +add_action('getpaid_new_invoice', 'getpaid_new_invoice'); |
|
1018 | 1018 | |
1019 | 1019 | /** |
1020 | 1020 | * This function updates invoice caches. |
1021 | 1021 | * |
1022 | 1022 | * @param WPInv_Invoice $invoice |
1023 | 1023 | */ |
1024 | -function getpaid_update_invoice_caches( $invoice ) { |
|
1024 | +function getpaid_update_invoice_caches($invoice) { |
|
1025 | 1025 | |
1026 | 1026 | // Cache invoice number. |
1027 | - wp_cache_set( $invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids" ); |
|
1027 | + wp_cache_set($invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids"); |
|
1028 | 1028 | |
1029 | 1029 | // Cache invoice key. |
1030 | - wp_cache_set( $invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids" ); |
|
1030 | + wp_cache_set($invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids"); |
|
1031 | 1031 | |
1032 | 1032 | // (Maybe) cache transaction id. |
1033 | 1033 | $transaction_id = $invoice->get_transaction_id(); |
1034 | 1034 | |
1035 | - if ( ! empty( $transaction_id ) ) { |
|
1036 | - wp_cache_set( $transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids" ); |
|
1035 | + if (!empty($transaction_id)) { |
|
1036 | + wp_cache_set($transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids"); |
|
1037 | 1037 | } |
1038 | 1038 | |
1039 | 1039 | } |
1040 | -add_action( 'getpaid_new_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
1041 | -add_action( 'getpaid_update_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
1040 | +add_action('getpaid_new_invoice', 'getpaid_update_invoice_caches', 5); |
|
1041 | +add_action('getpaid_update_invoice', 'getpaid_update_invoice_caches', 5); |
|
1042 | 1042 | |
1043 | 1043 | /** |
1044 | 1044 | * Duplicates an invoice. |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | * @param WPInv_Invoice $old_invoice The invoice to duplicate |
1049 | 1049 | * @return WPInv_Invoice The new invoice. |
1050 | 1050 | */ |
1051 | -function getpaid_duplicate_invoice( $old_invoice ) { |
|
1051 | +function getpaid_duplicate_invoice($old_invoice) { |
|
1052 | 1052 | |
1053 | 1053 | // Create the new invoice. |
1054 | 1054 | $invoice = new WPInv_Invoice(); |
@@ -1109,123 +1109,123 @@ discard block |
||
1109 | 1109 | * @param WPInv_Invoice $invoice |
1110 | 1110 | * @return array |
1111 | 1111 | */ |
1112 | -function getpaid_get_invoice_meta( $invoice ) { |
|
1112 | +function getpaid_get_invoice_meta($invoice) { |
|
1113 | 1113 | |
1114 | 1114 | // Load the invoice meta. |
1115 | 1115 | $meta = array( |
1116 | 1116 | |
1117 | 1117 | 'number' => array( |
1118 | 1118 | 'label' => sprintf( |
1119 | - __( '%s Number', 'invoicing' ), |
|
1120 | - ucfirst( $invoice->get_type() ) |
|
1119 | + __('%s Number', 'invoicing'), |
|
1120 | + ucfirst($invoice->get_type()) |
|
1121 | 1121 | ), |
1122 | - 'value' => sanitize_text_field( $invoice->get_number() ), |
|
1122 | + 'value' => sanitize_text_field($invoice->get_number()), |
|
1123 | 1123 | ), |
1124 | 1124 | |
1125 | 1125 | 'status' => array( |
1126 | 1126 | 'label' => sprintf( |
1127 | - __( '%s Status', 'invoicing' ), |
|
1128 | - ucfirst( $invoice->get_type() ) |
|
1127 | + __('%s Status', 'invoicing'), |
|
1128 | + ucfirst($invoice->get_type()) |
|
1129 | 1129 | ), |
1130 | 1130 | 'value' => $invoice->get_status_label_html(), |
1131 | 1131 | ), |
1132 | 1132 | |
1133 | 1133 | 'date' => array( |
1134 | 1134 | 'label' => sprintf( |
1135 | - __( '%s Date', 'invoicing' ), |
|
1136 | - ucfirst( $invoice->get_type() ) |
|
1135 | + __('%s Date', 'invoicing'), |
|
1136 | + ucfirst($invoice->get_type()) |
|
1137 | 1137 | ), |
1138 | - 'value' => getpaid_format_date( $invoice->get_created_date() ), |
|
1138 | + 'value' => getpaid_format_date($invoice->get_created_date()), |
|
1139 | 1139 | ), |
1140 | 1140 | |
1141 | 1141 | 'date_paid' => array( |
1142 | - 'label' => __( 'Paid On', 'invoicing' ), |
|
1143 | - 'value' => getpaid_format_date( $invoice->get_completed_date() ), |
|
1142 | + 'label' => __('Paid On', 'invoicing'), |
|
1143 | + 'value' => getpaid_format_date($invoice->get_completed_date()), |
|
1144 | 1144 | ), |
1145 | 1145 | |
1146 | 1146 | 'gateway' => array( |
1147 | - 'label' => __( 'Payment Method', 'invoicing' ), |
|
1148 | - 'value' => sanitize_text_field( $invoice->get_gateway_title() ), |
|
1147 | + 'label' => __('Payment Method', 'invoicing'), |
|
1148 | + 'value' => sanitize_text_field($invoice->get_gateway_title()), |
|
1149 | 1149 | ), |
1150 | 1150 | |
1151 | 1151 | 'transaction_id' => array( |
1152 | - 'label' => __( 'Transaction ID', 'invoicing' ), |
|
1153 | - 'value' => sanitize_text_field( $invoice->get_transaction_id() ), |
|
1152 | + 'label' => __('Transaction ID', 'invoicing'), |
|
1153 | + 'value' => sanitize_text_field($invoice->get_transaction_id()), |
|
1154 | 1154 | ), |
1155 | 1155 | |
1156 | 1156 | 'due_date' => array( |
1157 | - 'label' => __( 'Due Date', 'invoicing' ), |
|
1158 | - 'value' => getpaid_format_date( $invoice->get_due_date() ), |
|
1157 | + 'label' => __('Due Date', 'invoicing'), |
|
1158 | + 'value' => getpaid_format_date($invoice->get_due_date()), |
|
1159 | 1159 | ), |
1160 | 1160 | |
1161 | 1161 | 'vat_number' => array( |
1162 | - 'label' => __( 'VAT Number', 'invoicing' ), |
|
1163 | - 'value' => sanitize_text_field( $invoice->get_vat_number() ), |
|
1162 | + 'label' => __('VAT Number', 'invoicing'), |
|
1163 | + 'value' => sanitize_text_field($invoice->get_vat_number()), |
|
1164 | 1164 | ), |
1165 | 1165 | |
1166 | 1166 | ); |
1167 | 1167 | |
1168 | 1168 | // If it is not paid, remove the date of payment. |
1169 | - if ( ! $invoice->is_paid() ) { |
|
1170 | - unset( $meta[ 'date_paid' ] ); |
|
1171 | - unset( $meta[ 'transaction_id' ] ); |
|
1169 | + if (!$invoice->is_paid()) { |
|
1170 | + unset($meta['date_paid']); |
|
1171 | + unset($meta['transaction_id']); |
|
1172 | 1172 | } |
1173 | 1173 | |
1174 | - if ( ! $invoice->is_paid() || 'none' == $invoice->get_gateway() ) { |
|
1175 | - unset( $meta[ 'gateway' ] ); |
|
1174 | + if (!$invoice->is_paid() || 'none' == $invoice->get_gateway()) { |
|
1175 | + unset($meta['gateway']); |
|
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | // Only display the due date if due dates are enabled. |
1179 | - if ( ! $invoice->needs_payment() || ! wpinv_get_option( 'overdue_active' ) ) { |
|
1180 | - unset( $meta[ 'due_date' ] ); |
|
1179 | + if (!$invoice->needs_payment() || !wpinv_get_option('overdue_active')) { |
|
1180 | + unset($meta['due_date']); |
|
1181 | 1181 | } |
1182 | 1182 | |
1183 | 1183 | // Only display the vat number if taxes are enabled. |
1184 | - if ( ! wpinv_use_taxes() ) { |
|
1185 | - unset( $meta[ 'vat_number' ] ); |
|
1184 | + if (!wpinv_use_taxes()) { |
|
1185 | + unset($meta['vat_number']); |
|
1186 | 1186 | } |
1187 | 1187 | |
1188 | - if ( $invoice->is_recurring() ) { |
|
1188 | + if ($invoice->is_recurring()) { |
|
1189 | 1189 | |
1190 | 1190 | // Link to the parent invoice. |
1191 | - if ( $invoice->is_renewal() ) { |
|
1191 | + if ($invoice->is_renewal()) { |
|
1192 | 1192 | |
1193 | - $meta[ 'parent' ] = array( |
|
1193 | + $meta['parent'] = array( |
|
1194 | 1194 | |
1195 | 1195 | 'label' => sprintf( |
1196 | - __( 'Parent %s', 'invoicing' ), |
|
1197 | - ucfirst( $invoice->get_type() ) |
|
1196 | + __('Parent %s', 'invoicing'), |
|
1197 | + ucfirst($invoice->get_type()) |
|
1198 | 1198 | ), |
1199 | 1199 | |
1200 | - 'value' => wpinv_invoice_link( $invoice->get_parent_id() ), |
|
1200 | + 'value' => wpinv_invoice_link($invoice->get_parent_id()), |
|
1201 | 1201 | |
1202 | 1202 | ); |
1203 | 1203 | |
1204 | 1204 | } |
1205 | 1205 | |
1206 | - $subscription = wpinv_get_subscription( $invoice ); |
|
1206 | + $subscription = wpinv_get_subscription($invoice); |
|
1207 | 1207 | |
1208 | - if ( ! empty ( $subscription ) ) { |
|
1208 | + if (!empty ($subscription)) { |
|
1209 | 1209 | |
1210 | 1210 | // Display the renewal date. |
1211 | - if ( $subscription->is_active() && 'cancelled' != $subscription->get_status() ) { |
|
1211 | + if ($subscription->is_active() && 'cancelled' != $subscription->get_status()) { |
|
1212 | 1212 | |
1213 | - $meta[ 'renewal_date' ] = array( |
|
1213 | + $meta['renewal_date'] = array( |
|
1214 | 1214 | |
1215 | - 'label' => __( 'Renews On', 'invoicing' ), |
|
1216 | - 'value' => getpaid_format_date( $subscription->get_expiration() ), |
|
1215 | + 'label' => __('Renews On', 'invoicing'), |
|
1216 | + 'value' => getpaid_format_date($subscription->get_expiration()), |
|
1217 | 1217 | |
1218 | 1218 | ); |
1219 | 1219 | |
1220 | 1220 | } |
1221 | 1221 | |
1222 | - if ( $invoice->is_parent() ) { |
|
1222 | + if ($invoice->is_parent()) { |
|
1223 | 1223 | |
1224 | 1224 | // Display the recurring amount. |
1225 | - $meta[ 'recurring_total' ] = array( |
|
1225 | + $meta['recurring_total'] = array( |
|
1226 | 1226 | |
1227 | - 'label' => __( 'Recurring Amount', 'invoicing' ), |
|
1228 | - 'value' => wpinv_price( wpinv_format_amount( $subscription->get_recurring_amount() ), $invoice->get_currency() ), |
|
1227 | + 'label' => __('Recurring Amount', 'invoicing'), |
|
1228 | + 'value' => wpinv_price(wpinv_format_amount($subscription->get_recurring_amount()), $invoice->get_currency()), |
|
1229 | 1229 | |
1230 | 1230 | ); |
1231 | 1231 | |
@@ -1235,15 +1235,15 @@ discard block |
||
1235 | 1235 | } |
1236 | 1236 | |
1237 | 1237 | // Add the invoice total to the meta. |
1238 | - $meta[ 'invoice_total' ] = array( |
|
1238 | + $meta['invoice_total'] = array( |
|
1239 | 1239 | |
1240 | - 'label' => __( 'Total Amount', 'invoicing' ), |
|
1241 | - 'value' => wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ), |
|
1240 | + 'label' => __('Total Amount', 'invoicing'), |
|
1241 | + 'value' => wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()), |
|
1242 | 1242 | |
1243 | 1243 | ); |
1244 | 1244 | |
1245 | 1245 | // Provide a way for third party plugins to filter the meta. |
1246 | - $meta = apply_filters( 'getpaid_invoice_meta_data', $meta, $invoice ); |
|
1246 | + $meta = apply_filters('getpaid_invoice_meta_data', $meta, $invoice); |
|
1247 | 1247 | |
1248 | 1248 | return $meta; |
1249 | 1249 |