@@ -7,28 +7,28 @@ 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_Ajax { |
15 | 15 | public static function init() { |
16 | - add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
17 | - add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
16 | + add_action('init', array(__CLASS__, 'define_ajax'), 0); |
|
17 | + add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0); |
|
18 | 18 | self::add_ajax_events(); |
19 | 19 | } |
20 | 20 | |
21 | 21 | public static function define_ajax() { |
22 | - if ( !empty( $_GET['wpinv-ajax'] ) ) { |
|
23 | - if ( ! defined( 'DOING_AJAX' ) ) { |
|
24 | - define( 'DOING_AJAX', true ); |
|
22 | + if (!empty($_GET['wpinv-ajax'])) { |
|
23 | + if (!defined('DOING_AJAX')) { |
|
24 | + define('DOING_AJAX', true); |
|
25 | 25 | } |
26 | - if ( ! defined( 'WC_DOING_AJAX' ) ) { |
|
27 | - define( 'WC_DOING_AJAX', true ); |
|
26 | + if (!defined('WC_DOING_AJAX')) { |
|
27 | + define('WC_DOING_AJAX', true); |
|
28 | 28 | } |
29 | 29 | // Turn off display_errors during AJAX events to prevent malformed JSON |
30 | - if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
31 | - /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
30 | + if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) { |
|
31 | + /** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0); |
|
32 | 32 | } |
33 | 33 | $GLOBALS['wpdb']->hide_errors(); |
34 | 34 | } |
@@ -37,24 +37,24 @@ discard block |
||
37 | 37 | public static function do_wpinv_ajax() { |
38 | 38 | global $wp_query; |
39 | 39 | |
40 | - if ( !empty( $_GET['wpinv-ajax'] ) ) { |
|
41 | - $wp_query->set( 'wpinv-ajax', sanitize_text_field( $_GET['wpinv-ajax'] ) ); |
|
40 | + if (!empty($_GET['wpinv-ajax'])) { |
|
41 | + $wp_query->set('wpinv-ajax', sanitize_text_field($_GET['wpinv-ajax'])); |
|
42 | 42 | } |
43 | 43 | |
44 | - if ( $action = $wp_query->get( 'wpinv-ajax' ) ) { |
|
44 | + if ($action = $wp_query->get('wpinv-ajax')) { |
|
45 | 45 | self::wpinv_ajax_headers(); |
46 | - do_action( 'wpinv_ajax_' . sanitize_text_field( $action ) ); |
|
46 | + do_action('wpinv_ajax_' . sanitize_text_field($action)); |
|
47 | 47 | die(); |
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | 51 | private static function wpinv_ajax_headers() { |
52 | 52 | send_origin_headers(); |
53 | - /** @scrutinizer ignore-unhandled */ @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
54 | - /** @scrutinizer ignore-unhandled */ @header( 'X-Robots-Tag: noindex' ); |
|
53 | + /** @scrutinizer ignore-unhandled */ @header('Content-Type: text/html; charset=' . get_option('blog_charset')); |
|
54 | + /** @scrutinizer ignore-unhandled */ @header('X-Robots-Tag: noindex'); |
|
55 | 55 | send_nosniff_header(); |
56 | 56 | nocache_headers(); |
57 | - status_header( 200 ); |
|
57 | + status_header(200); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | public static function add_ajax_events() { |
@@ -77,39 +77,39 @@ discard block |
||
77 | 77 | 'buy_items' => true, |
78 | 78 | ); |
79 | 79 | |
80 | - foreach ( $ajax_events as $ajax_event => $nopriv ) { |
|
81 | - add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
80 | + foreach ($ajax_events as $ajax_event => $nopriv) { |
|
81 | + add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
82 | 82 | |
83 | - if ( !defined( 'WPI_AJAX_' . strtoupper( $nopriv ) ) ) { |
|
84 | - define( 'WPI_AJAX_' . strtoupper( $nopriv ), 1 ); |
|
83 | + if (!defined('WPI_AJAX_' . strtoupper($nopriv))) { |
|
84 | + define('WPI_AJAX_' . strtoupper($nopriv), 1); |
|
85 | 85 | } |
86 | 86 | |
87 | - if ( $nopriv ) { |
|
88 | - add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
87 | + if ($nopriv) { |
|
88 | + add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
89 | 89 | |
90 | - add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
90 | + add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | 95 | public static function add_note() { |
96 | - check_ajax_referer( 'add-invoice-note', '_nonce' ); |
|
96 | + check_ajax_referer('add-invoice-note', '_nonce'); |
|
97 | 97 | |
98 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
98 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
99 | 99 | die(-1); |
100 | 100 | } |
101 | 101 | |
102 | - $post_id = absint( $_POST['post_id'] ); |
|
103 | - $note = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) ); |
|
104 | - $note_type = sanitize_text_field( $_POST['note_type'] ); |
|
102 | + $post_id = absint($_POST['post_id']); |
|
103 | + $note = wp_kses_post(trim(stripslashes($_POST['note']))); |
|
104 | + $note_type = sanitize_text_field($_POST['note_type']); |
|
105 | 105 | |
106 | 106 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
107 | 107 | |
108 | - if ( $post_id > 0 ) { |
|
109 | - $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note ); |
|
108 | + if ($post_id > 0) { |
|
109 | + $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note); |
|
110 | 110 | |
111 | - if ( $note_id > 0 && !is_wp_error( $note_id ) ) { |
|
112 | - wpinv_get_invoice_note_line_item( $note_id ); |
|
111 | + if ($note_id > 0 && !is_wp_error($note_id)) { |
|
112 | + wpinv_get_invoice_note_line_item($note_id); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
@@ -117,16 +117,16 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | public static function delete_note() { |
120 | - check_ajax_referer( 'delete-invoice-note', '_nonce' ); |
|
120 | + check_ajax_referer('delete-invoice-note', '_nonce'); |
|
121 | 121 | |
122 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
122 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
123 | 123 | die(-1); |
124 | 124 | } |
125 | 125 | |
126 | - $note_id = (int)$_POST['note_id']; |
|
126 | + $note_id = (int) $_POST['note_id']; |
|
127 | 127 | |
128 | - if ( $note_id > 0 ) { |
|
129 | - wp_delete_comment( $note_id, true ); |
|
128 | + if ($note_id > 0) { |
|
129 | + wp_delete_comment($note_id, true); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | die(); |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | } |
140 | 140 | |
141 | 141 | public static function checkout() { |
142 | - if ( ! defined( 'WPINV_CHECKOUT' ) ) { |
|
143 | - define( 'WPINV_CHECKOUT', true ); |
|
142 | + if (!defined('WPINV_CHECKOUT')) { |
|
143 | + define('WPINV_CHECKOUT', true); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | wpinv_process_checkout(); |
@@ -149,53 +149,53 @@ discard block |
||
149 | 149 | |
150 | 150 | public static function add_invoice_item() { |
151 | 151 | global $wpi_userID, $wpinv_ip_address_country; |
152 | - check_ajax_referer( 'invoice-item', '_nonce' ); |
|
153 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
152 | + check_ajax_referer('invoice-item', '_nonce'); |
|
153 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
154 | 154 | die(-1); |
155 | 155 | } |
156 | 156 | |
157 | - $item_id = sanitize_text_field( $_POST['item_id'] ); |
|
158 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
157 | + $item_id = sanitize_text_field($_POST['item_id']); |
|
158 | + $invoice_id = absint($_POST['invoice_id']); |
|
159 | 159 | |
160 | - if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) { |
|
160 | + if (!is_numeric($invoice_id) || !is_numeric($item_id)) { |
|
161 | 161 | die(); |
162 | 162 | } |
163 | 163 | |
164 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
165 | - if ( empty( $invoice ) ) { |
|
164 | + $invoice = wpinv_get_invoice($invoice_id); |
|
165 | + if (empty($invoice)) { |
|
166 | 166 | die(); |
167 | 167 | } |
168 | 168 | |
169 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
169 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
170 | 170 | die(); // Don't allow modify items for paid invoice. |
171 | 171 | } |
172 | 172 | |
173 | - if ( !empty( $_POST['user_id'] ) ) { |
|
174 | - $wpi_userID = absint( $_POST['user_id'] ); |
|
173 | + if (!empty($_POST['user_id'])) { |
|
174 | + $wpi_userID = absint($_POST['user_id']); |
|
175 | 175 | } |
176 | 176 | |
177 | - $item = new WPInv_Item( $item_id ); |
|
178 | - if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) { |
|
177 | + $item = new WPInv_Item($item_id); |
|
178 | + if (!(!empty($item) && $item->post_type == 'wpi_item')) { |
|
179 | 179 | die(); |
180 | 180 | } |
181 | 181 | |
182 | 182 | // Validate item before adding to invoice because recurring item must be paid individually. |
183 | - if ( !empty( $invoice->cart_details ) ) { |
|
183 | + if (!empty($invoice->cart_details)) { |
|
184 | 184 | $valid = true; |
185 | 185 | |
186 | - if ( $recurring_item = $invoice->get_recurring() ) { |
|
187 | - if ( $recurring_item != $item_id ) { |
|
186 | + if ($recurring_item = $invoice->get_recurring()) { |
|
187 | + if ($recurring_item != $item_id) { |
|
188 | 188 | $valid = false; |
189 | 189 | } |
190 | - } else if ( wpinv_is_recurring_item( $item_id ) ) { |
|
190 | + } else if (wpinv_is_recurring_item($item_id)) { |
|
191 | 191 | $valid = false; |
192 | 192 | } |
193 | 193 | |
194 | - if ( !$valid ) { |
|
194 | + if (!$valid) { |
|
195 | 195 | $response = array(); |
196 | 196 | $response['success'] = false; |
197 | - $response['msg'] = __( 'You can not add item because recurring item must be paid individually!', 'invoicing' ); |
|
198 | - wp_send_json( $response ); |
|
197 | + $response['msg'] = __('You can not add item because recurring item must be paid individually!', 'invoicing'); |
|
198 | + wp_send_json($response); |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | |
204 | 204 | $data = array(); |
205 | 205 | $data['invoice_id'] = $invoice_id; |
206 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
206 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
207 | 207 | |
208 | - wpinv_set_checkout_session( $data ); |
|
208 | + wpinv_set_checkout_session($data); |
|
209 | 209 | |
210 | - $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int)$_POST['qty'] > 0 ? (int)$_POST['qty'] : 1; |
|
210 | + $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int) $_POST['qty'] > 0 ? (int) $_POST['qty'] : 1; |
|
211 | 211 | |
212 | 212 | $args = array( |
213 | 213 | 'id' => $item_id, |
@@ -220,21 +220,21 @@ discard block |
||
220 | 220 | 'fees' => array() |
221 | 221 | ); |
222 | 222 | |
223 | - $invoice->add_item( $item_id, $args ); |
|
223 | + $invoice->add_item($item_id, $args); |
|
224 | 224 | $invoice->save(); |
225 | 225 | |
226 | - if ( empty( $_POST['country'] ) ) { |
|
226 | + if (empty($_POST['country'])) { |
|
227 | 227 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
228 | 228 | } |
229 | - if ( empty( $_POST['state'] ) ) { |
|
229 | + if (empty($_POST['state'])) { |
|
230 | 230 | $_POST['state'] = $invoice->state; |
231 | 231 | } |
232 | 232 | |
233 | - $invoice->country = sanitize_text_field( $_POST['country'] ); |
|
234 | - $invoice->state = sanitize_text_field( $_POST['state'] ); |
|
233 | + $invoice->country = sanitize_text_field($_POST['country']); |
|
234 | + $invoice->state = sanitize_text_field($_POST['state']); |
|
235 | 235 | |
236 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
237 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
236 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
237 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
238 | 238 | |
239 | 239 | $wpinv_ip_address_country = $invoice->country; |
240 | 240 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | |
243 | 243 | $response = array(); |
244 | 244 | $response['success'] = true; |
245 | - $response['data']['items'] = wpinv_admin_get_line_items( $invoice ); |
|
245 | + $response['data']['items'] = wpinv_admin_get_line_items($invoice); |
|
246 | 246 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
247 | 247 | $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
248 | 248 | $response['data']['tax'] = $invoice->get_tax(); |
@@ -254,40 +254,40 @@ discard block |
||
254 | 254 | |
255 | 255 | wpinv_set_checkout_session($checkout_session); |
256 | 256 | |
257 | - wp_send_json( $response ); |
|
257 | + wp_send_json($response); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | public static function remove_invoice_item() { |
261 | 261 | global $wpi_userID, $wpinv_ip_address_country; |
262 | 262 | |
263 | - check_ajax_referer( 'invoice-item', '_nonce' ); |
|
264 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
263 | + check_ajax_referer('invoice-item', '_nonce'); |
|
264 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
265 | 265 | die(-1); |
266 | 266 | } |
267 | 267 | |
268 | - $item_id = sanitize_text_field( $_POST['item_id'] ); |
|
269 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
270 | - $cart_index = isset( $_POST['index'] ) && $_POST['index'] >= 0 ? $_POST['index'] : false; |
|
268 | + $item_id = sanitize_text_field($_POST['item_id']); |
|
269 | + $invoice_id = absint($_POST['invoice_id']); |
|
270 | + $cart_index = isset($_POST['index']) && $_POST['index'] >= 0 ? $_POST['index'] : false; |
|
271 | 271 | |
272 | - if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) { |
|
272 | + if (!is_numeric($invoice_id) || !is_numeric($item_id)) { |
|
273 | 273 | die(); |
274 | 274 | } |
275 | 275 | |
276 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
277 | - if ( empty( $invoice ) ) { |
|
276 | + $invoice = wpinv_get_invoice($invoice_id); |
|
277 | + if (empty($invoice)) { |
|
278 | 278 | die(); |
279 | 279 | } |
280 | 280 | |
281 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
281 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
282 | 282 | die(); // Don't allow modify items for paid invoice. |
283 | 283 | } |
284 | 284 | |
285 | - if ( !empty( $_POST['user_id'] ) ) { |
|
286 | - $wpi_userID = absint( $_POST['user_id'] ); |
|
285 | + if (!empty($_POST['user_id'])) { |
|
286 | + $wpi_userID = absint($_POST['user_id']); |
|
287 | 287 | } |
288 | 288 | |
289 | - $item = new WPInv_Item( $item_id ); |
|
290 | - if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) { |
|
289 | + $item = new WPInv_Item($item_id); |
|
290 | + if (!(!empty($item) && $item->post_type == 'wpi_item')) { |
|
291 | 291 | die(); |
292 | 292 | } |
293 | 293 | |
@@ -295,9 +295,9 @@ discard block |
||
295 | 295 | |
296 | 296 | $data = array(); |
297 | 297 | $data['invoice_id'] = $invoice_id; |
298 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
298 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
299 | 299 | |
300 | - wpinv_set_checkout_session( $data ); |
|
300 | + wpinv_set_checkout_session($data); |
|
301 | 301 | |
302 | 302 | $args = array( |
303 | 303 | 'id' => $item_id, |
@@ -305,21 +305,21 @@ discard block |
||
305 | 305 | 'cart_index' => $cart_index |
306 | 306 | ); |
307 | 307 | |
308 | - $invoice->remove_item( $item_id, $args ); |
|
308 | + $invoice->remove_item($item_id, $args); |
|
309 | 309 | $invoice->save(); |
310 | 310 | |
311 | - if ( empty( $_POST['country'] ) ) { |
|
311 | + if (empty($_POST['country'])) { |
|
312 | 312 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
313 | 313 | } |
314 | - if ( empty( $_POST['state'] ) ) { |
|
314 | + if (empty($_POST['state'])) { |
|
315 | 315 | $_POST['state'] = $invoice->state; |
316 | 316 | } |
317 | 317 | |
318 | - $invoice->country = sanitize_text_field( $_POST['country'] ); |
|
319 | - $invoice->state = sanitize_text_field( $_POST['state'] ); |
|
318 | + $invoice->country = sanitize_text_field($_POST['country']); |
|
319 | + $invoice->state = sanitize_text_field($_POST['state']); |
|
320 | 320 | |
321 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
322 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
321 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
322 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
323 | 323 | |
324 | 324 | $wpinv_ip_address_country = $invoice->country; |
325 | 325 | |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | |
328 | 328 | $response = array(); |
329 | 329 | $response['success'] = true; |
330 | - $response['data']['items'] = wpinv_admin_get_line_items( $invoice ); |
|
330 | + $response['data']['items'] = wpinv_admin_get_line_items($invoice); |
|
331 | 331 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
332 | 332 | $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
333 | 333 | $response['data']['tax'] = $invoice->get_tax(); |
@@ -339,55 +339,55 @@ discard block |
||
339 | 339 | |
340 | 340 | wpinv_set_checkout_session($checkout_session); |
341 | 341 | |
342 | - wp_send_json( $response ); |
|
342 | + wp_send_json($response); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | public static function create_invoice_item() { |
346 | - check_ajax_referer( 'invoice-item', '_nonce' ); |
|
347 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
346 | + check_ajax_referer('invoice-item', '_nonce'); |
|
347 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
348 | 348 | die(-1); |
349 | 349 | } |
350 | 350 | |
351 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
351 | + $invoice_id = absint($_POST['invoice_id']); |
|
352 | 352 | |
353 | 353 | // Find the item |
354 | - if ( !is_numeric( $invoice_id ) ) { |
|
354 | + if (!is_numeric($invoice_id)) { |
|
355 | 355 | die(); |
356 | 356 | } |
357 | 357 | |
358 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
359 | - if ( empty( $invoice ) ) { |
|
358 | + $invoice = wpinv_get_invoice($invoice_id); |
|
359 | + if (empty($invoice)) { |
|
360 | 360 | die(); |
361 | 361 | } |
362 | 362 | |
363 | 363 | // Validate item before adding to invoice because recurring item must be paid individually. |
364 | - if ( !empty( $invoice->cart_details ) && $invoice->get_recurring() ) { |
|
364 | + if (!empty($invoice->cart_details) && $invoice->get_recurring()) { |
|
365 | 365 | $response = array(); |
366 | 366 | $response['success'] = false; |
367 | - $response['msg'] = __( 'You can not add item because recurring item must be paid individually!', 'invoicing' ); |
|
368 | - wp_send_json( $response ); |
|
367 | + $response['msg'] = __('You can not add item because recurring item must be paid individually!', 'invoicing'); |
|
368 | + wp_send_json($response); |
|
369 | 369 | } |
370 | 370 | |
371 | - $save_item = wp_unslash( $_POST['_wpinv_quick'] ); |
|
371 | + $save_item = wp_unslash($_POST['_wpinv_quick']); |
|
372 | 372 | |
373 | 373 | $meta = array(); |
374 | 374 | $meta['type'] = !empty($save_item['type']) ? sanitize_text_field($save_item['type']) : 'custom'; |
375 | - $meta['price'] = !empty($save_item['price']) ? wpinv_sanitize_amount( $save_item['price'] ) : 0; |
|
375 | + $meta['price'] = !empty($save_item['price']) ? wpinv_sanitize_amount($save_item['price']) : 0; |
|
376 | 376 | $meta['vat_rule'] = !empty($save_item['vat_rule']) ? sanitize_text_field($save_item['vat_rule']) : 'digital'; |
377 | 377 | $meta['vat_class'] = !empty($save_item['vat_class']) ? sanitize_text_field($save_item['vat_class']) : '_standard'; |
378 | 378 | |
379 | 379 | $data = array(); |
380 | 380 | $data['post_title'] = sanitize_text_field($save_item['name']); |
381 | 381 | $data['post_status'] = 'publish'; |
382 | - $data['post_excerpt'] = ! empty( $save_item['excerpt'] ) ? wp_kses_post( $save_item['excerpt'] ) : ''; |
|
382 | + $data['post_excerpt'] = !empty($save_item['excerpt']) ? wp_kses_post($save_item['excerpt']) : ''; |
|
383 | 383 | $data['meta'] = $meta; |
384 | 384 | |
385 | 385 | $item = new WPInv_Item(); |
386 | - $item->create( $data ); |
|
386 | + $item->create($data); |
|
387 | 387 | |
388 | - if ( !empty( $item ) ) { |
|
388 | + if (!empty($item)) { |
|
389 | 389 | $_POST['item_id'] = $item->ID; |
390 | - $_POST['qty'] = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int)$save_item['qty'] : 1; |
|
390 | + $_POST['qty'] = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int) $save_item['qty'] : 1; |
|
391 | 391 | |
392 | 392 | self::add_invoice_item(); |
393 | 393 | } |
@@ -395,15 +395,15 @@ discard block |
||
395 | 395 | } |
396 | 396 | |
397 | 397 | public static function get_billing_details() { |
398 | - check_ajax_referer( 'get-billing-details', '_nonce' ); |
|
398 | + check_ajax_referer('get-billing-details', '_nonce'); |
|
399 | 399 | |
400 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
400 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
401 | 401 | die(-1); |
402 | 402 | } |
403 | 403 | |
404 | - $user_id = (int)$_POST['user_id']; |
|
404 | + $user_id = (int) $_POST['user_id']; |
|
405 | 405 | $billing_details = wpinv_get_user_address($user_id); |
406 | - $billing_details = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id ); |
|
406 | + $billing_details = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id); |
|
407 | 407 | |
408 | 408 | if (isset($billing_details['user_id'])) { |
409 | 409 | unset($billing_details['user_id']); |
@@ -417,20 +417,20 @@ discard block |
||
417 | 417 | $response['success'] = true; |
418 | 418 | $response['data']['billing_details'] = $billing_details; |
419 | 419 | |
420 | - wp_send_json( $response ); |
|
420 | + wp_send_json($response); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | public static function admin_recalculate_totals() { |
424 | 424 | global $wpi_userID, $wpinv_ip_address_country; |
425 | 425 | |
426 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
427 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
426 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
427 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
428 | 428 | die(-1); |
429 | 429 | } |
430 | 430 | |
431 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
432 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
433 | - if ( empty( $invoice ) ) { |
|
431 | + $invoice_id = absint($_POST['invoice_id']); |
|
432 | + $invoice = wpinv_get_invoice($invoice_id); |
|
433 | + if (empty($invoice)) { |
|
434 | 434 | die(); |
435 | 435 | } |
436 | 436 | |
@@ -438,23 +438,23 @@ discard block |
||
438 | 438 | |
439 | 439 | $data = array(); |
440 | 440 | $data['invoice_id'] = $invoice_id; |
441 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
441 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
442 | 442 | |
443 | - wpinv_set_checkout_session( $data ); |
|
443 | + wpinv_set_checkout_session($data); |
|
444 | 444 | |
445 | - if ( !empty( $_POST['user_id'] ) ) { |
|
446 | - $wpi_userID = absint( $_POST['user_id'] ); |
|
445 | + if (!empty($_POST['user_id'])) { |
|
446 | + $wpi_userID = absint($_POST['user_id']); |
|
447 | 447 | } |
448 | 448 | |
449 | - if ( empty( $_POST['country'] ) ) { |
|
449 | + if (empty($_POST['country'])) { |
|
450 | 450 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
451 | 451 | } |
452 | 452 | |
453 | - $invoice->country = sanitize_text_field( $_POST['country'] ); |
|
454 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
455 | - if ( isset( $_POST['state'] ) ) { |
|
456 | - $invoice->state = sanitize_text_field( $_POST['state'] ); |
|
457 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
453 | + $invoice->country = sanitize_text_field($_POST['country']); |
|
454 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
455 | + if (isset($_POST['state'])) { |
|
456 | + $invoice->state = sanitize_text_field($_POST['state']); |
|
457 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | $wpinv_ip_address_country = $invoice->country; |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | |
464 | 464 | $response = array(); |
465 | 465 | $response['success'] = true; |
466 | - $response['data']['items'] = wpinv_admin_get_line_items( $invoice ); |
|
466 | + $response['data']['items'] = wpinv_admin_get_line_items($invoice); |
|
467 | 467 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
468 | 468 | $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
469 | 469 | $response['data']['tax'] = $invoice->get_tax(); |
@@ -475,25 +475,25 @@ discard block |
||
475 | 475 | |
476 | 476 | wpinv_set_checkout_session($checkout_session); |
477 | 477 | |
478 | - wp_send_json( $response ); |
|
478 | + wp_send_json($response); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | public static function admin_apply_discount() { |
482 | 482 | global $wpi_userID; |
483 | 483 | |
484 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
485 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
484 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
485 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
486 | 486 | die(-1); |
487 | 487 | } |
488 | 488 | |
489 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
490 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
491 | - if ( empty( $invoice_id ) || empty( $discount_code ) ) { |
|
489 | + $invoice_id = absint($_POST['invoice_id']); |
|
490 | + $discount_code = sanitize_text_field($_POST['code']); |
|
491 | + if (empty($invoice_id) || empty($discount_code)) { |
|
492 | 492 | die(); |
493 | 493 | } |
494 | 494 | |
495 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
496 | - if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) { |
|
495 | + $invoice = wpinv_get_invoice($invoice_id); |
|
496 | + if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) { |
|
497 | 497 | die(); |
498 | 498 | } |
499 | 499 | |
@@ -501,49 +501,49 @@ discard block |
||
501 | 501 | |
502 | 502 | $data = array(); |
503 | 503 | $data['invoice_id'] = $invoice_id; |
504 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
504 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
505 | 505 | |
506 | - wpinv_set_checkout_session( $data ); |
|
506 | + wpinv_set_checkout_session($data); |
|
507 | 507 | |
508 | 508 | $response = array(); |
509 | 509 | $response['success'] = false; |
510 | - $response['msg'] = __( 'This discount is invalid.', 'invoicing' ); |
|
510 | + $response['msg'] = __('This discount is invalid.', 'invoicing'); |
|
511 | 511 | $response['data']['code'] = $discount_code; |
512 | 512 | |
513 | - if ( wpinv_is_discount_valid( $discount_code, $invoice->get_user_id() ) ) { |
|
514 | - $discounts = wpinv_set_cart_discount( $discount_code ); |
|
513 | + if (wpinv_is_discount_valid($discount_code, $invoice->get_user_id())) { |
|
514 | + $discounts = wpinv_set_cart_discount($discount_code); |
|
515 | 515 | |
516 | 516 | $response['success'] = true; |
517 | - $response['msg'] = __( 'Discount has been applied successfully.', 'invoicing' ); |
|
518 | - } else { |
|
517 | + $response['msg'] = __('Discount has been applied successfully.', 'invoicing'); |
|
518 | + } else { |
|
519 | 519 | $errors = wpinv_get_errors(); |
520 | - if ( !empty( $errors['wpinv-discount-error'] ) ) { |
|
520 | + if (!empty($errors['wpinv-discount-error'])) { |
|
521 | 521 | $response['msg'] = $errors['wpinv-discount-error']; |
522 | 522 | } |
523 | - wpinv_unset_error( 'wpinv-discount-error' ); |
|
523 | + wpinv_unset_error('wpinv-discount-error'); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | wpinv_set_checkout_session($checkout_session); |
527 | 527 | |
528 | - wp_send_json( $response ); |
|
528 | + wp_send_json($response); |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | public static function admin_remove_discount() { |
532 | 532 | global $wpi_userID; |
533 | 533 | |
534 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
535 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
534 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
535 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
536 | 536 | die(-1); |
537 | 537 | } |
538 | 538 | |
539 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
540 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
541 | - if ( empty( $invoice_id ) || empty( $discount_code ) ) { |
|
539 | + $invoice_id = absint($_POST['invoice_id']); |
|
540 | + $discount_code = sanitize_text_field($_POST['code']); |
|
541 | + if (empty($invoice_id) || empty($discount_code)) { |
|
542 | 542 | die(); |
543 | 543 | } |
544 | 544 | |
545 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
546 | - if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) { |
|
545 | + $invoice = wpinv_get_invoice($invoice_id); |
|
546 | + if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) { |
|
547 | 547 | die(); |
548 | 548 | } |
549 | 549 | |
@@ -551,38 +551,38 @@ discard block |
||
551 | 551 | |
552 | 552 | $data = array(); |
553 | 553 | $data['invoice_id'] = $invoice_id; |
554 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
554 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
555 | 555 | |
556 | - wpinv_set_checkout_session( $data ); |
|
556 | + wpinv_set_checkout_session($data); |
|
557 | 557 | |
558 | 558 | $response = array(); |
559 | 559 | $response['success'] = false; |
560 | 560 | $response['msg'] = NULL; |
561 | 561 | |
562 | - $discounts = wpinv_unset_cart_discount( $discount_code ); |
|
562 | + $discounts = wpinv_unset_cart_discount($discount_code); |
|
563 | 563 | $response['success'] = true; |
564 | - $response['msg'] = __( 'Discount has been removed successfully.', 'invoicing' ); |
|
564 | + $response['msg'] = __('Discount has been removed successfully.', 'invoicing'); |
|
565 | 565 | |
566 | 566 | wpinv_set_checkout_session($checkout_session); |
567 | 567 | |
568 | - wp_send_json( $response ); |
|
568 | + wp_send_json($response); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | public static function check_email() { |
572 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
573 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
572 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
573 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
574 | 574 | die(-1); |
575 | 575 | } |
576 | 576 | |
577 | - $email = sanitize_text_field( $_POST['email'] ); |
|
577 | + $email = sanitize_text_field($_POST['email']); |
|
578 | 578 | |
579 | 579 | $response = array(); |
580 | - if ( is_email( $email ) && email_exists( $email ) && $user_data = get_user_by( 'email', $email ) ) { |
|
580 | + if (is_email($email) && email_exists($email) && $user_data = get_user_by('email', $email)) { |
|
581 | 581 | $user_id = $user_data->ID; |
582 | 582 | $user_login = $user_data->user_login; |
583 | 583 | $display_name = $user_data->display_name ? $user_data->display_name : $user_login; |
584 | 584 | $billing_details = wpinv_get_user_address($user_id); |
585 | - $billing_details = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id ); |
|
585 | + $billing_details = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id); |
|
586 | 586 | |
587 | 587 | if (isset($billing_details['user_id'])) { |
588 | 588 | unset($billing_details['user_id']); |
@@ -598,54 +598,54 @@ discard block |
||
598 | 598 | $response['data']['billing_details'] = $billing_details; |
599 | 599 | } |
600 | 600 | |
601 | - wp_send_json( $response ); |
|
601 | + wp_send_json($response); |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | public static function run_tool() { |
605 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
606 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
605 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
606 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
607 | 607 | die(-1); |
608 | 608 | } |
609 | 609 | |
610 | - $tool = sanitize_text_field( $_POST['tool'] ); |
|
610 | + $tool = sanitize_text_field($_POST['tool']); |
|
611 | 611 | |
612 | - do_action( 'wpinv_run_tool' ); |
|
612 | + do_action('wpinv_run_tool'); |
|
613 | 613 | |
614 | - if ( !empty( $tool ) ) { |
|
615 | - do_action( 'wpinv_tool_' . $tool ); |
|
614 | + if (!empty($tool)) { |
|
615 | + do_action('wpinv_tool_' . $tool); |
|
616 | 616 | } |
617 | 617 | } |
618 | 618 | |
619 | 619 | public static function apply_discount() { |
620 | 620 | global $wpi_userID; |
621 | 621 | |
622 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
622 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
623 | 623 | |
624 | 624 | $response = array(); |
625 | 625 | |
626 | - if ( isset( $_POST['code'] ) ) { |
|
627 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
626 | + if (isset($_POST['code'])) { |
|
627 | + $discount_code = sanitize_text_field($_POST['code']); |
|
628 | 628 | |
629 | 629 | $response['success'] = false; |
630 | 630 | $response['msg'] = ''; |
631 | 631 | $response['data']['code'] = $discount_code; |
632 | 632 | |
633 | 633 | $invoice = wpinv_get_invoice_cart(); |
634 | - if ( empty( $invoice->ID ) ) { |
|
635 | - $response['msg'] = __( 'Invalid checkout request.', 'invoicing' ); |
|
636 | - wp_send_json( $response ); |
|
634 | + if (empty($invoice->ID)) { |
|
635 | + $response['msg'] = __('Invalid checkout request.', 'invoicing'); |
|
636 | + wp_send_json($response); |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | $wpi_userID = $invoice->get_user_id(); |
640 | 640 | |
641 | - if ( wpinv_is_discount_valid( $discount_code, $wpi_userID ) ) { |
|
642 | - $discount = wpinv_get_discount_by_code( $discount_code ); |
|
643 | - $discounts = wpinv_set_cart_discount( $discount_code ); |
|
644 | - $amount = wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) ); |
|
645 | - $total = wpinv_get_cart_total( null, $discounts ); |
|
646 | - $cart_totals = wpinv_recalculate_tax( true ); |
|
641 | + if (wpinv_is_discount_valid($discount_code, $wpi_userID)) { |
|
642 | + $discount = wpinv_get_discount_by_code($discount_code); |
|
643 | + $discounts = wpinv_set_cart_discount($discount_code); |
|
644 | + $amount = wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID)); |
|
645 | + $total = wpinv_get_cart_total(null, $discounts); |
|
646 | + $cart_totals = wpinv_recalculate_tax(true); |
|
647 | 647 | |
648 | - if ( !empty( $cart_totals ) ) { |
|
648 | + if (!empty($cart_totals)) { |
|
649 | 649 | $response['success'] = true; |
650 | 650 | $response['data'] = $cart_totals; |
651 | 651 | $response['data']['code'] = $discount_code; |
@@ -654,29 +654,29 @@ discard block |
||
654 | 654 | } |
655 | 655 | } else { |
656 | 656 | $errors = wpinv_get_errors(); |
657 | - $response['msg'] = $errors['wpinv-discount-error']; |
|
658 | - wpinv_unset_error( 'wpinv-discount-error' ); |
|
657 | + $response['msg'] = $errors['wpinv-discount-error']; |
|
658 | + wpinv_unset_error('wpinv-discount-error'); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | // Allow for custom discount code handling |
662 | - $response = apply_filters( 'wpinv_ajax_discount_response', $response ); |
|
662 | + $response = apply_filters('wpinv_ajax_discount_response', $response); |
|
663 | 663 | } |
664 | 664 | |
665 | - wp_send_json( $response ); |
|
665 | + wp_send_json($response); |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | public static function remove_discount() { |
669 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
669 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
670 | 670 | |
671 | 671 | $response = array(); |
672 | 672 | |
673 | - if ( isset( $_POST['code'] ) ) { |
|
674 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
675 | - $discounts = wpinv_unset_cart_discount( $discount_code ); |
|
676 | - $total = wpinv_get_cart_total( null, $discounts ); |
|
677 | - $cart_totals = wpinv_recalculate_tax( true ); |
|
673 | + if (isset($_POST['code'])) { |
|
674 | + $discount_code = sanitize_text_field($_POST['code']); |
|
675 | + $discounts = wpinv_unset_cart_discount($discount_code); |
|
676 | + $total = wpinv_get_cart_total(null, $discounts); |
|
677 | + $cart_totals = wpinv_recalculate_tax(true); |
|
678 | 678 | |
679 | - if ( !empty( $cart_totals ) ) { |
|
679 | + if (!empty($cart_totals)) { |
|
680 | 680 | $response['success'] = true; |
681 | 681 | $response['data'] = $cart_totals; |
682 | 682 | $response['data']['code'] = $discount_code; |
@@ -685,10 +685,10 @@ discard block |
||
685 | 685 | } |
686 | 686 | |
687 | 687 | // Allow for custom discount code handling |
688 | - $response = apply_filters( 'wpinv_ajax_discount_response', $response ); |
|
688 | + $response = apply_filters('wpinv_ajax_discount_response', $response); |
|
689 | 689 | } |
690 | 690 | |
691 | - wp_send_json( $response ); |
|
691 | + wp_send_json($response); |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | |
@@ -700,53 +700,53 @@ discard block |
||
700 | 700 | public static function buy_items() { |
701 | 701 | $user_id = get_current_user_id(); |
702 | 702 | |
703 | - if ( empty( $user_id ) ) { // If not logged in then lets redirect to the login page |
|
704 | - wp_send_json( array( |
|
705 | - 'success' => wp_login_url( wp_get_referer() ) |
|
706 | - ) ); |
|
703 | + if (empty($user_id)) { // If not logged in then lets redirect to the login page |
|
704 | + wp_send_json(array( |
|
705 | + 'success' => wp_login_url(wp_get_referer()) |
|
706 | + )); |
|
707 | 707 | } else { |
708 | 708 | // Only check nonce if logged in as it could be cached when logged out. |
709 | - if ( ! isset( $_POST['wpinv_buy_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_buy_nonce'], 'wpinv_buy_items' ) ) { |
|
710 | - wp_send_json( array( |
|
711 | - 'error' => __( 'Security checks failed.', 'invoicing' ) |
|
712 | - ) ); |
|
709 | + if (!isset($_POST['wpinv_buy_nonce']) || !wp_verify_nonce($_POST['wpinv_buy_nonce'], 'wpinv_buy_items')) { |
|
710 | + wp_send_json(array( |
|
711 | + 'error' => __('Security checks failed.', 'invoicing') |
|
712 | + )); |
|
713 | 713 | wp_die(); |
714 | 714 | } |
715 | 715 | |
716 | 716 | // allow to set a custom price through post_id |
717 | 717 | $items = $_POST['items']; |
718 | - $related_post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : 0; |
|
719 | - $custom_item_price = $related_post_id ? abs( get_post_meta( $related_post_id, '_wpi_custom_price', true ) ) : 0; |
|
718 | + $related_post_id = isset($_POST['post_id']) ? (int) $_POST['post_id'] : 0; |
|
719 | + $custom_item_price = $related_post_id ? abs(get_post_meta($related_post_id, '_wpi_custom_price', true)) : 0; |
|
720 | 720 | |
721 | 721 | $cart_items = array(); |
722 | - if ( $items ) { |
|
723 | - $items = explode( ',', $items ); |
|
722 | + if ($items) { |
|
723 | + $items = explode(',', $items); |
|
724 | 724 | |
725 | - foreach( $items as $item ) { |
|
725 | + foreach ($items as $item) { |
|
726 | 726 | $item_id = $item; |
727 | 727 | $quantity = 1; |
728 | 728 | |
729 | - if ( strpos( $item, '|' ) !== false ) { |
|
730 | - $item_parts = explode( '|', $item ); |
|
729 | + if (strpos($item, '|') !== false) { |
|
730 | + $item_parts = explode('|', $item); |
|
731 | 731 | $item_id = $item_parts[0]; |
732 | 732 | $quantity = $item_parts[1]; |
733 | 733 | } |
734 | 734 | |
735 | - if ( $item_id && $quantity ) { |
|
735 | + if ($item_id && $quantity) { |
|
736 | 736 | $cart_items_arr = array( |
737 | - 'id' => (int)$item_id, |
|
738 | - 'quantity' => (int)$quantity |
|
737 | + 'id' => (int) $item_id, |
|
738 | + 'quantity' => (int) $quantity |
|
739 | 739 | ); |
740 | 740 | |
741 | 741 | // If there is a related post id then add it to meta |
742 | - if ( $related_post_id ) { |
|
742 | + if ($related_post_id) { |
|
743 | 743 | $cart_items_arr['meta'] = array( |
744 | 744 | 'post_id' => $related_post_id |
745 | 745 | ); |
746 | 746 | } |
747 | 747 | |
748 | 748 | // If there is a custom price then set it. |
749 | - if ( $custom_item_price ) { |
|
749 | + if ($custom_item_price) { |
|
750 | 750 | $cart_items_arr['custom_price'] = $custom_item_price; |
751 | 751 | } |
752 | 752 | |
@@ -762,37 +762,37 @@ discard block |
||
762 | 762 | * @param int $related_post_id The related post id if any. |
763 | 763 | * @since 1.0.0 |
764 | 764 | */ |
765 | - $cart_items = apply_filters( 'wpinv_buy_cart_items', $cart_items, $related_post_id ); |
|
765 | + $cart_items = apply_filters('wpinv_buy_cart_items', $cart_items, $related_post_id); |
|
766 | 766 | |
767 | 767 | // Make sure its not in the cart already, if it is then redirect to checkout. |
768 | 768 | $cart_invoice = wpinv_get_invoice_cart(); |
769 | 769 | |
770 | - if ( isset( $cart_invoice->items ) && !empty( $cart_invoice->items ) && !empty( $cart_items ) && serialize( $cart_invoice->items ) == serialize( $cart_items ) ) { |
|
771 | - wp_send_json( array( |
|
770 | + if (isset($cart_invoice->items) && !empty($cart_invoice->items) && !empty($cart_items) && serialize($cart_invoice->items) == serialize($cart_items)) { |
|
771 | + wp_send_json(array( |
|
772 | 772 | 'success' => $cart_invoice->get_checkout_payment_url() |
773 | - ) ); |
|
773 | + )); |
|
774 | 774 | wp_die(); |
775 | 775 | } |
776 | 776 | |
777 | 777 | // Check if user has invoice with same items waiting to be paid. |
778 | - $user_invoices = wpinv_get_users_invoices( $user_id , 10 , false , 'wpi-pending' ); |
|
779 | - if ( !empty( $user_invoices ) ) { |
|
780 | - foreach( $user_invoices as $user_invoice ) { |
|
778 | + $user_invoices = wpinv_get_users_invoices($user_id, 10, false, 'wpi-pending'); |
|
779 | + if (!empty($user_invoices)) { |
|
780 | + foreach ($user_invoices as $user_invoice) { |
|
781 | 781 | $user_cart_details = array(); |
782 | - $invoice = wpinv_get_invoice( $user_invoice->ID ); |
|
782 | + $invoice = wpinv_get_invoice($user_invoice->ID); |
|
783 | 783 | $cart_details = $invoice->get_cart_details(); |
784 | 784 | |
785 | - if ( !empty( $cart_details ) ) { |
|
786 | - foreach ( $cart_details as $invoice_item ) { |
|
785 | + if (!empty($cart_details)) { |
|
786 | + foreach ($cart_details as $invoice_item) { |
|
787 | 787 | $ii_arr = array(); |
788 | - $ii_arr['id'] = (int)$invoice_item['id']; |
|
789 | - $ii_arr['quantity'] = (int)$invoice_item['quantity']; |
|
788 | + $ii_arr['id'] = (int) $invoice_item['id']; |
|
789 | + $ii_arr['quantity'] = (int) $invoice_item['quantity']; |
|
790 | 790 | |
791 | - if (isset( $invoice_item['meta'] ) && !empty( $invoice_item['meta'] ) ) { |
|
791 | + if (isset($invoice_item['meta']) && !empty($invoice_item['meta'])) { |
|
792 | 792 | $ii_arr['meta'] = $invoice_item['meta']; |
793 | 793 | } |
794 | 794 | |
795 | - if ( isset( $invoice_item['custom_price'] ) && !empty( $invoice_item['custom_price'] ) ) { |
|
795 | + if (isset($invoice_item['custom_price']) && !empty($invoice_item['custom_price'])) { |
|
796 | 796 | $ii_arr['custom_price'] = $invoice_item['custom_price']; |
797 | 797 | } |
798 | 798 | |
@@ -800,17 +800,17 @@ discard block |
||
800 | 800 | } |
801 | 801 | } |
802 | 802 | |
803 | - if ( !empty( $user_cart_details ) && serialize( $cart_items ) == serialize( $user_cart_details ) ) { |
|
804 | - wp_send_json( array( |
|
803 | + if (!empty($user_cart_details) && serialize($cart_items) == serialize($user_cart_details)) { |
|
804 | + wp_send_json(array( |
|
805 | 805 | 'success' => $invoice->get_checkout_payment_url() |
806 | - ) ); |
|
806 | + )); |
|
807 | 807 | wp_die(); |
808 | 808 | } |
809 | 809 | } |
810 | 810 | } |
811 | 811 | |
812 | 812 | // Create invoice and send user to checkout |
813 | - if ( !empty( $cart_items ) ) { |
|
813 | + if (!empty($cart_items)) { |
|
814 | 814 | $invoice_data = array( |
815 | 815 | 'status' => 'wpi-pending', |
816 | 816 | 'created_via' => 'wpi', |
@@ -818,21 +818,21 @@ discard block |
||
818 | 818 | 'cart_details' => $cart_items, |
819 | 819 | ); |
820 | 820 | |
821 | - $invoice = wpinv_insert_invoice( $invoice_data, true ); |
|
821 | + $invoice = wpinv_insert_invoice($invoice_data, true); |
|
822 | 822 | |
823 | - if ( !empty( $invoice ) && isset( $invoice->ID ) ) { |
|
824 | - wp_send_json( array( |
|
823 | + if (!empty($invoice) && isset($invoice->ID)) { |
|
824 | + wp_send_json(array( |
|
825 | 825 | 'success' => $invoice->get_checkout_payment_url() |
826 | - ) ); |
|
826 | + )); |
|
827 | 827 | } else { |
828 | - wp_send_json( array( |
|
829 | - 'error' => __( 'Invoice failed to create', 'invoicing' ) |
|
830 | - ) ); |
|
828 | + wp_send_json(array( |
|
829 | + 'error' => __('Invoice failed to create', 'invoicing') |
|
830 | + )); |
|
831 | 831 | } |
832 | 832 | } else { |
833 | - wp_send_json( array( |
|
834 | - 'error' => __( 'Items not valid.', 'invoicing' ) |
|
835 | - ) ); |
|
833 | + wp_send_json(array( |
|
834 | + 'error' => __('Items not valid.', 'invoicing') |
|
835 | + )); |
|
836 | 836 | } |
837 | 837 | } |
838 | 838 |
@@ -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(); |
@@ -32,33 +32,33 @@ discard block |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | public function define_constants() { |
35 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
36 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
35 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
36 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | private function actions() { |
40 | 40 | /* Internationalize the text strings used. */ |
41 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
41 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
42 | 42 | |
43 | 43 | /* Perform actions on admin initialization. */ |
44 | - add_action( 'admin_init', array( &$this, 'admin_init') ); |
|
45 | - add_action( 'init', array( &$this, 'init' ), 3 ); |
|
46 | - add_action( 'init', array( &$this, 'wpinv_actions' ) ); |
|
44 | + add_action('admin_init', array(&$this, 'admin_init')); |
|
45 | + add_action('init', array(&$this, 'init'), 3); |
|
46 | + add_action('init', array(&$this, 'wpinv_actions')); |
|
47 | 47 | |
48 | - if ( class_exists( 'BuddyPress' ) ) { |
|
49 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
48 | + if (class_exists('BuddyPress')) { |
|
49 | + add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
|
50 | 50 | } |
51 | 51 | |
52 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
53 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
52 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
53 | + add_action('widgets_init', array(&$this, 'register_widgets')); |
|
54 | 54 | |
55 | - if ( is_admin() ) { |
|
56 | - add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) ); |
|
57 | - add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) ); |
|
58 | - add_action( 'admin_init', array( &$this, 'init_ayecode_connect_helper' ) ); |
|
55 | + if (is_admin()) { |
|
56 | + add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts')); |
|
57 | + add_action('admin_body_class', array(&$this, 'admin_body_class')); |
|
58 | + add_action('admin_init', array(&$this, 'init_ayecode_connect_helper')); |
|
59 | 59 | |
60 | 60 | } else { |
61 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
61 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -68,28 +68,28 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference. |
70 | 70 | */ |
71 | - do_action_ref_array( 'wpinv_actions', array( &$this ) ); |
|
71 | + do_action_ref_array('wpinv_actions', array(&$this)); |
|
72 | 72 | |
73 | - add_action( 'admin_init', array( &$this, 'activation_redirect') ); |
|
73 | + add_action('admin_init', array(&$this, 'activation_redirect')); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Maybe show the AyeCode Connect Notice. |
78 | 78 | */ |
79 | - public function init_ayecode_connect_helper(){ |
|
79 | + public function init_ayecode_connect_helper() { |
|
80 | 80 | // AyeCode Connect notice |
81 | - if ( is_admin() ){ |
|
81 | + if (is_admin()) { |
|
82 | 82 | // set the strings so they can be translated |
83 | 83 | $strings = array( |
84 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
85 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
86 | - '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>" ), |
|
87 | - 'connect_button' => __("Connect Site","invoicing"), |
|
88 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
89 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
90 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
84 | + 'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"), |
|
85 | + 'connect_external' => __("Please confirm you wish to connect your site?", "invoicing"), |
|
86 | + '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>"), |
|
87 | + 'connect_button' => __("Connect Site", "invoicing"), |
|
88 | + 'connecting_button' => __("Connecting...", "invoicing"), |
|
89 | + 'error_localhost' => __("This service will only work with a live domain, not a localhost.", "invoicing"), |
|
90 | + 'error' => __("Something went wrong, please refresh and try again.", "invoicing"), |
|
91 | 91 | ); |
92 | - new AyeCode_Connect_Helper($strings,array('wpi-addons')); |
|
92 | + new AyeCode_Connect_Helper($strings, array('wpi-addons')); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
@@ -97,10 +97,10 @@ discard block |
||
97 | 97 | /* Internationalize the text strings used. */ |
98 | 98 | $this->load_textdomain(); |
99 | 99 | |
100 | - do_action( 'wpinv_loaded' ); |
|
100 | + do_action('wpinv_loaded'); |
|
101 | 101 | |
102 | 102 | // Fix oxygen page builder conflict |
103 | - if ( function_exists( 'ct_css_output' ) ) { |
|
103 | + if (function_exists('ct_css_output')) { |
|
104 | 104 | wpinv_oxygen_fix_conflict(); |
105 | 105 | } |
106 | 106 | } |
@@ -110,230 +110,230 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @since 1.0 |
112 | 112 | */ |
113 | - public function load_textdomain( $locale = NULL ) { |
|
114 | - if ( empty( $locale ) ) { |
|
115 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
113 | + public function load_textdomain($locale = NULL) { |
|
114 | + if (empty($locale)) { |
|
115 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
116 | 116 | } |
117 | 117 | |
118 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
118 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
119 | 119 | |
120 | - unload_textdomain( 'invoicing' ); |
|
121 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
122 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
120 | + unload_textdomain('invoicing'); |
|
121 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
122 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
123 | 123 | |
124 | 124 | /** |
125 | 125 | * Define language constants. |
126 | 126 | */ |
127 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
127 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | public function includes() { |
131 | 131 | global $wpinv_options; |
132 | 132 | |
133 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
133 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
134 | 134 | $wpinv_options = wpinv_get_settings(); |
135 | 135 | |
136 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
137 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' ); |
|
138 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
139 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
140 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
141 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
142 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
143 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
144 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' ); |
|
145 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
146 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
147 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
148 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
149 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
150 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' ); |
|
151 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' ); |
|
152 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' ); |
|
153 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php' ); |
|
154 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' ); |
|
155 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' ); |
|
156 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
157 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
158 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
159 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
160 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
161 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
162 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
163 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
164 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
165 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' ); |
|
166 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
167 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' ); |
|
168 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
169 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
170 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
171 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
172 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
173 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
174 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
175 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
176 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
177 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
178 | - |
|
179 | - if ( !class_exists( 'WPInv_EUVat' ) ) { |
|
180 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
136 | + require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php'); |
|
137 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php'); |
|
138 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
139 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
140 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
141 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
142 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
143 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
144 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php'); |
|
145 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
146 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
147 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
148 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
149 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
150 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php'); |
|
151 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php'); |
|
152 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php'); |
|
153 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php'); |
|
154 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php'); |
|
155 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php'); |
|
156 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'); |
|
157 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php'); |
|
158 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
159 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
160 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
161 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
162 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
163 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
164 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
165 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php'); |
|
166 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
167 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php'); |
|
168 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php'); |
|
169 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
170 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php'); |
|
171 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php'); |
|
172 | + require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php'); |
|
173 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php'); |
|
174 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php'); |
|
175 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php'); |
|
176 | + require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php'); |
|
177 | + require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php'); |
|
178 | + |
|
179 | + if (!class_exists('WPInv_EUVat')) { |
|
180 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
181 | 181 | } |
182 | 182 | |
183 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
184 | - if ( !empty( $gateways ) ) { |
|
185 | - foreach ( $gateways as $gateway ) { |
|
186 | - if ( $gateway == 'manual' ) { |
|
183 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
184 | + if (!empty($gateways)) { |
|
185 | + foreach ($gateways as $gateway) { |
|
186 | + if ($gateway == 'manual') { |
|
187 | 187 | continue; |
188 | 188 | } |
189 | 189 | |
190 | 190 | $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; |
191 | 191 | |
192 | - if ( file_exists( $gateway_file ) ) { |
|
193 | - require_once( $gateway_file ); |
|
192 | + if (file_exists($gateway_file)) { |
|
193 | + require_once($gateway_file); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | } |
197 | - require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' ); |
|
197 | + require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php'); |
|
198 | 198 | |
199 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
200 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
201 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
202 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' ); |
|
199 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
200 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
201 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
202 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php'); |
|
203 | 203 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' ); |
204 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' ); |
|
205 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' ); |
|
206 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
207 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' ); |
|
208 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
209 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
210 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
204 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php'); |
|
205 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php'); |
|
206 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
207 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php'); |
|
208 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
209 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
210 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
211 | 211 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
212 | 212 | // load the user class only on the users.php page |
213 | 213 | global $pagenow; |
214 | - if($pagenow=='users.php'){ |
|
214 | + if ($pagenow == 'users.php') { |
|
215 | 215 | new WPInv_Admin_Users(); |
216 | 216 | } |
217 | 217 | } |
218 | 218 | |
219 | 219 | // Register cli commands |
220 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
221 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
222 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
220 | + if (defined('WP_CLI') && WP_CLI) { |
|
221 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'); |
|
222 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | // include css inliner |
226 | - if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { |
|
227 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
226 | + if (!class_exists('Emogrifier') && class_exists('DOMDocument')) { |
|
227 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
228 | 228 | } |
229 | 229 | |
230 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
230 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | public function init() { |
234 | 234 | } |
235 | 235 | |
236 | 236 | public function admin_init() { |
237 | - add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) ); |
|
237 | + add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php')); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | public function activation_redirect() { |
241 | 241 | // Bail if no activation redirect |
242 | - if ( !get_transient( '_wpinv_activation_redirect' ) ) { |
|
242 | + if (!get_transient('_wpinv_activation_redirect')) { |
|
243 | 243 | return; |
244 | 244 | } |
245 | 245 | |
246 | 246 | // Delete the redirect transient |
247 | - delete_transient( '_wpinv_activation_redirect' ); |
|
247 | + delete_transient('_wpinv_activation_redirect'); |
|
248 | 248 | |
249 | 249 | // Bail if activating from network, or bulk |
250 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
250 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
251 | 251 | return; |
252 | 252 | } |
253 | 253 | |
254 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
254 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
255 | 255 | exit; |
256 | 256 | } |
257 | 257 | |
258 | 258 | public function enqueue_scripts() { |
259 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
259 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
260 | 260 | |
261 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION ); |
|
262 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
261 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION); |
|
262 | + wp_enqueue_style('wpinv_front_style'); |
|
263 | 263 | |
264 | 264 | // Register scripts |
265 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
266 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ), WPINV_VERSION ); |
|
265 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
266 | + wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), WPINV_VERSION); |
|
267 | 267 | |
268 | 268 | $localize = array(); |
269 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
270 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
269 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
270 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
271 | 271 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
272 | 272 | $localize['currency_pos'] = wpinv_currency_position(); |
273 | 273 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
274 | 274 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
275 | 275 | $localize['decimals'] = wpinv_decimals(); |
276 | - $localize['txtComplete'] = __( 'Complete', 'invoicing' ); |
|
276 | + $localize['txtComplete'] = __('Complete', 'invoicing'); |
|
277 | 277 | $localize['UseTaxes'] = wpinv_use_taxes(); |
278 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
278 | + $localize['checkoutNonce'] = wp_create_nonce('wpinv_checkout_nonce'); |
|
279 | 279 | |
280 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
280 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
281 | 281 | |
282 | - wp_enqueue_script( 'jquery-blockui' ); |
|
282 | + wp_enqueue_script('jquery-blockui'); |
|
283 | 283 | $autofill_api = wpinv_get_option('address_autofill_api'); |
284 | 284 | $autofill_active = wpinv_get_option('address_autofill_active'); |
285 | - if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { |
|
286 | - if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { |
|
287 | - wp_dequeue_script( 'google-maps-api' ); |
|
285 | + if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { |
|
286 | + if (wp_script_is('google-maps-api', 'enqueued')) { |
|
287 | + wp_dequeue_script('google-maps-api'); |
|
288 | 288 | } |
289 | - wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); |
|
290 | - wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); |
|
289 | + wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); |
|
290 | + wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true); |
|
291 | 291 | } |
292 | 292 | |
293 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
294 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
293 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
294 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
295 | 295 | |
296 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
297 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
296 | + wp_enqueue_script('wpinv-front-script'); |
|
297 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | public function admin_enqueue_scripts() { |
301 | 301 | global $post, $pagenow; |
302 | 302 | |
303 | 303 | $post_type = wpinv_admin_post_type(); |
304 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
305 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : ''; |
|
304 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
305 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : ''; |
|
306 | 306 | |
307 | 307 | $jquery_ui_css = false; |
308 | - if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) { |
|
308 | + if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
|
309 | 309 | $jquery_ui_css = true; |
310 | - } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) { |
|
310 | + } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') { |
|
311 | 311 | $jquery_ui_css = true; |
312 | 312 | } |
313 | - if ( $jquery_ui_css ) { |
|
314 | - wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); |
|
315 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
313 | + if ($jquery_ui_css) { |
|
314 | + wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16'); |
|
315 | + wp_enqueue_style('jquery-ui-css'); |
|
316 | 316 | } |
317 | 317 | |
318 | - wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
|
319 | - wp_enqueue_style( 'wpinv_meta_box_style' ); |
|
318 | + wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
319 | + wp_enqueue_style('wpinv_meta_box_style'); |
|
320 | 320 | |
321 | - wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION ); |
|
322 | - wp_enqueue_style( 'wpinv_admin_style' ); |
|
321 | + wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION); |
|
322 | + wp_enqueue_style('wpinv_admin_style'); |
|
323 | 323 | |
324 | - $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ); |
|
325 | - if ( $page == 'wpinv-subscriptions' ) { |
|
326 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
324 | + $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')); |
|
325 | + if ($page == 'wpinv-subscriptions') { |
|
326 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
327 | 327 | } |
328 | 328 | |
329 | - if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) { |
|
330 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
329 | + if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) { |
|
330 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
331 | 331 | } |
332 | 332 | |
333 | - wp_enqueue_style( 'wp-color-picker' ); |
|
334 | - wp_enqueue_script( 'wp-color-picker' ); |
|
333 | + wp_enqueue_style('wp-color-picker'); |
|
334 | + wp_enqueue_script('wp-color-picker'); |
|
335 | 335 | |
336 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
336 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
337 | 337 | |
338 | 338 | if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
339 | 339 | $autofill_api = wpinv_get_option('address_autofill_api'); |
@@ -344,20 +344,20 @@ discard block |
||
344 | 344 | } |
345 | 345 | } |
346 | 346 | |
347 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
348 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
347 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
348 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
349 | 349 | |
350 | - wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ), WPINV_VERSION ); |
|
351 | - wp_enqueue_script( 'wpinv-admin-script' ); |
|
350 | + wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION); |
|
351 | + wp_enqueue_script('wpinv-admin-script'); |
|
352 | 352 | |
353 | 353 | $localize = array(); |
354 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
355 | - $localize['post_ID'] = isset( $post->ID ) ? $post->ID : ''; |
|
356 | - $localize['wpinv_nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
357 | - $localize['add_invoice_note_nonce'] = wp_create_nonce( 'add-invoice-note' ); |
|
358 | - $localize['delete_invoice_note_nonce'] = wp_create_nonce( 'delete-invoice-note' ); |
|
359 | - $localize['invoice_item_nonce'] = wp_create_nonce( 'invoice-item' ); |
|
360 | - $localize['billing_details_nonce'] = wp_create_nonce( 'get-billing-details' ); |
|
354 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
355 | + $localize['post_ID'] = isset($post->ID) ? $post->ID : ''; |
|
356 | + $localize['wpinv_nonce'] = wp_create_nonce('wpinv-nonce'); |
|
357 | + $localize['add_invoice_note_nonce'] = wp_create_nonce('add-invoice-note'); |
|
358 | + $localize['delete_invoice_note_nonce'] = wp_create_nonce('delete-invoice-note'); |
|
359 | + $localize['invoice_item_nonce'] = wp_create_nonce('invoice-item'); |
|
360 | + $localize['billing_details_nonce'] = wp_create_nonce('get-billing-details'); |
|
361 | 361 | $localize['tax'] = wpinv_tax_amount(); |
362 | 362 | $localize['discount'] = wpinv_discount_amount(); |
363 | 363 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
@@ -365,69 +365,69 @@ discard block |
||
365 | 365 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
366 | 366 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
367 | 367 | $localize['decimals'] = wpinv_decimals(); |
368 | - $localize['save_invoice'] = __( 'Save Invoice', 'invoicing' ); |
|
369 | - $localize['status_publish'] = wpinv_status_nicename( 'publish' ); |
|
370 | - $localize['status_pending'] = wpinv_status_nicename( 'wpi-pending' ); |
|
371 | - $localize['delete_tax_rate'] = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ); |
|
372 | - $localize['OneItemMin'] = __( 'Invoice must contain at least one item', 'invoicing' ); |
|
373 | - $localize['DeleteInvoiceItem'] = __( 'Are you sure you wish to delete this item?', 'invoicing' ); |
|
374 | - $localize['FillBillingDetails'] = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ); |
|
375 | - $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' ); |
|
376 | - $localize['AreYouSure'] = __( 'Are you sure?', 'invoicing' ); |
|
377 | - $localize['emptyInvoice'] = __( 'Add at least one item to save invoice!', 'invoicing' ); |
|
378 | - $localize['errDeleteItem'] = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ); |
|
379 | - $localize['delete_subscription'] = __( 'Are you sure you want to delete this subscription?', 'invoicing' ); |
|
380 | - $localize['action_edit'] = __( 'Edit', 'invoicing' ); |
|
381 | - $localize['action_cancel'] = __( 'Cancel', 'invoicing' ); |
|
382 | - |
|
383 | - $localize = apply_filters( 'wpinv_admin_js_localize', $localize ); |
|
384 | - |
|
385 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize ); |
|
386 | - |
|
387 | - if ( $page == 'wpinv-subscriptions' ) { |
|
388 | - wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
389 | - wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
368 | + $localize['save_invoice'] = __('Save Invoice', 'invoicing'); |
|
369 | + $localize['status_publish'] = wpinv_status_nicename('publish'); |
|
370 | + $localize['status_pending'] = wpinv_status_nicename('wpi-pending'); |
|
371 | + $localize['delete_tax_rate'] = __('Are you sure you wish to delete this tax rate?', 'invoicing'); |
|
372 | + $localize['OneItemMin'] = __('Invoice must contain at least one item', 'invoicing'); |
|
373 | + $localize['DeleteInvoiceItem'] = __('Are you sure you wish to delete this item?', 'invoicing'); |
|
374 | + $localize['FillBillingDetails'] = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'); |
|
375 | + $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'); |
|
376 | + $localize['AreYouSure'] = __('Are you sure?', 'invoicing'); |
|
377 | + $localize['emptyInvoice'] = __('Add at least one item to save invoice!', 'invoicing'); |
|
378 | + $localize['errDeleteItem'] = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'); |
|
379 | + $localize['delete_subscription'] = __('Are you sure you want to delete this subscription?', 'invoicing'); |
|
380 | + $localize['action_edit'] = __('Edit', 'invoicing'); |
|
381 | + $localize['action_cancel'] = __('Cancel', 'invoicing'); |
|
382 | + |
|
383 | + $localize = apply_filters('wpinv_admin_js_localize', $localize); |
|
384 | + |
|
385 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize); |
|
386 | + |
|
387 | + if ($page == 'wpinv-subscriptions') { |
|
388 | + wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION); |
|
389 | + wp_enqueue_script('wpinv-sub-admin-script'); |
|
390 | 390 | } |
391 | 391 | } |
392 | 392 | |
393 | - public function admin_body_class( $classes ) { |
|
393 | + public function admin_body_class($classes) { |
|
394 | 394 | global $pagenow, $post, $current_screen; |
395 | 395 | |
396 | - if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) { |
|
396 | + if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) { |
|
397 | 397 | $classes .= ' wpinv-cpt'; |
398 | 398 | } |
399 | 399 | |
400 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
400 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
401 | 401 | |
402 | - $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false; |
|
403 | - if ( $add_class ) { |
|
404 | - $classes .= ' wpi-' . wpinv_sanitize_key( $page ); |
|
402 | + $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false; |
|
403 | + if ($add_class) { |
|
404 | + $classes .= ' wpi-' . wpinv_sanitize_key($page); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | $settings_class = array(); |
408 | - if ( $page == 'wpinv-settings' ) { |
|
409 | - if ( !empty( $_REQUEST['tab'] ) ) { |
|
410 | - $settings_class[] = sanitize_text_field( $_REQUEST['tab'] ); |
|
408 | + if ($page == 'wpinv-settings') { |
|
409 | + if (!empty($_REQUEST['tab'])) { |
|
410 | + $settings_class[] = sanitize_text_field($_REQUEST['tab']); |
|
411 | 411 | } |
412 | 412 | |
413 | - if ( !empty( $_REQUEST['section'] ) ) { |
|
414 | - $settings_class[] = sanitize_text_field( $_REQUEST['section'] ); |
|
413 | + if (!empty($_REQUEST['section'])) { |
|
414 | + $settings_class[] = sanitize_text_field($_REQUEST['section']); |
|
415 | 415 | } |
416 | 416 | |
417 | - $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main'; |
|
417 | + $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main'; |
|
418 | 418 | } |
419 | 419 | |
420 | - if ( !empty( $settings_class ) ) { |
|
421 | - $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) ); |
|
420 | + if (!empty($settings_class)) { |
|
421 | + $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-')); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | $post_type = wpinv_admin_post_type(); |
425 | 425 | |
426 | - if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) { |
|
426 | + if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) { |
|
427 | 427 | return $classes .= ' wpinv'; |
428 | 428 | } |
429 | 429 | |
430 | - if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) { |
|
430 | + if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) { |
|
431 | 431 | $classes .= ' wpi-editable-n'; |
432 | 432 | } |
433 | 433 | |
@@ -439,21 +439,21 @@ discard block |
||
439 | 439 | } |
440 | 440 | |
441 | 441 | public function wpinv_actions() { |
442 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
443 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
442 | + if (isset($_REQUEST['wpi_action'])) { |
|
443 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
444 | 444 | } |
445 | 445 | } |
446 | 446 | |
447 | - public function pre_get_posts( $wp_query ) { |
|
448 | - 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() ) { |
|
449 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
447 | + public function pre_get_posts($wp_query) { |
|
448 | + 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()) { |
|
449 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | return $wp_query; |
453 | 453 | } |
454 | 454 | |
455 | 455 | public function bp_invoicing_init() { |
456 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
456 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | /** |
@@ -461,11 +461,11 @@ discard block |
||
461 | 461 | * |
462 | 462 | */ |
463 | 463 | public function register_widgets() { |
464 | - register_widget( "WPInv_Checkout_Widget" ); |
|
465 | - register_widget( "WPInv_History_Widget" ); |
|
466 | - register_widget( "WPInv_Receipt_Widget" ); |
|
467 | - register_widget( "WPInv_Subscriptions_Widget" ); |
|
468 | - register_widget( "WPInv_Buy_Item_Widget" ); |
|
469 | - register_widget( "WPInv_Messages_Widget" ); |
|
464 | + register_widget("WPInv_Checkout_Widget"); |
|
465 | + register_widget("WPInv_History_Widget"); |
|
466 | + register_widget("WPInv_Receipt_Widget"); |
|
467 | + register_widget("WPInv_Subscriptions_Widget"); |
|
468 | + register_widget("WPInv_Buy_Item_Widget"); |
|
469 | + register_widget("WPInv_Messages_Widget"); |
|
470 | 470 | } |
471 | 471 | } |
472 | 472 | \ No newline at end of file |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | * @param string $group The group to assign this job to. |
13 | 13 | * @return string The action ID. |
14 | 14 | */ |
15 | -function as_enqueue_async_action( $hook, $args = array(), $group = '' ) { |
|
16 | - return ActionScheduler::factory()->async( $hook, $args, $group ); |
|
15 | +function as_enqueue_async_action($hook, $args = array(), $group = '') { |
|
16 | + return ActionScheduler::factory()->async($hook, $args, $group); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return string The job ID |
28 | 28 | */ |
29 | -function as_schedule_single_action( $timestamp, $hook, $args = array(), $group = '' ) { |
|
30 | - return ActionScheduler::factory()->single( $hook, $args, $timestamp, $group ); |
|
29 | +function as_schedule_single_action($timestamp, $hook, $args = array(), $group = '') { |
|
30 | + return ActionScheduler::factory()->single($hook, $args, $timestamp, $group); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return string The job ID |
43 | 43 | */ |
44 | -function as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args = array(), $group = '' ) { |
|
45 | - return ActionScheduler::factory()->recurring( $hook, $args, $timestamp, $interval_in_seconds, $group ); |
|
44 | +function as_schedule_recurring_action($timestamp, $interval_in_seconds, $hook, $args = array(), $group = '') { |
|
45 | + return ActionScheduler::factory()->recurring($hook, $args, $timestamp, $interval_in_seconds, $group); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @return string The job ID |
70 | 70 | */ |
71 | -function as_schedule_cron_action( $timestamp, $schedule, $hook, $args = array(), $group = '' ) { |
|
72 | - return ActionScheduler::factory()->cron( $hook, $args, $timestamp, $schedule, $group ); |
|
71 | +function as_schedule_cron_action($timestamp, $schedule, $hook, $args = array(), $group = '') { |
|
72 | + return ActionScheduler::factory()->cron($hook, $args, $timestamp, $schedule, $group); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -88,18 +88,18 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return string The scheduled action ID if a scheduled action was found, or empty string if no matching action found. |
90 | 90 | */ |
91 | -function as_unschedule_action( $hook, $args = array(), $group = '' ) { |
|
91 | +function as_unschedule_action($hook, $args = array(), $group = '') { |
|
92 | 92 | $params = array(); |
93 | - if ( is_array($args) ) { |
|
93 | + if (is_array($args)) { |
|
94 | 94 | $params['args'] = $args; |
95 | 95 | } |
96 | - if ( !empty($group) ) { |
|
96 | + if (!empty($group)) { |
|
97 | 97 | $params['group'] = $group; |
98 | 98 | } |
99 | - $job_id = ActionScheduler::store()->find_action( $hook, $params ); |
|
99 | + $job_id = ActionScheduler::store()->find_action($hook, $params); |
|
100 | 100 | |
101 | - if ( ! empty( $job_id ) ) { |
|
102 | - ActionScheduler::store()->cancel_action( $job_id ); |
|
101 | + if (!empty($job_id)) { |
|
102 | + ActionScheduler::store()->cancel_action($job_id); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | return $job_id; |
@@ -112,20 +112,20 @@ discard block |
||
112 | 112 | * @param array $args Args that would have been passed to the job |
113 | 113 | * @param string $group |
114 | 114 | */ |
115 | -function as_unschedule_all_actions( $hook, $args = array(), $group = '' ) { |
|
116 | - if ( empty( $args ) ) { |
|
117 | - if ( ! empty( $hook ) && empty( $group ) ) { |
|
118 | - ActionScheduler_Store::instance()->cancel_actions_by_hook( $hook ); |
|
115 | +function as_unschedule_all_actions($hook, $args = array(), $group = '') { |
|
116 | + if (empty($args)) { |
|
117 | + if (!empty($hook) && empty($group)) { |
|
118 | + ActionScheduler_Store::instance()->cancel_actions_by_hook($hook); |
|
119 | 119 | return; |
120 | 120 | } |
121 | - if ( ! empty( $group ) && empty( $hook ) ) { |
|
122 | - ActionScheduler_Store::instance()->cancel_actions_by_group( $group ); |
|
121 | + if (!empty($group) && empty($hook)) { |
|
122 | + ActionScheduler_Store::instance()->cancel_actions_by_group($group); |
|
123 | 123 | return; |
124 | 124 | } |
125 | 125 | } |
126 | 126 | do { |
127 | - $unscheduled_action = as_unschedule_action( $hook, $args, $group ); |
|
128 | - } while ( ! empty( $unscheduled_action ) ); |
|
127 | + $unscheduled_action = as_unschedule_action($hook, $args, $group); |
|
128 | + } while (!empty($unscheduled_action)); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -143,31 +143,31 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @return int|bool The timestamp for the next occurrence of a pending scheduled action, true for an async or in-progress action or false if there is no matching action. |
145 | 145 | */ |
146 | -function as_next_scheduled_action( $hook, $args = NULL, $group = '' ) { |
|
146 | +function as_next_scheduled_action($hook, $args = NULL, $group = '') { |
|
147 | 147 | $params = array(); |
148 | - if ( is_array($args) ) { |
|
148 | + if (is_array($args)) { |
|
149 | 149 | $params['args'] = $args; |
150 | 150 | } |
151 | - if ( !empty($group) ) { |
|
151 | + if (!empty($group)) { |
|
152 | 152 | $params['group'] = $group; |
153 | 153 | } |
154 | 154 | |
155 | 155 | $params['status'] = ActionScheduler_Store::STATUS_RUNNING; |
156 | - $job_id = ActionScheduler::store()->find_action( $hook, $params ); |
|
157 | - if ( ! empty( $job_id ) ) { |
|
156 | + $job_id = ActionScheduler::store()->find_action($hook, $params); |
|
157 | + if (!empty($job_id)) { |
|
158 | 158 | return true; |
159 | 159 | } |
160 | 160 | |
161 | 161 | $params['status'] = ActionScheduler_Store::STATUS_PENDING; |
162 | - $job_id = ActionScheduler::store()->find_action( $hook, $params ); |
|
163 | - if ( empty($job_id) ) { |
|
162 | + $job_id = ActionScheduler::store()->find_action($hook, $params); |
|
163 | + if (empty($job_id)) { |
|
164 | 164 | return false; |
165 | 165 | } |
166 | - $job = ActionScheduler::store()->fetch_action( $job_id ); |
|
166 | + $job = ActionScheduler::store()->fetch_action($job_id); |
|
167 | 167 | $scheduled_date = $job->get_schedule()->get_date(); |
168 | - if ( $scheduled_date ) { |
|
169 | - return (int) $scheduled_date->format( 'U' ); |
|
170 | - } elseif ( NULL === $scheduled_date ) { // pending async action with NullSchedule |
|
168 | + if ($scheduled_date) { |
|
169 | + return (int) $scheduled_date->format('U'); |
|
170 | + } elseif (NULL === $scheduled_date) { // pending async action with NullSchedule |
|
171 | 171 | return true; |
172 | 172 | } |
173 | 173 | return false; |
@@ -195,26 +195,26 @@ discard block |
||
195 | 195 | * |
196 | 196 | * @return array |
197 | 197 | */ |
198 | -function as_get_scheduled_actions( $args = array(), $return_format = OBJECT ) { |
|
198 | +function as_get_scheduled_actions($args = array(), $return_format = OBJECT) { |
|
199 | 199 | $store = ActionScheduler::store(); |
200 | - foreach ( array('date', 'modified') as $key ) { |
|
201 | - if ( isset($args[$key]) ) { |
|
200 | + foreach (array('date', 'modified') as $key) { |
|
201 | + if (isset($args[$key])) { |
|
202 | 202 | $args[$key] = as_get_datetime_object($args[$key]); |
203 | 203 | } |
204 | 204 | } |
205 | - $ids = $store->query_actions( $args ); |
|
205 | + $ids = $store->query_actions($args); |
|
206 | 206 | |
207 | - if ( $return_format == 'ids' || $return_format == 'int' ) { |
|
207 | + if ($return_format == 'ids' || $return_format == 'int') { |
|
208 | 208 | return $ids; |
209 | 209 | } |
210 | 210 | |
211 | 211 | $actions = array(); |
212 | - foreach ( $ids as $action_id ) { |
|
213 | - $actions[$action_id] = $store->fetch_action( $action_id ); |
|
212 | + foreach ($ids as $action_id) { |
|
213 | + $actions[$action_id] = $store->fetch_action($action_id); |
|
214 | 214 | } |
215 | 215 | |
216 | - if ( $return_format == ARRAY_A ) { |
|
217 | - foreach ( $actions as $action_id => $action_object ) { |
|
216 | + if ($return_format == ARRAY_A) { |
|
217 | + foreach ($actions as $action_id => $action_object) { |
|
218 | 218 | $actions[$action_id] = get_object_vars($action_object); |
219 | 219 | } |
220 | 220 | } |
@@ -239,13 +239,13 @@ discard block |
||
239 | 239 | * |
240 | 240 | * @return ActionScheduler_DateTime |
241 | 241 | */ |
242 | -function as_get_datetime_object( $date_string = null, $timezone = 'UTC' ) { |
|
243 | - if ( is_object( $date_string ) && $date_string instanceof DateTime ) { |
|
244 | - $date = new ActionScheduler_DateTime( $date_string->format( 'Y-m-d H:i:s' ), new DateTimeZone( $timezone ) ); |
|
245 | - } elseif ( is_numeric( $date_string ) ) { |
|
246 | - $date = new ActionScheduler_DateTime( '@' . $date_string, new DateTimeZone( $timezone ) ); |
|
242 | +function as_get_datetime_object($date_string = null, $timezone = 'UTC') { |
|
243 | + if (is_object($date_string) && $date_string instanceof DateTime) { |
|
244 | + $date = new ActionScheduler_DateTime($date_string->format('Y-m-d H:i:s'), new DateTimeZone($timezone)); |
|
245 | + } elseif (is_numeric($date_string)) { |
|
246 | + $date = new ActionScheduler_DateTime('@' . $date_string, new DateTimeZone($timezone)); |
|
247 | 247 | } else { |
248 | - $date = new ActionScheduler_DateTime( $date_string, new DateTimeZone( $timezone ) ); |
|
248 | + $date = new ActionScheduler_DateTime($date_string, new DateTimeZone($timezone)); |
|
249 | 249 | } |
250 | 250 | return $date; |
251 | 251 | } |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | */ |
11 | 11 | class ActionScheduler_AdminView_Deprecated { |
12 | 12 | |
13 | - public function action_scheduler_post_type_args( $args ) { |
|
14 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
13 | + public function action_scheduler_post_type_args($args) { |
|
14 | + _deprecated_function(__METHOD__, '2.0.0'); |
|
15 | 15 | return $args; |
16 | 16 | } |
17 | 17 | |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * @param array $views An associative array of views and view labels which can be used to filter the 'scheduled-action' posts displayed on the Scheduled Actions administration screen. |
22 | 22 | * @return array $views An associative array of views and view labels which can be used to filter the 'scheduled-action' posts displayed on the Scheduled Actions administration screen. |
23 | 23 | */ |
24 | - public function list_table_views( $views ) { |
|
25 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
24 | + public function list_table_views($views) { |
|
25 | + _deprecated_function(__METHOD__, '2.0.0'); |
|
26 | 26 | return $views; |
27 | 27 | } |
28 | 28 | |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | * @param array $actions An associative array of actions which can be performed on the 'scheduled-action' post type. |
35 | 35 | * @return array $actions An associative array of actions which can be performed on the 'scheduled-action' post type. |
36 | 36 | */ |
37 | - public function bulk_actions( $actions ) { |
|
38 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
37 | + public function bulk_actions($actions) { |
|
38 | + _deprecated_function(__METHOD__, '2.0.0'); |
|
39 | 39 | return $actions; |
40 | 40 | } |
41 | 41 | |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | * @param array $columns An associative array of columns that are use for the table on the Scheduled Actions administration screen. |
49 | 49 | * @return array $columns An associative array of columns that are use for the table on the Scheduled Actions administration screen. |
50 | 50 | */ |
51 | - public function list_table_columns( $columns ) { |
|
52 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
51 | + public function list_table_columns($columns) { |
|
52 | + _deprecated_function(__METHOD__, '2.0.0'); |
|
53 | 53 | return $columns; |
54 | 54 | } |
55 | 55 | |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | * @param array $columns An associative array of columns that can be used to sort the table on the Scheduled Actions administration screen. |
60 | 60 | * @return array $columns An associative array of columns that can be used to sort the table on the Scheduled Actions administration screen. |
61 | 61 | */ |
62 | - public static function list_table_sortable_columns( $columns ) { |
|
63 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
62 | + public static function list_table_sortable_columns($columns) { |
|
63 | + _deprecated_function(__METHOD__, '2.0.0'); |
|
64 | 64 | return $columns; |
65 | 65 | } |
66 | 66 | |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | * @param string $column_name The key for the column for which we should output our content. |
71 | 71 | * @param int $post_id The ID of the 'scheduled-action' post for which this row relates. |
72 | 72 | */ |
73 | - public static function list_table_column_content( $column_name, $post_id ) { |
|
74 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
73 | + public static function list_table_column_content($column_name, $post_id) { |
|
74 | + _deprecated_function(__METHOD__, '2.0.0'); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | * @param array $actions An associative array of actions which can be performed on the 'scheduled-action' post type. |
83 | 83 | * @return array $actions An associative array of actions which can be performed on the 'scheduled-action' post type. |
84 | 84 | */ |
85 | - public static function row_actions( $actions, $post ) { |
|
86 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
85 | + public static function row_actions($actions, $post) { |
|
86 | + _deprecated_function(__METHOD__, '2.0.0'); |
|
87 | 87 | return $actions; |
88 | 88 | } |
89 | 89 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @codeCoverageIgnore |
94 | 94 | */ |
95 | 95 | public static function maybe_execute_action() { |
96 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
96 | + _deprecated_function(__METHOD__, '2.0.0'); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @return string A human friendly string representation of the interval. |
110 | 110 | */ |
111 | 111 | public static function admin_notices() { |
112 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
112 | + _deprecated_function(__METHOD__, '2.0.0'); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | * @param WP_Query $query Instance of a WP_Query object |
120 | 120 | * @return string MySQL orderby string. |
121 | 121 | */ |
122 | - public function custom_orderby( $orderby, $query ){ |
|
123 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
122 | + public function custom_orderby($orderby, $query) { |
|
123 | + _deprecated_function(__METHOD__, '2.0.0'); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -130,8 +130,8 @@ discard block |
||
130 | 130 | * @param WP_Query $query Instance of a WP_Query object |
131 | 131 | * @return string MySQL search string. |
132 | 132 | */ |
133 | - public function search_post_password( $search, $query ) { |
|
134 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
133 | + public function search_post_password($search, $query) { |
|
134 | + _deprecated_function(__METHOD__, '2.0.0'); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | * @param array $messages |
141 | 141 | * @return array |
142 | 142 | */ |
143 | - public function post_updated_messages( $messages ) { |
|
144 | - _deprecated_function( __METHOD__, '2.0.0' ); |
|
143 | + public function post_updated_messages($messages) { |
|
144 | + _deprecated_function(__METHOD__, '2.0.0'); |
|
145 | 145 | return $messages; |
146 | 146 | } |
147 | 147 | } |
148 | 148 | \ No newline at end of file |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return string The job ID |
20 | 20 | */ |
21 | -function wc_schedule_single_action( $timestamp, $hook, $args = array(), $group = '' ) { |
|
22 | - _deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_single_action()' ); |
|
23 | - return as_schedule_single_action( $timestamp, $hook, $args, $group ); |
|
21 | +function wc_schedule_single_action($timestamp, $hook, $args = array(), $group = '') { |
|
22 | + _deprecated_function(__FUNCTION__, '2.1.0', 'as_schedule_single_action()'); |
|
23 | + return as_schedule_single_action($timestamp, $hook, $args, $group); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @return string The job ID |
38 | 38 | */ |
39 | -function wc_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args = array(), $group = '' ) { |
|
40 | - _deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_recurring_action()' ); |
|
41 | - return as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args, $group ); |
|
39 | +function wc_schedule_recurring_action($timestamp, $interval_in_seconds, $hook, $args = array(), $group = '') { |
|
40 | + _deprecated_function(__FUNCTION__, '2.1.0', 'as_schedule_recurring_action()'); |
|
41 | + return as_schedule_recurring_action($timestamp, $interval_in_seconds, $hook, $args, $group); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return string The job ID |
66 | 66 | */ |
67 | -function wc_schedule_cron_action( $timestamp, $schedule, $hook, $args = array(), $group = '' ) { |
|
68 | - _deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_cron_action()' ); |
|
69 | - return as_schedule_cron_action( $timestamp, $schedule, $hook, $args, $group ); |
|
67 | +function wc_schedule_cron_action($timestamp, $schedule, $hook, $args = array(), $group = '') { |
|
68 | + _deprecated_function(__FUNCTION__, '2.1.0', 'as_schedule_cron_action()'); |
|
69 | + return as_schedule_cron_action($timestamp, $schedule, $hook, $args, $group); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @deprecated 2.1.0 |
80 | 80 | */ |
81 | -function wc_unschedule_action( $hook, $args = array(), $group = '' ) { |
|
82 | - _deprecated_function( __FUNCTION__, '2.1.0', 'as_unschedule_action()' ); |
|
83 | - as_unschedule_action( $hook, $args, $group ); |
|
81 | +function wc_unschedule_action($hook, $args = array(), $group = '') { |
|
82 | + _deprecated_function(__FUNCTION__, '2.1.0', 'as_unschedule_action()'); |
|
83 | + as_unschedule_action($hook, $args, $group); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return int|bool The timestamp for the next occurrence, or false if nothing was found |
94 | 94 | */ |
95 | -function wc_next_scheduled_action( $hook, $args = NULL, $group = '' ) { |
|
96 | - _deprecated_function( __FUNCTION__, '2.1.0', 'as_next_scheduled_action()' ); |
|
97 | - return as_next_scheduled_action( $hook, $args, $group ); |
|
95 | +function wc_next_scheduled_action($hook, $args = NULL, $group = '') { |
|
96 | + _deprecated_function(__FUNCTION__, '2.1.0', 'as_next_scheduled_action()'); |
|
97 | + return as_next_scheduled_action($hook, $args, $group); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return array |
122 | 122 | */ |
123 | -function wc_get_scheduled_actions( $args = array(), $return_format = OBJECT ) { |
|
124 | - _deprecated_function( __FUNCTION__, '2.1.0', 'as_get_scheduled_actions()' ); |
|
125 | - return as_get_scheduled_actions( $args, $return_format ); |
|
123 | +function wc_get_scheduled_actions($args = array(), $return_format = OBJECT) { |
|
124 | + _deprecated_function(__FUNCTION__, '2.1.0', 'as_get_scheduled_actions()'); |
|
125 | + return as_get_scheduled_actions($args, $return_format); |
|
126 | 126 | } |
@@ -13,16 +13,16 @@ |
||
13 | 13 | * |
14 | 14 | * @return DateTime|null |
15 | 15 | */ |
16 | - public function next( DateTime $after = NULL ) { |
|
17 | - if ( empty( $after ) ) { |
|
16 | + public function next(DateTime $after = NULL) { |
|
17 | + if (empty($after)) { |
|
18 | 18 | $return_value = $this->get_date(); |
19 | 19 | $replacement_method = 'get_date()'; |
20 | 20 | } else { |
21 | - $return_value = $this->get_next( $after ); |
|
21 | + $return_value = $this->get_next($after); |
|
22 | 22 | $replacement_method = 'get_next( $after )'; |
23 | 23 | } |
24 | 24 | |
25 | - _deprecated_function( __METHOD__, '3.0.0', __CLASS__ . '::' . $replacement_method ); |
|
25 | + _deprecated_function(__METHOD__, '3.0.0', __CLASS__ . '::' . $replacement_method); |
|
26 | 26 | |
27 | 27 | return $return_value; |
28 | 28 | } |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | * |
14 | 14 | * @param int $action_id The ID of the action. |
15 | 15 | */ |
16 | - public function mark_failed_fetch_action( $action_id ) { |
|
17 | - _deprecated_function( __METHOD__, '3.0.0', 'ActionScheduler_Store::mark_failure()' ); |
|
18 | - self::$store->mark_failure( $action_id ); |
|
16 | + public function mark_failed_fetch_action($action_id) { |
|
17 | + _deprecated_function(__METHOD__, '3.0.0', 'ActionScheduler_Store::mark_failure()'); |
|
18 | + self::$store->mark_failure($action_id); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * @since 2.2.6 |
25 | 25 | */ |
26 | 26 | protected static function hook() { |
27 | - _deprecated_function( __METHOD__, '3.0.0' ); |
|
27 | + _deprecated_function(__METHOD__, '3.0.0'); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @since 2.2.6 |
34 | 34 | */ |
35 | 35 | protected static function unhook() { |
36 | - _deprecated_function( __METHOD__, '3.0.0' ); |
|
36 | + _deprecated_function(__METHOD__, '3.0.0'); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @return DateTimeZone |
44 | 44 | */ |
45 | 45 | protected function get_local_timezone() { |
46 | - _deprecated_function( __FUNCTION__, '2.1.0', 'ActionScheduler_TimezoneHelper::set_local_timezone()' ); |
|
46 | + _deprecated_function(__FUNCTION__, '2.1.0', 'ActionScheduler_TimezoneHelper::set_local_timezone()'); |
|
47 | 47 | return ActionScheduler_TimezoneHelper::get_local_timezone(); |
48 | 48 | } |
49 | 49 | } |
@@ -12,16 +12,16 @@ |
||
12 | 12 | * @return int The number of seconds. |
13 | 13 | */ |
14 | 14 | protected function get_maximum_execution_time() { |
15 | - _deprecated_function( __METHOD__, '2.1.1', 'ActionScheduler_Abstract_QueueRunner::get_time_limit()' ); |
|
15 | + _deprecated_function(__METHOD__, '2.1.1', 'ActionScheduler_Abstract_QueueRunner::get_time_limit()'); |
|
16 | 16 | |
17 | 17 | $maximum_execution_time = 30; |
18 | 18 | |
19 | 19 | // Apply deprecated filter |
20 | - if ( has_filter( 'action_scheduler_maximum_execution_time' ) ) { |
|
21 | - _deprecated_function( 'action_scheduler_maximum_execution_time', '2.1.1', 'action_scheduler_queue_runner_time_limit' ); |
|
22 | - $maximum_execution_time = apply_filters( 'action_scheduler_maximum_execution_time', $maximum_execution_time ); |
|
20 | + if (has_filter('action_scheduler_maximum_execution_time')) { |
|
21 | + _deprecated_function('action_scheduler_maximum_execution_time', '2.1.1', 'action_scheduler_queue_runner_time_limit'); |
|
22 | + $maximum_execution_time = apply_filters('action_scheduler_maximum_execution_time', $maximum_execution_time); |
|
23 | 23 | } |
24 | 24 | |
25 | - return absint( $maximum_execution_time ); |
|
25 | + return absint($maximum_execution_time); |
|
26 | 26 | } |
27 | 27 | } |
@@ -25,29 +25,29 @@ |
||
25 | 25 | * |
26 | 26 | */ |
27 | 27 | |
28 | -if ( ! function_exists( 'action_scheduler_register_3_dot_1_dot_4' ) ) { |
|
28 | +if (!function_exists('action_scheduler_register_3_dot_1_dot_4')) { |
|
29 | 29 | |
30 | - if ( ! class_exists( 'ActionScheduler_Versions' ) ) { |
|
31 | - require_once( 'classes/ActionScheduler_Versions.php' ); |
|
32 | - add_action( 'plugins_loaded', array( 'ActionScheduler_Versions', 'initialize_latest_version' ), 1, 0 ); |
|
30 | + if (!class_exists('ActionScheduler_Versions')) { |
|
31 | + require_once('classes/ActionScheduler_Versions.php'); |
|
32 | + add_action('plugins_loaded', array('ActionScheduler_Versions', 'initialize_latest_version'), 1, 0); |
|
33 | 33 | } |
34 | 34 | |
35 | - add_action( 'plugins_loaded', 'action_scheduler_register_3_dot_1_dot_4', 0, 0 ); |
|
35 | + add_action('plugins_loaded', 'action_scheduler_register_3_dot_1_dot_4', 0, 0); |
|
36 | 36 | |
37 | 37 | function action_scheduler_register_3_dot_1_dot_4() { |
38 | 38 | $versions = ActionScheduler_Versions::instance(); |
39 | - $versions->register( '3.1.4', 'action_scheduler_initialize_3_dot_1_dot_4' ); |
|
39 | + $versions->register('3.1.4', 'action_scheduler_initialize_3_dot_1_dot_4'); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | function action_scheduler_initialize_3_dot_1_dot_4() { |
43 | - require_once( 'classes/abstracts/ActionScheduler.php' ); |
|
44 | - ActionScheduler::init( __FILE__ ); |
|
43 | + require_once('classes/abstracts/ActionScheduler.php'); |
|
44 | + ActionScheduler::init(__FILE__); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | // Support usage in themes - load this version if no plugin has loaded a version yet. |
48 | - if ( did_action( 'plugins_loaded' ) && ! class_exists( 'ActionScheduler' ) ) { |
|
48 | + if (did_action('plugins_loaded') && !class_exists('ActionScheduler')) { |
|
49 | 49 | action_scheduler_initialize_3_dot_1_dot_4(); |
50 | - do_action( 'action_scheduler_pre_theme_init' ); |
|
50 | + do_action('action_scheduler_pre_theme_init'); |
|
51 | 51 | ActionScheduler_Versions::initialize_latest_version(); |
52 | 52 | } |
53 | 53 | } |