@@ -30,36 +30,36 @@ 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_is_subscriptions_history_page() { |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | function wpinv_send_to_success_page( $args = null ) { |
72 | - $redirect = wpinv_get_success_page_uri(); |
|
72 | + $redirect = wpinv_get_success_page_uri(); |
|
73 | 73 | |
74 | 74 | if ( !empty( $args ) ) { |
75 | 75 | // Check for backward compatibility |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | function wpinv_send_to_failed_page( $args = null ) { |
92 | - $redirect = wpinv_get_failed_transaction_uri(); |
|
92 | + $redirect = wpinv_get_failed_transaction_uri(); |
|
93 | 93 | |
94 | 94 | if ( !empty( $args ) ) { |
95 | 95 | // Check for backward compatibility |
@@ -109,72 +109,72 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | function wpinv_get_checkout_uri( $args = array() ) { |
112 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
113 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
112 | + $uri = wpinv_get_option( 'checkout_page', false ); |
|
113 | + $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
114 | 114 | |
115 | - if ( !empty( $args ) ) { |
|
116 | - // Check for backward compatibility |
|
117 | - if ( is_string( $args ) ) |
|
118 | - $args = str_replace( '?', '', $args ); |
|
115 | + if ( !empty( $args ) ) { |
|
116 | + // Check for backward compatibility |
|
117 | + if ( is_string( $args ) ) |
|
118 | + $args = str_replace( '?', '', $args ); |
|
119 | 119 | |
120 | - $args = wp_parse_args( $args ); |
|
120 | + $args = wp_parse_args( $args ); |
|
121 | 121 | |
122 | - $uri = add_query_arg( $args, $uri ); |
|
123 | - } |
|
122 | + $uri = add_query_arg( $args, $uri ); |
|
123 | + } |
|
124 | 124 | |
125 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
125 | + $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
126 | 126 | |
127 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
127 | + $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
128 | 128 | |
129 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
130 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
131 | - } |
|
129 | + if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
130 | + $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
131 | + } |
|
132 | 132 | |
133 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
133 | + return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | function wpinv_send_back_to_checkout( $args = array() ) { |
137 | - $redirect = wpinv_get_checkout_uri(); |
|
137 | + $redirect = wpinv_get_checkout_uri(); |
|
138 | 138 | |
139 | - if ( ! empty( $args ) ) { |
|
140 | - // Check for backward compatibility |
|
141 | - if ( is_string( $args ) ) |
|
142 | - $args = str_replace( '?', '', $args ); |
|
139 | + if ( ! empty( $args ) ) { |
|
140 | + // Check for backward compatibility |
|
141 | + if ( is_string( $args ) ) |
|
142 | + $args = str_replace( '?', '', $args ); |
|
143 | 143 | |
144 | - $args = wp_parse_args( $args ); |
|
144 | + $args = wp_parse_args( $args ); |
|
145 | 145 | |
146 | - $redirect = add_query_arg( $args, $redirect ); |
|
147 | - } |
|
146 | + $redirect = add_query_arg( $args, $redirect ); |
|
147 | + } |
|
148 | 148 | |
149 | - wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
150 | - exit; |
|
149 | + wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
150 | + exit; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | function wpinv_get_success_page_url( $query_string = null ) { |
154 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
155 | - $success_page = get_permalink( $success_page ); |
|
154 | + $success_page = wpinv_get_option( 'success_page', 0 ); |
|
155 | + $success_page = get_permalink( $success_page ); |
|
156 | 156 | |
157 | - if ( $query_string ) |
|
158 | - $success_page .= $query_string; |
|
157 | + if ( $query_string ) |
|
158 | + $success_page .= $query_string; |
|
159 | 159 | |
160 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
160 | + return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | function wpinv_get_failed_transaction_uri( $extras = false ) { |
164 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
165 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
164 | + $uri = wpinv_get_option( 'failure_page', '' ); |
|
165 | + $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
166 | 166 | |
167 | - if ( $extras ) |
|
168 | - $uri .= $extras; |
|
167 | + if ( $extras ) |
|
168 | + $uri .= $extras; |
|
169 | 169 | |
170 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
170 | + return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | function wpinv_is_failed_transaction_page() { |
174 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
175 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
174 | + $ret = wpinv_get_option( 'failure_page', false ); |
|
175 | + $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
176 | 176 | |
177 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
177 | + return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | function wpinv_transaction_query( $type = 'start' ) { |
@@ -320,36 +320,36 @@ discard block |
||
320 | 320 | $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
321 | 321 | |
322 | 322 | if ( $require_billing_details ) { |
323 | - if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
324 | - $required_fields['first_name'] = array( |
|
325 | - 'error_id' => 'invalid_first_name', |
|
326 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
327 | - ); |
|
328 | - } |
|
329 | - if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
330 | - $required_fields['address'] = array( |
|
331 | - 'error_id' => 'invalid_address', |
|
332 | - 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
333 | - ); |
|
334 | - } |
|
335 | - if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
336 | - $required_fields['city'] = array( |
|
337 | - 'error_id' => 'invalid_city', |
|
338 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
339 | - ); |
|
340 | - } |
|
341 | - if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
342 | - $required_fields['state'] = array( |
|
343 | - 'error_id' => 'invalid_state', |
|
344 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
345 | - ); |
|
346 | - } |
|
347 | - if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
348 | - $required_fields['country'] = array( |
|
349 | - 'error_id' => 'invalid_country', |
|
350 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
351 | - ); |
|
352 | - } |
|
323 | + if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
324 | + $required_fields['first_name'] = array( |
|
325 | + 'error_id' => 'invalid_first_name', |
|
326 | + 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
327 | + ); |
|
328 | + } |
|
329 | + if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
330 | + $required_fields['address'] = array( |
|
331 | + 'error_id' => 'invalid_address', |
|
332 | + 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
333 | + ); |
|
334 | + } |
|
335 | + if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
336 | + $required_fields['city'] = array( |
|
337 | + 'error_id' => 'invalid_city', |
|
338 | + 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
339 | + ); |
|
340 | + } |
|
341 | + if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
342 | + $required_fields['state'] = array( |
|
343 | + 'error_id' => 'invalid_state', |
|
344 | + 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
345 | + ); |
|
346 | + } |
|
347 | + if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
348 | + $required_fields['country'] = array( |
|
349 | + 'error_id' => 'invalid_country', |
|
350 | + 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
351 | + ); |
|
352 | + } |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |