@@ -1,126 +1,126 @@ 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-payment-form-design', __( 'Payment Form', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' ); |
|
29 | - add_meta_box( 'wpinv-payment-form-shortcode', __( 'Shortcode', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_shortcode', 'wpi_payment_form', 'side' ); |
|
28 | + add_meta_box('wpinv-payment-form-design', __('Payment Form', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal'); |
|
29 | + add_meta_box('wpinv-payment-form-shortcode', __('Shortcode', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output_shortcode', 'wpi_payment_form', 'side'); |
|
30 | 30 | |
31 | - add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' ); |
|
32 | - add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' ); |
|
33 | - add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' ); |
|
31 | + add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high'); |
|
32 | + add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high'); |
|
33 | + add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high'); |
|
34 | 34 | |
35 | - if ( ! empty( $post->ID ) && get_post_meta( $post->ID, 'payment_form_data', true ) ) { |
|
36 | - add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high' ); |
|
35 | + if (!empty($post->ID) && get_post_meta($post->ID, 'payment_form_data', true)) { |
|
36 | + add_meta_box('wpinv-invoice-payment-form-details', __('Payment Form Details', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high'); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal'); |
40 | 40 | } |
41 | -add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 ); |
|
41 | +add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2); |
|
42 | 42 | |
43 | -function wpinv_save_meta_boxes( $post_id, $post, $update = false ) { |
|
44 | - remove_action( 'save_post', __FUNCTION__ ); |
|
43 | +function wpinv_save_meta_boxes($post_id, $post, $update = false) { |
|
44 | + remove_action('save_post', __FUNCTION__); |
|
45 | 45 | |
46 | 46 | // $post_id and $post are required |
47 | - if ( empty( $post_id ) || empty( $post ) ) { |
|
47 | + if (empty($post_id) || empty($post)) { |
|
48 | 48 | return; |
49 | 49 | } |
50 | 50 | |
51 | - if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) { |
|
51 | + if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) { |
|
52 | 52 | return; |
53 | 53 | } |
54 | 54 | |
55 | 55 | // Dont' save meta boxes for revisions or autosaves |
56 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
56 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
57 | 57 | return; |
58 | 58 | } |
59 | 59 | |
60 | - if ( $post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote' ) { |
|
61 | - if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
60 | + if ($post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote') { |
|
61 | + if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
62 | 62 | return; |
63 | 63 | } |
64 | 64 | |
65 | - if ( isset( $_POST['wpinv_save_invoice'] ) && wp_verify_nonce( $_POST['wpinv_save_invoice'], 'wpinv_save_invoice' ) ) { |
|
66 | - WPInv_Meta_Box_Items::save( $post_id, $_POST, $post ); |
|
65 | + if (isset($_POST['wpinv_save_invoice']) && wp_verify_nonce($_POST['wpinv_save_invoice'], 'wpinv_save_invoice')) { |
|
66 | + WPInv_Meta_Box_Items::save($post_id, $_POST, $post); |
|
67 | 67 | } |
68 | - } else if ( $post->post_type == 'wpi_item' ) { |
|
69 | - GetPaid_Meta_Box_Item_Details::save( $post_id ); |
|
68 | + } else if ($post->post_type == 'wpi_item') { |
|
69 | + GetPaid_Meta_Box_Item_Details::save($post_id); |
|
70 | 70 | } |
71 | 71 | } |
72 | -add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 ); |
|
72 | +add_action('save_post', 'wpinv_save_meta_boxes', 10, 3); |
|
73 | 73 | |
74 | 74 | function wpinv_register_item_meta_boxes() { |
75 | 75 | global $wpinv_euvat; |
76 | 76 | |
77 | 77 | // Item details metabox. |
78 | - add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' ); |
|
78 | + add_meta_box('wpinv_item_details', __('Item Details', 'invoicing'), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high'); |
|
79 | 79 | |
80 | 80 | // If taxes are enabled, register the tax metabox. |
81 | - if ( $wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes() ) { |
|
82 | - add_meta_box( 'wpinv_item_vat', __( 'VAT / Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' ); |
|
81 | + if ($wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes()) { |
|
82 | + add_meta_box('wpinv_item_vat', __('VAT / Tax', 'invoicing'), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high'); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | // Item info. |
86 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' ); |
|
86 | + add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core'); |
|
87 | 87 | |
88 | 88 | } |
89 | 89 | |
90 | 90 | function wpinv_register_discount_meta_boxes() { |
91 | - add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' ); |
|
91 | + add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high'); |
|
92 | 92 | } |
93 | 93 | |
94 | -function wpinv_discount_metabox_details( $post ) { |
|
94 | +function wpinv_discount_metabox_details($post) { |
|
95 | 95 | $discount_id = $post->ID; |
96 | - $discount = wpinv_get_discount( $discount_id ); |
|
96 | + $discount = wpinv_get_discount($discount_id); |
|
97 | 97 | |
98 | - $type = wpinv_get_discount_type( $discount_id ); |
|
99 | - $item_reqs = wpinv_get_discount_item_reqs( $discount_id ); |
|
100 | - $excluded_items = wpinv_get_discount_excluded_items( $discount_id ); |
|
101 | - $min_total = wpinv_get_discount_min_total( $discount_id ); |
|
102 | - $max_total = wpinv_get_discount_max_total( $discount_id ); |
|
103 | - $max_uses = wpinv_get_discount_max_uses( $discount_id ); |
|
104 | - $single_use = wpinv_discount_is_single_use( $discount_id ); |
|
105 | - $recurring = (bool)wpinv_discount_is_recurring( $discount_id ); |
|
106 | - $start_date = wpinv_get_discount_start_date( $discount_id ); |
|
107 | - $expiration_date = wpinv_get_discount_expiration( $discount_id ); |
|
98 | + $type = wpinv_get_discount_type($discount_id); |
|
99 | + $item_reqs = wpinv_get_discount_item_reqs($discount_id); |
|
100 | + $excluded_items = wpinv_get_discount_excluded_items($discount_id); |
|
101 | + $min_total = wpinv_get_discount_min_total($discount_id); |
|
102 | + $max_total = wpinv_get_discount_max_total($discount_id); |
|
103 | + $max_uses = wpinv_get_discount_max_uses($discount_id); |
|
104 | + $single_use = wpinv_discount_is_single_use($discount_id); |
|
105 | + $recurring = (bool) wpinv_discount_is_recurring($discount_id); |
|
106 | + $start_date = wpinv_get_discount_start_date($discount_id); |
|
107 | + $expiration_date = wpinv_get_discount_expiration($discount_id); |
|
108 | 108 | |
109 | - if ( ! empty( $start_date ) && strpos( $start_date, '0000' ) === false ) { |
|
110 | - $start_time = strtotime( $start_date ); |
|
111 | - $start_h = date_i18n( 'H', $start_time ); |
|
112 | - $start_m = date_i18n( 'i', $start_time ); |
|
113 | - $start_date = date_i18n( 'Y-m-d', $start_time ); |
|
109 | + if (!empty($start_date) && strpos($start_date, '0000') === false) { |
|
110 | + $start_time = strtotime($start_date); |
|
111 | + $start_h = date_i18n('H', $start_time); |
|
112 | + $start_m = date_i18n('i', $start_time); |
|
113 | + $start_date = date_i18n('Y-m-d', $start_time); |
|
114 | 114 | } else { |
115 | 115 | $start_h = '00'; |
116 | 116 | $start_m = '00'; |
117 | 117 | } |
118 | 118 | |
119 | - if ( ! empty( $expiration_date ) && strpos( $expiration_date, '0000' ) === false ) { |
|
120 | - $expiration_time = strtotime( $expiration_date ); |
|
121 | - $expiration_h = date_i18n( 'H', $expiration_time ); |
|
122 | - $expiration_m = date_i18n( 'i', $expiration_time ); |
|
123 | - $expiration_date = date_i18n( 'Y-m-d', $expiration_time ); |
|
119 | + if (!empty($expiration_date) && strpos($expiration_date, '0000') === false) { |
|
120 | + $expiration_time = strtotime($expiration_date); |
|
121 | + $expiration_h = date_i18n('H', $expiration_time); |
|
122 | + $expiration_m = date_i18n('i', $expiration_time); |
|
123 | + $expiration_date = date_i18n('Y-m-d', $expiration_time); |
|
124 | 124 | } else { |
125 | 125 | $expiration_h = '23'; |
126 | 126 | $expiration_m = '59'; |
@@ -130,220 +130,220 @@ discard block |
||
130 | 130 | $max_total = $max_total > 0 ? $max_total : ''; |
131 | 131 | $max_uses = $max_uses > 0 ? $max_uses : ''; |
132 | 132 | ?> |
133 | -<?php do_action( 'wpinv_discount_form_top', $post ); ?> |
|
134 | -<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?> |
|
133 | +<?php do_action('wpinv_discount_form_top', $post); ?> |
|
134 | +<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?> |
|
135 | 135 | <table class="form-table wpi-form-table"> |
136 | 136 | <tbody> |
137 | - <?php do_action( 'wpinv_discount_form_first', $post ); ?> |
|
138 | - <?php do_action( 'wpinv_discount_form_before_code', $post ); ?> |
|
137 | + <?php do_action('wpinv_discount_form_first', $post); ?> |
|
138 | + <?php do_action('wpinv_discount_form_before_code', $post); ?> |
|
139 | 139 | <tr> |
140 | 140 | <th valign="top" scope="row"> |
141 | - <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label> |
|
141 | + <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label> |
|
142 | 142 | </th> |
143 | 143 | <td> |
144 | - <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required> |
|
145 | - <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p> |
|
144 | + <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required> |
|
145 | + <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p> |
|
146 | 146 | </td> |
147 | 147 | </tr> |
148 | - <?php do_action( 'wpinv_discount_form_before_type', $post ); ?> |
|
148 | + <?php do_action('wpinv_discount_form_before_type', $post); ?> |
|
149 | 149 | <tr> |
150 | 150 | <th valign="top" scope="row"> |
151 | - <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label> |
|
151 | + <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label> |
|
152 | 152 | </th> |
153 | 153 | <td> |
154 | 154 | <select id="wpinv_discount_type" name="type" class="medium-text wpi_select2"> |
155 | - <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?> |
|
156 | - <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option> |
|
155 | + <?php foreach (wpinv_get_discount_types() as $value => $label) { ?> |
|
156 | + <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option> |
|
157 | 157 | <?php } ?> |
158 | 158 | </select> |
159 | - <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p> |
|
159 | + <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p> |
|
160 | 160 | </td> |
161 | 161 | </tr> |
162 | - <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?> |
|
162 | + <?php do_action('wpinv_discount_form_before_amount', $post); ?> |
|
163 | 163 | <tr> |
164 | 164 | <th valign="top" scope="row"> |
165 | - <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label> |
|
165 | + <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label> |
|
166 | 166 | </th> |
167 | 167 | <td> |
168 | - <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> |
|
169 | - <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p> |
|
170 | - <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p> |
|
168 | + <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> |
|
169 | + <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p> |
|
170 | + <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p> |
|
171 | 171 | </td> |
172 | 172 | </tr> |
173 | - <?php do_action( 'wpinv_discount_form_before_items', $post ); ?> |
|
173 | + <?php do_action('wpinv_discount_form_before_items', $post); ?> |
|
174 | 174 | <tr> |
175 | 175 | <th valign="top" scope="row"> |
176 | - <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label> |
|
176 | + <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label> |
|
177 | 177 | </th> |
178 | 178 | <td> |
179 | - <p><?php echo wpinv_item_dropdown( array( |
|
179 | + <p><?php echo wpinv_item_dropdown(array( |
|
180 | 180 | 'name' => 'items[]', |
181 | 181 | 'id' => 'items', |
182 | 182 | 'selected' => $item_reqs, |
183 | 183 | 'multiple' => true, |
184 | 184 | 'class' => 'medium-text wpi_select2', |
185 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
185 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
186 | 186 | 'show_recurring' => true, |
187 | - ) ); ?> |
|
187 | + )); ?> |
|
188 | 188 | </p> |
189 | - <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> |
|
189 | + <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> |
|
190 | 190 | </td> |
191 | 191 | </tr> |
192 | - <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?> |
|
192 | + <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?> |
|
193 | 193 | <tr> |
194 | 194 | <th valign="top" scope="row"> |
195 | - <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label> |
|
195 | + <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label> |
|
196 | 196 | </th> |
197 | 197 | <td> |
198 | - <p><?php echo wpinv_item_dropdown( array( |
|
198 | + <p><?php echo wpinv_item_dropdown(array( |
|
199 | 199 | 'name' => 'excluded_items[]', |
200 | 200 | 'id' => 'excluded_items', |
201 | 201 | 'selected' => $excluded_items, |
202 | 202 | 'multiple' => true, |
203 | 203 | 'class' => 'medium-text wpi_select2', |
204 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
204 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
205 | 205 | 'show_recurring' => true, |
206 | - ) ); ?> |
|
206 | + )); ?> |
|
207 | 207 | </p> |
208 | - <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p> |
|
208 | + <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p> |
|
209 | 209 | </td> |
210 | 210 | </tr> |
211 | - <?php do_action( 'wpinv_discount_form_before_start', $post ); ?> |
|
211 | + <?php do_action('wpinv_discount_form_before_start', $post); ?> |
|
212 | 212 | <tr> |
213 | 213 | <th valign="top" scope="row"> |
214 | - <label for="wpinv_discount_start"><?php _e( 'Start Date', 'invoicing' ); ?></label> |
|
214 | + <label for="wpinv_discount_start"><?php _e('Start Date', 'invoicing'); ?></label> |
|
215 | 215 | </th> |
216 | 216 | <td> |
217 | - <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( $start_date ); ?>"> @ <select id="wpinv_discount_start_h" name="start_h"> |
|
218 | - <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
219 | - <option value="<?php echo $value;?>" <?php selected( $value, $start_h ); ?>><?php echo $value;?></option> |
|
217 | + <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr($start_date); ?>"> @ <select id="wpinv_discount_start_h" name="start_h"> |
|
218 | + <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
219 | + <option value="<?php echo $value; ?>" <?php selected($value, $start_h); ?>><?php echo $value; ?></option> |
|
220 | 220 | <?php } ?> |
221 | 221 | </select> : <select id="wpinv_discount_start_m" name="start_m"> |
222 | - <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
223 | - <option value="<?php echo $value;?>" <?php selected( $value, $start_m ); ?>><?php echo $value;?></option> |
|
222 | + <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
223 | + <option value="<?php echo $value; ?>" <?php selected($value, $start_m); ?>><?php echo $value; ?></option> |
|
224 | 224 | <?php } ?> |
225 | 225 | </select> |
226 | - <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> |
|
226 | + <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> |
|
227 | 227 | </td> |
228 | 228 | </tr> |
229 | - <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?> |
|
229 | + <?php do_action('wpinv_discount_form_before_expiration', $post); ?> |
|
230 | 230 | <tr> |
231 | 231 | <th valign="top" scope="row"> |
232 | - <label for="wpinv_discount_expiration"><?php _e( 'Expiration Date', 'invoicing' ); ?></label> |
|
232 | + <label for="wpinv_discount_expiration"><?php _e('Expiration Date', 'invoicing'); ?></label> |
|
233 | 233 | </th> |
234 | 234 | <td> |
235 | - <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( $expiration_date ); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h"> |
|
236 | - <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
237 | - <option value="<?php echo $value;?>" <?php selected( $value, $expiration_h ); ?>><?php echo $value;?></option> |
|
235 | + <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr($expiration_date); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h"> |
|
236 | + <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
237 | + <option value="<?php echo $value; ?>" <?php selected($value, $expiration_h); ?>><?php echo $value; ?></option> |
|
238 | 238 | <?php } ?> |
239 | 239 | </select> : <select id="wpinv_discount_expiration_m" name="expiration_m"> |
240 | - <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
241 | - <option value="<?php echo $value;?>" <?php selected( $value, $expiration_m ); ?>><?php echo $value;?></option> |
|
240 | + <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
241 | + <option value="<?php echo $value; ?>" <?php selected($value, $expiration_m); ?>><?php echo $value; ?></option> |
|
242 | 242 | <?php } ?> |
243 | 243 | </select> |
244 | - <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 | + <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> |
|
245 | 245 | </td> |
246 | 246 | </tr> |
247 | - <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?> |
|
247 | + <?php do_action('wpinv_discount_form_before_min_total', $post); ?> |
|
248 | 248 | <tr> |
249 | 249 | <th valign="top" scope="row"> |
250 | - <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label> |
|
250 | + <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label> |
|
251 | 251 | </th> |
252 | 252 | <td> |
253 | 253 | <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>"> |
254 | - <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
254 | + <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
255 | 255 | </td> |
256 | 256 | </tr> |
257 | - <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?> |
|
257 | + <?php do_action('wpinv_discount_form_before_max_total', $post); ?> |
|
258 | 258 | <tr> |
259 | 259 | <th valign="top" scope="row"> |
260 | - <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label> |
|
260 | + <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label> |
|
261 | 261 | </th> |
262 | 262 | <td> |
263 | 263 | <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>"> |
264 | - <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
264 | + <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
265 | 265 | </td> |
266 | 266 | </tr> |
267 | - <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?> |
|
267 | + <?php do_action('wpinv_discount_form_before_recurring', $post); ?> |
|
268 | 268 | <tr> |
269 | 269 | <th valign="top" scope="row"> |
270 | - <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label> |
|
270 | + <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label> |
|
271 | 271 | </th> |
272 | 272 | <td> |
273 | 273 | <select id="wpinv_discount_recurring" name="recurring" class="medium-text wpi_select2"> |
274 | - <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option> |
|
275 | - <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option> |
|
274 | + <option value="0" <?php selected(false, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option> |
|
275 | + <option value="1" <?php selected(true, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option> |
|
276 | 276 | </select> |
277 | - <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 | + <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> |
|
278 | 278 | </td> |
279 | 279 | </tr> |
280 | - <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?> |
|
280 | + <?php do_action('wpinv_discount_form_before_max_uses', $post); ?> |
|
281 | 281 | <tr> |
282 | 282 | <th valign="top" scope="row"> |
283 | - <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label> |
|
283 | + <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label> |
|
284 | 284 | </th> |
285 | 285 | <td> |
286 | 286 | <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>"> |
287 | - <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p> |
|
287 | + <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p> |
|
288 | 288 | </td> |
289 | 289 | </tr> |
290 | - <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?> |
|
290 | + <?php do_action('wpinv_discount_form_before_single_use', $post); ?> |
|
291 | 291 | <tr> |
292 | 292 | <th valign="top" scope="row"> |
293 | - <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label> |
|
293 | + <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label> |
|
294 | 294 | </th> |
295 | 295 | <td> |
296 | - <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>> |
|
297 | - <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span> |
|
296 | + <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>> |
|
297 | + <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span> |
|
298 | 298 | </td> |
299 | 299 | </tr> |
300 | - <?php do_action( 'wpinv_discount_form_last', $post ); ?> |
|
300 | + <?php do_action('wpinv_discount_form_last', $post); ?> |
|
301 | 301 | </tbody> |
302 | 302 | </table> |
303 | -<?php do_action( 'wpinv_discount_form_bottom', $post ); ?> |
|
303 | +<?php do_action('wpinv_discount_form_bottom', $post); ?> |
|
304 | 304 | <?php |
305 | 305 | } |
306 | 306 | |
307 | -function wpinv_discount_metabox_save( $post_id, $post, $update = false ) { |
|
308 | - $post_type = !empty( $post ) ? $post->post_type : ''; |
|
307 | +function wpinv_discount_metabox_save($post_id, $post, $update = false) { |
|
308 | + $post_type = !empty($post) ? $post->post_type : ''; |
|
309 | 309 | |
310 | - if ( $post_type != 'wpi_discount' ) { |
|
310 | + if ($post_type != 'wpi_discount') { |
|
311 | 311 | return; |
312 | 312 | } |
313 | 313 | |
314 | - 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 | + 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'))) { |
|
315 | 315 | return; |
316 | 316 | } |
317 | 317 | |
318 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
318 | + if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
319 | 319 | return; |
320 | 320 | } |
321 | 321 | |
322 | - if ( !current_user_can( wpinv_get_capability(), $post_id ) ) { |
|
322 | + if (!current_user_can(wpinv_get_capability(), $post_id)) { |
|
323 | 323 | return; |
324 | 324 | } |
325 | 325 | |
326 | - if ( !empty( $_POST['start'] ) && isset( $_POST['start_h'] ) && isset( $_POST['start_m'] ) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '' ) { |
|
326 | + if (!empty($_POST['start']) && isset($_POST['start_h']) && isset($_POST['start_m']) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '') { |
|
327 | 327 | $_POST['start'] = $_POST['start'] . ' ' . $_POST['start_h'] . ':' . $_POST['start_m']; |
328 | 328 | } |
329 | 329 | |
330 | - if ( !empty( $_POST['expiration'] ) && isset( $_POST['expiration_h'] ) && isset( $_POST['expiration_m'] ) ) { |
|
330 | + if (!empty($_POST['expiration']) && isset($_POST['expiration_h']) && isset($_POST['expiration_m'])) { |
|
331 | 331 | $_POST['expiration'] = $_POST['expiration'] . ' ' . $_POST['expiration_h'] . ':' . $_POST['expiration_m']; |
332 | 332 | } |
333 | 333 | |
334 | - return /** @scrutinizer ignore-call */ wpinv_store_discount( $post_id, $_POST, $post, $update ); |
|
334 | + return /** @scrutinizer ignore-call */ wpinv_store_discount($post_id, $_POST, $post, $update); |
|
335 | 335 | } |
336 | -add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 ); |
|
336 | +add_action('save_post', 'wpinv_discount_metabox_save', 10, 3); |
|
337 | 337 | |
338 | 338 | /** |
339 | 339 | * Remove trash link from the default form. |
340 | 340 | */ |
341 | -function getpaid_remove_action_link( $actions, $post ) { |
|
342 | - $post = get_post( $post ); |
|
343 | - if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
344 | - unset( $actions['trash'] ); |
|
345 | - unset( $actions['inline hide-if-no-js'] ); |
|
341 | +function getpaid_remove_action_link($actions, $post) { |
|
342 | + $post = get_post($post); |
|
343 | + if ('wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form()) { |
|
344 | + unset($actions['trash']); |
|
345 | + unset($actions['inline hide-if-no-js']); |
|
346 | 346 | } |
347 | 347 | return $actions; |
348 | 348 | } |
349 | -add_filter( 'post_row_actions', 'getpaid_remove_action_link', 10, 2 ); |
|
349 | +add_filter('post_row_actions', 'getpaid_remove_action_link', 10, 2); |
@@ -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,43 +21,43 @@ 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 | global $wpinv_euvat, $ajax_cart_details; |
26 | 26 | |
27 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
28 | - $invoice = new WPInv_Invoice( $post_id ); |
|
27 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
28 | + $invoice = new WPInv_Invoice($post_id); |
|
29 | 29 | $ajax_cart_details = $invoice->get_cart_details(); |
30 | - $subtotal = $invoice->get_subtotal( true ); |
|
30 | + $subtotal = $invoice->get_subtotal(true); |
|
31 | 31 | $discount_raw = $invoice->get_discount(); |
32 | - $discount = wpinv_price( $discount_raw, $invoice->get_currency() ); |
|
32 | + $discount = wpinv_price($discount_raw, $invoice->get_currency()); |
|
33 | 33 | $discounts = $discount_raw > 0 ? $invoice->get_discounts() : ''; |
34 | - $tax = $invoice->get_tax( true ); |
|
35 | - $total = $invoice->get_total( true ); |
|
34 | + $tax = $invoice->get_tax(true); |
|
35 | + $total = $invoice->get_total(true); |
|
36 | 36 | $item_quantities = wpinv_item_quantities_enabled(); |
37 | 37 | $use_taxes = wpinv_use_taxes(); |
38 | - if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) { |
|
38 | + if (!$use_taxes && (float) $invoice->get_tax() > 0) { |
|
39 | 39 | $use_taxes = true; |
40 | 40 | } |
41 | - $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post ); |
|
41 | + $item_types = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post); |
|
42 | 42 | $is_recurring = $invoice->is_recurring(); |
43 | 43 | $post_type_object = get_post_type_object($invoice->post_type); |
44 | 44 | $type_title = $post_type_object->labels->singular_name; |
45 | 45 | |
46 | 46 | $cols = 5; |
47 | - if ( $item_quantities ) { |
|
47 | + if ($item_quantities) { |
|
48 | 48 | $cols++; |
49 | 49 | } |
50 | - if ( $use_taxes ) { |
|
50 | + if ($use_taxes) { |
|
51 | 51 | $cols++; |
52 | 52 | } |
53 | 53 | $class = ''; |
54 | - if ( $invoice->is_paid() ) { |
|
54 | + if ($invoice->is_paid()) { |
|
55 | 55 | $class .= ' wpinv-paid'; |
56 | 56 | } |
57 | - if ( $invoice->is_refunded() ) { |
|
57 | + if ($invoice->is_refunded()) { |
|
58 | 58 | $class .= ' wpinv-refunded'; |
59 | 59 | } |
60 | - if ( $is_recurring ) { |
|
60 | + if ($is_recurring) { |
|
61 | 61 | $class .= ' wpi-recurring'; |
62 | 62 | } |
63 | 63 | ?> |
@@ -65,21 +65,21 @@ discard block |
||
65 | 65 | <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0"> |
66 | 66 | <thead> |
67 | 67 | <tr> |
68 | - <th class="id"><?php _e( 'ID', 'invoicing' );?></th> |
|
69 | - <th class="title"><?php _e( 'Item', 'invoicing' );?></th> |
|
70 | - <th class="price"><?php _e( 'Price', 'invoicing' );?></th> |
|
71 | - <?php if ( $item_quantities ) { ?> |
|
72 | - <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th> |
|
68 | + <th class="id"><?php _e('ID', 'invoicing'); ?></th> |
|
69 | + <th class="title"><?php _e('Item', 'invoicing'); ?></th> |
|
70 | + <th class="price"><?php _e('Price', 'invoicing'); ?></th> |
|
71 | + <?php if ($item_quantities) { ?> |
|
72 | + <th class="qty"><?php _e('Qty', 'invoicing'); ?></th> |
|
73 | 73 | <?php } ?> |
74 | - <th class="total"><?php _e( 'Total', 'invoicing' );?></th> |
|
75 | - <?php if ( $use_taxes ) { ?> |
|
76 | - <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th> |
|
74 | + <th class="total"><?php _e('Total', 'invoicing'); ?></th> |
|
75 | + <?php if ($use_taxes) { ?> |
|
76 | + <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th> |
|
77 | 77 | <?php } ?> |
78 | 78 | <th class="action"></th> |
79 | 79 | </tr> |
80 | 80 | </thead> |
81 | 81 | <tbody class="wpinv-line-items"> |
82 | - <?php echo wpinv_admin_get_line_items( $invoice ); ?> |
|
82 | + <?php echo wpinv_admin_get_line_items($invoice); ?> |
|
83 | 83 | </tbody> |
84 | 84 | <tfoot class="wpinv-totals"> |
85 | 85 | <tr> |
@@ -90,45 +90,45 @@ discard block |
||
90 | 90 | <td class="id"> |
91 | 91 | </td> |
92 | 92 | <td class="title"> |
93 | - <input type="text" class="regular-text" placeholder="<?php _e( 'Item Name', 'invoicing' ); ?>" value="" name="_wpinv_quick[name]"> |
|
94 | - <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?> |
|
93 | + <input type="text" class="regular-text" placeholder="<?php _e('Item Name', 'invoicing'); ?>" value="" name="_wpinv_quick[name]"> |
|
94 | + <?php if ($wpinv_euvat->allow_vat_rules()) { ?> |
|
95 | 95 | <div class="wp-clearfix"> |
96 | 96 | <label class="wpi-vat-rule"> |
97 | - <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span> |
|
97 | + <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span> |
|
98 | 98 | <span class="input-text-wrap"> |
99 | - <?php echo wpinv_html_select( array( |
|
99 | + <?php echo wpinv_html_select(array( |
|
100 | 100 | 'options' => $wpinv_euvat->get_rules(), |
101 | 101 | 'name' => '_wpinv_quick[vat_rule]', |
102 | 102 | 'id' => '_wpinv_quick_vat_rule', |
103 | 103 | 'show_option_all' => false, |
104 | 104 | 'show_option_none' => false, |
105 | 105 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-rule wpi_select2', |
106 | - ) ); ?> |
|
106 | + )); ?> |
|
107 | 107 | </span> |
108 | 108 | </label> |
109 | 109 | </div> |
110 | - <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?> |
|
110 | + <?php } if ($wpinv_euvat->allow_vat_classes()) { ?> |
|
111 | 111 | <div class="wp-clearfix"> |
112 | 112 | <label class="wpi-vat-class"> |
113 | - <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span> |
|
113 | + <span class="title"><?php _e('VAT class', 'invoicing'); ?></span> |
|
114 | 114 | <span class="input-text-wrap"> |
115 | - <?php echo wpinv_html_select( array( |
|
115 | + <?php echo wpinv_html_select(array( |
|
116 | 116 | 'options' => $wpinv_euvat->get_all_classes(), |
117 | 117 | 'name' => '_wpinv_quick[vat_class]', |
118 | 118 | 'id' => '_wpinv_quick_vat_class', |
119 | 119 | 'show_option_all' => false, |
120 | 120 | 'show_option_none' => false, |
121 | 121 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-class wpi_select2', |
122 | - ) ); ?> |
|
122 | + )); ?> |
|
123 | 123 | </span> |
124 | 124 | </label> |
125 | 125 | </div> |
126 | 126 | <?php } ?> |
127 | 127 | <div class="wp-clearfix"> |
128 | 128 | <label class="wpi-item-type"> |
129 | - <span class="title"><?php _e( 'Item type', 'invoicing' );?></span> |
|
129 | + <span class="title"><?php _e('Item type', 'invoicing'); ?></span> |
|
130 | 130 | <span class="input-text-wrap"> |
131 | - <?php echo wpinv_html_select( array( |
|
131 | + <?php echo wpinv_html_select(array( |
|
132 | 132 | 'options' => $item_types, |
133 | 133 | 'name' => '_wpinv_quick[type]', |
134 | 134 | 'id' => '_wpinv_quick_type', |
@@ -136,37 +136,37 @@ discard block |
||
136 | 136 | 'show_option_all' => false, |
137 | 137 | 'show_option_none' => false, |
138 | 138 | 'class' => 'gdmbx2-text-medium wpinv-quick-type wpi_select2', |
139 | - ) ); ?> |
|
139 | + )); ?> |
|
140 | 140 | </span> |
141 | 141 | </label> |
142 | 142 | </div> |
143 | 143 | |
144 | 144 | <div class="wp-clearfix"> |
145 | 145 | <?php |
146 | - echo wpinv_html_textarea( array( |
|
146 | + echo wpinv_html_textarea(array( |
|
147 | 147 | 'name' => '_wpinv_quick[excerpt]', |
148 | 148 | 'id' => '_wpinv_quick_excerpt', |
149 | 149 | 'value' => '', |
150 | 150 | 'class' => 'large-text', |
151 | - 'label' => __( 'Item description', 'invoicing' ), |
|
152 | - ) ); |
|
151 | + 'label' => __('Item description', 'invoicing'), |
|
152 | + )); |
|
153 | 153 | ?> |
154 | 154 | </div> |
155 | 155 | |
156 | 156 | <div class="wp-clearfix"> |
157 | 157 | <label class="wpi-item-actions"> |
158 | 158 | <span class="input-text-wrap"> |
159 | - <input type="button" value="<?php esc_attr_e( 'Add', 'invoicing' ); ?>" class="button button-primary" id="wpinv-save-item"><input type="button" value="Cancel" class="button button-secondary" id="wpinv-cancel-item"> |
|
159 | + <input type="button" value="<?php esc_attr_e('Add', 'invoicing'); ?>" class="button button-primary" id="wpinv-save-item"><input type="button" value="Cancel" class="button button-secondary" id="wpinv-cancel-item"> |
|
160 | 160 | </span> |
161 | 161 | </label> |
162 | 162 | </div> |
163 | 163 | </td> |
164 | 164 | <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td> |
165 | - <?php if ( $item_quantities ) { ?> |
|
165 | + <?php if ($item_quantities) { ?> |
|
166 | 166 | <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td> |
167 | 167 | <?php } ?> |
168 | 168 | <td class="total"></td> |
169 | - <?php if ( $use_taxes ) { ?> |
|
169 | + <?php if ($use_taxes) { ?> |
|
170 | 170 | <td class="tax"></td> |
171 | 171 | <?php } ?> |
172 | 172 | <td class="action"></td> |
@@ -179,29 +179,29 @@ discard block |
||
179 | 179 | <td colspan="<?php echo $cols; ?>"></td> |
180 | 180 | </tr> |
181 | 181 | <tr class="totals"> |
182 | - <td colspan="<?php echo ( $cols - 4 ); ?>"></td> |
|
182 | + <td colspan="<?php echo ($cols - 4); ?>"></td> |
|
183 | 183 | <td colspan="4"> |
184 | 184 | <table cellspacing="0" cellpadding="0"> |
185 | 185 | <tr class="subtotal"> |
186 | - <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td> |
|
187 | - <td class="total"><?php echo $subtotal;?></td> |
|
186 | + <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td> |
|
187 | + <td class="total"><?php echo $subtotal; ?></td> |
|
188 | 188 | <td class="action"></td> |
189 | 189 | </tr> |
190 | 190 | <tr class="discount"> |
191 | - <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td> |
|
192 | - <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td> |
|
191 | + <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td> |
|
192 | + <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td> |
|
193 | 193 | <td class="action"></td> |
194 | 194 | </tr> |
195 | - <?php if ( $use_taxes ) { ?> |
|
195 | + <?php if ($use_taxes) { ?> |
|
196 | 196 | <tr class="tax"> |
197 | - <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td> |
|
198 | - <td class="total"><?php echo $tax;?></td> |
|
197 | + <td class="name"><?php _e('Tax:', 'invoicing'); ?></td> |
|
198 | + <td class="total"><?php echo $tax; ?></td> |
|
199 | 199 | <td class="action"></td> |
200 | 200 | </tr> |
201 | 201 | <?php } ?> |
202 | 202 | <tr class="total"> |
203 | - <td class="name"><?php echo apply_filters( 'wpinv_invoice_items_total_label', __( 'Invoice Total:', 'invoicing' ), $invoice );?></td> |
|
204 | - <td class="total"><?php echo $total;?></td> |
|
203 | + <td class="name"><?php echo apply_filters('wpinv_invoice_items_total_label', __('Invoice Total:', 'invoicing'), $invoice); ?></td> |
|
204 | + <td class="total"><?php echo $total; ?></td> |
|
205 | 205 | <td class="action"></td> |
206 | 206 | </tr> |
207 | 207 | </table> |
@@ -212,19 +212,19 @@ discard block |
||
212 | 212 | <div class="wpinv-actions"> |
213 | 213 | <?php ob_start(); ?> |
214 | 214 | <?php |
215 | - if ( !$invoice->is_paid() && !$invoice->is_refunded() ) { |
|
216 | - if ( !$invoice->is_recurring() ) { |
|
217 | - echo wpinv_item_dropdown( array( |
|
215 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
216 | + if (!$invoice->is_recurring()) { |
|
217 | + echo wpinv_item_dropdown(array( |
|
218 | 218 | 'name' => 'wpinv_invoice_item', |
219 | 219 | 'id' => 'wpinv_invoice_item', |
220 | 220 | 'show_recurring' => true, |
221 | 221 | 'class' => 'wpi_select2', |
222 | - ) ); |
|
222 | + )); |
|
223 | 223 | ?> |
224 | - <input type="button" value="<?php echo sprintf(esc_attr__( 'Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e( 'Create new item', 'invoicing' );?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e( 'Recalculate Totals', 'invoicing' );?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals"> |
|
224 | + <input type="button" value="<?php echo sprintf(esc_attr__('Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e('Create new item', 'invoicing'); ?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e('Recalculate Totals', 'invoicing'); ?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals"> |
|
225 | 225 | <?php } ?> |
226 | - <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?> |
|
227 | - <?php $item_actions = ob_get_clean(); echo apply_filters( 'wpinv_invoice_items_actions_content', $item_actions, $invoice, $post ); ?> |
|
226 | + <?php do_action('wpinv_invoice_items_actions', $invoice); ?> |
|
227 | + <?php $item_actions = ob_get_clean(); echo apply_filters('wpinv_invoice_items_actions_content', $item_actions, $invoice, $post); ?> |
|
228 | 228 | </div> |
229 | 229 | </div> |
230 | 230 | <?php |
@@ -233,96 +233,96 @@ discard block |
||
233 | 233 | /** |
234 | 234 | * Display the items buy now shortcode. |
235 | 235 | */ |
236 | - public static function shortcode( $post ) { |
|
236 | + public static function shortcode($post) { |
|
237 | 237 | |
238 | - if ( ! is_numeric( $post ) ) { |
|
238 | + if (!is_numeric($post)) { |
|
239 | 239 | $post = $post->ID; |
240 | 240 | } |
241 | 241 | |
242 | 242 | echo "<input type='text' style='min-width: 100%; font-size: small;' value='[getpaid item=$post]' disabled>"; |
243 | 243 | } |
244 | 244 | |
245 | - public static function save( $post_id, $data, $post ) { |
|
246 | - $invoice = new WPInv_Invoice( $post_id ); |
|
245 | + public static function save($post_id, $data, $post) { |
|
246 | + $invoice = new WPInv_Invoice($post_id); |
|
247 | 247 | |
248 | 248 | // Billing |
249 | - $first_name = sanitize_text_field( $data['wpinv_first_name'] ); |
|
250 | - $last_name = sanitize_text_field( $data['wpinv_last_name'] ); |
|
251 | - $company = sanitize_text_field( $data['wpinv_company'] ); |
|
252 | - $vat_number = sanitize_text_field( $data['wpinv_vat_number'] ); |
|
253 | - $phone = sanitize_text_field( $data['wpinv_phone'] ); |
|
254 | - $address = sanitize_text_field( $data['wpinv_address'] ); |
|
255 | - $city = sanitize_text_field( $data['wpinv_city'] ); |
|
256 | - $zip = sanitize_text_field( $data['wpinv_zip'] ); |
|
257 | - $country = sanitize_text_field( $data['wpinv_country'] ); |
|
258 | - $state = sanitize_text_field( $data['wpinv_state'] ); |
|
249 | + $first_name = sanitize_text_field($data['wpinv_first_name']); |
|
250 | + $last_name = sanitize_text_field($data['wpinv_last_name']); |
|
251 | + $company = sanitize_text_field($data['wpinv_company']); |
|
252 | + $vat_number = sanitize_text_field($data['wpinv_vat_number']); |
|
253 | + $phone = sanitize_text_field($data['wpinv_phone']); |
|
254 | + $address = sanitize_text_field($data['wpinv_address']); |
|
255 | + $city = sanitize_text_field($data['wpinv_city']); |
|
256 | + $zip = sanitize_text_field($data['wpinv_zip']); |
|
257 | + $country = sanitize_text_field($data['wpinv_country']); |
|
258 | + $state = sanitize_text_field($data['wpinv_state']); |
|
259 | 259 | |
260 | 260 | // Details |
261 | - $status = sanitize_text_field( $data['wpinv_status'] ); |
|
262 | - $old_status = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status; |
|
263 | - $number = sanitize_text_field( $data['wpinv_number'] ); |
|
264 | - $due_date = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : ''; |
|
265 | - $date_created = isset( $data['date_created'] ) ? sanitize_text_field( $data['date_created'] ) : ''; |
|
261 | + $status = sanitize_text_field($data['wpinv_status']); |
|
262 | + $old_status = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status; |
|
263 | + $number = sanitize_text_field($data['wpinv_number']); |
|
264 | + $due_date = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : ''; |
|
265 | + $date_created = isset($data['date_created']) ? sanitize_text_field($data['date_created']) : ''; |
|
266 | 266 | //$discounts = sanitize_text_field( $data['wpinv_discounts'] ); |
267 | 267 | //$discount = sanitize_text_field( $data['wpinv_discount'] ); |
268 | 268 | |
269 | 269 | $disable_taxes = 0; |
270 | 270 | |
271 | - if ( ! empty( $data['disable_taxes'] ) ) { |
|
271 | + if (!empty($data['disable_taxes'])) { |
|
272 | 272 | $disable_taxes = 1; |
273 | 273 | } |
274 | 274 | |
275 | - $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip(); |
|
276 | - |
|
277 | - $invoice->set( 'due_date', $due_date ); |
|
278 | - $invoice->set( 'first_name', $first_name ); |
|
279 | - $invoice->set( 'last_name', $last_name ); |
|
280 | - $invoice->set( 'company', $company ); |
|
281 | - $invoice->set( 'vat_number', $vat_number ); |
|
282 | - $invoice->set( 'phone', $phone ); |
|
283 | - $invoice->set( 'address', $address ); |
|
284 | - $invoice->set( 'city', $city ); |
|
285 | - $invoice->set( 'zip', $zip ); |
|
286 | - $invoice->set( 'country', $country ); |
|
287 | - $invoice->set( 'state', $state ); |
|
288 | - $invoice->set( 'status', $status ); |
|
289 | - $invoice->set( 'set', $status ); |
|
275 | + $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip(); |
|
276 | + |
|
277 | + $invoice->set('due_date', $due_date); |
|
278 | + $invoice->set('first_name', $first_name); |
|
279 | + $invoice->set('last_name', $last_name); |
|
280 | + $invoice->set('company', $company); |
|
281 | + $invoice->set('vat_number', $vat_number); |
|
282 | + $invoice->set('phone', $phone); |
|
283 | + $invoice->set('address', $address); |
|
284 | + $invoice->set('city', $city); |
|
285 | + $invoice->set('zip', $zip); |
|
286 | + $invoice->set('country', $country); |
|
287 | + $invoice->set('state', $state); |
|
288 | + $invoice->set('status', $status); |
|
289 | + $invoice->set('set', $status); |
|
290 | 290 | //$invoice->set( 'number', $number ); |
291 | 291 | //$invoice->set( 'discounts', $discounts ); |
292 | 292 | //$invoice->set( 'discount', $discount ); |
293 | - $invoice->set( 'disable_taxes', $disable_taxes ); |
|
294 | - $invoice->set( 'ip', $ip ); |
|
293 | + $invoice->set('disable_taxes', $disable_taxes); |
|
294 | + $invoice->set('ip', $ip); |
|
295 | 295 | $invoice->old_status = $_POST['original_post_status']; |
296 | 296 | |
297 | 297 | $currency = $invoice->get_currency(); |
298 | - if ( ! empty( $data['wpinv_currency'] ) ) { |
|
299 | - $currency = sanitize_text_field( $data['wpinv_currency'] ); |
|
298 | + if (!empty($data['wpinv_currency'])) { |
|
299 | + $currency = sanitize_text_field($data['wpinv_currency']); |
|
300 | 300 | } |
301 | 301 | |
302 | - if ( empty( $currency ) ) { |
|
302 | + if (empty($currency)) { |
|
303 | 303 | $currency = wpinv_get_currency(); |
304 | 304 | } |
305 | 305 | |
306 | - if ( ! $invoice->is_paid() ) { |
|
306 | + if (!$invoice->is_paid()) { |
|
307 | 307 | $invoice->currency = $currency; |
308 | 308 | } |
309 | 309 | |
310 | - if ( !empty( $data['wpinv_gateway'] ) ) { |
|
311 | - $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) ); |
|
310 | + if (!empty($data['wpinv_gateway'])) { |
|
311 | + $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway'])); |
|
312 | 312 | } |
313 | 313 | $saved = $invoice->save(); |
314 | 314 | |
315 | 315 | $emails = ''; |
316 | - if ( ! empty( $data['wpinv_cc'] ) ) { |
|
317 | - $emails = wpinv_clean( $data['wpinv_cc'] ); |
|
316 | + if (!empty($data['wpinv_cc'])) { |
|
317 | + $emails = wpinv_clean($data['wpinv_cc']); |
|
318 | 318 | } |
319 | - update_post_meta( $invoice->ID, 'wpinv_email_cc', $emails ); |
|
319 | + update_post_meta($invoice->ID, 'wpinv_email_cc', $emails); |
|
320 | 320 | |
321 | - if ( ! empty( $date_created ) && strtotime( $date_created, current_time( 'timestamp' ) ) ) { |
|
321 | + if (!empty($date_created) && strtotime($date_created, current_time('timestamp'))) { |
|
322 | 322 | |
323 | - $time = strtotime( $date_created, current_time( 'timestamp' ) ); |
|
324 | - $date = date( 'Y-m-d H:i:s', $time ); |
|
325 | - $date_gmt = get_gmt_from_date( $date ); |
|
323 | + $time = strtotime($date_created, current_time('timestamp')); |
|
324 | + $date = date('Y-m-d H:i:s', $time); |
|
325 | + $date_gmt = get_gmt_from_date($date); |
|
326 | 326 | |
327 | 327 | wp_update_post( |
328 | 328 | array( |
@@ -337,37 +337,37 @@ discard block |
||
337 | 337 | } |
338 | 338 | |
339 | 339 | // Check for payment notes |
340 | - if ( !empty( $data['invoice_note'] ) ) { |
|
341 | - $note = wp_kses( $data['invoice_note'], array() ); |
|
342 | - $note_type = sanitize_text_field( $data['invoice_note_type'] ); |
|
340 | + if (!empty($data['invoice_note'])) { |
|
341 | + $note = wp_kses($data['invoice_note'], array()); |
|
342 | + $note_type = sanitize_text_field($data['invoice_note_type']); |
|
343 | 343 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
344 | 344 | |
345 | - wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note ); |
|
345 | + wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | // Update user address if empty. |
349 | - if ( $saved && !empty( $invoice ) ) { |
|
350 | - if ( $user_id = $invoice->get_user_id() ) { |
|
351 | - $user_address = wpinv_get_user_address( $user_id, false ); |
|
349 | + if ($saved && !empty($invoice)) { |
|
350 | + if ($user_id = $invoice->get_user_id()) { |
|
351 | + $user_address = wpinv_get_user_address($user_id, false); |
|
352 | 352 | |
353 | 353 | if (empty($user_address['first_name'])) { |
354 | - update_user_meta( $user_id, '_wpinv_first_name', $first_name ); |
|
355 | - update_user_meta( $user_id, '_wpinv_last_name', $last_name ); |
|
354 | + update_user_meta($user_id, '_wpinv_first_name', $first_name); |
|
355 | + update_user_meta($user_id, '_wpinv_last_name', $last_name); |
|
356 | 356 | } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) { |
357 | - update_user_meta( $user_id, '_wpinv_last_name', $last_name ); |
|
357 | + update_user_meta($user_id, '_wpinv_last_name', $last_name); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) { |
361 | - update_user_meta( $user_id, '_wpinv_address', $address ); |
|
362 | - update_user_meta( $user_id, '_wpinv_city', $city ); |
|
363 | - update_user_meta( $user_id, '_wpinv_state', $state ); |
|
364 | - update_user_meta( $user_id, '_wpinv_country', $country ); |
|
365 | - update_user_meta( $user_id, '_wpinv_zip', $zip ); |
|
366 | - update_user_meta( $user_id, '_wpinv_phone', $phone ); |
|
361 | + update_user_meta($user_id, '_wpinv_address', $address); |
|
362 | + update_user_meta($user_id, '_wpinv_city', $city); |
|
363 | + update_user_meta($user_id, '_wpinv_state', $state); |
|
364 | + update_user_meta($user_id, '_wpinv_country', $country); |
|
365 | + update_user_meta($user_id, '_wpinv_zip', $zip); |
|
366 | + update_user_meta($user_id, '_wpinv_phone', $phone); |
|
367 | 367 | } |
368 | 368 | } |
369 | 369 | |
370 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
370 | + do_action('wpinv_invoice_metabox_saved', $invoice); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | return $saved; |
@@ -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_Info { |
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. |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
100 | - * Returns item type tolltip. |
|
101 | - * |
|
102 | - */ |
|
100 | + * Returns item type tolltip. |
|
101 | + * |
|
102 | + */ |
|
103 | 103 | public static function get_tooltip( $post ) { |
104 | 104 | |
105 | 105 | ob_start(); |
@@ -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,20 +21,20 @@ 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 | ?> |
30 | 30 | |
31 | 31 | <div class='bsui' style='padding-top: 10px;'> |
32 | - <?php do_action( 'wpinv_item_before_info_metabox', $item ); ?> |
|
32 | + <?php do_action('wpinv_item_before_info_metabox', $item); ?> |
|
33 | 33 | |
34 | 34 | <div class="wpinv_item_type form-group row"> |
35 | 35 | <label for="wpinv_item_type" class="col-sm-12 col-form-label"> |
36 | - <?php _e( 'Item Type', 'invoicing' );?> |
|
37 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( self::get_tooltip( $post ) ); ?>"></span> |
|
36 | + <?php _e('Item Type', 'invoicing'); ?> |
|
37 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e(self::get_tooltip($post)); ?>"></span> |
|
38 | 38 | </label> |
39 | 39 | |
40 | 40 | <div class="col-sm-12"> |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | array( |
45 | 45 | 'id' => 'wpinv_item_type', |
46 | 46 | 'name' => 'wpinv_item_type', |
47 | - 'placeholder' => __( 'Select item type', 'invoicing' ), |
|
48 | - 'value' => $item->get_type( 'edit' ), |
|
47 | + 'placeholder' => __('Select item type', 'invoicing'), |
|
48 | + 'value' => $item->get_type('edit'), |
|
49 | 49 | 'select2' => true, |
50 | 50 | 'data-allow-clear' => 'false', |
51 | 51 | 'no_wrap' => true, |
@@ -59,38 +59,38 @@ discard block |
||
59 | 59 | |
60 | 60 | <div class="wpinv_item_shortcode form-group row"> |
61 | 61 | <label for="wpinv_item_shortcode" class="col-sm-12 col-form-label"> |
62 | - <?php _e( 'Payment Form Shortcode', 'invoicing' );?> |
|
63 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a payment form', 'invoicing' ); ?>"></span> |
|
62 | + <?php _e('Payment Form Shortcode', 'invoicing'); ?> |
|
63 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a payment form', 'invoicing'); ?>"></span> |
|
64 | 64 | </label> |
65 | 65 | |
66 | 66 | <div class="col-sm-12"> |
67 | - <input onClick="this.select()" type="text" id="wpinv_item_shortcode" value="[getpaid item=<?php echo esc_attr( $item->get_id() ); ?>]" style="width: 100%;" /> |
|
67 | + <input onClick="this.select()" type="text" id="wpinv_item_shortcode" value="[getpaid item=<?php echo esc_attr($item->get_id()); ?>]" style="width: 100%;" /> |
|
68 | 68 | </div> |
69 | 69 | </div> |
70 | 70 | |
71 | 71 | <div class="wpinv_item_buy_shortcode form-group row"> |
72 | 72 | <label for="wpinv_item_button_shortcode" class="col-sm-12 col-form-label"> |
73 | - <?php _e( 'Payment Button Shortcode', 'invoicing' );?> |
|
74 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a buy now button', 'invoicing' ); ?>"></span> |
|
73 | + <?php _e('Payment Button Shortcode', 'invoicing'); ?> |
|
74 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a buy now button', 'invoicing'); ?>"></span> |
|
75 | 75 | </label> |
76 | 76 | |
77 | 77 | <div class="col-sm-12"> |
78 | - <input onClick="this.select()" type="text" id="wpinv_item_button_shortcode" value="[getpaid item=<?php echo esc_attr( $item->get_id() ); ?> button='Buy Now']" style="width: 100%;" /> |
|
78 | + <input onClick="this.select()" type="text" id="wpinv_item_button_shortcode" value="[getpaid item=<?php echo esc_attr($item->get_id()); ?> button='Buy Now']" style="width: 100%;" /> |
|
79 | 79 | </div> |
80 | 80 | </div> |
81 | 81 | |
82 | 82 | <div class="wpinv_item_custom_id form-group"> |
83 | - <?php _e( 'Custom ID', 'invoicing' );?> — <?php echo sanitize_text_field( $item->get_custom_id() ) ?> |
|
83 | + <?php _e('Custom ID', 'invoicing'); ?> — <?php echo sanitize_text_field($item->get_custom_id()) ?> |
|
84 | 84 | </div> |
85 | 85 | |
86 | - <?php do_action( 'wpinv_meta_values_metabox_before', $post ); ?> |
|
87 | - <?php foreach ( apply_filters( 'wpinv_show_meta_values_for_keys', array() ) as $meta_key ) : ?> |
|
86 | + <?php do_action('wpinv_meta_values_metabox_before', $post); ?> |
|
87 | + <?php foreach (apply_filters('wpinv_show_meta_values_for_keys', array()) as $meta_key) : ?> |
|
88 | 88 | <div class="wpinv_item_custom_id form-group"> |
89 | - <?php sanitize_text_field( $meta_key );?> — <?php echo sanitize_text_field( get_post_meta( $item->get_id(), '_wpinv_' . $meta_key, true ) ); ?> |
|
89 | + <?php sanitize_text_field($meta_key); ?> — <?php echo sanitize_text_field(get_post_meta($item->get_id(), '_wpinv_' . $meta_key, true)); ?> |
|
90 | 90 | </div> |
91 | 91 | <?php endforeach; ?> |
92 | - <?php do_action( 'wpinv_meta_values_metabox_after', $post ); ?> |
|
93 | - <?php do_action( 'wpinv_item_info_metabox', $item ); ?> |
|
92 | + <?php do_action('wpinv_meta_values_metabox_after', $post); ?> |
|
93 | + <?php do_action('wpinv_item_info_metabox', $item); ?> |
|
94 | 94 | </div> |
95 | 95 | <?php |
96 | 96 | |
@@ -100,16 +100,16 @@ discard block |
||
100 | 100 | * Returns item type tolltip. |
101 | 101 | * |
102 | 102 | */ |
103 | - public static function get_tooltip( $post ) { |
|
103 | + public static function get_tooltip($post) { |
|
104 | 104 | |
105 | 105 | ob_start(); |
106 | 106 | ?> |
107 | 107 | |
108 | - <?php _e( '<b>Standard:</b> Standard item type', 'invoicing' );?><br> <br> |
|
109 | - <?php _e( '<b>Fee:</b> Like Registration Fee, Sign up Fee etc', 'invoicing' );?><br> <br> |
|
108 | + <?php _e('<b>Standard:</b> Standard item type', 'invoicing'); ?><br> <br> |
|
109 | + <?php _e('<b>Fee:</b> Like Registration Fee, Sign up Fee etc', 'invoicing'); ?><br> <br> |
|
110 | 110 | |
111 | 111 | <?php |
112 | - do_action( 'wpinv_item_info_metabox_after', $post ); |
|
112 | + do_action('wpinv_item_info_metabox_after', $post); |
|
113 | 113 | |
114 | 114 | return ob_get_clean(); |
115 | 115 |
@@ -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_VAT { |
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 | global $wpinv_euvat; |
26 | 26 | |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
54 | - * Output the VAT rules settings. |
|
55 | - * |
|
56 | - * @param WPInv_Item $item |
|
54 | + * Output the VAT rules settings. |
|
55 | + * |
|
56 | + * @param WPInv_Item $item |
|
57 | 57 | * @param WPInv_EUVat $wpinv_euvat |
58 | - */ |
|
58 | + */ |
|
59 | 59 | public static function output_vat_rules( $item, $wpinv_euvat ) { |
60 | 60 | ?> |
61 | 61 | |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
96 | - * Output the VAT class settings. |
|
97 | - * |
|
98 | - * @param WPInv_Item $item |
|
96 | + * Output the VAT class settings. |
|
97 | + * |
|
98 | + * @param WPInv_Item $item |
|
99 | 99 | * @param WPInv_EUVat $wpinv_euvat |
100 | - */ |
|
100 | + */ |
|
101 | 101 | public static function output_vat_classes( $item, $wpinv_euvat ) { |
102 | 102 | ?> |
103 | 103 |
@@ -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,31 +21,31 @@ 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 | global $wpinv_euvat; |
26 | 26 | |
27 | 27 | // Prepare the item. |
28 | - $item = new WPInv_Item( $post ); |
|
28 | + $item = new WPInv_Item($post); |
|
29 | 29 | |
30 | 30 | echo "<div class='bsui' style='max-width: 600px;padding-top: 10px;'>"; |
31 | 31 | |
32 | - do_action( 'wpinv_item_before_vat_metabox', $item ); |
|
32 | + do_action('wpinv_item_before_vat_metabox', $item); |
|
33 | 33 | |
34 | 34 | // Output the vat rules settings. |
35 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
36 | - do_action( 'wpinv_item_vat_metabox_before_vat_rules', $item ); |
|
37 | - self::output_vat_rules( $item, $wpinv_euvat ); |
|
38 | - do_action( 'wpinv_item_vat_metabox_vat_rules', $item ); |
|
35 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
36 | + do_action('wpinv_item_vat_metabox_before_vat_rules', $item); |
|
37 | + self::output_vat_rules($item, $wpinv_euvat); |
|
38 | + do_action('wpinv_item_vat_metabox_vat_rules', $item); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | // Output vat class settings. |
42 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
43 | - do_action( 'wpinv_item_vat_metabox_before_vat_rules', $item ); |
|
44 | - self::output_vat_classes( $item, $wpinv_euvat ); |
|
45 | - do_action( 'wpinv_item_vat_metabox_vat_class', $item ); |
|
42 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
43 | + do_action('wpinv_item_vat_metabox_before_vat_rules', $item); |
|
44 | + self::output_vat_classes($item, $wpinv_euvat); |
|
45 | + do_action('wpinv_item_vat_metabox_vat_class', $item); |
|
46 | 46 | } |
47 | 47 | |
48 | - do_action( 'wpinv_item_vat_metabox', $item ); |
|
48 | + do_action('wpinv_item_vat_metabox', $item); |
|
49 | 49 | |
50 | 50 | echo '</div>'; |
51 | 51 | } |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | * @param WPInv_Item $item |
57 | 57 | * @param WPInv_EUVat $wpinv_euvat |
58 | 58 | */ |
59 | - public static function output_vat_rules( $item, $wpinv_euvat ) { |
|
59 | + public static function output_vat_rules($item, $wpinv_euvat) { |
|
60 | 60 | ?> |
61 | 61 | |
62 | 62 | <div class="wpinv_vat_rules"> |
63 | 63 | |
64 | 64 | <div class="form-group row"> |
65 | 65 | <label for="wpinv_vat_rules" class="col-sm-3 col-form-label"> |
66 | - <?php _e( 'VAT Rule', 'invoicing' );?> |
|
66 | + <?php _e('VAT Rule', 'invoicing'); ?> |
|
67 | 67 | </label> |
68 | 68 | <div class="col-sm-8"> |
69 | 69 | <?php |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | array( |
72 | 72 | 'id' => 'wpinv_vat_rules', |
73 | 73 | 'name' => 'wpinv_vat_rules', |
74 | - 'placeholder' => __( 'Select VAT rule', 'invoicing' ), |
|
75 | - 'value' => $item->get_vat_rule( 'edit' ), |
|
74 | + 'placeholder' => __('Select VAT rule', 'invoicing'), |
|
75 | + 'value' => $item->get_vat_rule('edit'), |
|
76 | 76 | 'select2' => true, |
77 | 77 | 'data-allow-clear' => 'false', |
78 | 78 | 'no_wrap' => true, |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | ?> |
83 | 83 | </div> |
84 | 84 | <div class="col-sm-1 pt-2 pl-0"> |
85 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'When you select physical product rules, only consumers and businesses in your country will be charged VAT. The VAT rate used will be the rate in your country. <br><br>If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer. Only businesses in your country will be charged VAT.', 'invoicing' ); ?>"></span> |
|
85 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('When you select physical product rules, only consumers and businesses in your country will be charged VAT. The VAT rate used will be the rate in your country. <br><br>If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer. Only businesses in your country will be charged VAT.', 'invoicing'); ?>"></span> |
|
86 | 86 | </div> |
87 | 87 | </div> |
88 | 88 | |
@@ -98,14 +98,14 @@ discard block |
||
98 | 98 | * @param WPInv_Item $item |
99 | 99 | * @param WPInv_EUVat $wpinv_euvat |
100 | 100 | */ |
101 | - public static function output_vat_classes( $item, $wpinv_euvat ) { |
|
101 | + public static function output_vat_classes($item, $wpinv_euvat) { |
|
102 | 102 | ?> |
103 | 103 | |
104 | 104 | <div class="wpinv_vat_classes"> |
105 | 105 | |
106 | 106 | <div class="form-group row"> |
107 | 107 | <label for="wpinv_vat_class" class="col-sm-3 col-form-label"> |
108 | - <?php _e( 'VAT Class', 'invoicing' );?> |
|
108 | + <?php _e('VAT Class', 'invoicing'); ?> |
|
109 | 109 | </label> |
110 | 110 | <div class="col-sm-8"> |
111 | 111 | <?php |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | array( |
114 | 114 | 'id' => 'wpinv_vat_class', |
115 | 115 | 'name' => 'wpinv_vat_class', |
116 | - 'placeholder' => __( 'Select VAT class', 'invoicing' ), |
|
117 | - 'value' => $item->get_vat_class( 'edit' ), |
|
116 | + 'placeholder' => __('Select VAT class', 'invoicing'), |
|
117 | + 'value' => $item->get_vat_class('edit'), |
|
118 | 118 | 'select2' => true, |
119 | 119 | 'data-allow-clear' => 'false', |
120 | 120 | 'no_wrap' => true, |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | ?> |
125 | 125 | </div> |
126 | 126 | <div class="col-sm-1 pt-2 pl-0"> |
127 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select the VAT rate class to use for this invoice item', 'invoicing' ); ?>"></span> |
|
127 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select the VAT rate class to use for this invoice item', 'invoicing'); ?>"></span> |
|
128 | 128 | </div> |
129 | 129 | </div> |
130 | 130 |
@@ -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(); |
@@ -33,35 +33,35 @@ 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( &$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(&$this, 'wpinv_actions')); |
|
48 | 48 | |
49 | - if ( class_exists( 'BuddyPress' ) ) { |
|
50 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
49 | + if (class_exists('BuddyPress')) { |
|
50 | + add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
|
51 | 51 | } |
52 | 52 | |
53 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
54 | - add_action( 'wp_footer', array( &$this, 'wp_footer' ) ); |
|
55 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
56 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
53 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
54 | + add_action('wp_footer', array(&$this, 'wp_footer')); |
|
55 | + add_action('widgets_init', array(&$this, 'register_widgets')); |
|
56 | + add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids')); |
|
57 | 57 | |
58 | - if ( is_admin() ) { |
|
59 | - add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) ); |
|
60 | - add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ) ); |
|
61 | - add_action( 'admin_init', array( &$this, 'init_ayecode_connect_helper' ) ); |
|
58 | + if (is_admin()) { |
|
59 | + add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts')); |
|
60 | + add_filter('admin_body_class', array(&$this, 'admin_body_class')); |
|
61 | + add_action('admin_init', array(&$this, 'init_ayecode_connect_helper')); |
|
62 | 62 | |
63 | 63 | } else { |
64 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
64 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -71,28 +71,28 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference. |
73 | 73 | */ |
74 | - do_action_ref_array( 'wpinv_actions', array( &$this ) ); |
|
74 | + do_action_ref_array('wpinv_actions', array(&$this)); |
|
75 | 75 | |
76 | - add_action( 'admin_init', array( &$this, 'activation_redirect') ); |
|
76 | + add_action('admin_init', array(&$this, 'activation_redirect')); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
80 | 80 | * Maybe show the AyeCode Connect Notice. |
81 | 81 | */ |
82 | - public function init_ayecode_connect_helper(){ |
|
82 | + public function init_ayecode_connect_helper() { |
|
83 | 83 | // AyeCode Connect notice |
84 | - if ( is_admin() ){ |
|
84 | + if (is_admin()) { |
|
85 | 85 | // set the strings so they can be translated |
86 | 86 | $strings = array( |
87 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
88 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
89 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
90 | - 'connect_button' => __("Connect Site","invoicing"), |
|
91 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
92 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
93 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
87 | + 'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"), |
|
88 | + 'connect_external' => __("Please confirm you wish to connect your site?", "invoicing"), |
|
89 | + 'connect' => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"), |
|
90 | + 'connect_button' => __("Connect Site", "invoicing"), |
|
91 | + 'connecting_button' => __("Connecting...", "invoicing"), |
|
92 | + 'error_localhost' => __("This service will only work with a live domain, not a localhost.", "invoicing"), |
|
93 | + 'error' => __("Something went wrong, please refresh and try again.", "invoicing"), |
|
94 | 94 | ); |
95 | - new AyeCode_Connect_Helper($strings,array('wpi-addons')); |
|
95 | + new AyeCode_Connect_Helper($strings, array('wpi-addons')); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | /* Internationalize the text strings used. */ |
101 | 101 | $this->load_textdomain(); |
102 | 102 | |
103 | - do_action( 'wpinv_loaded' ); |
|
103 | + do_action('wpinv_loaded'); |
|
104 | 104 | |
105 | 105 | // Fix oxygen page builder conflict |
106 | - if ( function_exists( 'ct_css_output' ) ) { |
|
106 | + if (function_exists('ct_css_output')) { |
|
107 | 107 | wpinv_oxygen_fix_conflict(); |
108 | 108 | } |
109 | 109 | } |
@@ -113,140 +113,140 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @since 1.0 |
115 | 115 | */ |
116 | - public function load_textdomain( $locale = NULL ) { |
|
117 | - if ( empty( $locale ) ) { |
|
118 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
116 | + public function load_textdomain($locale = NULL) { |
|
117 | + if (empty($locale)) { |
|
118 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
119 | 119 | } |
120 | 120 | |
121 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
121 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
122 | 122 | |
123 | - unload_textdomain( 'invoicing' ); |
|
124 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
125 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
123 | + unload_textdomain('invoicing'); |
|
124 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
125 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
126 | 126 | |
127 | 127 | /** |
128 | 128 | * Define language constants. |
129 | 129 | */ |
130 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
130 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | public function includes() { |
134 | 134 | global $wpinv_options; |
135 | 135 | |
136 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
136 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
137 | 137 | $wpinv_options = wpinv_get_settings(); |
138 | 138 | |
139 | 139 | // Load composer packages. |
140 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
140 | + require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php'); |
|
141 | 141 | |
142 | 142 | // load AUI |
143 | - require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
143 | + require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php'); |
|
144 | 144 | |
145 | 145 | // Register autoloader. |
146 | 146 | try { |
147 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
148 | - } catch ( Exception $e ) { |
|
149 | - log_noptin_message( $e->getMessage() ); |
|
150 | - } |
|
151 | - |
|
152 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' ); |
|
153 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
154 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
155 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
156 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
157 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
158 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
159 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' ); |
|
160 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
161 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
162 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
163 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
164 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
165 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' ); |
|
166 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' ); |
|
167 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' ); |
|
168 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php' ); |
|
169 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' ); |
|
170 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' ); |
|
171 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
172 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
173 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
174 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
175 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
176 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
177 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
178 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
179 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
180 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' ); |
|
181 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
182 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' ); |
|
183 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
184 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
185 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
186 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
187 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
188 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
189 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
190 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
191 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
192 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
193 | - require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
194 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' ); |
|
195 | - |
|
196 | - if ( !class_exists( 'WPInv_EUVat' ) ) { |
|
197 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
147 | + spl_autoload_register(array($this, 'autoload'), true); |
|
148 | + } catch (Exception $e) { |
|
149 | + log_noptin_message($e->getMessage()); |
|
150 | + } |
|
151 | + |
|
152 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php'); |
|
153 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
154 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
155 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
156 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
157 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
158 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
159 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php'); |
|
160 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
161 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
162 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
163 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
164 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
165 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php'); |
|
166 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php'); |
|
167 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php'); |
|
168 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php'); |
|
169 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php'); |
|
170 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php'); |
|
171 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'); |
|
172 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php'); |
|
173 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
174 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
175 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
176 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
177 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
178 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
179 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
180 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php'); |
|
181 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
182 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php'); |
|
183 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php'); |
|
184 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
185 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php'); |
|
186 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php'); |
|
187 | + require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php'); |
|
188 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php'); |
|
189 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php'); |
|
190 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php'); |
|
191 | + require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php'); |
|
192 | + require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php'); |
|
193 | + require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php'); |
|
194 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php'); |
|
195 | + |
|
196 | + if (!class_exists('WPInv_EUVat')) { |
|
197 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
198 | 198 | } |
199 | 199 | |
200 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
201 | - if ( !empty( $gateways ) ) { |
|
202 | - foreach ( $gateways as $gateway ) { |
|
203 | - if ( $gateway == 'manual' ) { |
|
200 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
201 | + if (!empty($gateways)) { |
|
202 | + foreach ($gateways as $gateway) { |
|
203 | + if ($gateway == 'manual') { |
|
204 | 204 | continue; |
205 | 205 | } |
206 | 206 | |
207 | 207 | $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; |
208 | 208 | |
209 | - if ( file_exists( $gateway_file ) ) { |
|
210 | - require_once( $gateway_file ); |
|
209 | + if (file_exists($gateway_file)) { |
|
210 | + require_once($gateway_file); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 | } |
214 | - require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' ); |
|
214 | + require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php'); |
|
215 | 215 | |
216 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
217 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
218 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
219 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' ); |
|
216 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
217 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
218 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
219 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php'); |
|
220 | 220 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' ); |
221 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' ); |
|
222 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' ); |
|
223 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
224 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
225 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' ); |
|
226 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
227 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
228 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
229 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
221 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php'); |
|
222 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php'); |
|
223 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php'); |
|
224 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
225 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php'); |
|
226 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
227 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
228 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
229 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php'); |
|
230 | 230 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
231 | 231 | // load the user class only on the users.php page |
232 | 232 | global $pagenow; |
233 | - if($pagenow=='users.php'){ |
|
233 | + if ($pagenow == 'users.php') { |
|
234 | 234 | new WPInv_Admin_Users(); |
235 | 235 | } |
236 | 236 | } |
237 | 237 | |
238 | 238 | // Register cli commands |
239 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
240 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
241 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
239 | + if (defined('WP_CLI') && WP_CLI) { |
|
240 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'); |
|
241 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | // include css inliner |
245 | - if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { |
|
246 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
245 | + if (!class_exists('Emogrifier') && class_exists('DOMDocument')) { |
|
246 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
247 | 247 | } |
248 | 248 | |
249 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
249 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -257,18 +257,18 @@ discard block |
||
257 | 257 | * @since 1.0.19 |
258 | 258 | * @return void |
259 | 259 | */ |
260 | - public function autoload( $class_name ) { |
|
260 | + public function autoload($class_name) { |
|
261 | 261 | |
262 | 262 | // Normalize the class name... |
263 | - $class_name = strtolower( $class_name ); |
|
263 | + $class_name = strtolower($class_name); |
|
264 | 264 | |
265 | 265 | // ... and make sure it is our class. |
266 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
266 | + if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) { |
|
267 | 267 | return; |
268 | 268 | } |
269 | 269 | |
270 | 270 | // Next, prepare the file name from the class. |
271 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
271 | + $file_name = 'class-' . str_replace('_', '-', $class_name) . '.php'; |
|
272 | 272 | |
273 | 273 | // And an array of possible locations in order of importance. |
274 | 274 | $locations = array( |
@@ -279,11 +279,11 @@ discard block |
||
279 | 279 | ); |
280 | 280 | |
281 | 281 | // Base path of the classes. |
282 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
282 | + $plugin_path = untrailingslashit(WPINV_PLUGIN_DIR); |
|
283 | 283 | |
284 | - foreach ( $locations as $location ) { |
|
284 | + foreach ($locations as $location) { |
|
285 | 285 | |
286 | - if ( file_exists( "$plugin_path/$location/$file_name" ) ) { |
|
286 | + if (file_exists("$plugin_path/$location/$file_name")) { |
|
287 | 287 | include "$plugin_path/$location/$file_name"; |
288 | 288 | break; |
289 | 289 | } |
@@ -297,114 +297,114 @@ discard block |
||
297 | 297 | |
298 | 298 | public function admin_init() { |
299 | 299 | self::$instance->default_payment_form = wpinv_get_default_payment_form(); |
300 | - add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) ); |
|
300 | + add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php')); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | public function activation_redirect() { |
304 | 304 | // Bail if no activation redirect |
305 | - if ( !get_transient( '_wpinv_activation_redirect' ) ) { |
|
305 | + if (!get_transient('_wpinv_activation_redirect')) { |
|
306 | 306 | return; |
307 | 307 | } |
308 | 308 | |
309 | 309 | // Delete the redirect transient |
310 | - delete_transient( '_wpinv_activation_redirect' ); |
|
310 | + delete_transient('_wpinv_activation_redirect'); |
|
311 | 311 | |
312 | 312 | // Bail if activating from network, or bulk |
313 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
313 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
314 | 314 | return; |
315 | 315 | } |
316 | 316 | |
317 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
317 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
318 | 318 | exit; |
319 | 319 | } |
320 | 320 | |
321 | 321 | public function enqueue_scripts() { |
322 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
322 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
323 | 323 | |
324 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION ); |
|
325 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
324 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION); |
|
325 | + wp_enqueue_style('wpinv_front_style'); |
|
326 | 326 | |
327 | 327 | // Register scripts |
328 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
329 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ), filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) ); |
|
328 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
329 | + wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), filemtime(WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js')); |
|
330 | 330 | |
331 | 331 | $localize = array(); |
332 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
333 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
332 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
333 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
334 | 334 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
335 | 335 | $localize['currency_pos'] = wpinv_currency_position(); |
336 | 336 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
337 | 337 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
338 | 338 | $localize['decimals'] = wpinv_decimals(); |
339 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
339 | + $localize['txtComplete'] = __('Continue', 'invoicing'); |
|
340 | 340 | $localize['UseTaxes'] = wpinv_use_taxes(); |
341 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
341 | + $localize['checkoutNonce'] = wp_create_nonce('wpinv_checkout_nonce'); |
|
342 | 342 | |
343 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
343 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
344 | 344 | |
345 | - wp_enqueue_script( 'jquery-blockui' ); |
|
345 | + wp_enqueue_script('jquery-blockui'); |
|
346 | 346 | $autofill_api = wpinv_get_option('address_autofill_api'); |
347 | 347 | $autofill_active = wpinv_get_option('address_autofill_active'); |
348 | - if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { |
|
349 | - if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { |
|
350 | - wp_dequeue_script( 'google-maps-api' ); |
|
348 | + if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { |
|
349 | + if (wp_script_is('google-maps-api', 'enqueued')) { |
|
350 | + wp_dequeue_script('google-maps-api'); |
|
351 | 351 | } |
352 | - wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); |
|
353 | - wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); |
|
352 | + wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); |
|
353 | + wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true); |
|
354 | 354 | } |
355 | 355 | |
356 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
357 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
356 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
357 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
358 | 358 | |
359 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
360 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
359 | + wp_enqueue_script('wpinv-front-script'); |
|
360 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
361 | 361 | |
362 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
363 | - wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ), $version, true ); |
|
362 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js'); |
|
363 | + wp_enqueue_script('wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('wpinv-front-script', 'wp-hooks'), $version, true); |
|
364 | 364 | } |
365 | 365 | |
366 | - public function admin_enqueue_scripts( $hook ) { |
|
366 | + public function admin_enqueue_scripts($hook) { |
|
367 | 367 | global $post, $pagenow; |
368 | 368 | |
369 | 369 | $post_type = wpinv_admin_post_type(); |
370 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
371 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : ''; |
|
370 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
371 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : ''; |
|
372 | 372 | |
373 | 373 | $jquery_ui_css = false; |
374 | - if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) { |
|
374 | + if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
|
375 | 375 | $jquery_ui_css = true; |
376 | - } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) { |
|
376 | + } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') { |
|
377 | 377 | $jquery_ui_css = true; |
378 | 378 | } |
379 | - if ( $jquery_ui_css ) { |
|
380 | - wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); |
|
381 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
382 | - wp_deregister_style( 'yoast-seo-select2' ); |
|
383 | - wp_deregister_style( 'yoast-seo-monorepo' ); |
|
379 | + if ($jquery_ui_css) { |
|
380 | + wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16'); |
|
381 | + wp_enqueue_style('jquery-ui-css'); |
|
382 | + wp_deregister_style('yoast-seo-select2'); |
|
383 | + wp_deregister_style('yoast-seo-monorepo'); |
|
384 | 384 | } |
385 | 385 | |
386 | - wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
|
387 | - wp_enqueue_style( 'wpinv_meta_box_style' ); |
|
386 | + wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
387 | + wp_enqueue_style('wpinv_meta_box_style'); |
|
388 | 388 | |
389 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' ); |
|
390 | - wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version ); |
|
391 | - wp_enqueue_style( 'wpinv_admin_style' ); |
|
389 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css'); |
|
390 | + wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version); |
|
391 | + wp_enqueue_style('wpinv_admin_style'); |
|
392 | 392 | |
393 | - $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ); |
|
394 | - if ( $page == 'wpinv-subscriptions' ) { |
|
395 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
396 | - wp_deregister_style( 'yoast-seo-select2' ); |
|
397 | - wp_deregister_style( 'yoast-seo-monorepo' ); |
|
393 | + $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')); |
|
394 | + if ($page == 'wpinv-subscriptions') { |
|
395 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
396 | + wp_deregister_style('yoast-seo-select2'); |
|
397 | + wp_deregister_style('yoast-seo-monorepo'); |
|
398 | 398 | } |
399 | 399 | |
400 | - if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) { |
|
401 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
400 | + if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) { |
|
401 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
402 | 402 | } |
403 | 403 | |
404 | - wp_enqueue_style( 'wp-color-picker' ); |
|
405 | - wp_enqueue_script( 'wp-color-picker' ); |
|
404 | + wp_enqueue_style('wp-color-picker'); |
|
405 | + wp_enqueue_script('wp-color-picker'); |
|
406 | 406 | |
407 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
407 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
408 | 408 | |
409 | 409 | if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
410 | 410 | $autofill_api = wpinv_get_option('address_autofill_api'); |
@@ -415,21 +415,21 @@ discard block |
||
415 | 415 | } |
416 | 416 | } |
417 | 417 | |
418 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
419 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
418 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
419 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
420 | 420 | |
421 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' ); |
|
422 | - wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ), $version ); |
|
423 | - wp_enqueue_script( 'wpinv-admin-script' ); |
|
421 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js'); |
|
422 | + wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), $version); |
|
423 | + wp_enqueue_script('wpinv-admin-script'); |
|
424 | 424 | |
425 | 425 | $localize = array(); |
426 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
427 | - $localize['post_ID'] = isset( $post->ID ) ? $post->ID : ''; |
|
428 | - $localize['wpinv_nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
429 | - $localize['add_invoice_note_nonce'] = wp_create_nonce( 'add-invoice-note' ); |
|
430 | - $localize['delete_invoice_note_nonce'] = wp_create_nonce( 'delete-invoice-note' ); |
|
431 | - $localize['invoice_item_nonce'] = wp_create_nonce( 'invoice-item' ); |
|
432 | - $localize['billing_details_nonce'] = wp_create_nonce( 'get-billing-details' ); |
|
426 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
427 | + $localize['post_ID'] = isset($post->ID) ? $post->ID : ''; |
|
428 | + $localize['wpinv_nonce'] = wp_create_nonce('wpinv-nonce'); |
|
429 | + $localize['add_invoice_note_nonce'] = wp_create_nonce('add-invoice-note'); |
|
430 | + $localize['delete_invoice_note_nonce'] = wp_create_nonce('delete-invoice-note'); |
|
431 | + $localize['invoice_item_nonce'] = wp_create_nonce('invoice-item'); |
|
432 | + $localize['billing_details_nonce'] = wp_create_nonce('get-billing-details'); |
|
433 | 433 | $localize['tax'] = wpinv_tax_amount(); |
434 | 434 | $localize['discount'] = wpinv_discount_amount(); |
435 | 435 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
@@ -437,101 +437,101 @@ discard block |
||
437 | 437 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
438 | 438 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
439 | 439 | $localize['decimals'] = wpinv_decimals(); |
440 | - $localize['save_invoice'] = __( 'Save Invoice', 'invoicing' ); |
|
441 | - $localize['status_publish'] = wpinv_status_nicename( 'publish' ); |
|
442 | - $localize['status_pending'] = wpinv_status_nicename( 'wpi-pending' ); |
|
443 | - $localize['delete_tax_rate'] = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ); |
|
444 | - $localize['OneItemMin'] = __( 'Invoice must contain at least one item', 'invoicing' ); |
|
445 | - $localize['DeleteInvoiceItem'] = __( 'Are you sure you wish to delete this item?', 'invoicing' ); |
|
446 | - $localize['FillBillingDetails'] = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ); |
|
447 | - $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' ); |
|
448 | - $localize['AreYouSure'] = __( 'Are you sure?', 'invoicing' ); |
|
449 | - $localize['emptyInvoice'] = __( 'Add at least one item to save invoice!', 'invoicing' ); |
|
450 | - $localize['errDeleteItem'] = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ); |
|
451 | - $localize['delete_subscription'] = __( 'Are you sure you want to delete this subscription?', 'invoicing' ); |
|
452 | - $localize['action_edit'] = __( 'Edit', 'invoicing' ); |
|
453 | - $localize['action_cancel'] = __( 'Cancel', 'invoicing' ); |
|
454 | - $localize['item_description'] = __( 'Item Description', 'invoicing' ); |
|
455 | - |
|
456 | - $localize = apply_filters( 'wpinv_admin_js_localize', $localize ); |
|
457 | - |
|
458 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize ); |
|
440 | + $localize['save_invoice'] = __('Save Invoice', 'invoicing'); |
|
441 | + $localize['status_publish'] = wpinv_status_nicename('publish'); |
|
442 | + $localize['status_pending'] = wpinv_status_nicename('wpi-pending'); |
|
443 | + $localize['delete_tax_rate'] = __('Are you sure you wish to delete this tax rate?', 'invoicing'); |
|
444 | + $localize['OneItemMin'] = __('Invoice must contain at least one item', 'invoicing'); |
|
445 | + $localize['DeleteInvoiceItem'] = __('Are you sure you wish to delete this item?', 'invoicing'); |
|
446 | + $localize['FillBillingDetails'] = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'); |
|
447 | + $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'); |
|
448 | + $localize['AreYouSure'] = __('Are you sure?', 'invoicing'); |
|
449 | + $localize['emptyInvoice'] = __('Add at least one item to save invoice!', 'invoicing'); |
|
450 | + $localize['errDeleteItem'] = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'); |
|
451 | + $localize['delete_subscription'] = __('Are you sure you want to delete this subscription?', 'invoicing'); |
|
452 | + $localize['action_edit'] = __('Edit', 'invoicing'); |
|
453 | + $localize['action_cancel'] = __('Cancel', 'invoicing'); |
|
454 | + $localize['item_description'] = __('Item Description', 'invoicing'); |
|
455 | + |
|
456 | + $localize = apply_filters('wpinv_admin_js_localize', $localize); |
|
457 | + |
|
458 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize); |
|
459 | 459 | |
460 | 460 | // Load payment form scripts on our admin pages only. |
461 | - if ( ( $hook == 'post-new.php' || $hook == 'post.php' ) && 'wpi_payment_form' === $post->post_type ) { |
|
461 | + if (($hook == 'post-new.php' || $hook == 'post.php') && 'wpi_payment_form' === $post->post_type) { |
|
462 | 462 | |
463 | - wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION ); |
|
464 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
465 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
463 | + wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION); |
|
464 | + wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION); |
|
465 | + wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION); |
|
466 | 466 | |
467 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
468 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
467 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js'); |
|
468 | + wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version); |
|
469 | 469 | |
470 | - wp_localize_script( 'wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array( |
|
470 | + wp_localize_script('wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array( |
|
471 | 471 | 'elements' => $this->form_elements->get_elements(), |
472 | - 'form_elements' => $this->form_elements->get_form_elements( $post->ID ), |
|
472 | + 'form_elements' => $this->form_elements->get_form_elements($post->ID), |
|
473 | 473 | 'all_items' => $this->form_elements->get_published_items(), |
474 | 474 | 'currency' => wpinv_currency_symbol(), |
475 | 475 | 'position' => wpinv_currency_position(), |
476 | 476 | 'decimals' => (int) wpinv_decimals(), |
477 | 477 | 'thousands_sep' => wpinv_thousands_separator(), |
478 | 478 | 'decimals_sep' => wpinv_decimal_separator(), |
479 | - 'form_items' => $this->form_elements->get_form_items( $post->ID ), |
|
479 | + 'form_items' => $this->form_elements->get_form_items($post->ID), |
|
480 | 480 | 'is_default' => $post->ID == $this->default_payment_form, |
481 | - ) ); |
|
481 | + )); |
|
482 | 482 | |
483 | - wp_enqueue_script( 'wpinv-admin-payment-form-script' ); |
|
483 | + wp_enqueue_script('wpinv-admin-payment-form-script'); |
|
484 | 484 | } |
485 | 485 | |
486 | - if ( $page == 'wpinv-subscriptions' ) { |
|
487 | - wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
488 | - wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
486 | + if ($page == 'wpinv-subscriptions') { |
|
487 | + wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION); |
|
488 | + wp_enqueue_script('wpinv-sub-admin-script'); |
|
489 | 489 | } |
490 | 490 | |
491 | - if ( $page == 'wpinv-reports' ) { |
|
492 | - wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' ); |
|
491 | + if ($page == 'wpinv-reports') { |
|
492 | + wp_enqueue_script('jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array('jquery'), '0.7'); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | } |
496 | 496 | |
497 | - public function admin_body_class( $classes ) { |
|
497 | + public function admin_body_class($classes) { |
|
498 | 498 | global $pagenow, $post, $current_screen; |
499 | 499 | |
500 | - if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote' ) ) { |
|
500 | + if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote')) { |
|
501 | 501 | $classes .= ' wpinv-cpt'; |
502 | 502 | } |
503 | 503 | |
504 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
504 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
505 | 505 | |
506 | - $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false; |
|
507 | - if ( $add_class ) { |
|
508 | - $classes .= ' wpi-' . wpinv_sanitize_key( $page ); |
|
506 | + $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false; |
|
507 | + if ($add_class) { |
|
508 | + $classes .= ' wpi-' . wpinv_sanitize_key($page); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | $settings_class = array(); |
512 | - if ( $page == 'wpinv-settings' ) { |
|
513 | - if ( !empty( $_REQUEST['tab'] ) ) { |
|
514 | - $settings_class[] = sanitize_text_field( $_REQUEST['tab'] ); |
|
512 | + if ($page == 'wpinv-settings') { |
|
513 | + if (!empty($_REQUEST['tab'])) { |
|
514 | + $settings_class[] = sanitize_text_field($_REQUEST['tab']); |
|
515 | 515 | } |
516 | 516 | |
517 | - if ( !empty( $_REQUEST['section'] ) ) { |
|
518 | - $settings_class[] = sanitize_text_field( $_REQUEST['section'] ); |
|
517 | + if (!empty($_REQUEST['section'])) { |
|
518 | + $settings_class[] = sanitize_text_field($_REQUEST['section']); |
|
519 | 519 | } |
520 | 520 | |
521 | - $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main'; |
|
521 | + $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main'; |
|
522 | 522 | } |
523 | 523 | |
524 | - if ( !empty( $settings_class ) ) { |
|
525 | - $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) ); |
|
524 | + if (!empty($settings_class)) { |
|
525 | + $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-')); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | $post_type = wpinv_admin_post_type(); |
529 | 529 | |
530 | - if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) { |
|
530 | + if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) { |
|
531 | 531 | return $classes .= ' wpinv'; |
532 | 532 | } |
533 | 533 | |
534 | - if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) { |
|
534 | + if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) { |
|
535 | 535 | $classes .= ' wpi-editable-n'; |
536 | 536 | } |
537 | 537 | |
@@ -543,21 +543,21 @@ discard block |
||
543 | 543 | } |
544 | 544 | |
545 | 545 | public function wpinv_actions() { |
546 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
547 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
546 | + if (isset($_REQUEST['wpi_action'])) { |
|
547 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
548 | 548 | } |
549 | 549 | } |
550 | 550 | |
551 | - public function pre_get_posts( $wp_query ) { |
|
552 | - 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() ) { |
|
553 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
551 | + public function pre_get_posts($wp_query) { |
|
552 | + 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()) { |
|
553 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | return $wp_query; |
557 | 557 | } |
558 | 558 | |
559 | 559 | public function bp_invoicing_init() { |
560 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
560 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | /** |
@@ -565,13 +565,13 @@ discard block |
||
565 | 565 | * |
566 | 566 | */ |
567 | 567 | public function register_widgets() { |
568 | - register_widget( "WPInv_Checkout_Widget" ); |
|
569 | - register_widget( "WPInv_History_Widget" ); |
|
570 | - register_widget( "WPInv_Receipt_Widget" ); |
|
571 | - register_widget( "WPInv_Subscriptions_Widget" ); |
|
572 | - register_widget( "WPInv_Buy_Item_Widget" ); |
|
573 | - register_widget( "WPInv_Messages_Widget" ); |
|
574 | - register_widget( 'WPInv_GetPaid_Widget' ); |
|
568 | + register_widget("WPInv_Checkout_Widget"); |
|
569 | + register_widget("WPInv_History_Widget"); |
|
570 | + register_widget("WPInv_Receipt_Widget"); |
|
571 | + register_widget("WPInv_Subscriptions_Widget"); |
|
572 | + register_widget("WPInv_Buy_Item_Widget"); |
|
573 | + register_widget("WPInv_Messages_Widget"); |
|
574 | + register_widget('WPInv_GetPaid_Widget'); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | /** |
@@ -580,10 +580,10 @@ discard block |
||
580 | 580 | * @since 1.0.19 |
581 | 581 | * @param int[] $excluded_posts_ids |
582 | 582 | */ |
583 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
583 | + public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) { |
|
584 | 584 | |
585 | 585 | // Ensure that we have an array. |
586 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
586 | + if (!is_array($excluded_posts_ids)) { |
|
587 | 587 | $excluded_posts_ids = array(); |
588 | 588 | } |
589 | 589 | |
@@ -591,24 +591,24 @@ discard block |
||
591 | 591 | $our_pages = array(); |
592 | 592 | |
593 | 593 | // Checkout page. |
594 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
594 | + $our_pages[] = wpinv_get_option('checkout_page', false); |
|
595 | 595 | |
596 | 596 | // Success page. |
597 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
597 | + $our_pages[] = wpinv_get_option('success_page', false); |
|
598 | 598 | |
599 | 599 | // Failure page. |
600 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
600 | + $our_pages[] = wpinv_get_option('failure_page', false); |
|
601 | 601 | |
602 | 602 | // History page. |
603 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
603 | + $our_pages[] = wpinv_get_option('invoice_history_page', false); |
|
604 | 604 | |
605 | 605 | // Subscriptions page. |
606 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
606 | + $our_pages[] = wpinv_get_option('invoice_subscription_page', false); |
|
607 | 607 | |
608 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
608 | + $our_pages = array_map('intval', array_filter($our_pages)); |
|
609 | 609 | |
610 | 610 | $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
611 | - return array_unique( $excluded_posts_ids ); |
|
611 | + return array_unique($excluded_posts_ids); |
|
612 | 612 | |
613 | 613 | } |
614 | 614 |