@@ -348,7 +348,7 @@ |
||
348 | 348 | |
349 | 349 | $query_args = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true ); |
350 | 350 | if ( !empty( $status ) && $status != 'all' ) { |
351 | - $query_args['status'] = $status; |
|
351 | + $query_args['status'] = $status; |
|
352 | 352 | } |
353 | 353 | $invoices = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) ); |
354 | 354 |
@@ -30,40 +30,40 @@ discard block |
||
30 | 30 | } |
31 | 31 | |
32 | 32 | function wpinv_can_checkout() { |
33 | - $can_checkout = true; // Always true for now |
|
33 | + $can_checkout = true; // Always true for now |
|
34 | 34 | |
35 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
35 | + return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | function wpinv_get_success_page_uri() { |
39 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
40 | - $page_id = absint( $page_id ); |
|
39 | + $page_id = wpinv_get_option( 'success_page', 0 ); |
|
40 | + $page_id = absint( $page_id ); |
|
41 | 41 | |
42 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
42 | + return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | function wpinv_get_history_page_uri() { |
46 | - $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
47 | - $page_id = absint( $page_id ); |
|
46 | + $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
47 | + $page_id = absint( $page_id ); |
|
48 | 48 | |
49 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
49 | + return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | function wpinv_is_success_page() { |
53 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
54 | - $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
53 | + $is_success_page = wpinv_get_option( 'success_page', false ); |
|
54 | + $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
55 | 55 | |
56 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
56 | + return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | function wpinv_is_invoice_history_page() { |
60 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
61 | - $ret = $ret ? is_page( $ret ) : false; |
|
62 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
60 | + $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
61 | + $ret = $ret ? is_page( $ret ) : false; |
|
62 | + return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | function wpinv_send_to_success_page( $args = null ) { |
66 | - $redirect = wpinv_get_success_page_uri(); |
|
66 | + $redirect = wpinv_get_success_page_uri(); |
|
67 | 67 | |
68 | 68 | if ( !empty( $args ) ) { |
69 | 69 | // Check for backward compatibility |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | function wpinv_send_to_failed_page( $args = null ) { |
86 | - $redirect = wpinv_get_failed_transaction_uri(); |
|
86 | + $redirect = wpinv_get_failed_transaction_uri(); |
|
87 | 87 | |
88 | 88 | if ( !empty( $args ) ) { |
89 | 89 | // Check for backward compatibility |
@@ -103,72 +103,72 @@ discard block |
||
103 | 103 | } |
104 | 104 | |
105 | 105 | function wpinv_get_checkout_uri( $args = array() ) { |
106 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
107 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
106 | + $uri = wpinv_get_option( 'checkout_page', false ); |
|
107 | + $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
108 | 108 | |
109 | - if ( !empty( $args ) ) { |
|
110 | - // Check for backward compatibility |
|
111 | - if ( is_string( $args ) ) |
|
112 | - $args = str_replace( '?', '', $args ); |
|
109 | + if ( !empty( $args ) ) { |
|
110 | + // Check for backward compatibility |
|
111 | + if ( is_string( $args ) ) |
|
112 | + $args = str_replace( '?', '', $args ); |
|
113 | 113 | |
114 | - $args = wp_parse_args( $args ); |
|
114 | + $args = wp_parse_args( $args ); |
|
115 | 115 | |
116 | - $uri = add_query_arg( $args, $uri ); |
|
117 | - } |
|
116 | + $uri = add_query_arg( $args, $uri ); |
|
117 | + } |
|
118 | 118 | |
119 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
119 | + $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
120 | 120 | |
121 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
121 | + $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
122 | 122 | |
123 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
124 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
125 | - } |
|
123 | + if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
124 | + $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
125 | + } |
|
126 | 126 | |
127 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
127 | + return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | function wpinv_send_back_to_checkout( $args = array() ) { |
131 | - $redirect = wpinv_get_checkout_uri(); |
|
131 | + $redirect = wpinv_get_checkout_uri(); |
|
132 | 132 | |
133 | - if ( ! empty( $args ) ) { |
|
134 | - // Check for backward compatibility |
|
135 | - if ( is_string( $args ) ) |
|
136 | - $args = str_replace( '?', '', $args ); |
|
133 | + if ( ! empty( $args ) ) { |
|
134 | + // Check for backward compatibility |
|
135 | + if ( is_string( $args ) ) |
|
136 | + $args = str_replace( '?', '', $args ); |
|
137 | 137 | |
138 | - $args = wp_parse_args( $args ); |
|
138 | + $args = wp_parse_args( $args ); |
|
139 | 139 | |
140 | - $redirect = add_query_arg( $args, $redirect ); |
|
141 | - } |
|
140 | + $redirect = add_query_arg( $args, $redirect ); |
|
141 | + } |
|
142 | 142 | |
143 | - wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
144 | - exit; |
|
143 | + wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
144 | + exit; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | function wpinv_get_success_page_url( $query_string = null ) { |
148 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
149 | - $success_page = get_permalink( $success_page ); |
|
148 | + $success_page = wpinv_get_option( 'success_page', 0 ); |
|
149 | + $success_page = get_permalink( $success_page ); |
|
150 | 150 | |
151 | - if ( $query_string ) |
|
152 | - $success_page .= $query_string; |
|
151 | + if ( $query_string ) |
|
152 | + $success_page .= $query_string; |
|
153 | 153 | |
154 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
154 | + return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | function wpinv_get_failed_transaction_uri( $extras = false ) { |
158 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
159 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
158 | + $uri = wpinv_get_option( 'failure_page', '' ); |
|
159 | + $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
160 | 160 | |
161 | - if ( $extras ) |
|
162 | - $uri .= $extras; |
|
161 | + if ( $extras ) |
|
162 | + $uri .= $extras; |
|
163 | 163 | |
164 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
164 | + return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | function wpinv_is_failed_transaction_page() { |
168 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
169 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
168 | + $ret = wpinv_get_option( 'failure_page', false ); |
|
169 | + $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
170 | 170 | |
171 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
171 | + return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | function wpinv_transaction_query( $type = 'start' ) { |
@@ -13,9 +13,9 @@ |
||
13 | 13 | ) ); |
14 | 14 | echo '<div class="' . implode( ' ', $classes ) . '">'; |
15 | 15 | // Loop error codes and display errors |
16 | - foreach ( $errors as $error_id => $error ) { |
|
16 | + foreach ( $errors as $error_id => $error ) { |
|
17 | 17 | echo '<p class="wpinv_error" id="wpinv_error_' . $error_id . '"><strong>' . __( 'Error', 'invoicing' ) . '</strong>: ' . $error . '</p>'; |
18 | - } |
|
18 | + } |
|
19 | 19 | echo '</div>'; |
20 | 20 | wpinv_clear_errors(); |
21 | 21 | } |
@@ -286,26 +286,26 @@ discard block |
||
286 | 286 | } |
287 | 287 | |
288 | 288 | function wpinv_get_chosen_gateway( $invoice_id = 0 ) { |
289 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
289 | + $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
290 | 290 | |
291 | 291 | $chosen = false; |
292 | 292 | if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) { |
293 | 293 | $chosen = $invoice->get_gateway(); |
294 | 294 | } |
295 | 295 | |
296 | - $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
296 | + $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
297 | 297 | |
298 | - if ( false !== $chosen ) { |
|
299 | - $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
300 | - } |
|
298 | + if ( false !== $chosen ) { |
|
299 | + $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
300 | + } |
|
301 | 301 | |
302 | - if ( ! empty ( $chosen ) ) { |
|
303 | - $enabled_gateway = urldecode( $chosen ); |
|
304 | - } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
305 | - $enabled_gateway = 'manual'; |
|
306 | - } else { |
|
307 | - $enabled_gateway = wpinv_get_default_gateway(); |
|
308 | - } |
|
302 | + if ( ! empty ( $chosen ) ) { |
|
303 | + $enabled_gateway = urldecode( $chosen ); |
|
304 | + } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
305 | + $enabled_gateway = 'manual'; |
|
306 | + } else { |
|
307 | + $enabled_gateway = wpinv_get_default_gateway(); |
|
308 | + } |
|
309 | 309 | |
310 | 310 | if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) { |
311 | 311 | if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){ |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | |
317 | 317 | } |
318 | 318 | |
319 | - return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
319 | + return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | function wpinv_record_gateway_error( $title = '', $message = '', $parent = 0 ) { |
@@ -324,21 +324,21 @@ discard block |
||
324 | 324 | } |
325 | 325 | |
326 | 326 | function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
327 | - $ret = 0; |
|
328 | - $args = array( |
|
329 | - 'meta_key' => '_wpinv_gateway', |
|
330 | - 'meta_value' => $gateway_id, |
|
331 | - 'nopaging' => true, |
|
332 | - 'post_type' => 'wpi_invoice', |
|
333 | - 'post_status' => $status, |
|
334 | - 'fields' => 'ids' |
|
335 | - ); |
|
336 | - |
|
337 | - $payments = new WP_Query( $args ); |
|
338 | - |
|
339 | - if( $payments ) |
|
340 | - $ret = $payments->post_count; |
|
341 | - return $ret; |
|
327 | + $ret = 0; |
|
328 | + $args = array( |
|
329 | + 'meta_key' => '_wpinv_gateway', |
|
330 | + 'meta_value' => $gateway_id, |
|
331 | + 'nopaging' => true, |
|
332 | + 'post_type' => 'wpi_invoice', |
|
333 | + 'post_status' => $status, |
|
334 | + 'fields' => 'ids' |
|
335 | + ); |
|
336 | + |
|
337 | + $payments = new WP_Query( $args ); |
|
338 | + |
|
339 | + if( $payments ) |
|
340 | + $ret = $payments->post_count; |
|
341 | + return $ret; |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | function wpinv_settings_update_gateways( $input ) { |
@@ -887,8 +887,8 @@ |
||
887 | 887 | if ( !empty( $data ) && isset( $data['cart_discounts'] ) ) { |
888 | 888 | unset( $data['cart_discounts'] ); |
889 | 889 | |
890 | - wpinv_set_checkout_session( $data ); |
|
891 | - return true; |
|
890 | + wpinv_set_checkout_session( $data ); |
|
891 | + return true; |
|
892 | 892 | } |
893 | 893 | |
894 | 894 | return false; |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | |
141 | 141 | function wpinv_get_default_labels() { |
142 | 142 | $defaults = array( |
143 | - 'singular' => __( 'Invoice', 'invoicing' ), |
|
144 | - 'plural' => __( 'Invoices', 'invoicing' ) |
|
143 | + 'singular' => __( 'Invoice', 'invoicing' ), |
|
144 | + 'plural' => __( 'Invoices', 'invoicing' ) |
|
145 | 145 | ); |
146 | 146 | |
147 | 147 | return apply_filters( 'wpinv_default_invoices_name', $defaults ); |
@@ -160,20 +160,20 @@ discard block |
||
160 | 160 | } |
161 | 161 | |
162 | 162 | function wpinv_change_default_title( $title ) { |
163 | - if ( !is_admin() ) { |
|
163 | + if ( !is_admin() ) { |
|
164 | 164 | $label = wpinv_get_label_singular(); |
165 | 165 | $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label ); |
166 | 166 | return $title; |
167 | - } |
|
167 | + } |
|
168 | 168 | |
169 | - $screen = get_current_screen(); |
|
169 | + $screen = get_current_screen(); |
|
170 | 170 | |
171 | - if ( 'wpi_invoice' == $screen->post_type ) { |
|
171 | + if ( 'wpi_invoice' == $screen->post_type ) { |
|
172 | 172 | $label = wpinv_get_label_singular(); |
173 | 173 | $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label ); |
174 | - } |
|
174 | + } |
|
175 | 175 | |
176 | - return $title; |
|
176 | + return $title; |
|
177 | 177 | } |
178 | 178 | add_filter( 'enter_title_here', 'wpinv_change_default_title' ); |
179 | 179 |
@@ -166,13 +166,13 @@ |
||
166 | 166 | $is_writeable = $is_dir && is_writeable( $this->export_dir ); |
167 | 167 | |
168 | 168 | if ( $is_dir && $is_writeable ) { |
169 | - return true; |
|
169 | + return true; |
|
170 | 170 | } else if ( $is_dir && !$is_writeable ) { |
171 | - if ( !$this->wp_filesystem->chmod( $this->export_dir, FS_CHMOD_DIR ) ) { |
|
172 | - return wp_sprintf( __( 'Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing' ), $this->export_dir ); |
|
173 | - } |
|
171 | + if ( !$this->wp_filesystem->chmod( $this->export_dir, FS_CHMOD_DIR ) ) { |
|
172 | + return wp_sprintf( __( 'Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing' ), $this->export_dir ); |
|
173 | + } |
|
174 | 174 | |
175 | - return true; |
|
175 | + return true; |
|
176 | 176 | } else { |
177 | 177 | if ( !$this->wp_filesystem->mkdir( $this->export_dir, FS_CHMOD_DIR ) ) { |
178 | 178 | return wp_sprintf( __( 'Filesystem ERROR: Could not create directory %s. This is usually due to inconsistent file permissions.', 'invoicing' ), $this->export_dir ); |
@@ -437,7 +437,7 @@ |
||
437 | 437 | } |
438 | 438 | |
439 | 439 | function wpinv_get_php_arg_separator_output() { |
440 | - return ini_get( 'arg_separator.output' ); |
|
440 | + return ini_get( 'arg_separator.output' ); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | function wpinv_rgb_from_hex( $color ) { |
@@ -5,12 +5,12 @@ |
||
5 | 5 | // @codingStandardsIgnoreFile |
6 | 6 | |
7 | 7 | /** |
8 | - * This interface exists to provide backwards compatibility with PHP 5.3 |
|
9 | - * |
|
10 | - * This should _not_ be used by any third-party code. |
|
11 | - * |
|
12 | - * @ignore |
|
13 | - */ |
|
8 | + * This interface exists to provide backwards compatibility with PHP 5.3 |
|
9 | + * |
|
10 | + * This should _not_ be used by any third-party code. |
|
11 | + * |
|
12 | + * @ignore |
|
13 | + */ |
|
14 | 14 | if (interface_exists('JsonSerializable')) { |
15 | 15 | interface JsonSerializable extends \JsonSerializable |
16 | 16 | { |