@@ -1,65 +1,65 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | -function wpinv_add_meta_boxes( $post_type, $post ) { |
|
7 | +function wpinv_add_meta_boxes($post_type, $post) { |
|
8 | 8 | global $wpi_mb_invoice; |
9 | - if ( $post_type == 'wpi_invoice' && !empty( $post->ID ) ) { |
|
10 | - $wpi_mb_invoice = wpinv_get_invoice( $post->ID ); |
|
9 | + if ($post_type == 'wpi_invoice' && !empty($post->ID)) { |
|
10 | + $wpi_mb_invoice = wpinv_get_invoice($post->ID); |
|
11 | 11 | } |
12 | 12 | |
13 | - if ( !empty( $wpi_mb_invoice ) && !$wpi_mb_invoice->has_status( array( 'draft', 'auto-draft' ) ) ) { |
|
14 | - add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high' ); |
|
13 | + if (!empty($wpi_mb_invoice) && !$wpi_mb_invoice->has_status(array('draft', 'auto-draft'))) { |
|
14 | + add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high'); |
|
15 | 15 | } |
16 | 16 | |
17 | - if ( !empty( $wpi_mb_invoice ) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent() ) { |
|
18 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscriptions', 'invoicing' ), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high' ); |
|
17 | + if (!empty($wpi_mb_invoice) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent()) { |
|
18 | + add_meta_box('wpinv-mb-subscriptions', __('Subscriptions', 'invoicing'), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high'); |
|
19 | 19 | } |
20 | 20 | |
21 | - if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) { |
|
22 | - add_meta_box( 'wpinv-mb-renewals', __( 'Renewal Payment', 'invoicing' ), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high' ); |
|
21 | + if (wpinv_is_subscription_payment($wpi_mb_invoice)) { |
|
22 | + add_meta_box('wpinv-mb-renewals', __('Renewal Payment', 'invoicing'), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high'); |
|
23 | 23 | } |
24 | 24 | |
25 | - add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default' ); |
|
26 | - add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default' ); |
|
25 | + add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default'); |
|
26 | + add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default'); |
|
27 | 27 | |
28 | - add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' ); |
|
29 | - add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' ); |
|
30 | - add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' ); |
|
28 | + add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high'); |
|
29 | + add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high'); |
|
30 | + add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high'); |
|
31 | 31 | } |
32 | -add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 ); |
|
32 | +add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2); |
|
33 | 33 | |
34 | -function wpinv_save_meta_boxes( $post_id, $post, $update = false ) { |
|
35 | - remove_action( 'save_post', __FUNCTION__ ); |
|
34 | +function wpinv_save_meta_boxes($post_id, $post, $update = false) { |
|
35 | + remove_action('save_post', __FUNCTION__); |
|
36 | 36 | |
37 | 37 | // $post_id and $post are required |
38 | - if ( empty( $post_id ) || empty( $post ) ) { |
|
38 | + if (empty($post_id) || empty($post)) { |
|
39 | 39 | return; |
40 | 40 | } |
41 | 41 | |
42 | - if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) { |
|
42 | + if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) { |
|
43 | 43 | return; |
44 | 44 | } |
45 | 45 | |
46 | 46 | // Dont' save meta boxes for revisions or autosaves |
47 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
47 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
48 | 48 | return; |
49 | 49 | } |
50 | 50 | |
51 | - if ( $post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote' ) { |
|
52 | - if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
51 | + if ($post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote') { |
|
52 | + if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
56 | - if ( isset( $_POST['wpinv_save_invoice'] ) && wp_verify_nonce( $_POST['wpinv_save_invoice'], 'wpinv_save_invoice' ) ) { |
|
57 | - WPInv_Meta_Box_Items::save( $post_id, $_POST, $post ); |
|
56 | + if (isset($_POST['wpinv_save_invoice']) && wp_verify_nonce($_POST['wpinv_save_invoice'], 'wpinv_save_invoice')) { |
|
57 | + WPInv_Meta_Box_Items::save($post_id, $_POST, $post); |
|
58 | 58 | } |
59 | - } else if ( $post->post_type == 'wpi_item' ) { |
|
59 | + } else if ($post->post_type == 'wpi_item') { |
|
60 | 60 | // verify nonce |
61 | - if ( isset( $_POST['wpinv_vat_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save' ) ) { |
|
62 | - $fields = array(); |
|
61 | + if (isset($_POST['wpinv_vat_meta_box_nonce']) && wp_verify_nonce($_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save')) { |
|
62 | + $fields = array(); |
|
63 | 63 | $fields['_wpinv_price'] = 'wpinv_item_price'; |
64 | 64 | $fields['_wpinv_vat_class'] = 'wpinv_vat_class'; |
65 | 65 | $fields['_wpinv_vat_rule'] = 'wpinv_vat_rules'; |
@@ -72,256 +72,256 @@ discard block |
||
72 | 72 | $fields['_wpinv_trial_period'] = 'wpinv_trial_period'; |
73 | 73 | $fields['_wpinv_trial_interval'] = 'wpinv_trial_interval'; |
74 | 74 | |
75 | - if ( !isset( $_POST['wpinv_is_recurring'] ) ) { |
|
75 | + if (!isset($_POST['wpinv_is_recurring'])) { |
|
76 | 76 | $_POST['wpinv_is_recurring'] = 0; |
77 | 77 | } |
78 | 78 | |
79 | - if ( !isset( $_POST['wpinv_free_trial'] ) || empty( $_POST['wpinv_is_recurring'] ) ) { |
|
79 | + if (!isset($_POST['wpinv_free_trial']) || empty($_POST['wpinv_is_recurring'])) { |
|
80 | 80 | $_POST['wpinv_free_trial'] = 0; |
81 | 81 | } |
82 | 82 | |
83 | - foreach ( $fields as $field => $name ) { |
|
84 | - if ( isset( $_POST[ $name ] ) ) { |
|
85 | - if ( $field == '_wpinv_price' ) { |
|
86 | - if ( get_post_meta( $post_id, '_wpinv_type', true ) === 'package' ) { |
|
87 | - $value = wpinv_sanitize_amount( get_post_meta( $post_id, '_wpinv_price', true ) ); // Don't allow edit GD package item price. |
|
83 | + foreach ($fields as $field => $name) { |
|
84 | + if (isset($_POST[$name])) { |
|
85 | + if ($field == '_wpinv_price') { |
|
86 | + if (get_post_meta($post_id, '_wpinv_type', true) === 'package') { |
|
87 | + $value = wpinv_sanitize_amount(get_post_meta($post_id, '_wpinv_price', true)); // Don't allow edit GD package item price. |
|
88 | 88 | } else { |
89 | - $value = wpinv_sanitize_amount( $_POST[ $name ] ); |
|
89 | + $value = wpinv_sanitize_amount($_POST[$name]); |
|
90 | 90 | } |
91 | 91 | } else { |
92 | - $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ]; |
|
92 | + $value = is_string($_POST[$name]) ? sanitize_text_field($_POST[$name]) : $_POST[$name]; |
|
93 | 93 | } |
94 | 94 | |
95 | - $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name ); |
|
96 | - update_post_meta( $post_id, $field, $value ); |
|
95 | + $value = apply_filters('wpinv_item_metabox_save_' . $field, $value, $name); |
|
96 | + update_post_meta($post_id, $field, $value); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | - if ( !get_post_meta( $post_id, '_wpinv_custom_id', true ) ) { |
|
101 | - update_post_meta( $post_id, '_wpinv_custom_id', $post_id ); |
|
100 | + if (!get_post_meta($post_id, '_wpinv_custom_id', true)) { |
|
101 | + update_post_meta($post_id, '_wpinv_custom_id', $post_id); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | } |
105 | 105 | } |
106 | -add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 ); |
|
106 | +add_action('save_post', 'wpinv_save_meta_boxes', 10, 3); |
|
107 | 107 | |
108 | 108 | function wpinv_register_item_meta_boxes() { |
109 | 109 | global $wpinv_euvat; |
110 | 110 | |
111 | - add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' ); |
|
111 | + add_meta_box('wpinv_field_prices', __('Item Price', 'invoicing'), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high'); |
|
112 | 112 | |
113 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
114 | - add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' ); |
|
113 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
114 | + add_meta_box('wpinv_field_vat_rules', __('VAT rules type to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high'); |
|
115 | 115 | } |
116 | 116 | |
117 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
118 | - add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' ); |
|
117 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
118 | + add_meta_box('wpinv_field_vat_classes', __('VAT rates class to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high'); |
|
119 | 119 | } |
120 | 120 | |
121 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' ); |
|
122 | - add_meta_box( 'wpinv_field_meta_values', __( 'Item Meta Values', 'invoicing' ), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core' ); |
|
121 | + add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core'); |
|
122 | + add_meta_box('wpinv_field_meta_values', __('Item Meta Values', 'invoicing'), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core'); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | function wpinv_register_discount_meta_boxes() { |
126 | - add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' ); |
|
126 | + add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high'); |
|
127 | 127 | } |
128 | 128 | |
129 | -function wpinv_discount_metabox_details( $post ) { |
|
129 | +function wpinv_discount_metabox_details($post) { |
|
130 | 130 | $discount_id = $post->ID; |
131 | - $discount = wpinv_get_discount( $discount_id ); |
|
131 | + $discount = wpinv_get_discount($discount_id); |
|
132 | 132 | |
133 | - $type = wpinv_get_discount_type( $discount_id ); |
|
134 | - $item_reqs = wpinv_get_discount_item_reqs( $discount_id ); |
|
135 | - $excluded_items = wpinv_get_discount_excluded_items( $discount_id ); |
|
136 | - $min_total = wpinv_get_discount_min_total( $discount_id ); |
|
137 | - $max_total = wpinv_get_discount_max_total( $discount_id ); |
|
138 | - $max_uses = wpinv_get_discount_max_uses( $discount_id ); |
|
139 | - $single_use = wpinv_discount_is_single_use( $discount_id ); |
|
140 | - $recurring = (bool)wpinv_discount_is_recurring( $discount_id ); |
|
133 | + $type = wpinv_get_discount_type($discount_id); |
|
134 | + $item_reqs = wpinv_get_discount_item_reqs($discount_id); |
|
135 | + $excluded_items = wpinv_get_discount_excluded_items($discount_id); |
|
136 | + $min_total = wpinv_get_discount_min_total($discount_id); |
|
137 | + $max_total = wpinv_get_discount_max_total($discount_id); |
|
138 | + $max_uses = wpinv_get_discount_max_uses($discount_id); |
|
139 | + $single_use = wpinv_discount_is_single_use($discount_id); |
|
140 | + $recurring = (bool)wpinv_discount_is_recurring($discount_id); |
|
141 | 141 | |
142 | 142 | $min_total = $min_total > 0 ? $min_total : ''; |
143 | 143 | $max_total = $max_total > 0 ? $max_total : ''; |
144 | 144 | $max_uses = $max_uses > 0 ? $max_uses : ''; |
145 | 145 | ?> |
146 | -<?php do_action( 'wpinv_discount_form_top', $post ); ?> |
|
147 | -<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?> |
|
146 | +<?php do_action('wpinv_discount_form_top', $post); ?> |
|
147 | +<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?> |
|
148 | 148 | <table class="form-table wpi-form-table"> |
149 | 149 | <tbody> |
150 | - <?php do_action( 'wpinv_discount_form_first', $post ); ?> |
|
151 | - <?php do_action( 'wpinv_discount_form_before_code', $post ); ?> |
|
150 | + <?php do_action('wpinv_discount_form_first', $post); ?> |
|
151 | + <?php do_action('wpinv_discount_form_before_code', $post); ?> |
|
152 | 152 | <tr> |
153 | 153 | <th valign="top" scope="row"> |
154 | - <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label> |
|
154 | + <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label> |
|
155 | 155 | </th> |
156 | 156 | <td> |
157 | - <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required> |
|
158 | - <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p> |
|
157 | + <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required> |
|
158 | + <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p> |
|
159 | 159 | </td> |
160 | 160 | </tr> |
161 | - <?php do_action( 'wpinv_discount_form_before_type', $post ); ?> |
|
161 | + <?php do_action('wpinv_discount_form_before_type', $post); ?> |
|
162 | 162 | <tr> |
163 | 163 | <th valign="top" scope="row"> |
164 | - <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label> |
|
164 | + <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label> |
|
165 | 165 | </th> |
166 | 166 | <td> |
167 | 167 | <select id="wpinv_discount_type" name="type" class="medium-text"> |
168 | - <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?> |
|
169 | - <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option> |
|
168 | + <?php foreach (wpinv_get_discount_types() as $value => $label) { ?> |
|
169 | + <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option> |
|
170 | 170 | <?php } ?> |
171 | 171 | </select> |
172 | - <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p> |
|
172 | + <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p> |
|
173 | 173 | </td> |
174 | 174 | </tr> |
175 | - <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?> |
|
175 | + <?php do_action('wpinv_discount_form_before_amount', $post); ?> |
|
176 | 176 | <tr> |
177 | 177 | <th valign="top" scope="row"> |
178 | - <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label> |
|
178 | + <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label> |
|
179 | 179 | </th> |
180 | 180 | <td> |
181 | - <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr( wpinv_get_discount_amount( $discount_id ) ); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol() ;?></font> |
|
182 | - <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p> |
|
183 | - <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p> |
|
181 | + <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr(wpinv_get_discount_amount($discount_id)); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol(); ?></font> |
|
182 | + <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p> |
|
183 | + <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p> |
|
184 | 184 | </td> |
185 | 185 | </tr> |
186 | - <?php do_action( 'wpinv_discount_form_before_items', $post ); ?> |
|
186 | + <?php do_action('wpinv_discount_form_before_items', $post); ?> |
|
187 | 187 | <tr> |
188 | 188 | <th valign="top" scope="row"> |
189 | - <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label> |
|
189 | + <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label> |
|
190 | 190 | </th> |
191 | 191 | <td> |
192 | - <p><?php echo wpinv_item_dropdown( array( |
|
192 | + <p><?php echo wpinv_item_dropdown(array( |
|
193 | 193 | 'name' => 'items[]', |
194 | 194 | 'id' => 'items', |
195 | 195 | 'selected' => $item_reqs, |
196 | 196 | 'multiple' => true, |
197 | 197 | 'chosen' => true, |
198 | 198 | 'class' => 'medium-text', |
199 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
199 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
200 | 200 | 'show_recurring' => true, |
201 | - ) ); ?> |
|
201 | + )); ?> |
|
202 | 202 | </p> |
203 | - <p class="description"><?php _e( 'Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing' ); ?></p> |
|
203 | + <p class="description"><?php _e('Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing'); ?></p> |
|
204 | 204 | </td> |
205 | 205 | </tr> |
206 | - <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?> |
|
206 | + <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?> |
|
207 | 207 | <tr> |
208 | 208 | <th valign="top" scope="row"> |
209 | - <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label> |
|
209 | + <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label> |
|
210 | 210 | </th> |
211 | 211 | <td> |
212 | - <p><?php echo wpinv_item_dropdown( array( |
|
212 | + <p><?php echo wpinv_item_dropdown(array( |
|
213 | 213 | 'name' => 'excluded_items[]', |
214 | 214 | 'id' => 'excluded_items', |
215 | 215 | 'selected' => $excluded_items, |
216 | 216 | 'multiple' => true, |
217 | 217 | 'chosen' => true, |
218 | 218 | 'class' => 'medium-text', |
219 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
219 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
220 | 220 | 'show_recurring' => true, |
221 | - ) ); ?> |
|
221 | + )); ?> |
|
222 | 222 | </p> |
223 | - <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p> |
|
223 | + <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p> |
|
224 | 224 | </td> |
225 | 225 | </tr> |
226 | - <?php do_action( 'wpinv_discount_form_before_start', $post ); ?> |
|
226 | + <?php do_action('wpinv_discount_form_before_start', $post); ?> |
|
227 | 227 | <tr> |
228 | 228 | <th valign="top" scope="row"> |
229 | - <label for="wpinv_discount_start"><?php _e( 'Start Date', 'invoicing' ); ?></label> |
|
229 | + <label for="wpinv_discount_start"><?php _e('Start Date', 'invoicing'); ?></label> |
|
230 | 230 | </th> |
231 | 231 | <td> |
232 | - <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( wpinv_get_discount_start_date( $discount_id ) ); ?>"> |
|
233 | - <p class="description"><?php _e( 'Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?></p> |
|
232 | + <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr(wpinv_get_discount_start_date($discount_id)); ?>"> |
|
233 | + <p class="description"><?php _e('Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?></p> |
|
234 | 234 | </td> |
235 | 235 | </tr> |
236 | - <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?> |
|
236 | + <?php do_action('wpinv_discount_form_before_expiration', $post); ?> |
|
237 | 237 | <tr> |
238 | 238 | <th valign="top" scope="row"> |
239 | - <label for="wpinv_discount_expiration"><?php _e( 'Expiration Date', 'invoicing' ); ?></label> |
|
239 | + <label for="wpinv_discount_expiration"><?php _e('Expiration Date', 'invoicing'); ?></label> |
|
240 | 240 | </th> |
241 | 241 | <td> |
242 | - <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( wpinv_get_discount_expiration( $discount_id ) ); ?>"> |
|
243 | - <p class="description"><?php _e( 'Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing' ); ?></p> |
|
242 | + <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr(wpinv_get_discount_expiration($discount_id)); ?>"> |
|
243 | + <p class="description"><?php _e('Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing'); ?></p> |
|
244 | 244 | </td> |
245 | 245 | </tr> |
246 | - <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?> |
|
246 | + <?php do_action('wpinv_discount_form_before_min_total', $post); ?> |
|
247 | 247 | <tr> |
248 | 248 | <th valign="top" scope="row"> |
249 | - <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label> |
|
249 | + <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label> |
|
250 | 250 | </th> |
251 | 251 | <td> |
252 | 252 | <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>"> |
253 | - <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
253 | + <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
254 | 254 | </td> |
255 | 255 | </tr> |
256 | - <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?> |
|
256 | + <?php do_action('wpinv_discount_form_before_max_total', $post); ?> |
|
257 | 257 | <tr> |
258 | 258 | <th valign="top" scope="row"> |
259 | - <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label> |
|
259 | + <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label> |
|
260 | 260 | </th> |
261 | 261 | <td> |
262 | 262 | <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>"> |
263 | - <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
263 | + <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
264 | 264 | </td> |
265 | 265 | </tr> |
266 | - <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?> |
|
266 | + <?php do_action('wpinv_discount_form_before_recurring', $post); ?> |
|
267 | 267 | <tr> |
268 | 268 | <th valign="top" scope="row"> |
269 | - <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label> |
|
269 | + <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label> |
|
270 | 270 | </th> |
271 | 271 | <td> |
272 | 272 | <select id="wpinv_discount_recurring" name="recurring" class="medium-text"> |
273 | - <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option> |
|
274 | - <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option> |
|
273 | + <option value="0" <?php selected(false, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option> |
|
274 | + <option value="1" <?php selected(true, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option> |
|
275 | 275 | </select> |
276 | - <p class="description"><?php _e( '<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing' ); ?></p> |
|
276 | + <p class="description"><?php _e('<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing'); ?></p> |
|
277 | 277 | </td> |
278 | 278 | </tr> |
279 | - <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?> |
|
279 | + <?php do_action('wpinv_discount_form_before_max_uses', $post); ?> |
|
280 | 280 | <tr> |
281 | 281 | <th valign="top" scope="row"> |
282 | - <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label> |
|
282 | + <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label> |
|
283 | 283 | </th> |
284 | 284 | <td> |
285 | 285 | <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>"> |
286 | - <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p> |
|
286 | + <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p> |
|
287 | 287 | </td> |
288 | 288 | </tr> |
289 | - <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?> |
|
289 | + <?php do_action('wpinv_discount_form_before_single_use', $post); ?> |
|
290 | 290 | <tr> |
291 | 291 | <th valign="top" scope="row"> |
292 | - <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label> |
|
292 | + <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label> |
|
293 | 293 | </th> |
294 | 294 | <td> |
295 | - <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>> |
|
296 | - <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span> |
|
295 | + <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>> |
|
296 | + <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span> |
|
297 | 297 | </td> |
298 | 298 | </tr> |
299 | - <?php do_action( 'wpinv_discount_form_last', $post ); ?> |
|
299 | + <?php do_action('wpinv_discount_form_last', $post); ?> |
|
300 | 300 | </tbody> |
301 | 301 | </table> |
302 | -<?php do_action( 'wpinv_discount_form_bottom', $post ); ?> |
|
302 | +<?php do_action('wpinv_discount_form_bottom', $post); ?> |
|
303 | 303 | <?php |
304 | 304 | } |
305 | 305 | |
306 | -function wpinv_discount_metabox_save( $post_id, $post, $update = false ) { |
|
307 | - $post_type = !empty( $post ) ? $post->post_type : ''; |
|
306 | +function wpinv_discount_metabox_save($post_id, $post, $update = false) { |
|
307 | + $post_type = !empty($post) ? $post->post_type : ''; |
|
308 | 308 | |
309 | - if ( $post_type != 'wpi_discount' ) { |
|
309 | + if ($post_type != 'wpi_discount') { |
|
310 | 310 | return; |
311 | 311 | } |
312 | 312 | |
313 | - if ( !isset( $_POST['wpinv_discount_metabox_nonce'] ) || ( isset( $_POST['wpinv_discount_metabox_nonce'] ) && !wp_verify_nonce( $_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce' ) ) ) { |
|
313 | + if (!isset($_POST['wpinv_discount_metabox_nonce']) || (isset($_POST['wpinv_discount_metabox_nonce']) && !wp_verify_nonce($_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce'))) { |
|
314 | 314 | return; |
315 | 315 | } |
316 | 316 | |
317 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
317 | + if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
318 | 318 | return; |
319 | 319 | } |
320 | 320 | |
321 | - if ( !current_user_can( 'manage_options', $post_id ) ) { |
|
321 | + if (!current_user_can('manage_options', $post_id)) { |
|
322 | 322 | return; |
323 | 323 | } |
324 | 324 | |
325 | - return wpinv_store_discount( $post_id, $_POST, $post, $update ); |
|
325 | + return wpinv_store_discount($post_id, $_POST, $post, $update); |
|
326 | 326 | } |
327 | -add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 ); |
|
328 | 327 | \ No newline at end of file |
328 | +add_action('save_post', 'wpinv_discount_metabox_save', 10, 3); |
|
329 | 329 | \ No newline at end of file |
@@ -21,6 +21,9 @@ |
||
21 | 21 | add_shortcode( 'wpinv_messages', __CLASS__ . '::messages' ); |
22 | 22 | } |
23 | 23 | |
24 | + /** |
|
25 | + * @param string[] $function |
|
26 | + */ |
|
24 | 27 | public static function shortcode_wrapper( |
25 | 28 | $function, |
26 | 29 | $atts = array(), |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly |
4 | 4 | } |
5 | 5 | |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | 'wpinv_receipt' => __CLASS__ . '::receipt', |
15 | 15 | ); |
16 | 16 | |
17 | - foreach ( $shortcodes as $shortcode => $function ) { |
|
18 | - add_shortcode( apply_filters( "{$shortcode}_shortcode_tag", $shortcode ), $function ); |
|
17 | + foreach ($shortcodes as $shortcode => $function) { |
|
18 | + add_shortcode(apply_filters("{$shortcode}_shortcode_tag", $shortcode), $function); |
|
19 | 19 | } |
20 | 20 | |
21 | - add_shortcode( 'wpinv_messages', __CLASS__ . '::messages' ); |
|
21 | + add_shortcode('wpinv_messages', __CLASS__ . '::messages'); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public static function shortcode_wrapper( |
@@ -32,25 +32,25 @@ discard block |
||
32 | 32 | ) { |
33 | 33 | ob_start(); |
34 | 34 | |
35 | - echo empty( $wrapper['before'] ) ? '<div class="' . esc_attr( $wrapper['class'] ) . '">' : $wrapper['before']; |
|
36 | - call_user_func( $function, $atts ); |
|
37 | - echo empty( $wrapper['after'] ) ? '</div>' : $wrapper['after']; |
|
35 | + echo empty($wrapper['before']) ? '<div class="' . esc_attr($wrapper['class']) . '">' : $wrapper['before']; |
|
36 | + call_user_func($function, $atts); |
|
37 | + echo empty($wrapper['after']) ? '</div>' : $wrapper['after']; |
|
38 | 38 | |
39 | 39 | return ob_get_clean(); |
40 | 40 | } |
41 | 41 | |
42 | - public static function checkout( $atts = array(), $content = null ) { |
|
43 | - return wpinv_checkout_form( $atts, $content ); |
|
42 | + public static function checkout($atts = array(), $content = null) { |
|
43 | + return wpinv_checkout_form($atts, $content); |
|
44 | 44 | } |
45 | 45 | |
46 | - public static function messages( $atts, $content = null ) { |
|
46 | + public static function messages($atts, $content = null) { |
|
47 | 47 | ob_start(); |
48 | 48 | wpinv_print_errors(); |
49 | 49 | return '<div class="wpinv">' . ob_get_clean() . '</div>'; |
50 | 50 | } |
51 | 51 | |
52 | - public static function history( $atts, $content = null ) { |
|
53 | - return self::shortcode_wrapper( array( __CLASS__, 'history_output' ), $atts ); |
|
52 | + public static function history($atts, $content = null) { |
|
53 | + return self::shortcode_wrapper(array(__CLASS__, 'history_output'), $atts); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @param array $atts |
60 | 60 | */ |
61 | - public static function history_output( $atts ) { |
|
62 | - do_action( 'wpinv_before_user_invoice_history' ); |
|
63 | - wpinv_get_template_part( 'wpinv-invoice-history', $atts ); |
|
64 | - do_action( 'wpinv_after_user_invoice_history' ); |
|
61 | + public static function history_output($atts) { |
|
62 | + do_action('wpinv_before_user_invoice_history'); |
|
63 | + wpinv_get_template_part('wpinv-invoice-history', $atts); |
|
64 | + do_action('wpinv_after_user_invoice_history'); |
|
65 | 65 | } |
66 | 66 | |
67 | - public static function receipt( $atts, $content = null ) { |
|
68 | - return wpinv_payment_receipt( $atts, $content ); |
|
67 | + public static function receipt($atts, $content = null) { |
|
68 | + return wpinv_payment_receipt($atts, $content); |
|
69 | 69 | } |
70 | 70 | } |
@@ -11,45 +11,45 @@ |
||
11 | 11 | * @since 1.0.0 |
12 | 12 | */ |
13 | 13 | function wpinv_automatic_upgrade() { |
14 | - $wpi_version = get_option( 'wpinv_version' ); |
|
14 | + $wpi_version = get_option('wpinv_version'); |
|
15 | 15 | |
16 | - if ( $wpi_version == WPINV_VERSION ) { |
|
16 | + if ($wpi_version == WPINV_VERSION) { |
|
17 | 17 | return; |
18 | 18 | } |
19 | 19 | |
20 | - if ( version_compare( $wpi_version, '0.0.5', '<' ) ) { |
|
20 | + if (version_compare($wpi_version, '0.0.5', '<')) { |
|
21 | 21 | wpinv_v005_upgrades(); |
22 | 22 | } |
23 | 23 | |
24 | - update_option( 'wpinv_version', WPINV_VERSION ); |
|
24 | + update_option('wpinv_version', WPINV_VERSION); |
|
25 | 25 | } |
26 | -add_action( 'admin_init', 'wpinv_automatic_upgrade' ); |
|
26 | +add_action('admin_init', 'wpinv_automatic_upgrade'); |
|
27 | 27 | |
28 | 28 | function wpinv_v005_upgrades() { |
29 | 29 | global $wpdb; |
30 | 30 | |
31 | 31 | // Invoices status |
32 | - $results = $wpdb->get_results( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" ); |
|
33 | - if ( !empty( $results ) ) { |
|
34 | - $wpdb->query( "UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" ); |
|
32 | + $results = $wpdb->get_results("SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )"); |
|
33 | + if (!empty($results)) { |
|
34 | + $wpdb->query("UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )"); |
|
35 | 35 | |
36 | 36 | // Clean post cache |
37 | - foreach ( $results as $row ) { |
|
38 | - clean_post_cache( $row->ID ); |
|
37 | + foreach ($results as $row) { |
|
38 | + clean_post_cache($row->ID); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | 42 | // Item meta key changes |
43 | 43 | $query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )"; |
44 | - $results = $wpdb->get_results( $query ); |
|
44 | + $results = $wpdb->get_results($query); |
|
45 | 45 | |
46 | - if ( !empty( $results ) ) { |
|
47 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" ); |
|
48 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" ); |
|
49 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" ); |
|
46 | + if (!empty($results)) { |
|
47 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )"); |
|
48 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'"); |
|
49 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'"); |
|
50 | 50 | |
51 | - foreach ( $results as $row ) { |
|
52 | - clean_post_cache( $row->post_id ); |
|
51 | + foreach ($results as $row) { |
|
52 | + clean_post_cache($row->post_id); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 |
@@ -7,15 +7,15 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | class WPInv_Plugin { |
15 | 15 | private static $instance; |
16 | 16 | |
17 | 17 | public static function run() { |
18 | - if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) { |
|
18 | + if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) { |
|
19 | 19 | self::$instance = new WPInv_Plugin; |
20 | 20 | self::$instance->includes(); |
21 | 21 | self::$instance->actions(); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | self::$instance->reports = new WPInv_Reports(); |
24 | 24 | } |
25 | 25 | |
26 | - do_action( 'wpinv_loaded' ); |
|
26 | + do_action('wpinv_loaded'); |
|
27 | 27 | |
28 | 28 | return self::$instance; |
29 | 29 | } |
@@ -33,31 +33,31 @@ discard block |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | public function define_constants() { |
36 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
37 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
36 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
37 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | private function actions() { |
41 | 41 | /* Internationalize the text strings used. */ |
42 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
42 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
43 | 43 | |
44 | 44 | /* Perform actions on admin initialization. */ |
45 | - add_action( 'admin_init', array( &$this, 'admin_init') ); |
|
46 | - add_action( 'init', array( &$this, 'init' ), 3 ); |
|
47 | - add_action( 'init', array( 'WPInv_Shortcodes', 'init' ) ); |
|
48 | - add_action( 'init', array( &$this, 'wpinv_actions' ) ); |
|
45 | + add_action('admin_init', array(&$this, 'admin_init')); |
|
46 | + add_action('init', array(&$this, 'init'), 3); |
|
47 | + add_action('init', array('WPInv_Shortcodes', 'init')); |
|
48 | + add_action('init', array(&$this, 'wpinv_actions')); |
|
49 | 49 | |
50 | - if ( class_exists( 'BuddyPress' ) ) { |
|
51 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
50 | + if (class_exists('BuddyPress')) { |
|
51 | + add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
|
52 | 52 | } |
53 | 53 | |
54 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
54 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
55 | 55 | |
56 | - if ( is_admin() ) { |
|
57 | - add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) ); |
|
58 | - add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) ); |
|
56 | + if (is_admin()) { |
|
57 | + add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts')); |
|
58 | + add_action('admin_body_class', array(&$this, 'admin_body_class')); |
|
59 | 59 | } else { |
60 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
60 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference. |
69 | 69 | */ |
70 | - do_action_ref_array( 'wpinv_actions', array( &$this ) ); |
|
70 | + do_action_ref_array('wpinv_actions', array(&$this)); |
|
71 | 71 | |
72 | - add_action( 'admin_init', array( &$this, 'activation_redirect') ); |
|
72 | + add_action('admin_init', array(&$this, 'activation_redirect')); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | public function plugins_loaded() { |
@@ -83,193 +83,193 @@ discard block |
||
83 | 83 | * @since 1.0 |
84 | 84 | */ |
85 | 85 | public function load_textdomain() { |
86 | - $locale = apply_filters( 'plugin_locale', get_locale(), 'invoicing' ); |
|
86 | + $locale = apply_filters('plugin_locale', get_locale(), 'invoicing'); |
|
87 | 87 | |
88 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
89 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
88 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
89 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * Define language constants. |
93 | 93 | */ |
94 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
94 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | public function includes() { |
98 | 98 | global $wpinv_options; |
99 | 99 | |
100 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
100 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
101 | 101 | $wpinv_options = wpinv_get_settings(); |
102 | 102 | |
103 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' ); |
|
104 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
105 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
106 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
107 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
108 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
109 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
110 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' ); |
|
111 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
112 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
113 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
114 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
115 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
116 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gd-functions.php' ); |
|
117 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' ); |
|
103 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php'); |
|
104 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
105 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
106 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
107 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
108 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
109 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
110 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php'); |
|
111 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
112 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
113 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
114 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
115 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
116 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gd-functions.php'); |
|
117 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php'); |
|
118 | 118 | //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
119 | 119 | //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
120 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' ); |
|
120 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php'); |
|
121 | 121 | //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscription.php' ); |
122 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' ); |
|
123 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' ); |
|
124 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php' ); |
|
125 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
126 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
127 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
128 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' ); |
|
129 | - if ( !class_exists( 'Geodir_EUVat' ) ) { |
|
130 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
122 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php'); |
|
123 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php'); |
|
124 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php'); |
|
125 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
126 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
127 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
128 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php'); |
|
129 | + if (!class_exists('Geodir_EUVat')) { |
|
130 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
131 | 131 | } |
132 | 132 | |
133 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
134 | - if ( !empty( $gateways ) ) { |
|
135 | - foreach ( $gateways as $gateway ) { |
|
136 | - if ( $gateway == 'manual' ) { |
|
133 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
134 | + if (!empty($gateways)) { |
|
135 | + foreach ($gateways as $gateway) { |
|
136 | + if ($gateway == 'manual') { |
|
137 | 137 | continue; |
138 | 138 | } |
139 | 139 | |
140 | 140 | $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; |
141 | 141 | |
142 | - if ( file_exists( $gateway_file ) ) { |
|
143 | - require_once( $gateway_file ); |
|
142 | + if (file_exists($gateway_file)) { |
|
143 | + require_once($gateway_file); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | } |
147 | - require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' ); |
|
147 | + require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php'); |
|
148 | 148 | |
149 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
150 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
151 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
152 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' ); |
|
149 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
150 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
151 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
152 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php'); |
|
153 | 153 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' ); |
154 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' ); |
|
155 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' ); |
|
156 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
157 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' ); |
|
158 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
154 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php'); |
|
155 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php'); |
|
156 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
157 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php'); |
|
158 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
159 | 159 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
160 | 160 | } |
161 | 161 | |
162 | 162 | // include css inliner |
163 | - if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { |
|
164 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
163 | + if (!class_exists('Emogrifier') && class_exists('DOMDocument')) { |
|
164 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
165 | 165 | } |
166 | 166 | |
167 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
167 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | public function init() { |
171 | 171 | } |
172 | 172 | |
173 | 173 | public function admin_init() { |
174 | - if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) { |
|
174 | + if (!(defined('DOING_AJAX') && DOING_AJAX)) { |
|
175 | 175 | } |
176 | 176 | |
177 | - add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) ); |
|
177 | + add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php')); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | public function activation_redirect() { |
181 | 181 | // Bail if no activation redirect |
182 | - if ( !get_transient( '_wpinv_activation_redirect' ) ) { |
|
182 | + if (!get_transient('_wpinv_activation_redirect')) { |
|
183 | 183 | return; |
184 | 184 | } |
185 | 185 | |
186 | 186 | // Delete the redirect transient |
187 | - delete_transient( '_wpinv_activation_redirect' ); |
|
187 | + delete_transient('_wpinv_activation_redirect'); |
|
188 | 188 | |
189 | 189 | // Bail if activating from network, or bulk |
190 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
190 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | |
194 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
194 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
195 | 195 | exit; |
196 | 196 | } |
197 | 197 | |
198 | 198 | public function enqueue_scripts() { |
199 | - $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
199 | + $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
200 | 200 | |
201 | - wp_deregister_style( 'font-awesome' ); |
|
202 | - wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' ); |
|
203 | - wp_enqueue_style( 'font-awesome' ); |
|
201 | + wp_deregister_style('font-awesome'); |
|
202 | + wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0'); |
|
203 | + wp_enqueue_style('font-awesome'); |
|
204 | 204 | |
205 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION ); |
|
206 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
205 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION); |
|
206 | + wp_enqueue_style('wpinv_front_style'); |
|
207 | 207 | |
208 | 208 | // Register scripts |
209 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
210 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array( 'jquery', 'wpinv-vat-script' ), WPINV_VERSION ); |
|
209 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
210 | + wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array('jquery', 'wpinv-vat-script'), WPINV_VERSION); |
|
211 | 211 | |
212 | 212 | $localize = array(); |
213 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
214 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
213 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
214 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
215 | 215 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
216 | 216 | $localize['currency_pos'] = wpinv_currency_position(); |
217 | 217 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
218 | 218 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
219 | 219 | $localize['decimals'] = wpinv_decimals(); |
220 | 220 | |
221 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
221 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
222 | 222 | |
223 | - wp_enqueue_script( 'jquery-blockui' ); |
|
224 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
225 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
223 | + wp_enqueue_script('jquery-blockui'); |
|
224 | + wp_enqueue_script('wpinv-front-script'); |
|
225 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | public function admin_enqueue_scripts() { |
229 | 229 | global $post, $pagenow; |
230 | 230 | |
231 | 231 | $post_type = wpinv_admin_post_type(); |
232 | - $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
232 | + $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
233 | 233 | |
234 | - wp_deregister_style( 'font-awesome' ); |
|
235 | - wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' ); |
|
236 | - wp_enqueue_style( 'font-awesome' ); |
|
234 | + wp_deregister_style('font-awesome'); |
|
235 | + wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0'); |
|
236 | + wp_enqueue_style('font-awesome'); |
|
237 | 237 | |
238 | - wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); |
|
239 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
238 | + wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16'); |
|
239 | + wp_enqueue_style('jquery-ui-css'); |
|
240 | 240 | |
241 | - wp_register_style( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2' ); |
|
242 | - wp_enqueue_style( 'jquery-chosen' ); |
|
241 | + wp_register_style('jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2'); |
|
242 | + wp_enqueue_style('jquery-chosen'); |
|
243 | 243 | |
244 | - wp_register_script( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array( 'jquery' ), '1.6.2' ); |
|
245 | - wp_enqueue_script( 'jquery-chosen' ); |
|
244 | + wp_register_script('jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array('jquery'), '1.6.2'); |
|
245 | + wp_enqueue_script('jquery-chosen'); |
|
246 | 246 | |
247 | - wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
|
248 | - wp_enqueue_style( 'wpinv_meta_box_style' ); |
|
247 | + wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
248 | + wp_enqueue_style('wpinv_meta_box_style'); |
|
249 | 249 | |
250 | - wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION ); |
|
251 | - wp_enqueue_style( 'wpinv_admin_style' ); |
|
250 | + wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION); |
|
251 | + wp_enqueue_style('wpinv_admin_style'); |
|
252 | 252 | |
253 | - if ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) { |
|
254 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
253 | + if ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
|
254 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
255 | 255 | } |
256 | 256 | |
257 | - wp_enqueue_style( 'wp-color-picker' ); |
|
258 | - wp_enqueue_script( 'wp-color-picker' ); |
|
257 | + wp_enqueue_style('wp-color-picker'); |
|
258 | + wp_enqueue_script('wp-color-picker'); |
|
259 | 259 | |
260 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
260 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
261 | 261 | |
262 | - wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui' ), WPINV_VERSION ); |
|
263 | - wp_enqueue_script( 'wpinv-admin-script' ); |
|
262 | + wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array('jquery', 'jquery-blockui'), WPINV_VERSION); |
|
263 | + wp_enqueue_script('wpinv-admin-script'); |
|
264 | 264 | |
265 | 265 | $localize = array(); |
266 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
267 | - $localize['post_ID'] = isset( $post->ID ) ? $post->ID : ''; |
|
268 | - $localize['wpinv_nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
269 | - $localize['add_invoice_note_nonce'] = wp_create_nonce( 'add-invoice-note' ); |
|
270 | - $localize['delete_invoice_note_nonce'] = wp_create_nonce( 'delete-invoice-note' ); |
|
271 | - $localize['invoice_item_nonce'] = wp_create_nonce( 'invoice-item' ); |
|
272 | - $localize['billing_details_nonce'] = wp_create_nonce( 'get-billing-details' ); |
|
266 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
267 | + $localize['post_ID'] = isset($post->ID) ? $post->ID : ''; |
|
268 | + $localize['wpinv_nonce'] = wp_create_nonce('wpinv-nonce'); |
|
269 | + $localize['add_invoice_note_nonce'] = wp_create_nonce('add-invoice-note'); |
|
270 | + $localize['delete_invoice_note_nonce'] = wp_create_nonce('delete-invoice-note'); |
|
271 | + $localize['invoice_item_nonce'] = wp_create_nonce('invoice-item'); |
|
272 | + $localize['billing_details_nonce'] = wp_create_nonce('get-billing-details'); |
|
273 | 273 | $localize['tax'] = wpinv_tax_amount(); |
274 | 274 | $localize['discount'] = wpinv_discount_amount(); |
275 | 275 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
@@ -277,65 +277,65 @@ discard block |
||
277 | 277 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
278 | 278 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
279 | 279 | $localize['decimals'] = wpinv_decimals(); |
280 | - $localize['save_invoice'] = __( 'Save Invoice', 'invoicing' ); |
|
281 | - $localize['status_publish'] = wpinv_status_nicename( 'publish' ); |
|
282 | - $localize['status_pending'] = wpinv_status_nicename( 'wpi-pending' ); |
|
283 | - $localize['delete_tax_rate'] = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ); |
|
284 | - $localize['OneItemMin'] = __( 'Invoice must contain at least one item', 'invoicing' ); |
|
285 | - $localize['DeleteInvoiceItem'] = __( 'Are you sure you wish to delete this item?', 'invoicing' ); |
|
286 | - $localize['FillBillingDetails'] = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ); |
|
287 | - $localize['confirmCalcTotals'] = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ); |
|
288 | - $localize['AreYouSure'] = __( 'Are you sure?', 'invoicing' ); |
|
280 | + $localize['save_invoice'] = __('Save Invoice', 'invoicing'); |
|
281 | + $localize['status_publish'] = wpinv_status_nicename('publish'); |
|
282 | + $localize['status_pending'] = wpinv_status_nicename('wpi-pending'); |
|
283 | + $localize['delete_tax_rate'] = __('Are you sure you wish to delete this tax rate?', 'invoicing'); |
|
284 | + $localize['OneItemMin'] = __('Invoice must contain at least one item', 'invoicing'); |
|
285 | + $localize['DeleteInvoiceItem'] = __('Are you sure you wish to delete this item?', 'invoicing'); |
|
286 | + $localize['FillBillingDetails'] = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'); |
|
287 | + $localize['confirmCalcTotals'] = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'); |
|
288 | + $localize['AreYouSure'] = __('Are you sure?', 'invoicing'); |
|
289 | 289 | $localize['hasGD'] = wpinv_gd_active(); |
290 | 290 | $localize['hasPM'] = wpinv_pm_active(); |
291 | - $localize['emptyInvoice'] = __( 'Add atleast one item to save invoice!', 'invoicing' ); |
|
292 | - $localize['deletePackage'] = __( 'GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing' ); |
|
293 | - $localize['deletePackages'] = __( 'GD package items should be deleted from GD payment manager only', 'invoicing' ); |
|
294 | - $localize['deleteInvoiceFirst'] = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ); |
|
291 | + $localize['emptyInvoice'] = __('Add atleast one item to save invoice!', 'invoicing'); |
|
292 | + $localize['deletePackage'] = __('GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing'); |
|
293 | + $localize['deletePackages'] = __('GD package items should be deleted from GD payment manager only', 'invoicing'); |
|
294 | + $localize['deleteInvoiceFirst'] = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'); |
|
295 | 295 | |
296 | - $localize = apply_filters( 'wpinv_admin_js_localize', $localize ); |
|
296 | + $localize = apply_filters('wpinv_admin_js_localize', $localize); |
|
297 | 297 | |
298 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize ); |
|
298 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize); |
|
299 | 299 | } |
300 | 300 | |
301 | - public function admin_body_class( $classes ) { |
|
301 | + public function admin_body_class($classes) { |
|
302 | 302 | global $pagenow, $post, $current_screen; |
303 | 303 | |
304 | - if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) { |
|
304 | + if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) { |
|
305 | 305 | $classes .= ' wpinv-cpt'; |
306 | 306 | } |
307 | 307 | |
308 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
308 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
309 | 309 | |
310 | 310 | $add_class = false; |
311 | - if ( $pagenow == 'admin.php' && $page ) { |
|
312 | - $add_class = strpos( $page, 'wpinv-' ); |
|
311 | + if ($pagenow == 'admin.php' && $page) { |
|
312 | + $add_class = strpos($page, 'wpinv-'); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | $settings_class = array(); |
316 | - if ( $page == 'wpinv-settings' ) { |
|
317 | - if ( !empty( $_REQUEST['tab'] ) ) { |
|
318 | - $settings_class[] = sanitize_text_field( $_REQUEST['tab'] ); |
|
316 | + if ($page == 'wpinv-settings') { |
|
317 | + if (!empty($_REQUEST['tab'])) { |
|
318 | + $settings_class[] = sanitize_text_field($_REQUEST['tab']); |
|
319 | 319 | } |
320 | 320 | |
321 | - if ( !empty( $_REQUEST['section'] ) ) { |
|
322 | - $settings_class[] = sanitize_text_field( $_REQUEST['section'] ); |
|
321 | + if (!empty($_REQUEST['section'])) { |
|
322 | + $settings_class[] = sanitize_text_field($_REQUEST['section']); |
|
323 | 323 | } |
324 | 324 | |
325 | - $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main'; |
|
325 | + $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main'; |
|
326 | 326 | } |
327 | 327 | |
328 | - if ( !empty( $settings_class ) ) { |
|
329 | - $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) ); |
|
328 | + if (!empty($settings_class)) { |
|
329 | + $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-')); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | $post_type = wpinv_admin_post_type(); |
333 | 333 | |
334 | - if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) { |
|
334 | + if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) { |
|
335 | 335 | return $classes .= ' wpinv'; |
336 | 336 | } |
337 | 337 | |
338 | - if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) { |
|
338 | + if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) { |
|
339 | 339 | $classes .= ' wpi-editable-n'; |
340 | 340 | } |
341 | 341 | |
@@ -347,20 +347,20 @@ discard block |
||
347 | 347 | } |
348 | 348 | |
349 | 349 | public function wpinv_actions() { |
350 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
351 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
350 | + if (isset($_REQUEST['wpi_action'])) { |
|
351 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
352 | 352 | } |
353 | 353 | } |
354 | 354 | |
355 | - public function pre_get_posts( $wp_query ) { |
|
356 | - if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
357 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
355 | + public function pre_get_posts($wp_query) { |
|
356 | + if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
357 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | return $wp_query; |
361 | 361 | } |
362 | 362 | |
363 | 363 | public function bp_invoicing_init() { |
364 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
364 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
365 | 365 | } |
366 | 366 | } |
367 | 367 | \ No newline at end of file |