@@ -145,29 +145,29 @@ discard block |
||
145 | 145 | |
146 | 146 | function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
147 | 147 | if ( ! empty( $args ) && is_array( $args ) ) { |
148 | - extract( $args ); |
|
149 | - } |
|
148 | + extract( $args ); |
|
149 | + } |
|
150 | 150 | |
151 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
152 | - // Allow 3rd party plugin filter template file from their plugin. |
|
153 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
151 | + $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
152 | + // Allow 3rd party plugin filter template file from their plugin. |
|
153 | + $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
154 | 154 | |
155 | - if ( ! file_exists( $located ) ) { |
|
155 | + if ( ! file_exists( $located ) ) { |
|
156 | 156 | _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
157 | - return; |
|
158 | - } |
|
157 | + return; |
|
158 | + } |
|
159 | 159 | |
160 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
160 | + do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
161 | 161 | |
162 | - include( $located ); |
|
162 | + include( $located ); |
|
163 | 163 | |
164 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
164 | + do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
168 | - ob_start(); |
|
169 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
170 | - return ob_get_clean(); |
|
168 | + ob_start(); |
|
169 | + wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
170 | + return ob_get_clean(); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
@@ -197,126 +197,126 @@ discard block |
||
197 | 197 | } |
198 | 198 | |
199 | 199 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
200 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
200 | + do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
201 | 201 | |
202 | - // Setup possible parts |
|
203 | - $templates = array(); |
|
204 | - if ( isset( $name ) ) |
|
205 | - $templates[] = $slug . '-' . $name . '.php'; |
|
206 | - $templates[] = $slug . '.php'; |
|
202 | + // Setup possible parts |
|
203 | + $templates = array(); |
|
204 | + if ( isset( $name ) ) |
|
205 | + $templates[] = $slug . '-' . $name . '.php'; |
|
206 | + $templates[] = $slug . '.php'; |
|
207 | 207 | |
208 | - // Allow template parts to be filtered |
|
209 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
208 | + // Allow template parts to be filtered |
|
209 | + $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
210 | 210 | |
211 | - // Return the part that is found |
|
212 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
211 | + // Return the part that is found |
|
212 | + return wpinv_locate_tmpl( $templates, $load, false ); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
216 | - // No file found yet |
|
217 | - $located = false; |
|
216 | + // No file found yet |
|
217 | + $located = false; |
|
218 | 218 | |
219 | - // Try to find a template file |
|
220 | - foreach ( (array)$template_names as $template_name ) { |
|
219 | + // Try to find a template file |
|
220 | + foreach ( (array)$template_names as $template_name ) { |
|
221 | 221 | |
222 | - // Continue if template is empty |
|
223 | - if ( empty( $template_name ) ) |
|
224 | - continue; |
|
222 | + // Continue if template is empty |
|
223 | + if ( empty( $template_name ) ) |
|
224 | + continue; |
|
225 | 225 | |
226 | - // Trim off any slashes from the template name |
|
227 | - $template_name = ltrim( $template_name, '/' ); |
|
226 | + // Trim off any slashes from the template name |
|
227 | + $template_name = ltrim( $template_name, '/' ); |
|
228 | 228 | |
229 | - // try locating this template file by looping through the template paths |
|
230 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
229 | + // try locating this template file by looping through the template paths |
|
230 | + foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
231 | 231 | |
232 | - if( file_exists( $template_path . $template_name ) ) { |
|
233 | - $located = $template_path . $template_name; |
|
234 | - break; |
|
235 | - } |
|
236 | - } |
|
232 | + if( file_exists( $template_path . $template_name ) ) { |
|
233 | + $located = $template_path . $template_name; |
|
234 | + break; |
|
235 | + } |
|
236 | + } |
|
237 | 237 | |
238 | - if( !empty( $located ) ) { |
|
239 | - break; |
|
240 | - } |
|
241 | - } |
|
238 | + if( !empty( $located ) ) { |
|
239 | + break; |
|
240 | + } |
|
241 | + } |
|
242 | 242 | |
243 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
244 | - load_template( $located, $require_once ); |
|
243 | + if ( ( true == $load ) && ! empty( $located ) ) |
|
244 | + load_template( $located, $require_once ); |
|
245 | 245 | |
246 | - return $located; |
|
246 | + return $located; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | function wpinv_get_theme_template_paths() { |
250 | - $template_dir = wpinv_get_theme_template_dir_name(); |
|
250 | + $template_dir = wpinv_get_theme_template_dir_name(); |
|
251 | 251 | |
252 | - $file_paths = array( |
|
253 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
254 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
255 | - 100 => wpinv_get_templates_dir() |
|
256 | - ); |
|
252 | + $file_paths = array( |
|
253 | + 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
254 | + 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
255 | + 100 => wpinv_get_templates_dir() |
|
256 | + ); |
|
257 | 257 | |
258 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
258 | + $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
259 | 259 | |
260 | - // sort the file paths based on priority |
|
261 | - ksort( $file_paths, SORT_NUMERIC ); |
|
260 | + // sort the file paths based on priority |
|
261 | + ksort( $file_paths, SORT_NUMERIC ); |
|
262 | 262 | |
263 | - return array_map( 'trailingslashit', $file_paths ); |
|
263 | + return array_map( 'trailingslashit', $file_paths ); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | function wpinv_get_theme_template_dir_name() { |
267 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
267 | + return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | function wpinv_checkout_meta_tags() { |
271 | 271 | |
272 | - $pages = array(); |
|
273 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
274 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
275 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
276 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
272 | + $pages = array(); |
|
273 | + $pages[] = wpinv_get_option( 'success_page' ); |
|
274 | + $pages[] = wpinv_get_option( 'failure_page' ); |
|
275 | + $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
276 | + $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
277 | 277 | |
278 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
279 | - return; |
|
280 | - } |
|
278 | + if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
279 | + return; |
|
280 | + } |
|
281 | 281 | |
282 | - echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
282 | + echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
283 | 283 | } |
284 | 284 | add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
285 | 285 | |
286 | 286 | function wpinv_add_body_classes( $class ) { |
287 | - $classes = (array)$class; |
|
287 | + $classes = (array)$class; |
|
288 | 288 | |
289 | - if( wpinv_is_checkout() ) { |
|
290 | - $classes[] = 'wpinv-checkout'; |
|
291 | - $classes[] = 'wpinv-page'; |
|
292 | - } |
|
289 | + if( wpinv_is_checkout() ) { |
|
290 | + $classes[] = 'wpinv-checkout'; |
|
291 | + $classes[] = 'wpinv-page'; |
|
292 | + } |
|
293 | 293 | |
294 | - if( wpinv_is_success_page() ) { |
|
295 | - $classes[] = 'wpinv-success'; |
|
296 | - $classes[] = 'wpinv-page'; |
|
297 | - } |
|
294 | + if( wpinv_is_success_page() ) { |
|
295 | + $classes[] = 'wpinv-success'; |
|
296 | + $classes[] = 'wpinv-page'; |
|
297 | + } |
|
298 | 298 | |
299 | - if( wpinv_is_failed_transaction_page() ) { |
|
300 | - $classes[] = 'wpinv-failed-transaction'; |
|
301 | - $classes[] = 'wpinv-page'; |
|
302 | - } |
|
299 | + if( wpinv_is_failed_transaction_page() ) { |
|
300 | + $classes[] = 'wpinv-failed-transaction'; |
|
301 | + $classes[] = 'wpinv-page'; |
|
302 | + } |
|
303 | 303 | |
304 | - if( wpinv_is_invoice_history_page() ) { |
|
305 | - $classes[] = 'wpinv-history'; |
|
306 | - $classes[] = 'wpinv-page'; |
|
307 | - } |
|
304 | + if( wpinv_is_invoice_history_page() ) { |
|
305 | + $classes[] = 'wpinv-history'; |
|
306 | + $classes[] = 'wpinv-page'; |
|
307 | + } |
|
308 | 308 | |
309 | - if( wpinv_is_subscriptions_history_page() ) { |
|
310 | - $classes[] = 'wpinv-subscription'; |
|
311 | - $classes[] = 'wpinv-page'; |
|
312 | - } |
|
309 | + if( wpinv_is_subscriptions_history_page() ) { |
|
310 | + $classes[] = 'wpinv-subscription'; |
|
311 | + $classes[] = 'wpinv-page'; |
|
312 | + } |
|
313 | 313 | |
314 | - if( wpinv_is_test_mode() ) { |
|
315 | - $classes[] = 'wpinv-test-mode'; |
|
316 | - $classes[] = 'wpinv-page'; |
|
317 | - } |
|
314 | + if( wpinv_is_test_mode() ) { |
|
315 | + $classes[] = 'wpinv-test-mode'; |
|
316 | + $classes[] = 'wpinv-page'; |
|
317 | + } |
|
318 | 318 | |
319 | - return array_unique( $classes ); |
|
319 | + return array_unique( $classes ); |
|
320 | 320 | } |
321 | 321 | add_filter( 'body_class', 'wpinv_add_body_classes' ); |
322 | 322 | |
@@ -1029,21 +1029,21 @@ discard block |
||
1029 | 1029 | |
1030 | 1030 | $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
1031 | 1031 | |
1032 | - // Remove unavailable tags. |
|
1032 | + // Remove unavailable tags. |
|
1033 | 1033 | $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address ); |
1034 | 1034 | |
1035 | 1035 | // Clean up white space. |
1036 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
1036 | + $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
1037 | 1037 | $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
1038 | 1038 | |
1039 | 1039 | // Break newlines apart and remove empty lines/trim commas and white space. |
1040 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
1040 | + $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
1041 | 1041 | |
1042 | 1042 | // Add html breaks. |
1043 | - $formatted_address = implode( $separator, $formatted_address ); |
|
1043 | + $formatted_address = implode( $separator, $formatted_address ); |
|
1044 | 1044 | |
1045 | - // We're done! |
|
1046 | - return $formatted_address; |
|
1045 | + // We're done! |
|
1046 | + return $formatted_address; |
|
1047 | 1047 | |
1048 | 1048 | } |
1049 | 1049 | |
@@ -1373,13 +1373,13 @@ discard block |
||
1373 | 1373 | $payment_form = wpinv_get_default_payment_form(); |
1374 | 1374 | |
1375 | 1375 | ob_start(); |
1376 | - do_action( 'wpinv_checkout_content_before' ); |
|
1376 | + do_action( 'wpinv_checkout_content_before' ); |
|
1377 | 1377 | |
1378 | 1378 | if ( wpinv_get_cart_contents() ) { |
1379 | 1379 | |
1380 | 1380 | // Get the form elements and items. |
1381 | - $elements = $invoicing->form_elements->get_form_elements( $payment_form ); |
|
1382 | - $items = $invoicing->form_elements->convert_checkout_items( wpinv_get_cart_contents(), wpinv_get_invoice_cart() ); |
|
1381 | + $elements = $invoicing->form_elements->get_form_elements( $payment_form ); |
|
1382 | + $items = $invoicing->form_elements->convert_checkout_items( wpinv_get_cart_contents(), wpinv_get_invoice_cart() ); |
|
1383 | 1383 | ?> |
1384 | 1384 | <form class="wpinv_payment_form" action="<?php echo $form_action; ?>" method="POST"> |
1385 | 1385 | <?php do_action( 'wpinv_main_checkout_form_top' ); ?> |
@@ -1403,10 +1403,10 @@ discard block |
||
1403 | 1403 | do_action( 'wpinv_cart_empty' ); |
1404 | 1404 | } |
1405 | 1405 | echo '</div><!--end #wpinv_checkout_wrap-->'; |
1406 | - do_action( 'wpinv_checkout_content_after' ); |
|
1406 | + do_action( 'wpinv_checkout_content_after' ); |
|
1407 | 1407 | $content = ob_get_clean(); |
1408 | 1408 | |
1409 | - return str_replace( 'sr-only', '', $content ); |
|
1409 | + return str_replace( 'sr-only', '', $content ); |
|
1410 | 1410 | } |
1411 | 1411 | |
1412 | 1412 | function wpinv_checkout_cart( $cart_details = array(), $echo = true ) { |
@@ -1432,7 +1432,7 @@ discard block |
||
1432 | 1432 | add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
1433 | 1433 | |
1434 | 1434 | function wpinv_empty_cart_message() { |
1435 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1435 | + return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1436 | 1436 | } |
1437 | 1437 | |
1438 | 1438 | /** |
@@ -2252,14 +2252,14 @@ discard block |
||
2252 | 2252 | global $invoicing; |
2253 | 2253 | |
2254 | 2254 | // Ensure that it is published. |
2255 | - if ( 'publish' != get_post_status( $form ) ) { |
|
2256 | - return aui()->alert( |
|
2257 | - array( |
|
2258 | - 'type' => 'warning', |
|
2259 | - 'content' => __( 'This payment form is no longer active', 'invoicing' ), |
|
2260 | - ) |
|
2261 | - ); |
|
2262 | - } |
|
2255 | + if ( 'publish' != get_post_status( $form ) ) { |
|
2256 | + return aui()->alert( |
|
2257 | + array( |
|
2258 | + 'type' => 'warning', |
|
2259 | + 'content' => __( 'This payment form is no longer active', 'invoicing' ), |
|
2260 | + ) |
|
2261 | + ); |
|
2262 | + } |
|
2263 | 2263 | |
2264 | 2264 | // Get the form. |
2265 | 2265 | $form = new GetPaid_Payment_Form( $form ); |
@@ -2275,46 +2275,46 @@ discard block |
||
2275 | 2275 | global $invoicing; |
2276 | 2276 | |
2277 | 2277 | foreach ( array_keys( $items ) as $id ) { |
2278 | - if ( 'publish' != get_post_status( $id ) ) { |
|
2279 | - unset( $items[ $id ] ); |
|
2280 | - } |
|
2278 | + if ( 'publish' != get_post_status( $id ) ) { |
|
2279 | + unset( $items[ $id ] ); |
|
2280 | + } |
|
2281 | 2281 | } |
2282 | 2282 | |
2283 | 2283 | if ( empty( $items ) ) { |
2284 | - return aui()->alert( |
|
2285 | - array( |
|
2286 | - 'type' => 'warning', |
|
2287 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
2288 | - ) |
|
2289 | - ); |
|
2284 | + return aui()->alert( |
|
2285 | + array( |
|
2286 | + 'type' => 'warning', |
|
2287 | + 'content' => __( 'No published items found', 'invoicing' ), |
|
2288 | + ) |
|
2289 | + ); |
|
2290 | 2290 | } |
2291 | 2291 | |
2292 | 2292 | $item_key = getpaid_convert_items_to_string( $items ); |
2293 | 2293 | |
2294 | 2294 | // Get the form elements and items. |
2295 | 2295 | $form = wpinv_get_default_payment_form(); |
2296 | - $elements = $invoicing->form_elements->get_form_elements( $form ); |
|
2297 | - $items = $invoicing->form_elements->convert_normal_items( $items ); |
|
2296 | + $elements = $invoicing->form_elements->get_form_elements( $form ); |
|
2297 | + $items = $invoicing->form_elements->convert_normal_items( $items ); |
|
2298 | 2298 | |
2299 | - ob_start(); |
|
2300 | - echo "<form class='wpinv_payment_form'>"; |
|
2301 | - do_action( 'wpinv_payment_form_top' ); |
|
2299 | + ob_start(); |
|
2300 | + echo "<form class='wpinv_payment_form'>"; |
|
2301 | + do_action( 'wpinv_payment_form_top' ); |
|
2302 | 2302 | echo "<input type='hidden' name='form_id' value='$form'/>"; |
2303 | 2303 | echo "<input type='hidden' name='form_items' value='$item_key'/>"; |
2304 | - wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
2305 | - wp_nonce_field( 'vat_validation', '_wpi_nonce' ); |
|
2304 | + wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
2305 | + wp_nonce_field( 'vat_validation', '_wpi_nonce' ); |
|
2306 | 2306 | |
2307 | - foreach ( $elements as $element ) { |
|
2308 | - do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form ); |
|
2309 | - do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form ); |
|
2310 | - } |
|
2307 | + foreach ( $elements as $element ) { |
|
2308 | + do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form ); |
|
2309 | + do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form ); |
|
2310 | + } |
|
2311 | 2311 | |
2312 | - echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>"; |
|
2313 | - do_action( 'wpinv_payment_form_bottom' ); |
|
2314 | - echo '</form>'; |
|
2312 | + echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>"; |
|
2313 | + do_action( 'wpinv_payment_form_bottom' ); |
|
2314 | + echo '</form>'; |
|
2315 | 2315 | |
2316 | - $content = ob_get_clean(); |
|
2317 | - return str_replace( 'sr-only', '', $content ); |
|
2316 | + $content = ob_get_clean(); |
|
2317 | + return str_replace( 'sr-only', '', $content ); |
|
2318 | 2318 | } |
2319 | 2319 | |
2320 | 2320 | /** |
@@ -2326,47 +2326,47 @@ discard block |
||
2326 | 2326 | $invoice = wpinv_get_invoice( $invoice_id ); |
2327 | 2327 | |
2328 | 2328 | if ( empty( $invoice ) ) { |
2329 | - return aui()->alert( |
|
2330 | - array( |
|
2331 | - 'type' => 'warning', |
|
2332 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
2333 | - ) |
|
2334 | - ); |
|
2329 | + return aui()->alert( |
|
2330 | + array( |
|
2331 | + 'type' => 'warning', |
|
2332 | + 'content' => __( 'Invoice not found', 'invoicing' ), |
|
2333 | + ) |
|
2334 | + ); |
|
2335 | 2335 | } |
2336 | 2336 | |
2337 | 2337 | if ( $invoice->is_paid() ) { |
2338 | - return aui()->alert( |
|
2339 | - array( |
|
2340 | - 'type' => 'warning', |
|
2341 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
2342 | - ) |
|
2343 | - ); |
|
2338 | + return aui()->alert( |
|
2339 | + array( |
|
2340 | + 'type' => 'warning', |
|
2341 | + 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
2342 | + ) |
|
2343 | + ); |
|
2344 | 2344 | } |
2345 | 2345 | |
2346 | 2346 | // Get the form elements and items. |
2347 | 2347 | $form = wpinv_get_default_payment_form(); |
2348 | - $elements = $invoicing->form_elements->get_form_elements( $form ); |
|
2349 | - $items = $invoicing->form_elements->convert_checkout_items( $invoice->cart_details, $invoice ); |
|
2348 | + $elements = $invoicing->form_elements->get_form_elements( $form ); |
|
2349 | + $items = $invoicing->form_elements->convert_checkout_items( $invoice->cart_details, $invoice ); |
|
2350 | 2350 | |
2351 | - ob_start(); |
|
2352 | - echo "<form class='wpinv_payment_form'>"; |
|
2353 | - do_action( 'wpinv_payment_form_top' ); |
|
2351 | + ob_start(); |
|
2352 | + echo "<form class='wpinv_payment_form'>"; |
|
2353 | + do_action( 'wpinv_payment_form_top' ); |
|
2354 | 2354 | echo "<input type='hidden' name='form_id' value='$form'/>"; |
2355 | 2355 | echo "<input type='hidden' name='invoice_id' value='$invoice_id'/>"; |
2356 | - wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
2357 | - wp_nonce_field( 'vat_validation', '_wpi_nonce' ); |
|
2356 | + wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
2357 | + wp_nonce_field( 'vat_validation', '_wpi_nonce' ); |
|
2358 | 2358 | |
2359 | - foreach ( $elements as $element ) { |
|
2360 | - do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form ); |
|
2361 | - do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form ); |
|
2362 | - } |
|
2359 | + foreach ( $elements as $element ) { |
|
2360 | + do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form ); |
|
2361 | + do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form ); |
|
2362 | + } |
|
2363 | 2363 | |
2364 | - echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>"; |
|
2365 | - do_action( 'wpinv_payment_form_bottom' ); |
|
2366 | - echo '</form>'; |
|
2364 | + echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>"; |
|
2365 | + do_action( 'wpinv_payment_form_bottom' ); |
|
2366 | + echo '</form>'; |
|
2367 | 2367 | |
2368 | - $content = ob_get_clean(); |
|
2369 | - return str_replace( 'sr-only', '', $content ); |
|
2368 | + $content = ob_get_clean(); |
|
2369 | + return str_replace( 'sr-only', '', $content ); |
|
2370 | 2370 | } |
2371 | 2371 | |
2372 | 2372 | /** |
@@ -2421,7 +2421,7 @@ discard block |
||
2421 | 2421 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-form='$form'>$label</button>"; |
2422 | 2422 | } |
2423 | 2423 | |
2424 | - if ( ! empty( $items ) ) { |
|
2424 | + if ( ! empty( $items ) ) { |
|
2425 | 2425 | $items = esc_attr( $items ); |
2426 | 2426 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-item='$items'>$label</button>"; |
2427 | 2427 | } |
@@ -7,133 +7,133 @@ 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 | -if ( !is_admin() ) { |
|
15 | - add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
14 | +if (!is_admin()) { |
|
15 | + add_filter('template_include', 'wpinv_template', 10, 1); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | function wpinv_template_path() { |
19 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
19 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
23 | 23 | * Displays the invoice top bar. |
24 | 24 | */ |
25 | -function getpaid_invoice_top_bar( $invoice ) { |
|
26 | - if ( ! empty( $invoice ) ) { |
|
27 | - wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) ); |
|
25 | +function getpaid_invoice_top_bar($invoice) { |
|
26 | + if (!empty($invoice)) { |
|
27 | + wpinv_get_template('invoice/header.php', compact('invoice')); |
|
28 | 28 | } |
29 | 29 | } |
30 | -add_action( 'getpaid_invoice_top_bar', 'getpaid_invoice_top_bar' ); |
|
30 | +add_action('getpaid_invoice_top_bar', 'getpaid_invoice_top_bar'); |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * Displays the left side of the invoice top bar. |
34 | 34 | */ |
35 | -function getpaid_invoice_top_bar_left( $invoice ) { |
|
36 | - if ( ! empty( $invoice ) ) { |
|
37 | - wpinv_get_template( 'invoice/header-left.php', compact( 'invoice' ) ); |
|
35 | +function getpaid_invoice_top_bar_left($invoice) { |
|
36 | + if (!empty($invoice)) { |
|
37 | + wpinv_get_template('invoice/header-left.php', compact('invoice')); |
|
38 | 38 | } |
39 | 39 | } |
40 | -add_action( 'getpaid_invoice_top_bar_left', 'getpaid_invoice_top_bar_left' ); |
|
40 | +add_action('getpaid_invoice_top_bar_left', 'getpaid_invoice_top_bar_left'); |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Displays the right side of the invoice top bar. |
44 | 44 | */ |
45 | -function getpaid_invoice_top_bar_right( $invoice ) { |
|
46 | - if ( ! empty( $invoice ) ) { |
|
47 | - wpinv_get_template( 'invoice/header-right.php', compact( 'invoice' ) ); |
|
45 | +function getpaid_invoice_top_bar_right($invoice) { |
|
46 | + if (!empty($invoice)) { |
|
47 | + wpinv_get_template('invoice/header-right.php', compact('invoice')); |
|
48 | 48 | } |
49 | 49 | } |
50 | -add_action( 'getpaid_invoice_top_bar_right', 'getpaid_invoice_top_bar_right' ); |
|
50 | +add_action('getpaid_invoice_top_bar_right', 'getpaid_invoice_top_bar_right'); |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * Displays the invoice title. |
54 | 54 | */ |
55 | -function getpaid_invoice_title( $invoice ) { |
|
56 | - if ( ! empty( $invoice ) ) { |
|
57 | - wpinv_get_template( 'invoice/title.php', compact( 'invoice' ) ); |
|
55 | +function getpaid_invoice_title($invoice) { |
|
56 | + if (!empty($invoice)) { |
|
57 | + wpinv_get_template('invoice/title.php', compact('invoice')); |
|
58 | 58 | } |
59 | 59 | } |
60 | -add_action( 'getpaid_invoice_title', 'getpaid_invoice_title' ); |
|
60 | +add_action('getpaid_invoice_title', 'getpaid_invoice_title'); |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Displays the left side of the invoice title. |
64 | 64 | */ |
65 | -function getpaid_invoice_title_left( $invoice ) { |
|
66 | - if ( ! empty( $invoice ) ) { |
|
67 | - wpinv_get_template( 'invoice/title-left.php', compact( 'invoice' ) ); |
|
65 | +function getpaid_invoice_title_left($invoice) { |
|
66 | + if (!empty($invoice)) { |
|
67 | + wpinv_get_template('invoice/title-left.php', compact('invoice')); |
|
68 | 68 | } |
69 | 69 | } |
70 | -add_action( 'getpaid_invoice_title_left', 'getpaid_invoice_title_left' ); |
|
70 | +add_action('getpaid_invoice_title_left', 'getpaid_invoice_title_left'); |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Displays the right side of the invoice title. |
74 | 74 | */ |
75 | -function getpaid_invoice_title_right( $invoice ) { |
|
76 | - if ( ! empty( $invoice ) ) { |
|
77 | - wpinv_get_template( 'invoice/title-right.php', compact( 'invoice' ) ); |
|
75 | +function getpaid_invoice_title_right($invoice) { |
|
76 | + if (!empty($invoice)) { |
|
77 | + wpinv_get_template('invoice/title-right.php', compact('invoice')); |
|
78 | 78 | } |
79 | 79 | } |
80 | -add_action( 'getpaid_invoice_title_right', 'getpaid_invoice_title_right' ); |
|
80 | +add_action('getpaid_invoice_title_right', 'getpaid_invoice_title_right'); |
|
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Displays the invoice details. |
84 | 84 | */ |
85 | -function getpaid_invoice_details( $invoice ) { |
|
86 | - if ( ! empty( $invoice ) ) { |
|
87 | - wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) ); |
|
85 | +function getpaid_invoice_details($invoice) { |
|
86 | + if (!empty($invoice)) { |
|
87 | + wpinv_get_template('invoice/details.php', compact('invoice')); |
|
88 | 88 | } |
89 | 89 | } |
90 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details' ); |
|
90 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details'); |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Displays the left side of the invoice details. |
94 | 94 | */ |
95 | -function getpaid_invoice_details_left( $invoice ) { |
|
96 | - if ( ! empty( $invoice ) ) { |
|
97 | - wpinv_get_template( 'invoice/details-left.php', compact( 'invoice' ) ); |
|
95 | +function getpaid_invoice_details_left($invoice) { |
|
96 | + if (!empty($invoice)) { |
|
97 | + wpinv_get_template('invoice/details-left.php', compact('invoice')); |
|
98 | 98 | } |
99 | 99 | } |
100 | -add_action( 'getpaid_invoice_details_left', 'getpaid_invoice_details_left' ); |
|
100 | +add_action('getpaid_invoice_details_left', 'getpaid_invoice_details_left'); |
|
101 | 101 | |
102 | 102 | /** |
103 | 103 | * Displays the right side of the invoice details. |
104 | 104 | */ |
105 | -function getpaid_invoice_details_right( $invoice ) { |
|
106 | - if ( ! empty( $invoice ) ) { |
|
107 | - wpinv_get_template( 'invoice/details-right.php', compact( 'invoice' ) ); |
|
105 | +function getpaid_invoice_details_right($invoice) { |
|
106 | + if (!empty($invoice)) { |
|
107 | + wpinv_get_template('invoice/details-right.php', compact('invoice')); |
|
108 | 108 | } |
109 | 109 | } |
110 | -add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_details_right' ); |
|
110 | +add_action('getpaid_invoice_details_right', 'getpaid_invoice_details_right'); |
|
111 | 111 | |
112 | -function wpinv_before_invoice_content( $content ) { |
|
112 | +function wpinv_before_invoice_content($content) { |
|
113 | 113 | global $post; |
114 | 114 | |
115 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
115 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
116 | 116 | ob_start(); |
117 | - do_action( 'wpinv_before_invoice_content', $post->ID ); |
|
117 | + do_action('wpinv_before_invoice_content', $post->ID); |
|
118 | 118 | $content = ob_get_clean() . $content; |
119 | 119 | } |
120 | 120 | |
121 | 121 | return $content; |
122 | 122 | } |
123 | -add_filter( 'the_content', 'wpinv_before_invoice_content' ); |
|
123 | +add_filter('the_content', 'wpinv_before_invoice_content'); |
|
124 | 124 | |
125 | -function wpinv_after_invoice_content( $content ) { |
|
125 | +function wpinv_after_invoice_content($content) { |
|
126 | 126 | global $post; |
127 | 127 | |
128 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
128 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
129 | 129 | ob_start(); |
130 | - do_action( 'wpinv_after_invoice_content', $post->ID ); |
|
130 | + do_action('wpinv_after_invoice_content', $post->ID); |
|
131 | 131 | $content .= ob_get_clean(); |
132 | 132 | } |
133 | 133 | |
134 | 134 | return $content; |
135 | 135 | } |
136 | -add_filter( 'the_content', 'wpinv_after_invoice_content' ); |
|
136 | +add_filter('the_content', 'wpinv_after_invoice_content'); |
|
137 | 137 | |
138 | 138 | function wpinv_get_templates_dir() { |
139 | 139 | return WPINV_PLUGIN_DIR . 'templates'; |
@@ -143,105 +143,105 @@ discard block |
||
143 | 143 | return WPINV_PLUGIN_URL . 'templates'; |
144 | 144 | } |
145 | 145 | |
146 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
147 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
148 | - extract( $args ); |
|
146 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
147 | + if (!empty($args) && is_array($args)) { |
|
148 | + extract($args); |
|
149 | 149 | } |
150 | 150 | |
151 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
151 | + $located = wpinv_locate_template($template_name, $template_path, $default_path); |
|
152 | 152 | // Allow 3rd party plugin filter template file from their plugin. |
153 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
153 | + $located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
154 | 154 | |
155 | - if ( ! file_exists( $located ) ) { |
|
156 | - _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
|
155 | + if (!file_exists($located)) { |
|
156 | + _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1'); |
|
157 | 157 | return; |
158 | 158 | } |
159 | 159 | |
160 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
160 | + do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args); |
|
161 | 161 | |
162 | - include( $located ); |
|
162 | + include($located); |
|
163 | 163 | |
164 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
164 | + do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args); |
|
165 | 165 | } |
166 | 166 | |
167 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
167 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
168 | 168 | ob_start(); |
169 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
169 | + wpinv_get_template($template_name, $args, $template_path, $default_path); |
|
170 | 170 | return ob_get_clean(); |
171 | 171 | } |
172 | 172 | |
173 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
174 | - if ( ! $template_path ) { |
|
173 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
174 | + if (!$template_path) { |
|
175 | 175 | $template_path = wpinv_template_path(); |
176 | 176 | } |
177 | 177 | |
178 | - if ( ! $default_path ) { |
|
178 | + if (!$default_path) { |
|
179 | 179 | $default_path = WPINV_PLUGIN_DIR . 'templates/'; |
180 | 180 | } |
181 | 181 | |
182 | 182 | // Look within passed path within the theme - this is priority. |
183 | 183 | $template = locate_template( |
184 | 184 | array( |
185 | - trailingslashit( $template_path ) . $template_name, |
|
185 | + trailingslashit($template_path) . $template_name, |
|
186 | 186 | $template_name |
187 | 187 | ) |
188 | 188 | ); |
189 | 189 | |
190 | 190 | // Get default templates/ |
191 | - if ( !$template && $default_path ) { |
|
192 | - $template = trailingslashit( $default_path ) . $template_name; |
|
191 | + if (!$template && $default_path) { |
|
192 | + $template = trailingslashit($default_path) . $template_name; |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | // Return what we found. |
196 | - return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path ); |
|
196 | + return apply_filters('wpinv_locate_template', $template, $template_name, $template_path); |
|
197 | 197 | } |
198 | 198 | |
199 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
200 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
199 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
200 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
201 | 201 | |
202 | 202 | // Setup possible parts |
203 | 203 | $templates = array(); |
204 | - if ( isset( $name ) ) |
|
204 | + if (isset($name)) |
|
205 | 205 | $templates[] = $slug . '-' . $name . '.php'; |
206 | 206 | $templates[] = $slug . '.php'; |
207 | 207 | |
208 | 208 | // Allow template parts to be filtered |
209 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
209 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
210 | 210 | |
211 | 211 | // Return the part that is found |
212 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
212 | + return wpinv_locate_tmpl($templates, $load, false); |
|
213 | 213 | } |
214 | 214 | |
215 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
215 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
216 | 216 | // No file found yet |
217 | 217 | $located = false; |
218 | 218 | |
219 | 219 | // Try to find a template file |
220 | - foreach ( (array)$template_names as $template_name ) { |
|
220 | + foreach ((array) $template_names as $template_name) { |
|
221 | 221 | |
222 | 222 | // Continue if template is empty |
223 | - if ( empty( $template_name ) ) |
|
223 | + if (empty($template_name)) |
|
224 | 224 | continue; |
225 | 225 | |
226 | 226 | // Trim off any slashes from the template name |
227 | - $template_name = ltrim( $template_name, '/' ); |
|
227 | + $template_name = ltrim($template_name, '/'); |
|
228 | 228 | |
229 | 229 | // try locating this template file by looping through the template paths |
230 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
230 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
231 | 231 | |
232 | - if( file_exists( $template_path . $template_name ) ) { |
|
232 | + if (file_exists($template_path . $template_name)) { |
|
233 | 233 | $located = $template_path . $template_name; |
234 | 234 | break; |
235 | 235 | } |
236 | 236 | } |
237 | 237 | |
238 | - if( !empty( $located ) ) { |
|
238 | + if (!empty($located)) { |
|
239 | 239 | break; |
240 | 240 | } |
241 | 241 | } |
242 | 242 | |
243 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
244 | - load_template( $located, $require_once ); |
|
243 | + if ((true == $load) && !empty($located)) |
|
244 | + load_template($located, $require_once); |
|
245 | 245 | |
246 | 246 | return $located; |
247 | 247 | } |
@@ -250,159 +250,159 @@ discard block |
||
250 | 250 | $template_dir = wpinv_get_theme_template_dir_name(); |
251 | 251 | |
252 | 252 | $file_paths = array( |
253 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
254 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
253 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
254 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
255 | 255 | 100 => wpinv_get_templates_dir() |
256 | 256 | ); |
257 | 257 | |
258 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
258 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
259 | 259 | |
260 | 260 | // sort the file paths based on priority |
261 | - ksort( $file_paths, SORT_NUMERIC ); |
|
261 | + ksort($file_paths, SORT_NUMERIC); |
|
262 | 262 | |
263 | - return array_map( 'trailingslashit', $file_paths ); |
|
263 | + return array_map('trailingslashit', $file_paths); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | function wpinv_get_theme_template_dir_name() { |
267 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
267 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | function wpinv_checkout_meta_tags() { |
271 | 271 | |
272 | 272 | $pages = array(); |
273 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
274 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
275 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
276 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
273 | + $pages[] = wpinv_get_option('success_page'); |
|
274 | + $pages[] = wpinv_get_option('failure_page'); |
|
275 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
276 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
277 | 277 | |
278 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
278 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
279 | 279 | return; |
280 | 280 | } |
281 | 281 | |
282 | 282 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
283 | 283 | } |
284 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
284 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
285 | 285 | |
286 | -function wpinv_add_body_classes( $class ) { |
|
287 | - $classes = (array)$class; |
|
286 | +function wpinv_add_body_classes($class) { |
|
287 | + $classes = (array) $class; |
|
288 | 288 | |
289 | - if( wpinv_is_checkout() ) { |
|
289 | + if (wpinv_is_checkout()) { |
|
290 | 290 | $classes[] = 'wpinv-checkout'; |
291 | 291 | $classes[] = 'wpinv-page'; |
292 | 292 | } |
293 | 293 | |
294 | - if( wpinv_is_success_page() ) { |
|
294 | + if (wpinv_is_success_page()) { |
|
295 | 295 | $classes[] = 'wpinv-success'; |
296 | 296 | $classes[] = 'wpinv-page'; |
297 | 297 | } |
298 | 298 | |
299 | - if( wpinv_is_failed_transaction_page() ) { |
|
299 | + if (wpinv_is_failed_transaction_page()) { |
|
300 | 300 | $classes[] = 'wpinv-failed-transaction'; |
301 | 301 | $classes[] = 'wpinv-page'; |
302 | 302 | } |
303 | 303 | |
304 | - if( wpinv_is_invoice_history_page() ) { |
|
304 | + if (wpinv_is_invoice_history_page()) { |
|
305 | 305 | $classes[] = 'wpinv-history'; |
306 | 306 | $classes[] = 'wpinv-page'; |
307 | 307 | } |
308 | 308 | |
309 | - if( wpinv_is_subscriptions_history_page() ) { |
|
309 | + if (wpinv_is_subscriptions_history_page()) { |
|
310 | 310 | $classes[] = 'wpinv-subscription'; |
311 | 311 | $classes[] = 'wpinv-page'; |
312 | 312 | } |
313 | 313 | |
314 | - if( wpinv_is_test_mode() ) { |
|
314 | + if (wpinv_is_test_mode()) { |
|
315 | 315 | $classes[] = 'wpinv-test-mode'; |
316 | 316 | $classes[] = 'wpinv-page'; |
317 | 317 | } |
318 | 318 | |
319 | - return array_unique( $classes ); |
|
319 | + return array_unique($classes); |
|
320 | 320 | } |
321 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
321 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
322 | 322 | |
323 | -function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
|
324 | - $args = array( 'nopaging' => true ); |
|
323 | +function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') { |
|
324 | + $args = array('nopaging' => true); |
|
325 | 325 | |
326 | - if ( ! empty( $status ) ) |
|
326 | + if (!empty($status)) |
|
327 | 327 | $args['post_status'] = $status; |
328 | 328 | |
329 | - $discounts = wpinv_get_discounts( $args ); |
|
329 | + $discounts = wpinv_get_discounts($args); |
|
330 | 330 | $options = array(); |
331 | 331 | |
332 | - if ( $discounts ) { |
|
333 | - foreach ( $discounts as $discount ) { |
|
334 | - $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) ); |
|
332 | + if ($discounts) { |
|
333 | + foreach ($discounts as $discount) { |
|
334 | + $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID)); |
|
335 | 335 | } |
336 | 336 | } else { |
337 | - $options[0] = __( 'No discounts found', 'invoicing' ); |
|
337 | + $options[0] = __('No discounts found', 'invoicing'); |
|
338 | 338 | } |
339 | 339 | |
340 | - $output = wpinv_html_select( array( |
|
340 | + $output = wpinv_html_select(array( |
|
341 | 341 | 'name' => $name, |
342 | 342 | 'selected' => $selected, |
343 | 343 | 'options' => $options, |
344 | 344 | 'show_option_all' => false, |
345 | 345 | 'show_option_none' => false, |
346 | - ) ); |
|
346 | + )); |
|
347 | 347 | |
348 | 348 | return $output; |
349 | 349 | } |
350 | 350 | |
351 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
352 | - $current = date( 'Y' ); |
|
353 | - $start_year = $current - absint( $years_before ); |
|
354 | - $end_year = $current + absint( $years_after ); |
|
355 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
351 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
352 | + $current = date('Y'); |
|
353 | + $start_year = $current - absint($years_before); |
|
354 | + $end_year = $current + absint($years_after); |
|
355 | + $selected = empty($selected) ? date('Y') : $selected; |
|
356 | 356 | $options = array(); |
357 | 357 | |
358 | - while ( $start_year <= $end_year ) { |
|
359 | - $options[ absint( $start_year ) ] = $start_year; |
|
358 | + while ($start_year <= $end_year) { |
|
359 | + $options[absint($start_year)] = $start_year; |
|
360 | 360 | $start_year++; |
361 | 361 | } |
362 | 362 | |
363 | - $output = wpinv_html_select( array( |
|
363 | + $output = wpinv_html_select(array( |
|
364 | 364 | 'name' => $name, |
365 | 365 | 'selected' => $selected, |
366 | 366 | 'options' => $options, |
367 | 367 | 'show_option_all' => false, |
368 | 368 | 'show_option_none' => false |
369 | - ) ); |
|
369 | + )); |
|
370 | 370 | |
371 | 371 | return $output; |
372 | 372 | } |
373 | 373 | |
374 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
374 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
375 | 375 | |
376 | 376 | $options = array( |
377 | - '1' => __( 'January', 'invoicing' ), |
|
378 | - '2' => __( 'February', 'invoicing' ), |
|
379 | - '3' => __( 'March', 'invoicing' ), |
|
380 | - '4' => __( 'April', 'invoicing' ), |
|
381 | - '5' => __( 'May', 'invoicing' ), |
|
382 | - '6' => __( 'June', 'invoicing' ), |
|
383 | - '7' => __( 'July', 'invoicing' ), |
|
384 | - '8' => __( 'August', 'invoicing' ), |
|
385 | - '9' => __( 'September', 'invoicing' ), |
|
386 | - '10' => __( 'October', 'invoicing' ), |
|
387 | - '11' => __( 'November', 'invoicing' ), |
|
388 | - '12' => __( 'December', 'invoicing' ), |
|
377 | + '1' => __('January', 'invoicing'), |
|
378 | + '2' => __('February', 'invoicing'), |
|
379 | + '3' => __('March', 'invoicing'), |
|
380 | + '4' => __('April', 'invoicing'), |
|
381 | + '5' => __('May', 'invoicing'), |
|
382 | + '6' => __('June', 'invoicing'), |
|
383 | + '7' => __('July', 'invoicing'), |
|
384 | + '8' => __('August', 'invoicing'), |
|
385 | + '9' => __('September', 'invoicing'), |
|
386 | + '10' => __('October', 'invoicing'), |
|
387 | + '11' => __('November', 'invoicing'), |
|
388 | + '12' => __('December', 'invoicing'), |
|
389 | 389 | ); |
390 | 390 | |
391 | 391 | // If no month is selected, default to the current month |
392 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
392 | + $selected = empty($selected) ? date('n') : $selected; |
|
393 | 393 | |
394 | - $output = wpinv_html_select( array( |
|
394 | + $output = wpinv_html_select(array( |
|
395 | 395 | 'name' => $name, |
396 | 396 | 'selected' => $selected, |
397 | 397 | 'options' => $options, |
398 | 398 | 'show_option_all' => false, |
399 | 399 | 'show_option_none' => false |
400 | - ) ); |
|
400 | + )); |
|
401 | 401 | |
402 | 402 | return $output; |
403 | 403 | } |
404 | 404 | |
405 | -function wpinv_html_select( $args = array() ) { |
|
405 | +function wpinv_html_select($args = array()) { |
|
406 | 406 | $defaults = array( |
407 | 407 | 'options' => array(), |
408 | 408 | 'name' => null, |
@@ -411,8 +411,8 @@ discard block |
||
411 | 411 | 'selected' => 0, |
412 | 412 | 'placeholder' => null, |
413 | 413 | 'multiple' => false, |
414 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
415 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
414 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
415 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
416 | 416 | 'data' => array(), |
417 | 417 | 'onchange' => null, |
418 | 418 | 'required' => false, |
@@ -420,74 +420,74 @@ discard block |
||
420 | 420 | 'readonly' => false, |
421 | 421 | ); |
422 | 422 | |
423 | - $args = wp_parse_args( $args, $defaults ); |
|
423 | + $args = wp_parse_args($args, $defaults); |
|
424 | 424 | |
425 | 425 | $data_elements = ''; |
426 | - foreach ( $args['data'] as $key => $value ) { |
|
427 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
426 | + foreach ($args['data'] as $key => $value) { |
|
427 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
428 | 428 | } |
429 | 429 | |
430 | - if( $args['multiple'] ) { |
|
430 | + if ($args['multiple']) { |
|
431 | 431 | $multiple = ' MULTIPLE'; |
432 | 432 | } else { |
433 | 433 | $multiple = ''; |
434 | 434 | } |
435 | 435 | |
436 | - if( $args['placeholder'] ) { |
|
436 | + if ($args['placeholder']) { |
|
437 | 437 | $placeholder = $args['placeholder']; |
438 | 438 | } else { |
439 | 439 | $placeholder = ''; |
440 | 440 | } |
441 | 441 | |
442 | 442 | $options = ''; |
443 | - if( !empty( $args['onchange'] ) ) { |
|
444 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
443 | + if (!empty($args['onchange'])) { |
|
444 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
445 | 445 | } |
446 | 446 | |
447 | - if( !empty( $args['required'] ) ) { |
|
447 | + if (!empty($args['required'])) { |
|
448 | 448 | $options .= ' required="required"'; |
449 | 449 | } |
450 | 450 | |
451 | - if( !empty( $args['disabled'] ) ) { |
|
451 | + if (!empty($args['disabled'])) { |
|
452 | 452 | $options .= ' disabled'; |
453 | 453 | } |
454 | 454 | |
455 | - if( !empty( $args['readonly'] ) ) { |
|
455 | + if (!empty($args['readonly'])) { |
|
456 | 456 | $options .= ' readonly'; |
457 | 457 | } |
458 | 458 | |
459 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
460 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
459 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
460 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
461 | 461 | |
462 | - if ( $args['show_option_all'] ) { |
|
463 | - if( $args['multiple'] ) { |
|
464 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
462 | + if ($args['show_option_all']) { |
|
463 | + if ($args['multiple']) { |
|
464 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
465 | 465 | } else { |
466 | - $selected = selected( $args['selected'], 0, false ); |
|
466 | + $selected = selected($args['selected'], 0, false); |
|
467 | 467 | } |
468 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
468 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
469 | 469 | } |
470 | 470 | |
471 | - if ( !empty( $args['options'] ) ) { |
|
471 | + if (!empty($args['options'])) { |
|
472 | 472 | |
473 | - if ( $args['show_option_none'] ) { |
|
474 | - if( $args['multiple'] ) { |
|
475 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
473 | + if ($args['show_option_none']) { |
|
474 | + if ($args['multiple']) { |
|
475 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
476 | 476 | } else { |
477 | - $selected = selected( $args['selected'] === "", true, false ); |
|
477 | + $selected = selected($args['selected'] === "", true, false); |
|
478 | 478 | } |
479 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
479 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
480 | 480 | } |
481 | 481 | |
482 | - foreach( $args['options'] as $key => $option ) { |
|
482 | + foreach ($args['options'] as $key => $option) { |
|
483 | 483 | |
484 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
485 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
484 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
485 | + $selected = selected(true, (bool) in_array($key, $args['selected']), false); |
|
486 | 486 | } else { |
487 | - $selected = selected( $args['selected'], $key, false ); |
|
487 | + $selected = selected($args['selected'], $key, false); |
|
488 | 488 | } |
489 | 489 | |
490 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
490 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
491 | 491 | } |
492 | 492 | } |
493 | 493 | |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | return $output; |
497 | 497 | } |
498 | 498 | |
499 | -function wpinv_item_dropdown( $args = array() ) { |
|
499 | +function wpinv_item_dropdown($args = array()) { |
|
500 | 500 | $defaults = array( |
501 | 501 | 'name' => 'wpi_item', |
502 | 502 | 'id' => 'wpi_item', |
@@ -504,14 +504,14 @@ discard block |
||
504 | 504 | 'multiple' => false, |
505 | 505 | 'selected' => 0, |
506 | 506 | 'number' => 100, |
507 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
508 | - 'data' => array( 'search-type' => 'item' ), |
|
507 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
508 | + 'data' => array('search-type' => 'item'), |
|
509 | 509 | 'show_option_all' => false, |
510 | 510 | 'show_option_none' => false, |
511 | 511 | 'show_recurring' => false, |
512 | 512 | ); |
513 | 513 | |
514 | - $args = wp_parse_args( $args, $defaults ); |
|
514 | + $args = wp_parse_args($args, $defaults); |
|
515 | 515 | |
516 | 516 | $item_args = array( |
517 | 517 | 'post_type' => 'wpi_item', |
@@ -520,44 +520,44 @@ discard block |
||
520 | 520 | 'posts_per_page' => $args['number'] |
521 | 521 | ); |
522 | 522 | |
523 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
523 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
524 | 524 | |
525 | - $items = get_posts( $item_args ); |
|
525 | + $items = get_posts($item_args); |
|
526 | 526 | $options = array(); |
527 | - if ( $items ) { |
|
528 | - foreach ( $items as $item ) { |
|
529 | - $title = esc_html( $item->post_title ); |
|
527 | + if ($items) { |
|
528 | + foreach ($items as $item) { |
|
529 | + $title = esc_html($item->post_title); |
|
530 | 530 | |
531 | - if ( !empty( $args['show_recurring'] ) ) { |
|
532 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
531 | + if (!empty($args['show_recurring'])) { |
|
532 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
533 | 533 | } |
534 | 534 | |
535 | - $options[ absint( $item->ID ) ] = $title; |
|
535 | + $options[absint($item->ID)] = $title; |
|
536 | 536 | } |
537 | 537 | } |
538 | 538 | |
539 | 539 | // This ensures that any selected items are included in the drop down |
540 | - if( is_array( $args['selected'] ) ) { |
|
541 | - foreach( $args['selected'] as $item ) { |
|
542 | - if( ! in_array( $item, $options ) ) { |
|
543 | - $title = get_the_title( $item ); |
|
544 | - if ( !empty( $args['show_recurring'] ) ) { |
|
545 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
540 | + if (is_array($args['selected'])) { |
|
541 | + foreach ($args['selected'] as $item) { |
|
542 | + if (!in_array($item, $options)) { |
|
543 | + $title = get_the_title($item); |
|
544 | + if (!empty($args['show_recurring'])) { |
|
545 | + $title .= wpinv_get_item_suffix($item, false); |
|
546 | 546 | } |
547 | 547 | $options[$item] = $title; |
548 | 548 | } |
549 | 549 | } |
550 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
551 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
552 | - $title = get_the_title( $args['selected'] ); |
|
553 | - if ( !empty( $args['show_recurring'] ) ) { |
|
554 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
550 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
551 | + if (!in_array($args['selected'], $options)) { |
|
552 | + $title = get_the_title($args['selected']); |
|
553 | + if (!empty($args['show_recurring'])) { |
|
554 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
555 | 555 | } |
556 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
556 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
557 | 557 | } |
558 | 558 | } |
559 | 559 | |
560 | - $output = wpinv_html_select( array( |
|
560 | + $output = wpinv_html_select(array( |
|
561 | 561 | 'name' => $args['name'], |
562 | 562 | 'selected' => $args['selected'], |
563 | 563 | 'id' => $args['id'], |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | 'show_option_all' => $args['show_option_all'], |
569 | 569 | 'show_option_none' => $args['show_option_none'], |
570 | 570 | 'data' => $args['data'], |
571 | - ) ); |
|
571 | + )); |
|
572 | 572 | |
573 | 573 | return $output; |
574 | 574 | } |
@@ -588,16 +588,16 @@ discard block |
||
588 | 588 | ); |
589 | 589 | |
590 | 590 | $options = array(); |
591 | - if ( $items ) { |
|
592 | - foreach ( $items as $item ) { |
|
593 | - $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false ); |
|
591 | + if ($items) { |
|
592 | + foreach ($items as $item) { |
|
593 | + $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false); |
|
594 | 594 | } |
595 | 595 | } |
596 | 596 | |
597 | 597 | return $options; |
598 | 598 | } |
599 | 599 | |
600 | -function wpinv_html_checkbox( $args = array() ) { |
|
600 | +function wpinv_html_checkbox($args = array()) { |
|
601 | 601 | $defaults = array( |
602 | 602 | 'name' => null, |
603 | 603 | 'current' => null, |
@@ -608,38 +608,38 @@ discard block |
||
608 | 608 | ) |
609 | 609 | ); |
610 | 610 | |
611 | - $args = wp_parse_args( $args, $defaults ); |
|
611 | + $args = wp_parse_args($args, $defaults); |
|
612 | 612 | |
613 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
613 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
614 | 614 | $options = ''; |
615 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
615 | + if (!empty($args['options']['disabled'])) { |
|
616 | 616 | $options .= ' disabled="disabled"'; |
617 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
617 | + } elseif (!empty($args['options']['readonly'])) { |
|
618 | 618 | $options .= ' readonly'; |
619 | 619 | } |
620 | 620 | |
621 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
621 | + $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
622 | 622 | |
623 | 623 | return $output; |
624 | 624 | } |
625 | 625 | |
626 | -function wpinv_html_text( $args = array() ) { |
|
626 | +function wpinv_html_text($args = array()) { |
|
627 | 627 | // Backwards compatibility |
628 | - if ( func_num_args() > 1 ) { |
|
628 | + if (func_num_args() > 1) { |
|
629 | 629 | $args = func_get_args(); |
630 | 630 | |
631 | 631 | $name = $args[0]; |
632 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
633 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
634 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
632 | + $value = isset($args[1]) ? $args[1] : ''; |
|
633 | + $label = isset($args[2]) ? $args[2] : ''; |
|
634 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | $defaults = array( |
638 | 638 | 'id' => '', |
639 | - 'name' => isset( $name ) ? $name : 'text', |
|
640 | - 'value' => isset( $value ) ? $value : null, |
|
641 | - 'label' => isset( $label ) ? $label : null, |
|
642 | - 'desc' => isset( $desc ) ? $desc : null, |
|
639 | + 'name' => isset($name) ? $name : 'text', |
|
640 | + 'value' => isset($value) ? $value : null, |
|
641 | + 'label' => isset($label) ? $label : null, |
|
642 | + 'desc' => isset($desc) ? $desc : null, |
|
643 | 643 | 'placeholder' => '', |
644 | 644 | 'class' => 'regular-text', |
645 | 645 | 'disabled' => false, |
@@ -649,51 +649,51 @@ discard block |
||
649 | 649 | 'data' => false |
650 | 650 | ); |
651 | 651 | |
652 | - $args = wp_parse_args( $args, $defaults ); |
|
652 | + $args = wp_parse_args($args, $defaults); |
|
653 | 653 | |
654 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
654 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
655 | 655 | $options = ''; |
656 | - if( $args['required'] ) { |
|
656 | + if ($args['required']) { |
|
657 | 657 | $options .= ' required="required"'; |
658 | 658 | } |
659 | - if( $args['readonly'] ) { |
|
659 | + if ($args['readonly']) { |
|
660 | 660 | $options .= ' readonly'; |
661 | 661 | } |
662 | - if( $args['readonly'] ) { |
|
662 | + if ($args['readonly']) { |
|
663 | 663 | $options .= ' readonly'; |
664 | 664 | } |
665 | 665 | |
666 | 666 | $data = ''; |
667 | - if ( !empty( $args['data'] ) ) { |
|
668 | - foreach ( $args['data'] as $key => $value ) { |
|
669 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
667 | + if (!empty($args['data'])) { |
|
668 | + foreach ($args['data'] as $key => $value) { |
|
669 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
670 | 670 | } |
671 | 671 | } |
672 | 672 | |
673 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
674 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
675 | - if ( ! empty( $args['desc'] ) ) { |
|
676 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
673 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
674 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
675 | + if (!empty($args['desc'])) { |
|
676 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
677 | 677 | } |
678 | 678 | |
679 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
679 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
680 | 680 | |
681 | 681 | $output .= '</span>'; |
682 | 682 | |
683 | 683 | return $output; |
684 | 684 | } |
685 | 685 | |
686 | -function wpinv_html_date_field( $args = array() ) { |
|
687 | - if( empty( $args['class'] ) ) { |
|
686 | +function wpinv_html_date_field($args = array()) { |
|
687 | + if (empty($args['class'])) { |
|
688 | 688 | $args['class'] = 'wpiDatepicker'; |
689 | - } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) { |
|
689 | + } elseif (!strpos($args['class'], 'wpiDatepicker')) { |
|
690 | 690 | $args['class'] .= ' wpiDatepicker'; |
691 | 691 | } |
692 | 692 | |
693 | - return wpinv_html_text( $args ); |
|
693 | + return wpinv_html_text($args); |
|
694 | 694 | } |
695 | 695 | |
696 | -function wpinv_html_textarea( $args = array() ) { |
|
696 | +function wpinv_html_textarea($args = array()) { |
|
697 | 697 | $defaults = array( |
698 | 698 | 'name' => 'textarea', |
699 | 699 | 'value' => null, |
@@ -704,31 +704,31 @@ discard block |
||
704 | 704 | 'placeholder' => '', |
705 | 705 | ); |
706 | 706 | |
707 | - $args = wp_parse_args( $args, $defaults ); |
|
707 | + $args = wp_parse_args($args, $defaults); |
|
708 | 708 | |
709 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
709 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
710 | 710 | $disabled = ''; |
711 | - if( $args['disabled'] ) { |
|
711 | + if ($args['disabled']) { |
|
712 | 712 | $disabled = ' disabled="disabled"'; |
713 | 713 | } |
714 | 714 | |
715 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
716 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
717 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
715 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
716 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
717 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
718 | 718 | |
719 | - if ( ! empty( $args['desc'] ) ) { |
|
720 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
719 | + if (!empty($args['desc'])) { |
|
720 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
721 | 721 | } |
722 | 722 | $output .= '</span>'; |
723 | 723 | |
724 | 724 | return $output; |
725 | 725 | } |
726 | 726 | |
727 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
727 | +function wpinv_html_ajax_user_search($args = array()) { |
|
728 | 728 | $defaults = array( |
729 | 729 | 'name' => 'user_id', |
730 | 730 | 'value' => null, |
731 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
731 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
732 | 732 | 'label' => null, |
733 | 733 | 'desc' => null, |
734 | 734 | 'class' => '', |
@@ -737,13 +737,13 @@ discard block |
||
737 | 737 | 'data' => false |
738 | 738 | ); |
739 | 739 | |
740 | - $args = wp_parse_args( $args, $defaults ); |
|
740 | + $args = wp_parse_args($args, $defaults); |
|
741 | 741 | |
742 | 742 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
743 | 743 | |
744 | 744 | $output = '<span class="wpinv_user_search_wrap">'; |
745 | - $output .= wpinv_html_text( $args ); |
|
746 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
745 | + $output .= wpinv_html_text($args); |
|
746 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
747 | 747 | $output .= '</span>'; |
748 | 748 | |
749 | 749 | return $output; |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | function wpinv_ip_geolocation() { |
753 | 753 | global $wpinv_euvat; |
754 | 754 | |
755 | - $ip = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : ''; |
|
755 | + $ip = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : ''; |
|
756 | 756 | $content = ''; |
757 | 757 | $iso = ''; |
758 | 758 | $country = ''; |
@@ -763,69 +763,69 @@ discard block |
||
763 | 763 | $credit = ''; |
764 | 764 | $address = ''; |
765 | 765 | |
766 | - if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) { |
|
766 | + if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) { |
|
767 | 767 | try { |
768 | 768 | $iso = $geoip2_city->country->isoCode; |
769 | 769 | $country = $geoip2_city->country->name; |
770 | - $region = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : ''; |
|
770 | + $region = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : ''; |
|
771 | 771 | $city = $geoip2_city->city->name; |
772 | 772 | $longitude = $geoip2_city->location->longitude; |
773 | 773 | $latitude = $geoip2_city->location->latitude; |
774 | - $credit = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' ); |
|
775 | - } catch( Exception $e ) { } |
|
774 | + $credit = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing'); |
|
775 | + } catch (Exception $e) { } |
|
776 | 776 | } |
777 | 777 | |
778 | - if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) { |
|
778 | + if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) { |
|
779 | 779 | try { |
780 | - $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip ); |
|
780 | + $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip); |
|
781 | 781 | |
782 | - if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) { |
|
782 | + if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) { |
|
783 | 783 | $iso = $load_xml->geoplugin_countryCode; |
784 | 784 | $country = $load_xml->geoplugin_countryName; |
785 | - $region = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : ''; |
|
786 | - $city = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : ''; |
|
785 | + $region = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : ''; |
|
786 | + $city = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : ''; |
|
787 | 787 | $longitude = $load_xml->geoplugin_longitude; |
788 | 788 | $latitude = $load_xml->geoplugin_latitude; |
789 | 789 | $credit = $load_xml->geoplugin_credit; |
790 | - $credit = __( 'Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing' ) . '<br>' . $load_xml->geoplugin_credit; |
|
790 | + $credit = __('Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing') . '<br>' . $load_xml->geoplugin_credit; |
|
791 | 791 | } |
792 | - } catch( Exception $e ) { } |
|
792 | + } catch (Exception $e) { } |
|
793 | 793 | } |
794 | 794 | |
795 | - if ( $iso && $longitude && $latitude ) { |
|
796 | - if ( $city ) { |
|
795 | + if ($iso && $longitude && $latitude) { |
|
796 | + if ($city) { |
|
797 | 797 | $address .= $city . ', '; |
798 | 798 | } |
799 | 799 | |
800 | - if ( $region ) { |
|
800 | + if ($region) { |
|
801 | 801 | $address .= $region . ', '; |
802 | 802 | } |
803 | 803 | |
804 | 804 | $address .= $country . ' (' . $iso . ')'; |
805 | - $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>'; |
|
806 | - $content .= '<p>'. $credit . '</p>'; |
|
805 | + $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>'; |
|
806 | + $content .= '<p>' . $credit . '</p>'; |
|
807 | 807 | } else { |
808 | - $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>'; |
|
808 | + $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>'; |
|
809 | 809 | } |
810 | 810 | ?> |
811 | 811 | <!DOCTYPE html> |
812 | -<html><head><title><?php echo sprintf( __( 'IP: %s', 'invoicing' ), $ip );?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
812 | +<html><head><title><?php echo sprintf(__('IP: %s', 'invoicing'), $ip); ?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
813 | 813 | <body> |
814 | - <?php if ( $latitude && $latitude ) { ?> |
|
814 | + <?php if ($latitude && $latitude) { ?> |
|
815 | 815 | <div id="map"></div> |
816 | 816 | <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script> |
817 | 817 | <script type="text/javascript"> |
818 | 818 | var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', |
819 | 819 | osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors', |
820 | 820 | osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), |
821 | - latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>); |
|
821 | + latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>); |
|
822 | 822 | |
823 | 823 | var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]}); |
824 | 824 | |
825 | 825 | var marker = new L.Marker(latlng); |
826 | 826 | map.addLayer(marker); |
827 | 827 | |
828 | - marker.bindPopup("<p><?php esc_attr_e( $address );?></p>"); |
|
828 | + marker.bindPopup("<p><?php esc_attr_e($address); ?></p>"); |
|
829 | 829 | </script> |
830 | 830 | <?php } ?> |
831 | 831 | <div style="height:100px"><?php echo $content; ?></div> |
@@ -833,22 +833,22 @@ discard block |
||
833 | 833 | <?php |
834 | 834 | exit; |
835 | 835 | } |
836 | -add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
837 | -add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
836 | +add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
837 | +add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
838 | 838 | |
839 | 839 | // Set up the template for the invoice. |
840 | -function wpinv_template( $template ) { |
|
840 | +function wpinv_template($template) { |
|
841 | 841 | global $post; |
842 | 842 | |
843 | - if ( ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) { |
|
843 | + if ((is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) { |
|
844 | 844 | |
845 | 845 | // If the user can view this invoice, display it. |
846 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
847 | - return wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
846 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
847 | + return wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
848 | 848 | |
849 | 849 | // Else display an error message. |
850 | 850 | } else { |
851 | - return wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
851 | + return wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | } |
@@ -858,7 +858,7 @@ discard block |
||
858 | 858 | |
859 | 859 | function wpinv_get_business_address() { |
860 | 860 | $business_address = wpinv_store_address(); |
861 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
861 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
862 | 862 | |
863 | 863 | /* |
864 | 864 | $default_country = wpinv_get_default_country(); |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | |
883 | 883 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
884 | 884 | |
885 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
885 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
886 | 886 | } |
887 | 887 | |
888 | 888 | function wpinv_display_from_address() { |
@@ -892,116 +892,116 @@ discard block |
||
892 | 892 | if (empty($from_name)) { |
893 | 893 | $from_name = wpinv_get_business_name(); |
894 | 894 | } |
895 | - ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div> |
|
895 | + ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div> |
|
896 | 896 | <div class="wrapper col-xs-10"> |
897 | - <div class="name"><?php echo esc_html( $from_name ); ?></div> |
|
898 | - <?php if ( $address = wpinv_get_business_address() ) { ?> |
|
899 | - <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div> |
|
897 | + <div class="name"><?php echo esc_html($from_name); ?></div> |
|
898 | + <?php if ($address = wpinv_get_business_address()) { ?> |
|
899 | + <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div> |
|
900 | 900 | <?php } ?> |
901 | - <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?> |
|
902 | - <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?></div> |
|
901 | + <?php if ($email_from = wpinv_mail_get_from_address()) { ?> |
|
902 | + <div class="email_from"><?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?></div> |
|
903 | 903 | <?php } ?> |
904 | 904 | </div> |
905 | 905 | <?php |
906 | 906 | } |
907 | 907 | |
908 | -function wpinv_watermark( $id = 0 ) { |
|
909 | - $output = wpinv_get_watermark( $id ); |
|
908 | +function wpinv_watermark($id = 0) { |
|
909 | + $output = wpinv_get_watermark($id); |
|
910 | 910 | |
911 | - return apply_filters( 'wpinv_get_watermark', $output, $id ); |
|
911 | + return apply_filters('wpinv_get_watermark', $output, $id); |
|
912 | 912 | } |
913 | 913 | |
914 | -function wpinv_get_watermark( $id ) { |
|
915 | - if ( !$id > 0 ) { |
|
914 | +function wpinv_get_watermark($id) { |
|
915 | + if (!$id > 0) { |
|
916 | 916 | return NULL; |
917 | 917 | } |
918 | - $invoice = wpinv_get_invoice( $id ); |
|
918 | + $invoice = wpinv_get_invoice($id); |
|
919 | 919 | |
920 | - if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) { |
|
921 | - if ( $invoice->is_paid() ) { |
|
922 | - return __( 'Paid', 'invoicing' ); |
|
920 | + if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) { |
|
921 | + if ($invoice->is_paid()) { |
|
922 | + return __('Paid', 'invoicing'); |
|
923 | 923 | } |
924 | - if ( $invoice->is_refunded() ) { |
|
925 | - return __( 'Refunded', 'invoicing' ); |
|
924 | + if ($invoice->is_refunded()) { |
|
925 | + return __('Refunded', 'invoicing'); |
|
926 | 926 | } |
927 | - if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) { |
|
928 | - return __( 'Cancelled', 'invoicing' ); |
|
927 | + if ($invoice->has_status(array('wpi-cancelled'))) { |
|
928 | + return __('Cancelled', 'invoicing'); |
|
929 | 929 | } |
930 | 930 | } |
931 | 931 | |
932 | 932 | return NULL; |
933 | 933 | } |
934 | 934 | |
935 | -function wpinv_display_invoice_details( $invoice ) { |
|
935 | +function wpinv_display_invoice_details($invoice) { |
|
936 | 936 | global $wpinv_euvat; |
937 | 937 | |
938 | 938 | $invoice_id = $invoice->ID; |
939 | 939 | $vat_name = $wpinv_euvat->get_vat_name(); |
940 | 940 | $use_taxes = wpinv_use_taxes(); |
941 | 941 | |
942 | - $invoice_status = wpinv_get_invoice_status( $invoice_id ); |
|
942 | + $invoice_status = wpinv_get_invoice_status($invoice_id); |
|
943 | 943 | ?> |
944 | 944 | <table class="table table-bordered table-sm"> |
945 | - <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?> |
|
945 | + <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?> |
|
946 | 946 | <tr class="wpi-row-number"> |
947 | - <th><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></th> |
|
948 | - <td><?php echo esc_html( $invoice_number ); ?></td> |
|
947 | + <th><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></th> |
|
948 | + <td><?php echo esc_html($invoice_number); ?></td> |
|
949 | 949 | </tr> |
950 | 950 | <?php } ?> |
951 | 951 | <tr class="wpi-row-status"> |
952 | - <th><?php echo apply_filters( 'wpinv_invoice_status_label', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></th> |
|
953 | - <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td> |
|
952 | + <th><?php echo apply_filters('wpinv_invoice_status_label', __('Invoice Status', 'invoicing'), $invoice); ?></th> |
|
953 | + <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td> |
|
954 | 954 | </tr> |
955 | - <?php if ( $invoice->is_renewal() ) { ?> |
|
955 | + <?php if ($invoice->is_renewal()) { ?> |
|
956 | 956 | <tr class="wpi-row-parent"> |
957 | - <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></th> |
|
958 | - <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td> |
|
957 | + <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></th> |
|
958 | + <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td> |
|
959 | 959 | </tr> |
960 | 960 | <?php } ?> |
961 | - <?php if ( ( $gateway_name = wpinv_get_payment_gateway_name( $invoice_id ) ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?> |
|
961 | + <?php if (($gateway_name = wpinv_get_payment_gateway_name($invoice_id)) && ($invoice->is_paid() || $invoice->is_refunded())) { ?> |
|
962 | 962 | <tr class="wpi-row-gateway"> |
963 | - <th><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></th> |
|
963 | + <th><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></th> |
|
964 | 964 | <td><?php echo $gateway_name; ?></td> |
965 | 965 | </tr> |
966 | 966 | <?php } ?> |
967 | - <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?> |
|
967 | + <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?> |
|
968 | 968 | <tr class="wpi-row-date"> |
969 | - <th><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></th> |
|
969 | + <th><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></th> |
|
970 | 970 | <td><?php echo $invoice_date; ?></td> |
971 | 971 | </tr> |
972 | 972 | <?php } ?> |
973 | - <?php do_action( 'wpinv_display_details_before_due_date', $invoice_id ); ?> |
|
974 | - <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?> |
|
973 | + <?php do_action('wpinv_display_details_before_due_date', $invoice_id); ?> |
|
974 | + <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?> |
|
975 | 975 | <tr class="wpi-row-date"> |
976 | - <th><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></th> |
|
976 | + <th><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></th> |
|
977 | 977 | <td><?php echo $due_date; ?></td> |
978 | 978 | </tr> |
979 | 979 | <?php } ?> |
980 | - <?php do_action( 'wpinv_display_details_after_due_date', $invoice_id ); ?> |
|
981 | - <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?> |
|
980 | + <?php do_action('wpinv_display_details_after_due_date', $invoice_id); ?> |
|
981 | + <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?> |
|
982 | 982 | <tr class="wpi-row-ovatno"> |
983 | - <th><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th> |
|
983 | + <th><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th> |
|
984 | 984 | <td><?php echo $owner_vat_number; ?></td> |
985 | 985 | </tr> |
986 | 986 | <?php } ?> |
987 | - <?php if ( $use_taxes && ( $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) ) { ?> |
|
987 | + <?php if ($use_taxes && ($user_vat_number = wpinv_get_invoice_vat_number($invoice_id))) { ?> |
|
988 | 988 | <tr class="wpi-row-uvatno"> |
989 | - <th><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th> |
|
989 | + <th><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th> |
|
990 | 990 | <td><?php echo $user_vat_number; ?></td> |
991 | 991 | </tr> |
992 | 992 | <?php } ?> |
993 | 993 | <tr class="table-active tr-total wpi-row-total"> |
994 | - <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th> |
|
995 | - <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td> |
|
994 | + <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th> |
|
995 | + <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td> |
|
996 | 996 | </tr> |
997 | - <?php if ( $subscription = wpinv_get_subscription( $invoice_id ) ) { ?> |
|
997 | + <?php if ($subscription = wpinv_get_subscription($invoice_id)) { ?> |
|
998 | 998 | <tr class="table-active wpi-row-recurring-total"> |
999 | - <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Recurring Amount', 'invoicing' ), $invoice ); ?></th> |
|
1000 | - <td><strong><?php echo wpinv_price( wpinv_format_amount( $subscription->recurring_amount ), $invoice->get_currency() ); ?></strong></td> |
|
999 | + <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Recurring Amount', 'invoicing'), $invoice); ?></th> |
|
1000 | + <td><strong><?php echo wpinv_price(wpinv_format_amount($subscription->recurring_amount), $invoice->get_currency()); ?></strong></td> |
|
1001 | 1001 | </tr> |
1002 | 1002 | <tr class="wpi-row-expires"> |
1003 | - <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Renews On', 'invoicing' ), $invoice ); ?></th> |
|
1004 | - <td><?php echo sanitize_text_field( $subscription->expiration ); ?></td> |
|
1003 | + <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Renews On', 'invoicing'), $invoice); ?></th> |
|
1004 | + <td><?php echo sanitize_text_field($subscription->expiration); ?></td> |
|
1005 | 1005 | </tr> |
1006 | 1006 | <?php } ?> |
1007 | 1007 | </table> |
@@ -1018,69 +1018,69 @@ discard block |
||
1018 | 1018 | * @param string $separator How to separate address lines. |
1019 | 1019 | * @return string |
1020 | 1020 | */ |
1021 | -function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) { |
|
1021 | +function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') { |
|
1022 | 1022 | |
1023 | 1023 | // Retrieve the address markup... |
1024 | - $country= empty( $billing_details['country'] ) ? '' : $billing_details['country']; |
|
1025 | - $format = wpinv_get_full_address_format( $country ); |
|
1024 | + $country = empty($billing_details['country']) ? '' : $billing_details['country']; |
|
1025 | + $format = wpinv_get_full_address_format($country); |
|
1026 | 1026 | |
1027 | 1027 | // ... and the replacements. |
1028 | - $replacements = wpinv_get_invoice_address_replacements( $billing_details ); |
|
1028 | + $replacements = wpinv_get_invoice_address_replacements($billing_details); |
|
1029 | 1029 | |
1030 | - $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
|
1030 | + $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format); |
|
1031 | 1031 | |
1032 | 1032 | // Remove unavailable tags. |
1033 | - $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address ); |
|
1033 | + $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address); |
|
1034 | 1034 | |
1035 | 1035 | // Clean up white space. |
1036 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
1037 | - $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
|
1036 | + $formatted_address = preg_replace('/ +/', ' ', trim($formatted_address)); |
|
1037 | + $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address); |
|
1038 | 1038 | |
1039 | 1039 | // Break newlines apart and remove empty lines/trim commas and white space. |
1040 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
1040 | + $formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address))); |
|
1041 | 1041 | |
1042 | 1042 | // Add html breaks. |
1043 | - $formatted_address = implode( $separator, $formatted_address ); |
|
1043 | + $formatted_address = implode($separator, $formatted_address); |
|
1044 | 1044 | |
1045 | 1045 | // We're done! |
1046 | 1046 | return $formatted_address; |
1047 | 1047 | |
1048 | 1048 | } |
1049 | 1049 | |
1050 | -function wpinv_display_to_address( $invoice_id = 0 ) { |
|
1051 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1050 | +function wpinv_display_to_address($invoice_id = 0) { |
|
1051 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1052 | 1052 | |
1053 | - if ( empty( $invoice ) ) { |
|
1053 | + if (empty($invoice)) { |
|
1054 | 1054 | return NULL; |
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | $billing_details = $invoice->get_user_info(); |
1058 | - $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>'; |
|
1058 | + $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>'; |
|
1059 | 1059 | $output .= '<div class="wrapper col-xs-10">'; |
1060 | 1060 | |
1061 | 1061 | ob_start(); |
1062 | - do_action( 'wpinv_display_to_address_top', $invoice ); |
|
1062 | + do_action('wpinv_display_to_address_top', $invoice); |
|
1063 | 1063 | $output .= ob_get_clean(); |
1064 | 1064 | |
1065 | - $address_row = wpinv_get_invoice_address_markup( $billing_details ); |
|
1065 | + $address_row = wpinv_get_invoice_address_markup($billing_details); |
|
1066 | 1066 | |
1067 | - if ( $address_row ) { |
|
1067 | + if ($address_row) { |
|
1068 | 1068 | $output .= '<div class="address">' . $address_row . '</div>'; |
1069 | 1069 | } |
1070 | 1070 | |
1071 | - if ( $phone = $invoice->get_phone() ) { |
|
1072 | - $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ) . '</div>'; |
|
1071 | + if ($phone = $invoice->get_phone()) { |
|
1072 | + $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)) . '</div>'; |
|
1073 | 1073 | } |
1074 | - if ( $email = $invoice->get_email() ) { |
|
1075 | - $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' , 'invoicing'), esc_html( $email ) ) . '</div>'; |
|
1074 | + if ($email = $invoice->get_email()) { |
|
1075 | + $output .= '<div class="email">' . wp_sprintf(__('Email: %s', 'invoicing'), esc_html($email)) . '</div>'; |
|
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | ob_start(); |
1079 | - do_action( 'wpinv_display_to_address_bottom', $invoice ); |
|
1079 | + do_action('wpinv_display_to_address_bottom', $invoice); |
|
1080 | 1080 | $output .= ob_get_clean(); |
1081 | 1081 | |
1082 | 1082 | $output .= '</div>'; |
1083 | - $output = apply_filters( 'wpinv_display_to_address', $output, $invoice ); |
|
1083 | + $output = apply_filters('wpinv_display_to_address', $output, $invoice); |
|
1084 | 1084 | |
1085 | 1085 | echo $output; |
1086 | 1086 | } |
@@ -1088,72 +1088,72 @@ discard block |
||
1088 | 1088 | /** |
1089 | 1089 | * Displays invoice line items. |
1090 | 1090 | */ |
1091 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
1091 | +function wpinv_display_line_items($invoice_id = 0) { |
|
1092 | 1092 | |
1093 | 1093 | // Prepare the invoice. |
1094 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
1094 | + $invoice = new WPInv_Invoice($invoice_id); |
|
1095 | 1095 | |
1096 | 1096 | // Abort if there is no invoice. |
1097 | - if ( ! $invoice->get_id() ) { |
|
1097 | + if (!$invoice->get_id()) { |
|
1098 | 1098 | return; |
1099 | 1099 | } |
1100 | 1100 | |
1101 | - wpinv_get_template( 'line-items.php', compact( 'invoice' ) ); |
|
1101 | + wpinv_get_template('line-items.php', compact('invoice')); |
|
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | /** |
1105 | 1105 | * @param WPInv_Invoice $invoice |
1106 | 1106 | */ |
1107 | -function wpinv_display_invoice_notes( $invoice ) { |
|
1107 | +function wpinv_display_invoice_notes($invoice) { |
|
1108 | 1108 | |
1109 | - $notes = wpinv_get_invoice_notes( $invoice->ID, 'customer' ); |
|
1109 | + $notes = wpinv_get_invoice_notes($invoice->ID, 'customer'); |
|
1110 | 1110 | |
1111 | - if ( empty( $notes ) ) { |
|
1111 | + if (empty($notes)) { |
|
1112 | 1112 | return; |
1113 | 1113 | } |
1114 | 1114 | |
1115 | 1115 | echo '<div class="wpi_invoice_notes_container">'; |
1116 | - echo '<h2>' . __( 'Invoice Notes', 'invoicing' ) .'</h2>'; |
|
1116 | + echo '<h2>' . __('Invoice Notes', 'invoicing') . '</h2>'; |
|
1117 | 1117 | echo '<ul class="wpi_invoice_notes">'; |
1118 | 1118 | |
1119 | - foreach( $notes as $note ) { |
|
1120 | - wpinv_get_invoice_note_line_item( $note ); |
|
1119 | + foreach ($notes as $note) { |
|
1120 | + wpinv_get_invoice_note_line_item($note); |
|
1121 | 1121 | } |
1122 | 1122 | |
1123 | 1123 | echo '</ul>'; |
1124 | 1124 | echo '</div>'; |
1125 | 1125 | } |
1126 | -add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_display_invoice_notes' ); |
|
1126 | +add_action('wpinv_invoice_print_after_line_items', 'wpinv_display_invoice_notes'); |
|
1127 | 1127 | |
1128 | -function wpinv_display_invoice_totals( $invoice_id = 0 ) { |
|
1128 | +function wpinv_display_invoice_totals($invoice_id = 0) { |
|
1129 | 1129 | $use_taxes = wpinv_use_taxes(); |
1130 | 1130 | |
1131 | - do_action( 'wpinv_before_display_totals_table', $invoice_id ); |
|
1131 | + do_action('wpinv_before_display_totals_table', $invoice_id); |
|
1132 | 1132 | ?> |
1133 | 1133 | <table class="table table-sm table-bordered table-responsive"> |
1134 | 1134 | <tbody> |
1135 | - <?php do_action( 'wpinv_before_display_totals' ); ?> |
|
1135 | + <?php do_action('wpinv_before_display_totals'); ?> |
|
1136 | 1136 | <tr class="row-sub-total"> |
1137 | - <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td> |
|
1138 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
1137 | + <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td> |
|
1138 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
1139 | 1139 | </tr> |
1140 | - <?php do_action( 'wpinv_after_display_totals' ); ?> |
|
1141 | - <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?> |
|
1140 | + <?php do_action('wpinv_after_display_totals'); ?> |
|
1141 | + <?php if (wpinv_discount($invoice_id, false) > 0) { ?> |
|
1142 | 1142 | <tr class="row-discount"> |
1143 | - <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td> |
|
1144 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
1143 | + <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td> |
|
1144 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
1145 | 1145 | </tr> |
1146 | - <?php do_action( 'wpinv_after_display_discount' ); ?> |
|
1146 | + <?php do_action('wpinv_after_display_discount'); ?> |
|
1147 | 1147 | <?php } ?> |
1148 | - <?php if ( $use_taxes ) { ?> |
|
1148 | + <?php if ($use_taxes) { ?> |
|
1149 | 1149 | <tr class="row-tax"> |
1150 | - <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td> |
|
1151 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
1150 | + <td class="rate"><?php _e('Tax', 'invoicing'); ?></td> |
|
1151 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
1152 | 1152 | </tr> |
1153 | - <?php do_action( 'wpinv_after_display_tax' ); ?> |
|
1153 | + <?php do_action('wpinv_after_display_tax'); ?> |
|
1154 | 1154 | <?php } ?> |
1155 | - <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?> |
|
1156 | - <?php foreach ( $fees as $fee ) { ?> |
|
1155 | + <?php if ($fees = wpinv_get_fees($invoice_id)) { ?> |
|
1156 | + <?php foreach ($fees as $fee) { ?> |
|
1157 | 1157 | <tr class="row-fee"> |
1158 | 1158 | <td class="rate"><?php echo $fee['label']; ?></td> |
1159 | 1159 | <td class="total"><?php echo $fee['amount_display']; ?></td> |
@@ -1161,36 +1161,36 @@ discard block |
||
1161 | 1161 | <?php } ?> |
1162 | 1162 | <?php } ?> |
1163 | 1163 | <tr class="table-active row-total"> |
1164 | - <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td> |
|
1165 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
1164 | + <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td> |
|
1165 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
1166 | 1166 | </tr> |
1167 | - <?php do_action( 'wpinv_after_totals' ); ?> |
|
1167 | + <?php do_action('wpinv_after_totals'); ?> |
|
1168 | 1168 | </tbody> |
1169 | 1169 | |
1170 | 1170 | </table> |
1171 | 1171 | |
1172 | - <?php do_action( 'wpinv_after_totals_table' ); |
|
1172 | + <?php do_action('wpinv_after_totals_table'); |
|
1173 | 1173 | } |
1174 | 1174 | |
1175 | -function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) { |
|
1176 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1175 | +function wpinv_display_payments_info($invoice_id = 0, $echo = true) { |
|
1176 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1177 | 1177 | |
1178 | 1178 | ob_start(); |
1179 | - do_action( 'wpinv_before_display_payments_info', $invoice_id ); |
|
1180 | - if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
1179 | + do_action('wpinv_before_display_payments_info', $invoice_id); |
|
1180 | + if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid() || $invoice->is_refunded()) { |
|
1181 | 1181 | ?> |
1182 | 1182 | <div class="wpi-payment-info"> |
1183 | - <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p> |
|
1184 | - <?php if ( $gateway_title ) { ?> |
|
1185 | - <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p> |
|
1183 | + <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p> |
|
1184 | + <?php if ($gateway_title) { ?> |
|
1185 | + <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p> |
|
1186 | 1186 | <?php } ?> |
1187 | 1187 | </div> |
1188 | 1188 | <?php |
1189 | 1189 | } |
1190 | - do_action( 'wpinv_after_display_payments_info', $invoice_id ); |
|
1190 | + do_action('wpinv_after_display_payments_info', $invoice_id); |
|
1191 | 1191 | $outout = ob_get_clean(); |
1192 | 1192 | |
1193 | - if ( $echo ) { |
|
1193 | + if ($echo) { |
|
1194 | 1194 | echo $outout; |
1195 | 1195 | } else { |
1196 | 1196 | return $outout; |
@@ -1203,55 +1203,55 @@ discard block |
||
1203 | 1203 | function wpinv_display_style() { |
1204 | 1204 | |
1205 | 1205 | // Make sure that all scripts have been loaded. |
1206 | - if ( ! did_action( 'wp_enqueue_scripts' ) ) { |
|
1207 | - do_action( 'wp_enqueue_scripts' ); |
|
1206 | + if (!did_action('wp_enqueue_scripts')) { |
|
1207 | + do_action('wp_enqueue_scripts'); |
|
1208 | 1208 | } |
1209 | 1209 | |
1210 | 1210 | // Register the invoices style. |
1211 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) ); |
|
1211 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css')); |
|
1212 | 1212 | |
1213 | 1213 | // Load required styles |
1214 | - wp_print_styles( 'open-sans' ); |
|
1215 | - wp_print_styles( 'wpinv-single-style' ); |
|
1216 | - wp_print_styles( 'ayecode-ui' ); |
|
1214 | + wp_print_styles('open-sans'); |
|
1215 | + wp_print_styles('wpinv-single-style'); |
|
1216 | + wp_print_styles('ayecode-ui'); |
|
1217 | 1217 | |
1218 | 1218 | // Maybe load custom css. |
1219 | - $custom_css = wpinv_get_option( 'template_custom_css' ); |
|
1219 | + $custom_css = wpinv_get_option('template_custom_css'); |
|
1220 | 1220 | |
1221 | - if ( isset( $custom_css ) && ! empty( $custom_css ) ) { |
|
1222 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
1223 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
1221 | + if (isset($custom_css) && !empty($custom_css)) { |
|
1222 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
1223 | + $custom_css = str_replace('>', '>', $custom_css); |
|
1224 | 1224 | echo '<style type="text/css">'; |
1225 | 1225 | echo $custom_css; |
1226 | 1226 | echo '</style>'; |
1227 | 1227 | } |
1228 | 1228 | |
1229 | 1229 | } |
1230 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
1231 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
1230 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
1231 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
1232 | 1232 | |
1233 | 1233 | function wpinv_checkout_billing_details() { |
1234 | - $invoice_id = (int)wpinv_get_invoice_cart_id(); |
|
1234 | + $invoice_id = (int) wpinv_get_invoice_cart_id(); |
|
1235 | 1235 | if (empty($invoice_id)) { |
1236 | - wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ ); |
|
1236 | + wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__); |
|
1237 | 1237 | return null; |
1238 | 1238 | } |
1239 | 1239 | |
1240 | - $invoice = wpinv_get_invoice_cart( $invoice_id ); |
|
1240 | + $invoice = wpinv_get_invoice_cart($invoice_id); |
|
1241 | 1241 | if (empty($invoice)) { |
1242 | - wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ ); |
|
1242 | + wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__); |
|
1243 | 1243 | return null; |
1244 | 1244 | } |
1245 | 1245 | $user_id = $invoice->get_user_id(); |
1246 | 1246 | $user_info = $invoice->get_user_info(); |
1247 | - $address_info = wpinv_get_user_address( $user_id ); |
|
1247 | + $address_info = wpinv_get_user_address($user_id); |
|
1248 | 1248 | |
1249 | - if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) { |
|
1249 | + if (empty($user_info['first_name']) && !empty($user_info['first_name'])) { |
|
1250 | 1250 | $user_info['first_name'] = $user_info['first_name']; |
1251 | 1251 | $user_info['last_name'] = $user_info['last_name']; |
1252 | 1252 | } |
1253 | 1253 | |
1254 | - if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) { |
|
1254 | + if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) { |
|
1255 | 1255 | $user_info['country'] = $address_info['country']; |
1256 | 1256 | $user_info['state'] = $address_info['state']; |
1257 | 1257 | $user_info['city'] = $address_info['city']; |
@@ -1267,99 +1267,99 @@ discard block |
||
1267 | 1267 | 'address' |
1268 | 1268 | ); |
1269 | 1269 | |
1270 | - foreach ( $address_fields as $field ) { |
|
1271 | - if ( empty( $user_info[$field] ) ) { |
|
1270 | + foreach ($address_fields as $field) { |
|
1271 | + if (empty($user_info[$field])) { |
|
1272 | 1272 | $user_info[$field] = $address_info[$field]; |
1273 | 1273 | } |
1274 | 1274 | } |
1275 | 1275 | |
1276 | - return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice ); |
|
1276 | + return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice); |
|
1277 | 1277 | } |
1278 | 1278 | |
1279 | 1279 | function wpinv_admin_get_line_items($invoice = array()) { |
1280 | 1280 | $item_quantities = wpinv_item_quantities_enabled(); |
1281 | 1281 | $use_taxes = wpinv_use_taxes(); |
1282 | 1282 | |
1283 | - if ( empty( $invoice ) ) { |
|
1283 | + if (empty($invoice)) { |
|
1284 | 1284 | return NULL; |
1285 | 1285 | } |
1286 | 1286 | |
1287 | 1287 | $cart_items = $invoice->get_cart_details(); |
1288 | - if ( empty( $cart_items ) ) { |
|
1288 | + if (empty($cart_items)) { |
|
1289 | 1289 | return NULL; |
1290 | 1290 | } |
1291 | 1291 | |
1292 | 1292 | ob_start(); |
1293 | 1293 | |
1294 | - do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice ); |
|
1294 | + do_action('wpinv_admin_before_line_items', $cart_items, $invoice); |
|
1295 | 1295 | |
1296 | 1296 | $count = 0; |
1297 | - foreach ( $cart_items as $key => $cart_item ) { |
|
1297 | + foreach ($cart_items as $key => $cart_item) { |
|
1298 | 1298 | $item_id = $cart_item['id']; |
1299 | - $wpi_item = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL; |
|
1299 | + $wpi_item = $item_id > 0 ? new WPInv_Item($item_id) : NULL; |
|
1300 | 1300 | |
1301 | 1301 | if (empty($wpi_item)) { |
1302 | 1302 | continue; |
1303 | 1303 | } |
1304 | 1304 | |
1305 | - $item_price = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ), $invoice->get_currency() ); |
|
1306 | - $quantity = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
1307 | - $item_subtotal = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ), $invoice->get_currency() ); |
|
1305 | + $item_price = wpinv_price(wpinv_format_amount($cart_item['item_price']), $invoice->get_currency()); |
|
1306 | + $quantity = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
1307 | + $item_subtotal = wpinv_price(wpinv_format_amount($cart_item['subtotal']), $invoice->get_currency()); |
|
1308 | 1308 | $can_remove = true; |
1309 | 1309 | |
1310 | - $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice ); |
|
1310 | + $summary = apply_filters('wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice); |
|
1311 | 1311 | |
1312 | 1312 | $item_tax = ''; |
1313 | 1313 | $tax_rate = ''; |
1314 | - if ( $invoice->is_taxable() && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
1315 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() ); |
|
1316 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
1317 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
1314 | + if ($invoice->is_taxable() && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
1315 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency()); |
|
1316 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
1317 | + $tax_rate = $tax_rate > 0 ? (float) wpinv_round_amount($tax_rate, 4) : ''; |
|
1318 | 1318 | $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
1319 | 1319 | } |
1320 | 1320 | $line_item_tax = $item_tax . $tax_rate; |
1321 | 1321 | |
1322 | - if ( $line_item_tax === '' ) { |
|
1322 | + if ($line_item_tax === '') { |
|
1323 | 1323 | $line_item_tax = 0; // Zero tax |
1324 | 1324 | } |
1325 | 1325 | |
1326 | - $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">'; |
|
1326 | + $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">'; |
|
1327 | 1327 | $line_item .= '<td class="id">' . $item_id . '</td>'; |
1328 | - $line_item .= '<td class="title"><a href="' . get_edit_post_link( $item_id ) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix( $wpi_item ); |
|
1329 | - if ( $summary !== '' ) { |
|
1330 | - $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>'; |
|
1328 | + $line_item .= '<td class="title"><a href="' . get_edit_post_link($item_id) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix($wpi_item); |
|
1329 | + if ($summary !== '') { |
|
1330 | + $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>'; |
|
1331 | 1331 | } |
1332 | 1332 | $line_item .= '</td>'; |
1333 | 1333 | $line_item .= '<td class="price">' . $item_price . '</td>'; |
1334 | 1334 | |
1335 | - if ( $item_quantities ) { |
|
1336 | - if ( count( $cart_items ) == 1 && $quantity <= 1 ) { |
|
1335 | + if ($item_quantities) { |
|
1336 | + if (count($cart_items) == 1 && $quantity <= 1) { |
|
1337 | 1337 | $can_remove = false; |
1338 | 1338 | } |
1339 | 1339 | $line_item .= '<td class="qty" data-quantity="' . $quantity . '"> × ' . $quantity . '</td>'; |
1340 | 1340 | } else { |
1341 | - if ( count( $cart_items ) == 1 ) { |
|
1341 | + if (count($cart_items) == 1) { |
|
1342 | 1342 | $can_remove = false; |
1343 | 1343 | } |
1344 | 1344 | } |
1345 | 1345 | $line_item .= '<td class="total">' . $item_subtotal . '</td>'; |
1346 | 1346 | |
1347 | - if ( $use_taxes ) { |
|
1347 | + if ($use_taxes) { |
|
1348 | 1348 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
1349 | 1349 | } |
1350 | 1350 | $line_item .= '<td class="action">'; |
1351 | - if ( !$invoice->is_paid() && !$invoice->is_refunded() ) { |
|
1351 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
1352 | 1352 | $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>'; |
1353 | 1353 | } |
1354 | 1354 | $line_item .= '</td>'; |
1355 | 1355 | $line_item .= '</tr>'; |
1356 | 1356 | |
1357 | - echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice ); |
|
1357 | + echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice); |
|
1358 | 1358 | |
1359 | 1359 | $count++; |
1360 | 1360 | } |
1361 | 1361 | |
1362 | - do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice ); |
|
1362 | + do_action('wpinv_admin_after_line_items', $cart_items, $invoice); |
|
1363 | 1363 | |
1364 | 1364 | return ob_get_clean(); |
1365 | 1365 | } |
@@ -1369,70 +1369,70 @@ discard block |
||
1369 | 1369 | |
1370 | 1370 | // Set current invoice id. |
1371 | 1371 | $wpi_checkout_id = wpinv_get_invoice_cart_id(); |
1372 | - $form_action = esc_url( wpinv_get_checkout_uri() ); |
|
1372 | + $form_action = esc_url(wpinv_get_checkout_uri()); |
|
1373 | 1373 | $payment_form = wpinv_get_default_payment_form(); |
1374 | 1374 | |
1375 | 1375 | ob_start(); |
1376 | - do_action( 'wpinv_checkout_content_before' ); |
|
1376 | + do_action('wpinv_checkout_content_before'); |
|
1377 | 1377 | |
1378 | - if ( wpinv_get_cart_contents() ) { |
|
1378 | + if (wpinv_get_cart_contents()) { |
|
1379 | 1379 | |
1380 | 1380 | // Get the form elements and items. |
1381 | - $elements = $invoicing->form_elements->get_form_elements( $payment_form ); |
|
1382 | - $items = $invoicing->form_elements->convert_checkout_items( wpinv_get_cart_contents(), wpinv_get_invoice_cart() ); |
|
1381 | + $elements = $invoicing->form_elements->get_form_elements($payment_form); |
|
1382 | + $items = $invoicing->form_elements->convert_checkout_items(wpinv_get_cart_contents(), wpinv_get_invoice_cart()); |
|
1383 | 1383 | ?> |
1384 | 1384 | <form class="wpinv_payment_form" action="<?php echo $form_action; ?>" method="POST"> |
1385 | - <?php do_action( 'wpinv_main_checkout_form_top' ); ?> |
|
1386 | - <input type='hidden' name='form_id' value='<?php echo esc_attr( $payment_form ); ?>'/> |
|
1387 | - <input type='hidden' name='invoice_id' value='<?php echo esc_attr( $wpi_checkout_id ); ?>'/> |
|
1385 | + <?php do_action('wpinv_main_checkout_form_top'); ?> |
|
1386 | + <input type='hidden' name='form_id' value='<?php echo esc_attr($payment_form); ?>'/> |
|
1387 | + <input type='hidden' name='invoice_id' value='<?php echo esc_attr($wpi_checkout_id); ?>'/> |
|
1388 | 1388 | <?php |
1389 | - wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
1390 | - wp_nonce_field( 'vat_validation', '_wpi_nonce' ); |
|
1389 | + wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form'); |
|
1390 | + wp_nonce_field('vat_validation', '_wpi_nonce'); |
|
1391 | 1391 | |
1392 | - foreach ( $elements as $element ) { |
|
1393 | - do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $payment_form ); |
|
1394 | - do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $payment_form ); |
|
1392 | + foreach ($elements as $element) { |
|
1393 | + do_action('wpinv_frontend_render_payment_form_element', $element, $items, $payment_form); |
|
1394 | + do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $payment_form); |
|
1395 | 1395 | } |
1396 | 1396 | ?> |
1397 | 1397 | <div class='wpinv_payment_form_errors alert alert-danger d-none'></div> |
1398 | - <?php do_action( 'wpinv_main_checkout_form_bottom' ); ?> |
|
1398 | + <?php do_action('wpinv_main_checkout_form_bottom'); ?> |
|
1399 | 1399 | </form> |
1400 | 1400 | <?php |
1401 | 1401 | |
1402 | 1402 | } else { |
1403 | - do_action( 'wpinv_cart_empty' ); |
|
1403 | + do_action('wpinv_cart_empty'); |
|
1404 | 1404 | } |
1405 | 1405 | echo '</div><!--end #wpinv_checkout_wrap-->'; |
1406 | - do_action( 'wpinv_checkout_content_after' ); |
|
1406 | + do_action('wpinv_checkout_content_after'); |
|
1407 | 1407 | $content = ob_get_clean(); |
1408 | 1408 | |
1409 | - return str_replace( 'sr-only', '', $content ); |
|
1409 | + return str_replace('sr-only', '', $content); |
|
1410 | 1410 | } |
1411 | 1411 | |
1412 | -function wpinv_checkout_cart( $cart_details = array(), $echo = true ) { |
|
1412 | +function wpinv_checkout_cart($cart_details = array(), $echo = true) { |
|
1413 | 1413 | global $ajax_cart_details; |
1414 | 1414 | $ajax_cart_details = $cart_details; |
1415 | 1415 | |
1416 | 1416 | ob_start(); |
1417 | - do_action( 'wpinv_before_checkout_cart' ); |
|
1417 | + do_action('wpinv_before_checkout_cart'); |
|
1418 | 1418 | echo '<div id="wpinv_checkout_cart_form" method="post">'; |
1419 | 1419 | echo '<div id="wpinv_checkout_cart_wrap">'; |
1420 | - wpinv_get_template_part( 'wpinv-checkout-cart' ); |
|
1420 | + wpinv_get_template_part('wpinv-checkout-cart'); |
|
1421 | 1421 | echo '</div>'; |
1422 | 1422 | echo '</div>'; |
1423 | - do_action( 'wpinv_after_checkout_cart' ); |
|
1423 | + do_action('wpinv_after_checkout_cart'); |
|
1424 | 1424 | $content = ob_get_clean(); |
1425 | 1425 | |
1426 | - if ( $echo ) { |
|
1426 | + if ($echo) { |
|
1427 | 1427 | echo $content; |
1428 | 1428 | } else { |
1429 | 1429 | return $content; |
1430 | 1430 | } |
1431 | 1431 | } |
1432 | -add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
|
1432 | +add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10); |
|
1433 | 1433 | |
1434 | 1434 | function wpinv_empty_cart_message() { |
1435 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1435 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
1436 | 1436 | } |
1437 | 1437 | |
1438 | 1438 | /** |
@@ -1449,83 +1449,83 @@ discard block |
||
1449 | 1449 | ) |
1450 | 1450 | ); |
1451 | 1451 | } |
1452 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
1452 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
1453 | 1453 | |
1454 | 1454 | function wpinv_update_cart_button() { |
1455 | - if ( !wpinv_item_quantities_enabled() ) |
|
1455 | + if (!wpinv_item_quantities_enabled()) |
|
1456 | 1456 | return; |
1457 | 1457 | ?> |
1458 | - <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
|
1458 | + <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/> |
|
1459 | 1459 | <input type="hidden" name="wpi_action" value="update_cart"/> |
1460 | 1460 | <?php |
1461 | 1461 | } |
1462 | 1462 | |
1463 | 1463 | function wpinv_checkout_cart_columns() { |
1464 | 1464 | $default = 3; |
1465 | - if ( wpinv_item_quantities_enabled() ) { |
|
1465 | + if (wpinv_item_quantities_enabled()) { |
|
1466 | 1466 | $default++; |
1467 | 1467 | } |
1468 | 1468 | |
1469 | - if ( wpinv_use_taxes() ) { |
|
1469 | + if (wpinv_use_taxes()) { |
|
1470 | 1470 | $default++; |
1471 | 1471 | } |
1472 | 1472 | |
1473 | - return apply_filters( 'wpinv_checkout_cart_columns', $default ); |
|
1473 | + return apply_filters('wpinv_checkout_cart_columns', $default); |
|
1474 | 1474 | } |
1475 | 1475 | |
1476 | 1476 | function wpinv_display_cart_messages() { |
1477 | 1477 | global $wpi_session; |
1478 | 1478 | |
1479 | - $messages = $wpi_session->get( 'wpinv_cart_messages' ); |
|
1479 | + $messages = $wpi_session->get('wpinv_cart_messages'); |
|
1480 | 1480 | |
1481 | - if ( $messages ) { |
|
1482 | - foreach ( $messages as $message_id => $message ) { |
|
1481 | + if ($messages) { |
|
1482 | + foreach ($messages as $message_id => $message) { |
|
1483 | 1483 | // Try and detect what type of message this is |
1484 | - if ( strpos( strtolower( $message ), 'error' ) ) { |
|
1484 | + if (strpos(strtolower($message), 'error')) { |
|
1485 | 1485 | $type = 'error'; |
1486 | - } elseif ( strpos( strtolower( $message ), 'success' ) ) { |
|
1486 | + } elseif (strpos(strtolower($message), 'success')) { |
|
1487 | 1487 | $type = 'success'; |
1488 | 1488 | } else { |
1489 | 1489 | $type = 'info'; |
1490 | 1490 | } |
1491 | 1491 | |
1492 | - $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) ); |
|
1492 | + $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type)); |
|
1493 | 1493 | |
1494 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
1494 | + echo '<div class="' . implode(' ', $classes) . '">'; |
|
1495 | 1495 | // Loop message codes and display messages |
1496 | 1496 | echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>'; |
1497 | 1497 | echo '</div>'; |
1498 | 1498 | } |
1499 | 1499 | |
1500 | 1500 | // Remove all of the cart saving messages |
1501 | - $wpi_session->set( 'wpinv_cart_messages', null ); |
|
1501 | + $wpi_session->set('wpinv_cart_messages', null); |
|
1502 | 1502 | } |
1503 | 1503 | } |
1504 | -add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' ); |
|
1504 | +add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages'); |
|
1505 | 1505 | |
1506 | 1506 | function wpinv_discount_field() { |
1507 | - if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) { |
|
1507 | + if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) { |
|
1508 | 1508 | return; // Only show before a payment method has been selected if ajax is disabled |
1509 | 1509 | } |
1510 | 1510 | |
1511 | - if ( !wpinv_is_checkout() ) { |
|
1511 | + if (!wpinv_is_checkout()) { |
|
1512 | 1512 | return; |
1513 | 1513 | } |
1514 | 1514 | |
1515 | - if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) { |
|
1515 | + if (wpinv_has_active_discounts() && wpinv_get_cart_total()) { |
|
1516 | 1516 | ?> |
1517 | 1517 | <div id="wpinv-discount-field" class="panel panel-default"> |
1518 | 1518 | <div class="panel-body"> |
1519 | 1519 | <p> |
1520 | - <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label> |
|
1521 | - <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span> |
|
1520 | + <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label> |
|
1521 | + <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span> |
|
1522 | 1522 | </p> |
1523 | 1523 | <div class="form-group row"> |
1524 | 1524 | <div class="col-sm-4"> |
1525 | - <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/> |
|
1525 | + <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/> |
|
1526 | 1526 | </div> |
1527 | 1527 | <div class="col-sm-3"> |
1528 | - <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button> |
|
1528 | + <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button> |
|
1529 | 1529 | </div> |
1530 | 1530 | <div style="clear:both"></div> |
1531 | 1531 | <div class="col-sm-12 wpinv-discount-msg"> |
@@ -1538,10 +1538,10 @@ discard block |
||
1538 | 1538 | <?php |
1539 | 1539 | } |
1540 | 1540 | } |
1541 | -add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 ); |
|
1541 | +add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10); |
|
1542 | 1542 | |
1543 | 1543 | function wpinv_agree_to_terms_js() { |
1544 | - if ( wpinv_get_option( 'show_agree_to_terms', false ) ) { |
|
1544 | + if (wpinv_get_option('show_agree_to_terms', false)) { |
|
1545 | 1545 | ?> |
1546 | 1546 | <script type="text/javascript"> |
1547 | 1547 | jQuery(document).ready(function($){ |
@@ -1556,127 +1556,127 @@ discard block |
||
1556 | 1556 | <?php |
1557 | 1557 | } |
1558 | 1558 | } |
1559 | -add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' ); |
|
1559 | +add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js'); |
|
1560 | 1560 | |
1561 | -function wpinv_payment_mode_select( $title ) { |
|
1562 | - $gateways = wpinv_get_enabled_payment_gateways( true ); |
|
1563 | - $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways ); |
|
1564 | - $invoice = wpinv_get_invoice( 0, true ); |
|
1561 | +function wpinv_payment_mode_select($title) { |
|
1562 | + $gateways = wpinv_get_enabled_payment_gateways(true); |
|
1563 | + $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways); |
|
1564 | + $invoice = wpinv_get_invoice(0, true); |
|
1565 | 1565 | |
1566 | 1566 | do_action('wpinv_payment_mode_top'); |
1567 | - $invoice_id = $invoice ? (int)$invoice->ID : 0; |
|
1568 | - $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id ); |
|
1567 | + $invoice_id = $invoice ? (int) $invoice->ID : 0; |
|
1568 | + $chosen_gateway = wpinv_get_chosen_gateway($invoice_id); |
|
1569 | 1569 | ?> |
1570 | - <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ( ( $invoice && $invoice->is_free() ) ? 'style="display:none;" data-free="1"' : '' ); ?>> |
|
1571 | - <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?> |
|
1570 | + <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo (($invoice && $invoice->is_free()) ? 'style="display:none;" data-free="1"' : ''); ?>> |
|
1571 | + <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?> |
|
1572 | 1572 | <div id="wpinv-payment-mode-wrap" class="panel panel-default"> |
1573 | 1573 | <div class="panel-heading wpi-payment_methods_title"> |
1574 | - <h6 class="panel-title"><?php echo sanitize_text_field( $title ); ?></h6> |
|
1574 | + <h6 class="panel-title"><?php echo sanitize_text_field($title); ?></h6> |
|
1575 | 1575 | </div> |
1576 | 1576 | <div class="panel-body wpi-payment_methods"> |
1577 | 1577 | <?php |
1578 | - do_action( 'wpinv_payment_mode_before_gateways' ); |
|
1579 | - |
|
1580 | - if ( !empty( $gateways ) ) { |
|
1581 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
1582 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
1583 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
1584 | - $gateway_label = wpinv_get_gateway_checkout_label( $gateway_id ); |
|
1585 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
1578 | + do_action('wpinv_payment_mode_before_gateways'); |
|
1579 | + |
|
1580 | + if (!empty($gateways)) { |
|
1581 | + foreach ($gateways as $gateway_id => $gateway) { |
|
1582 | + $checked = checked($gateway_id, $chosen_gateway, false); |
|
1583 | + $button_label = wpinv_get_gateway_button_label($gateway_id); |
|
1584 | + $gateway_label = wpinv_get_gateway_checkout_label($gateway_id); |
|
1585 | + $description = wpinv_get_gateway_description($gateway_id); |
|
1586 | 1586 | ?> |
1587 | 1587 | <div class="pt-2 pb-2"> |
1588 | 1588 | <div class="radio"> |
1589 | - <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway_label ); ?></label> |
|
1589 | + <label><input type="radio" data-button-text="<?php echo esc_attr($button_label); ?>" value="<?php echo esc_attr($gateway_id); ?>" <?php echo $checked; ?> id="wpi_gateway_<?php echo esc_attr($gateway_id); ?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html($gateway_label); ?></label> |
|
1590 | 1590 | </div> |
1591 | - <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert"> |
|
1592 | - <?php if ( !empty( $description ) ) { ?> |
|
1593 | - <div class="wpi-gateway-desc"><?php _e( $description, 'invoicing' ); ?></div> |
|
1591 | + <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert"> |
|
1592 | + <?php if (!empty($description)) { ?> |
|
1593 | + <div class="wpi-gateway-desc"><?php _e($description, 'invoicing'); ?></div> |
|
1594 | 1594 | <?php } ?> |
1595 | - <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?> |
|
1595 | + <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?> |
|
1596 | 1596 | </div> |
1597 | 1597 | </div> |
1598 | 1598 | <?php |
1599 | 1599 | } |
1600 | 1600 | } else { |
1601 | - echo '<div class="alert alert-danger">'. __( 'No payment gateway active', 'invoicing' ) .'</div>'; |
|
1601 | + echo '<div class="alert alert-danger">' . __('No payment gateway active', 'invoicing') . '</div>'; |
|
1602 | 1602 | } |
1603 | 1603 | |
1604 | - do_action( 'wpinv_payment_mode_after_gateways' ); |
|
1604 | + do_action('wpinv_payment_mode_after_gateways'); |
|
1605 | 1605 | ?> |
1606 | 1606 | </div> |
1607 | 1607 | </div> |
1608 | - <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?> |
|
1608 | + <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?> |
|
1609 | 1609 | </div> |
1610 | 1610 | <?php |
1611 | 1611 | do_action('wpinv_payment_mode_bottom'); |
1612 | 1612 | } |
1613 | -add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' ); |
|
1613 | +add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select'); |
|
1614 | 1614 | |
1615 | 1615 | function wpinv_checkout_billing_info() { |
1616 | - if ( wpinv_is_checkout() ) { |
|
1616 | + if (wpinv_is_checkout()) { |
|
1617 | 1617 | $billing_details = wpinv_checkout_billing_details(); |
1618 | - $selected_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
1618 | + $selected_country = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
1619 | 1619 | ?> |
1620 | 1620 | <div id="wpinv-fields" class="clearfix"> |
1621 | 1621 | <div id="wpi-billing" class="wpi-billing clearfix panel panel-default"> |
1622 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div> |
|
1622 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div> |
|
1623 | 1623 | <div id="wpinv-fields-box" class="panel-body"> |
1624 | - <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?> |
|
1624 | + <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?> |
|
1625 | 1625 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1626 | - <label for="wpinv_first_name" class="wpi-label"><?php _e( 'First Name', 'invoicing' );?><?php if ( wpinv_get_option( 'fname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1626 | + <label for="wpinv_first_name" class="wpi-label"><?php _e('First Name', 'invoicing'); ?><?php if (wpinv_get_option('fname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1627 | 1627 | <?php |
1628 | - echo wpinv_html_text( array( |
|
1628 | + echo wpinv_html_text(array( |
|
1629 | 1629 | 'id' => 'wpinv_first_name', |
1630 | 1630 | 'name' => 'wpinv_first_name', |
1631 | 1631 | 'value' => $billing_details['first_name'], |
1632 | 1632 | 'class' => 'wpi-input form-control', |
1633 | - 'placeholder' => __( 'First name', 'invoicing' ), |
|
1634 | - 'required' => (bool)wpinv_get_option( 'fname_mandatory' ), |
|
1635 | - ) ); |
|
1633 | + 'placeholder' => __('First name', 'invoicing'), |
|
1634 | + 'required' => (bool) wpinv_get_option('fname_mandatory'), |
|
1635 | + )); |
|
1636 | 1636 | ?> |
1637 | 1637 | </p> |
1638 | 1638 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1639 | - <label for="wpinv_last_name" class="wpi-label"><?php _e( 'Last Name', 'invoicing' );?><?php if ( wpinv_get_option( 'lname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1639 | + <label for="wpinv_last_name" class="wpi-label"><?php _e('Last Name', 'invoicing'); ?><?php if (wpinv_get_option('lname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1640 | 1640 | <?php |
1641 | - echo wpinv_html_text( array( |
|
1641 | + echo wpinv_html_text(array( |
|
1642 | 1642 | 'id' => 'wpinv_last_name', |
1643 | 1643 | 'name' => 'wpinv_last_name', |
1644 | 1644 | 'value' => $billing_details['last_name'], |
1645 | 1645 | 'class' => 'wpi-input form-control', |
1646 | - 'placeholder' => __( 'Last name', 'invoicing' ), |
|
1647 | - 'required' => (bool)wpinv_get_option( 'lname_mandatory' ), |
|
1648 | - ) ); |
|
1646 | + 'placeholder' => __('Last name', 'invoicing'), |
|
1647 | + 'required' => (bool) wpinv_get_option('lname_mandatory'), |
|
1648 | + )); |
|
1649 | 1649 | ?> |
1650 | 1650 | </p> |
1651 | 1651 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1652 | - <label for="wpinv_address" class="wpi-label"><?php _e( 'Address', 'invoicing' );?><?php if ( wpinv_get_option( 'address_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1652 | + <label for="wpinv_address" class="wpi-label"><?php _e('Address', 'invoicing'); ?><?php if (wpinv_get_option('address_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1653 | 1653 | <?php |
1654 | - echo wpinv_html_text( array( |
|
1654 | + echo wpinv_html_text(array( |
|
1655 | 1655 | 'id' => 'wpinv_address', |
1656 | 1656 | 'name' => 'wpinv_address', |
1657 | 1657 | 'value' => $billing_details['address'], |
1658 | 1658 | 'class' => 'wpi-input form-control', |
1659 | - 'placeholder' => __( 'Address', 'invoicing' ), |
|
1660 | - 'required' => (bool)wpinv_get_option( 'address_mandatory' ), |
|
1661 | - ) ); |
|
1659 | + 'placeholder' => __('Address', 'invoicing'), |
|
1660 | + 'required' => (bool) wpinv_get_option('address_mandatory'), |
|
1661 | + )); |
|
1662 | 1662 | ?> |
1663 | 1663 | </p> |
1664 | 1664 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1665 | - <label for="wpinv_city" class="wpi-label"><?php _e( 'City', 'invoicing' );?><?php if ( wpinv_get_option( 'city_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1665 | + <label for="wpinv_city" class="wpi-label"><?php _e('City', 'invoicing'); ?><?php if (wpinv_get_option('city_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1666 | 1666 | <?php |
1667 | - echo wpinv_html_text( array( |
|
1667 | + echo wpinv_html_text(array( |
|
1668 | 1668 | 'id' => 'wpinv_city', |
1669 | 1669 | 'name' => 'wpinv_city', |
1670 | 1670 | 'value' => $billing_details['city'], |
1671 | 1671 | 'class' => 'wpi-input form-control', |
1672 | - 'placeholder' => __( 'City', 'invoicing' ), |
|
1673 | - 'required' => (bool)wpinv_get_option( 'city_mandatory' ), |
|
1674 | - ) ); |
|
1672 | + 'placeholder' => __('City', 'invoicing'), |
|
1673 | + 'required' => (bool) wpinv_get_option('city_mandatory'), |
|
1674 | + )); |
|
1675 | 1675 | ?> |
1676 | 1676 | </p> |
1677 | 1677 | <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf"> |
1678 | - <label for="wpinv_country" class="wpi-label"><?php _e( 'Country', 'invoicing' );?><?php if ( wpinv_get_option( 'country_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1679 | - <?php echo wpinv_html_select( array( |
|
1678 | + <label for="wpinv_country" class="wpi-label"><?php _e('Country', 'invoicing'); ?><?php if (wpinv_get_option('country_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1679 | + <?php echo wpinv_html_select(array( |
|
1680 | 1680 | 'options' => wpinv_get_country_list(), |
1681 | 1681 | 'name' => 'wpinv_country', |
1682 | 1682 | 'id' => 'wpinv_country', |
@@ -1684,16 +1684,16 @@ discard block |
||
1684 | 1684 | 'show_option_all' => false, |
1685 | 1685 | 'show_option_none' => false, |
1686 | 1686 | 'class' => 'wpi-input form-control wpi_select2', |
1687 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
1688 | - 'required' => (bool)wpinv_get_option( 'country_mandatory' ), |
|
1689 | - ) ); ?> |
|
1687 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
1688 | + 'required' => (bool) wpinv_get_option('country_mandatory'), |
|
1689 | + )); ?> |
|
1690 | 1690 | </p> |
1691 | 1691 | <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll"> |
1692 | - <label for="wpinv_state" class="wpi-label"><?php _e( 'State / Province', 'invoicing' );?><?php if ( wpinv_get_option( 'state_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1692 | + <label for="wpinv_state" class="wpi-label"><?php _e('State / Province', 'invoicing'); ?><?php if (wpinv_get_option('state_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1693 | 1693 | <?php |
1694 | - $states = wpinv_get_country_states( $selected_country ); |
|
1695 | - if( !empty( $states ) ) { |
|
1696 | - echo wpinv_html_select( array( |
|
1694 | + $states = wpinv_get_country_states($selected_country); |
|
1695 | + if (!empty($states)) { |
|
1696 | + echo wpinv_html_select(array( |
|
1697 | 1697 | 'options' => $states, |
1698 | 1698 | 'name' => 'wpinv_state', |
1699 | 1699 | 'id' => 'wpinv_state', |
@@ -1701,61 +1701,61 @@ discard block |
||
1701 | 1701 | 'show_option_all' => false, |
1702 | 1702 | 'show_option_none' => false, |
1703 | 1703 | 'class' => 'wpi-input form-control wpi_select2', |
1704 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
1705 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
1706 | - ) ); |
|
1704 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
1705 | + 'required' => (bool) wpinv_get_option('state_mandatory'), |
|
1706 | + )); |
|
1707 | 1707 | } else { |
1708 | - echo wpinv_html_text( array( |
|
1708 | + echo wpinv_html_text(array( |
|
1709 | 1709 | 'name' => 'wpinv_state', |
1710 | 1710 | 'value' => $billing_details['state'], |
1711 | 1711 | 'id' => 'wpinv_state', |
1712 | 1712 | 'class' => 'wpi-input form-control', |
1713 | - 'placeholder' => __( 'State / Province', 'invoicing' ), |
|
1714 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
1715 | - ) ); |
|
1713 | + 'placeholder' => __('State / Province', 'invoicing'), |
|
1714 | + 'required' => (bool) wpinv_get_option('state_mandatory'), |
|
1715 | + )); |
|
1716 | 1716 | } |
1717 | 1717 | ?> |
1718 | 1718 | </p> |
1719 | 1719 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1720 | - <label for="wpinv_zip" class="wpi-label"><?php _e( 'ZIP / Postcode', 'invoicing' );?><?php if ( wpinv_get_option( 'zip_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1720 | + <label for="wpinv_zip" class="wpi-label"><?php _e('ZIP / Postcode', 'invoicing'); ?><?php if (wpinv_get_option('zip_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1721 | 1721 | <?php |
1722 | - echo wpinv_html_text( array( |
|
1722 | + echo wpinv_html_text(array( |
|
1723 | 1723 | 'name' => 'wpinv_zip', |
1724 | 1724 | 'value' => $billing_details['zip'], |
1725 | 1725 | 'id' => 'wpinv_zip', |
1726 | 1726 | 'class' => 'wpi-input form-control', |
1727 | - 'placeholder' => __( 'ZIP / Postcode', 'invoicing' ), |
|
1728 | - 'required' => (bool)wpinv_get_option( 'zip_mandatory' ), |
|
1729 | - ) ); |
|
1727 | + 'placeholder' => __('ZIP / Postcode', 'invoicing'), |
|
1728 | + 'required' => (bool) wpinv_get_option('zip_mandatory'), |
|
1729 | + )); |
|
1730 | 1730 | ?> |
1731 | 1731 | </p> |
1732 | 1732 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1733 | - <label for="wpinv_phone" class="wpi-label"><?php _e( 'Phone', 'invoicing' );?><?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1733 | + <label for="wpinv_phone" class="wpi-label"><?php _e('Phone', 'invoicing'); ?><?php if (wpinv_get_option('phone_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1734 | 1734 | <?php |
1735 | - echo wpinv_html_text( array( |
|
1735 | + echo wpinv_html_text(array( |
|
1736 | 1736 | 'id' => 'wpinv_phone', |
1737 | 1737 | 'name' => 'wpinv_phone', |
1738 | 1738 | 'value' => $billing_details['phone'], |
1739 | 1739 | 'class' => 'wpi-input form-control', |
1740 | - 'placeholder' => __( 'Phone', 'invoicing' ), |
|
1741 | - 'required' => (bool)wpinv_get_option( 'phone_mandatory' ), |
|
1742 | - ) ); |
|
1740 | + 'placeholder' => __('Phone', 'invoicing'), |
|
1741 | + 'required' => (bool) wpinv_get_option('phone_mandatory'), |
|
1742 | + )); |
|
1743 | 1743 | ?> |
1744 | 1744 | </p> |
1745 | - <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?> |
|
1745 | + <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?> |
|
1746 | 1746 | <div class="clearfix"></div> |
1747 | 1747 | </div> |
1748 | 1748 | </div> |
1749 | - <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?> |
|
1749 | + <?php do_action('wpinv_after_billing_fields', $billing_details); ?> |
|
1750 | 1750 | </div> |
1751 | 1751 | <?php |
1752 | 1752 | } |
1753 | 1753 | } |
1754 | -add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' ); |
|
1754 | +add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info'); |
|
1755 | 1755 | |
1756 | 1756 | function wpinv_checkout_hidden_fields() { |
1757 | 1757 | ?> |
1758 | - <?php if ( is_user_logged_in() ) { ?> |
|
1758 | + <?php if (is_user_logged_in()) { ?> |
|
1759 | 1759 | <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/> |
1760 | 1760 | <?php } ?> |
1761 | 1761 | <input type="hidden" name="wpi_action" value="payment" /> |
@@ -1765,9 +1765,9 @@ discard block |
||
1765 | 1765 | function wpinv_checkout_button_purchase() { |
1766 | 1766 | ob_start(); |
1767 | 1767 | ?> |
1768 | - <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>" name="wpinv_payment" value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>"/> |
|
1768 | + <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>" name="wpinv_payment" value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>"/> |
|
1769 | 1769 | <?php |
1770 | - return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() ); |
|
1770 | + return apply_filters('wpinv_checkout_button_purchase', ob_get_clean()); |
|
1771 | 1771 | } |
1772 | 1772 | |
1773 | 1773 | function wpinv_checkout_total() { |
@@ -1776,64 +1776,64 @@ discard block |
||
1776 | 1776 | <div id="wpinv_checkout_total" class="panel panel-info"> |
1777 | 1777 | <div class="panel-body"> |
1778 | 1778 | <?php |
1779 | - do_action( 'wpinv_purchase_form_before_checkout_total' ); |
|
1779 | + do_action('wpinv_purchase_form_before_checkout_total'); |
|
1780 | 1780 | ?> |
1781 | - <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span> |
|
1781 | + <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span> |
|
1782 | 1782 | <?php |
1783 | - do_action( 'wpinv_purchase_form_after_checkout_total' ); |
|
1783 | + do_action('wpinv_purchase_form_after_checkout_total'); |
|
1784 | 1784 | ?> |
1785 | 1785 | </div> |
1786 | 1786 | </div> |
1787 | 1787 | <?php |
1788 | 1788 | } |
1789 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 ); |
|
1789 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998); |
|
1790 | 1790 | |
1791 | 1791 | function wpinv_checkout_submit() { |
1792 | 1792 | ?> |
1793 | 1793 | <div id="wpinv_purchase_submit" class="panel panel-success"> |
1794 | 1794 | <div class="panel-body text-center"> |
1795 | 1795 | <?php |
1796 | - do_action( 'wpinv_purchase_form_before_submit' ); |
|
1796 | + do_action('wpinv_purchase_form_before_submit'); |
|
1797 | 1797 | wpinv_checkout_hidden_fields(); |
1798 | 1798 | echo wpinv_checkout_button_purchase(); |
1799 | - do_action( 'wpinv_purchase_form_after_submit' ); |
|
1799 | + do_action('wpinv_purchase_form_after_submit'); |
|
1800 | 1800 | ?> |
1801 | 1801 | </div> |
1802 | 1802 | </div> |
1803 | 1803 | <?php |
1804 | 1804 | } |
1805 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 ); |
|
1805 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999); |
|
1806 | 1806 | |
1807 | -function wpinv_receipt_billing_address( $invoice_id = 0 ) { |
|
1808 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1807 | +function wpinv_receipt_billing_address($invoice_id = 0) { |
|
1808 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1809 | 1809 | |
1810 | - if ( empty( $invoice ) ) { |
|
1810 | + if (empty($invoice)) { |
|
1811 | 1811 | return NULL; |
1812 | 1812 | } |
1813 | 1813 | |
1814 | 1814 | $billing_details = $invoice->get_user_info(); |
1815 | - $address_row = wpinv_get_invoice_address_markup( $billing_details ); |
|
1815 | + $address_row = wpinv_get_invoice_address_markup($billing_details); |
|
1816 | 1816 | |
1817 | 1817 | ob_start(); |
1818 | 1818 | ?> |
1819 | 1819 | <table class="table table-bordered table-sm wpi-billing-details"> |
1820 | 1820 | <tbody> |
1821 | 1821 | <tr class="wpi-receipt-name"> |
1822 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
1823 | - <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td> |
|
1822 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
1823 | + <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td> |
|
1824 | 1824 | </tr> |
1825 | 1825 | <tr class="wpi-receipt-email"> |
1826 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
1827 | - <td><?php echo $billing_details['email'] ;?></td> |
|
1826 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
1827 | + <td><?php echo $billing_details['email']; ?></td> |
|
1828 | 1828 | </tr> |
1829 | 1829 | <tr class="wpi-receipt-address"> |
1830 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
1831 | - <td><?php echo $address_row ;?></td> |
|
1830 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
1831 | + <td><?php echo $address_row; ?></td> |
|
1832 | 1832 | </tr> |
1833 | - <?php if ( $billing_details['phone'] ) { ?> |
|
1833 | + <?php if ($billing_details['phone']) { ?> |
|
1834 | 1834 | <tr class="wpi-receipt-phone"> |
1835 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
1836 | - <td><?php echo esc_html( $billing_details['phone'] ) ;?></td> |
|
1835 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
1836 | + <td><?php echo esc_html($billing_details['phone']); ?></td> |
|
1837 | 1837 | </tr> |
1838 | 1838 | <?php } ?> |
1839 | 1839 | </tbody> |
@@ -1841,74 +1841,74 @@ discard block |
||
1841 | 1841 | <?php |
1842 | 1842 | $output = ob_get_clean(); |
1843 | 1843 | |
1844 | - $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id ); |
|
1844 | + $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id); |
|
1845 | 1845 | |
1846 | 1846 | echo $output; |
1847 | 1847 | } |
1848 | 1848 | |
1849 | -function wpinv_filter_success_page_content( $content ) { |
|
1850 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
1851 | - if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) { |
|
1852 | - $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content ); |
|
1849 | +function wpinv_filter_success_page_content($content) { |
|
1850 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
1851 | + if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) { |
|
1852 | + $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content); |
|
1853 | 1853 | } |
1854 | 1854 | } |
1855 | 1855 | |
1856 | 1856 | return $content; |
1857 | 1857 | } |
1858 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
1858 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
1859 | 1859 | |
1860 | -function wpinv_receipt_actions( $invoice ) { |
|
1861 | - if ( !empty( $invoice ) ) { |
|
1860 | +function wpinv_receipt_actions($invoice) { |
|
1861 | + if (!empty($invoice)) { |
|
1862 | 1862 | $actions = array(); |
1863 | 1863 | |
1864 | - if ( wpinv_user_can_view_invoice( $invoice->ID ) ) { |
|
1865 | - $actions['print'] = array( |
|
1866 | - 'url' => $invoice->get_view_url( true ), |
|
1867 | - 'name' => __( 'Print Invoice', 'invoicing' ), |
|
1864 | + if (wpinv_user_can_view_invoice($invoice->ID)) { |
|
1865 | + $actions['print'] = array( |
|
1866 | + 'url' => $invoice->get_view_url(true), |
|
1867 | + 'name' => __('Print Invoice', 'invoicing'), |
|
1868 | 1868 | 'class' => 'btn-primary', |
1869 | 1869 | ); |
1870 | 1870 | } |
1871 | 1871 | |
1872 | - if ( is_user_logged_in() ) { |
|
1872 | + if (is_user_logged_in()) { |
|
1873 | 1873 | $actions['history'] = array( |
1874 | 1874 | 'url' => wpinv_get_history_page_uri(), |
1875 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
1875 | + 'name' => __('Invoice History', 'invoicing'), |
|
1876 | 1876 | 'class' => 'btn-warning', |
1877 | 1877 | ); |
1878 | 1878 | } |
1879 | 1879 | |
1880 | - $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice ); |
|
1880 | + $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice); |
|
1881 | 1881 | |
1882 | - if ( !empty( $actions ) ) { |
|
1882 | + if (!empty($actions)) { |
|
1883 | 1883 | ?> |
1884 | 1884 | <div class="wpinv-receipt-actions text-right"> |
1885 | - <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?> |
|
1886 | - <a href="<?php echo esc_url( $action['url'] );?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class( $key );?>" <?php echo ( !empty($action['attrs']) ? $action['attrs'] : '' ) ;?>><?php echo esc_html( $action['name'] );?></a> |
|
1885 | + <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?> |
|
1886 | + <a href="<?php echo esc_url($action['url']); ?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class($key); ?>" <?php echo (!empty($action['attrs']) ? $action['attrs'] : ''); ?>><?php echo esc_html($action['name']); ?></a> |
|
1887 | 1887 | <?php } ?> |
1888 | 1888 | </div> |
1889 | 1889 | <?php |
1890 | 1890 | } |
1891 | 1891 | } |
1892 | 1892 | } |
1893 | -add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 ); |
|
1893 | +add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1); |
|
1894 | 1894 | |
1895 | -function wpinv_invoice_link( $invoice_id ) { |
|
1896 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1895 | +function wpinv_invoice_link($invoice_id) { |
|
1896 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1897 | 1897 | |
1898 | - if ( empty( $invoice ) ) { |
|
1898 | + if (empty($invoice)) { |
|
1899 | 1899 | return NULL; |
1900 | 1900 | } |
1901 | 1901 | |
1902 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
1902 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
1903 | 1903 | |
1904 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
1904 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
1905 | 1905 | } |
1906 | 1906 | |
1907 | -function wpinv_invoice_subscription_details( $invoice ) { |
|
1908 | - if ( !empty( $invoice ) && $invoice->is_recurring() && ! wpinv_is_subscription_payment( $invoice ) ) { |
|
1909 | - $subscription = wpinv_get_subscription( $invoice, true ); |
|
1907 | +function wpinv_invoice_subscription_details($invoice) { |
|
1908 | + if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) { |
|
1909 | + $subscription = wpinv_get_subscription($invoice, true); |
|
1910 | 1910 | |
1911 | - if ( empty( $subscription ) ) { |
|
1911 | + if (empty($subscription)) { |
|
1912 | 1912 | return; |
1913 | 1913 | } |
1914 | 1914 | |
@@ -1919,15 +1919,15 @@ discard block |
||
1919 | 1919 | $payments = $subscription->get_child_payments(); |
1920 | 1920 | ?> |
1921 | 1921 | <div class="wpinv-subscriptions-details"> |
1922 | - <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3> |
|
1922 | + <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3> |
|
1923 | 1923 | <table class="table"> |
1924 | 1924 | <thead> |
1925 | 1925 | <tr> |
1926 | - <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th> |
|
1927 | - <th><?php _e( 'Start Date', 'invoicing' ) ;?></th> |
|
1928 | - <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th> |
|
1929 | - <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th> |
|
1930 | - <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th> |
|
1926 | + <th><?php _e('Billing Cycle', 'invoicing'); ?></th> |
|
1927 | + <th><?php _e('Start Date', 'invoicing'); ?></th> |
|
1928 | + <th><?php _e('Expiration Date', 'invoicing'); ?></th> |
|
1929 | + <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th> |
|
1930 | + <th class="text-center"><?php _e('Status', 'invoicing'); ?></th> |
|
1931 | 1931 | </tr> |
1932 | 1932 | </thead> |
1933 | 1933 | <tbody> |
@@ -1941,29 +1941,29 @@ discard block |
||
1941 | 1941 | </tbody> |
1942 | 1942 | </table> |
1943 | 1943 | </div> |
1944 | - <?php if ( !empty( $payments ) ) { ?> |
|
1944 | + <?php if (!empty($payments)) { ?> |
|
1945 | 1945 | <div class="wpinv-renewal-payments"> |
1946 | - <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3> |
|
1946 | + <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3> |
|
1947 | 1947 | <table class="table"> |
1948 | 1948 | <thead> |
1949 | 1949 | <tr> |
1950 | 1950 | <th>#</th> |
1951 | - <th><?php _e( 'Invoice', 'invoicing' ) ;?></th> |
|
1952 | - <th><?php _e( 'Date', 'invoicing' ) ;?></th> |
|
1953 | - <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th> |
|
1951 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
1952 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
1953 | + <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th> |
|
1954 | 1954 | </tr> |
1955 | 1955 | </thead> |
1956 | 1956 | <tbody> |
1957 | 1957 | <?php |
1958 | 1958 | $i = 1; |
1959 | - foreach ( $payments as $payment ) { |
|
1959 | + foreach ($payments as $payment) { |
|
1960 | 1960 | $invoice_id = $payment->ID; |
1961 | 1961 | ?> |
1962 | 1962 | <tr> |
1963 | - <th scope="row"><?php echo $i;?></th> |
|
1964 | - <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td> |
|
1965 | - <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td> |
|
1966 | - <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td> |
|
1963 | + <th scope="row"><?php echo $i; ?></th> |
|
1964 | + <td><?php echo wpinv_invoice_link($invoice_id); ?></td> |
|
1965 | + <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td> |
|
1966 | + <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td> |
|
1967 | 1967 | </tr> |
1968 | 1968 | <?php $i++; } ?> |
1969 | 1969 | </tbody> |
@@ -1974,52 +1974,52 @@ discard block |
||
1974 | 1974 | } |
1975 | 1975 | } |
1976 | 1976 | |
1977 | -function wpinv_cart_total_label( $label, $invoice ) { |
|
1978 | - if ( empty( $invoice ) ) { |
|
1977 | +function wpinv_cart_total_label($label, $invoice) { |
|
1978 | + if (empty($invoice)) { |
|
1979 | 1979 | return $label; |
1980 | 1980 | } |
1981 | 1981 | |
1982 | 1982 | $prefix_label = ''; |
1983 | - if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) { |
|
1984 | - $prefix_label = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice ); |
|
1985 | - } else if ( $invoice->is_renewal() ) { |
|
1986 | - $prefix_label = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> '; |
|
1983 | + if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) { |
|
1984 | + $prefix_label = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice); |
|
1985 | + } else if ($invoice->is_renewal()) { |
|
1986 | + $prefix_label = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> '; |
|
1987 | 1987 | } |
1988 | 1988 | |
1989 | - if ( $prefix_label != '' ) { |
|
1990 | - $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
1989 | + if ($prefix_label != '') { |
|
1990 | + $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
1991 | 1991 | } |
1992 | 1992 | |
1993 | 1993 | return $label; |
1994 | 1994 | } |
1995 | -add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
1996 | -add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
1997 | -add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
1995 | +add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
1996 | +add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
1997 | +add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
1998 | 1998 | |
1999 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 ); |
|
1999 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1); |
|
2000 | 2000 | |
2001 | -function wpinv_invoice_print_description( $invoice ) { |
|
2002 | - if ( empty( $invoice ) ) { |
|
2001 | +function wpinv_invoice_print_description($invoice) { |
|
2002 | + if (empty($invoice)) { |
|
2003 | 2003 | return NULL; |
2004 | 2004 | } |
2005 | - if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) { |
|
2005 | + if ($description = wpinv_get_invoice_description($invoice->ID)) { |
|
2006 | 2006 | ?> |
2007 | 2007 | <div class="row wpinv-lower"> |
2008 | 2008 | <div class="col-sm-12 wpinv-description"> |
2009 | - <?php echo wpautop( $description ); ?> |
|
2009 | + <?php echo wpautop($description); ?> |
|
2010 | 2010 | </div> |
2011 | 2011 | </div> |
2012 | 2012 | <?php |
2013 | 2013 | } |
2014 | 2014 | } |
2015 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 ); |
|
2015 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1); |
|
2016 | 2016 | |
2017 | -function wpinv_invoice_print_payment_info( $invoice ) { |
|
2018 | - if ( empty( $invoice ) ) { |
|
2017 | +function wpinv_invoice_print_payment_info($invoice) { |
|
2018 | + if (empty($invoice)) { |
|
2019 | 2019 | return NULL; |
2020 | 2020 | } |
2021 | 2021 | |
2022 | - if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) { |
|
2022 | + if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) { |
|
2023 | 2023 | ?> |
2024 | 2024 | <div class="row wpinv-payments"> |
2025 | 2025 | <div class="col-sm-12"> |
@@ -2031,43 +2031,43 @@ discard block |
||
2031 | 2031 | } |
2032 | 2032 | // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 ); |
2033 | 2033 | |
2034 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
2035 | - if ( empty( $note ) ) { |
|
2034 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
2035 | + if (empty($note)) { |
|
2036 | 2036 | return NULL; |
2037 | 2037 | } |
2038 | 2038 | |
2039 | - if ( is_int( $note ) ) { |
|
2040 | - $note = get_comment( $note ); |
|
2039 | + if (is_int($note)) { |
|
2040 | + $note = get_comment($note); |
|
2041 | 2041 | } |
2042 | 2042 | |
2043 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
2043 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
2044 | 2044 | return NULL; |
2045 | 2045 | } |
2046 | 2046 | |
2047 | - $note_classes = array( 'note' ); |
|
2048 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
2047 | + $note_classes = array('note'); |
|
2048 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
2049 | 2049 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
2050 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
2051 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
2050 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
2051 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
2052 | 2052 | |
2053 | 2053 | ob_start(); |
2054 | 2054 | ?> |
2055 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>"> |
|
2055 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>"> |
|
2056 | 2056 | <div class="note_content"> |
2057 | - <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> |
|
2057 | + <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> |
|
2058 | 2058 | </div> |
2059 | 2059 | <p class="meta"> |
2060 | - <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf( __( '%1$s - %2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ), date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ); ?></abbr> |
|
2061 | - <?php if ( is_admin() && ( $note->comment_author !== 'System' || wpinv_current_user_can_manage_invoicing() ) ) { ?> |
|
2062 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
2060 | + <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf(__('%1$s - %2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n(get_option('date_format'), strtotime($note->comment_date)), date_i18n(get_option('time_format'), strtotime($note->comment_date))); ?></abbr> |
|
2061 | + <?php if (is_admin() && ($note->comment_author !== 'System' || wpinv_current_user_can_manage_invoicing())) { ?> |
|
2062 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
2063 | 2063 | <?php } ?> |
2064 | 2064 | </p> |
2065 | 2065 | </li> |
2066 | 2066 | <?php |
2067 | 2067 | $note_content = ob_get_clean(); |
2068 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
2068 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
2069 | 2069 | |
2070 | - if ( $echo ) { |
|
2070 | + if ($echo) { |
|
2071 | 2071 | echo $note_content; |
2072 | 2072 | } else { |
2073 | 2073 | return $note_content; |
@@ -2077,43 +2077,43 @@ discard block |
||
2077 | 2077 | function wpinv_invalid_invoice_content() { |
2078 | 2078 | global $post; |
2079 | 2079 | |
2080 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
2080 | + $invoice = wpinv_get_invoice($post->ID); |
|
2081 | 2081 | |
2082 | - $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' ); |
|
2083 | - if ( !empty( $invoice->ID ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
2084 | - if ( is_user_logged_in() ) { |
|
2085 | - if ( wpinv_require_login_to_checkout() ) { |
|
2086 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
2087 | - $error = __( 'You are not allowed to view this invoice.', 'invoicing' ); |
|
2082 | + $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing'); |
|
2083 | + if (!empty($invoice->ID) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) { |
|
2084 | + if (is_user_logged_in()) { |
|
2085 | + if (wpinv_require_login_to_checkout()) { |
|
2086 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
2087 | + $error = __('You are not allowed to view this invoice.', 'invoicing'); |
|
2088 | 2088 | } |
2089 | 2089 | } |
2090 | 2090 | } else { |
2091 | - if ( wpinv_require_login_to_checkout() ) { |
|
2092 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
2093 | - $error = __( 'You must be logged in to view this invoice.', 'invoicing' ); |
|
2091 | + if (wpinv_require_login_to_checkout()) { |
|
2092 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
2093 | + $error = __('You must be logged in to view this invoice.', 'invoicing'); |
|
2094 | 2094 | } |
2095 | 2095 | } |
2096 | 2096 | } |
2097 | 2097 | } else { |
2098 | - $error = __( 'This invoice is deleted or does not exist.', 'invoicing' ); |
|
2098 | + $error = __('This invoice is deleted or does not exist.', 'invoicing'); |
|
2099 | 2099 | } |
2100 | 2100 | ?> |
2101 | 2101 | <div class="row wpinv-row-invalid"> |
2102 | 2102 | <div class="col-md-6 col-md-offset-3 wpinv-message error"> |
2103 | - <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3> |
|
2103 | + <h3><?php _e('Access Denied', 'invoicing'); ?></h3> |
|
2104 | 2104 | <p class="wpinv-msg-text"><?php echo $error; ?></p> |
2105 | 2105 | </div> |
2106 | 2106 | </div> |
2107 | 2107 | <?php |
2108 | 2108 | } |
2109 | -add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' ); |
|
2109 | +add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content'); |
|
2110 | 2110 | |
2111 | -add_action( 'wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field'); |
|
2112 | -function wpinv_force_company_name_field(){ |
|
2111 | +add_action('wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field'); |
|
2112 | +function wpinv_force_company_name_field() { |
|
2113 | 2113 | $invoice = wpinv_get_invoice_cart(); |
2114 | - $user_id = wpinv_get_user_id( $invoice->ID ); |
|
2115 | - $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true ); |
|
2116 | - if ( 1 == wpinv_get_option( 'force_show_company' ) && !wpinv_use_taxes() ) { |
|
2114 | + $user_id = wpinv_get_user_id($invoice->ID); |
|
2115 | + $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true); |
|
2116 | + if (1 == wpinv_get_option('force_show_company') && !wpinv_use_taxes()) { |
|
2117 | 2117 | ?> |
2118 | 2118 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
2119 | 2119 | <label for="wpinv_company" class="wpi-label"><?php _e('Company Name', 'invoicing'); ?></label> |
@@ -2139,21 +2139,21 @@ discard block |
||
2139 | 2139 | * @return string |
2140 | 2140 | */ |
2141 | 2141 | function wpinv_get_policy_text() { |
2142 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
2142 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
2143 | 2143 | |
2144 | - $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' )); |
|
2144 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
2145 | 2145 | |
2146 | - if(!$privacy_page_id){ |
|
2147 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
2146 | + if (!$privacy_page_id) { |
|
2147 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
2148 | 2148 | } |
2149 | 2149 | |
2150 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
2150 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
2151 | 2151 | |
2152 | 2152 | $find_replace = array( |
2153 | 2153 | '[wpinv_privacy_policy]' => $privacy_link, |
2154 | 2154 | ); |
2155 | 2155 | |
2156 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
2156 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
2157 | 2157 | |
2158 | 2158 | return wp_kses_post(wpautop($privacy_text)); |
2159 | 2159 | } |
@@ -2162,25 +2162,25 @@ discard block |
||
2162 | 2162 | /** |
2163 | 2163 | * Allows the user to set their own price for an invoice item |
2164 | 2164 | */ |
2165 | -function wpinv_checkout_cart_item_name_your_price( $cart_item, $key ) { |
|
2165 | +function wpinv_checkout_cart_item_name_your_price($cart_item, $key) { |
|
2166 | 2166 | |
2167 | 2167 | //Ensure we have an item id |
2168 | - if(! is_array( $cart_item ) || empty( $cart_item['id'] ) ) { |
|
2168 | + if (!is_array($cart_item) || empty($cart_item['id'])) { |
|
2169 | 2169 | return; |
2170 | 2170 | } |
2171 | 2171 | |
2172 | 2172 | //Fetch the item |
2173 | 2173 | $item_id = $cart_item['id']; |
2174 | - $item = new WPInv_Item( $item_id ); |
|
2174 | + $item = new WPInv_Item($item_id); |
|
2175 | 2175 | |
2176 | - if(! $item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing() ) { |
|
2176 | + if (!$item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing()) { |
|
2177 | 2177 | return; |
2178 | 2178 | } |
2179 | 2179 | |
2180 | 2180 | //Fetch the dynamic pricing "strings" |
2181 | - $suggested_price_text = esc_html( wpinv_get_option( 'suggested_price_text', __( 'Suggested Price:', 'invoicing' ) ) ); |
|
2182 | - $minimum_price_text = esc_html( wpinv_get_option( 'minimum_price_text', __( 'Minimum Price:', 'invoicing' ) ) ); |
|
2183 | - $name_your_price_text = esc_html( wpinv_get_option( 'name_your_price_text', __( 'Name Your Price', 'invoicing' ) ) ); |
|
2181 | + $suggested_price_text = esc_html(wpinv_get_option('suggested_price_text', __('Suggested Price:', 'invoicing'))); |
|
2182 | + $minimum_price_text = esc_html(wpinv_get_option('minimum_price_text', __('Minimum Price:', 'invoicing'))); |
|
2183 | + $name_your_price_text = esc_html(wpinv_get_option('name_your_price_text', __('Name Your Price', 'invoicing'))); |
|
2184 | 2184 | |
2185 | 2185 | //Display a "name_your_price" button |
2186 | 2186 | echo " — <a href='#' class='wpinv-name-your-price-frontend small'>$name_your_price_text</a></div>"; |
@@ -2189,7 +2189,7 @@ discard block |
||
2189 | 2189 | echo '<div class="name-your-price-miniform">'; |
2190 | 2190 | |
2191 | 2191 | //Maybe display the recommended price |
2192 | - if( $item->get_price() > 0 && !empty( $suggested_price_text ) ) { |
|
2192 | + if ($item->get_price() > 0 && !empty($suggested_price_text)) { |
|
2193 | 2193 | $suggested_price = $item->get_the_price(); |
2194 | 2194 | echo "<div>$suggested_price_text — $suggested_price</div>"; |
2195 | 2195 | } |
@@ -2197,198 +2197,198 @@ discard block |
||
2197 | 2197 | //Display the update price form |
2198 | 2198 | $symbol = wpinv_currency_symbol(); |
2199 | 2199 | $position = wpinv_currency_position(); |
2200 | - $minimum = esc_attr( $item->get_minimum_price() ); |
|
2201 | - $price = esc_attr( $cart_item['item_price'] ); |
|
2202 | - $update = esc_attr__( "Update", 'invoicing' ); |
|
2200 | + $minimum = esc_attr($item->get_minimum_price()); |
|
2201 | + $price = esc_attr($cart_item['item_price']); |
|
2202 | + $update = esc_attr__("Update", 'invoicing'); |
|
2203 | 2203 | |
2204 | 2204 | //Ensure it supports dynamic prici |
2205 | - if( $price < $minimum ) { |
|
2205 | + if ($price < $minimum) { |
|
2206 | 2206 | $price = $minimum; |
2207 | 2207 | } |
2208 | 2208 | |
2209 | 2209 | echo '<label>'; |
2210 | 2210 | echo $position != 'right' ? $symbol . ' ' : ''; |
2211 | 2211 | echo "<input type='number' min='$minimum' placeholder='$price' value='$price' class='wpi-field-price' />"; |
2212 | - echo $position == 'right' ? ' ' . $symbol : '' ; |
|
2212 | + echo $position == 'right' ? ' ' . $symbol : ''; |
|
2213 | 2213 | echo "</label>"; |
2214 | 2214 | echo "<input type='hidden' value='$item_id' class='wpi-field-item' />"; |
2215 | 2215 | echo "<a class='btn btn-success wpinv-submit wpinv-update-dynamic-price-frontend'>$update</a>"; |
2216 | 2216 | |
2217 | 2217 | //Maybe display the minimum price |
2218 | - if( $item->get_minimum_price() > 0 && !empty( $minimum_price_text ) ) { |
|
2219 | - $minimum_price = wpinv_price( wpinv_format_amount( $item->get_minimum_price() ) ); |
|
2218 | + if ($item->get_minimum_price() > 0 && !empty($minimum_price_text)) { |
|
2219 | + $minimum_price = wpinv_price(wpinv_format_amount($item->get_minimum_price())); |
|
2220 | 2220 | echo "<div>$minimum_price_text — $minimum_price</div>"; |
2221 | 2221 | } |
2222 | 2222 | |
2223 | 2223 | echo "</div>"; |
2224 | 2224 | |
2225 | 2225 | } |
2226 | -add_action( 'wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2 ); |
|
2226 | +add_action('wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2); |
|
2227 | 2227 | |
2228 | 2228 | function wpinv_oxygen_fix_conflict() { |
2229 | 2229 | global $ct_ignore_post_types; |
2230 | 2230 | |
2231 | - if ( ! is_array( $ct_ignore_post_types ) ) { |
|
2231 | + if (!is_array($ct_ignore_post_types)) { |
|
2232 | 2232 | $ct_ignore_post_types = array(); |
2233 | 2233 | } |
2234 | 2234 | |
2235 | - $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' ); |
|
2235 | + $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item'); |
|
2236 | 2236 | |
2237 | - foreach ( $post_types as $post_type ) { |
|
2237 | + foreach ($post_types as $post_type) { |
|
2238 | 2238 | $ct_ignore_post_types[] = $post_type; |
2239 | 2239 | |
2240 | 2240 | // Ignore post type |
2241 | - add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 ); |
|
2241 | + add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999); |
|
2242 | 2242 | } |
2243 | 2243 | |
2244 | - remove_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
2245 | - add_filter( 'template_include', 'wpinv_template', 999, 1 ); |
|
2244 | + remove_filter('template_include', 'wpinv_template', 10, 1); |
|
2245 | + add_filter('template_include', 'wpinv_template', 999, 1); |
|
2246 | 2246 | } |
2247 | 2247 | |
2248 | 2248 | /** |
2249 | 2249 | * Helper function to display a payment form on the frontend. |
2250 | 2250 | */ |
2251 | -function getpaid_display_payment_form( $form ) { |
|
2251 | +function getpaid_display_payment_form($form) { |
|
2252 | 2252 | global $invoicing; |
2253 | 2253 | |
2254 | 2254 | // Ensure that it is published. |
2255 | - if ( 'publish' != get_post_status( $form ) ) { |
|
2255 | + if ('publish' != get_post_status($form)) { |
|
2256 | 2256 | return aui()->alert( |
2257 | 2257 | array( |
2258 | 2258 | 'type' => 'warning', |
2259 | - 'content' => __( 'This payment form is no longer active', 'invoicing' ), |
|
2259 | + 'content' => __('This payment form is no longer active', 'invoicing'), |
|
2260 | 2260 | ) |
2261 | 2261 | ); |
2262 | 2262 | } |
2263 | 2263 | |
2264 | 2264 | // Get the form. |
2265 | - $form = new GetPaid_Payment_Form( $form ); |
|
2266 | - $html = wpinv_get_template_html( 'payment-forms/form.php', compact( 'form' ) ); |
|
2267 | - return str_replace( 'sr-only', '', $html ); |
|
2265 | + $form = new GetPaid_Payment_Form($form); |
|
2266 | + $html = wpinv_get_template_html('payment-forms/form.php', compact('form')); |
|
2267 | + return str_replace('sr-only', '', $html); |
|
2268 | 2268 | |
2269 | 2269 | } |
2270 | 2270 | |
2271 | 2271 | /** |
2272 | 2272 | * Helper function to display a item payment form on the frontend. |
2273 | 2273 | */ |
2274 | -function getpaid_display_item_payment_form( $items ) { |
|
2274 | +function getpaid_display_item_payment_form($items) { |
|
2275 | 2275 | global $invoicing; |
2276 | 2276 | |
2277 | - foreach ( array_keys( $items ) as $id ) { |
|
2278 | - if ( 'publish' != get_post_status( $id ) ) { |
|
2279 | - unset( $items[ $id ] ); |
|
2277 | + foreach (array_keys($items) as $id) { |
|
2278 | + if ('publish' != get_post_status($id)) { |
|
2279 | + unset($items[$id]); |
|
2280 | 2280 | } |
2281 | 2281 | } |
2282 | 2282 | |
2283 | - if ( empty( $items ) ) { |
|
2283 | + if (empty($items)) { |
|
2284 | 2284 | return aui()->alert( |
2285 | 2285 | array( |
2286 | 2286 | 'type' => 'warning', |
2287 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
2287 | + 'content' => __('No published items found', 'invoicing'), |
|
2288 | 2288 | ) |
2289 | 2289 | ); |
2290 | 2290 | } |
2291 | 2291 | |
2292 | - $item_key = getpaid_convert_items_to_string( $items ); |
|
2292 | + $item_key = getpaid_convert_items_to_string($items); |
|
2293 | 2293 | |
2294 | 2294 | // Get the form elements and items. |
2295 | 2295 | $form = wpinv_get_default_payment_form(); |
2296 | - $elements = $invoicing->form_elements->get_form_elements( $form ); |
|
2297 | - $items = $invoicing->form_elements->convert_normal_items( $items ); |
|
2296 | + $elements = $invoicing->form_elements->get_form_elements($form); |
|
2297 | + $items = $invoicing->form_elements->convert_normal_items($items); |
|
2298 | 2298 | |
2299 | 2299 | ob_start(); |
2300 | 2300 | echo "<form class='wpinv_payment_form'>"; |
2301 | - do_action( 'wpinv_payment_form_top' ); |
|
2301 | + do_action('wpinv_payment_form_top'); |
|
2302 | 2302 | echo "<input type='hidden' name='form_id' value='$form'/>"; |
2303 | 2303 | echo "<input type='hidden' name='form_items' value='$item_key'/>"; |
2304 | - wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
2305 | - wp_nonce_field( 'vat_validation', '_wpi_nonce' ); |
|
2304 | + wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form'); |
|
2305 | + wp_nonce_field('vat_validation', '_wpi_nonce'); |
|
2306 | 2306 | |
2307 | - foreach ( $elements as $element ) { |
|
2308 | - do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form ); |
|
2309 | - do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form ); |
|
2307 | + foreach ($elements as $element) { |
|
2308 | + do_action('wpinv_frontend_render_payment_form_element', $element, $items, $form); |
|
2309 | + do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form); |
|
2310 | 2310 | } |
2311 | 2311 | |
2312 | 2312 | echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>"; |
2313 | - do_action( 'wpinv_payment_form_bottom' ); |
|
2313 | + do_action('wpinv_payment_form_bottom'); |
|
2314 | 2314 | echo '</form>'; |
2315 | 2315 | |
2316 | 2316 | $content = ob_get_clean(); |
2317 | - return str_replace( 'sr-only', '', $content ); |
|
2317 | + return str_replace('sr-only', '', $content); |
|
2318 | 2318 | } |
2319 | 2319 | |
2320 | 2320 | /** |
2321 | 2321 | * Helper function to display an invoice payment form on the frontend. |
2322 | 2322 | */ |
2323 | -function getpaid_display_invoice_payment_form( $invoice_id ) { |
|
2323 | +function getpaid_display_invoice_payment_form($invoice_id) { |
|
2324 | 2324 | global $invoicing; |
2325 | 2325 | |
2326 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
2326 | + $invoice = wpinv_get_invoice($invoice_id); |
|
2327 | 2327 | |
2328 | - if ( empty( $invoice ) ) { |
|
2328 | + if (empty($invoice)) { |
|
2329 | 2329 | return aui()->alert( |
2330 | 2330 | array( |
2331 | 2331 | 'type' => 'warning', |
2332 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
2332 | + 'content' => __('Invoice not found', 'invoicing'), |
|
2333 | 2333 | ) |
2334 | 2334 | ); |
2335 | 2335 | } |
2336 | 2336 | |
2337 | - if ( $invoice->is_paid() ) { |
|
2337 | + if ($invoice->is_paid()) { |
|
2338 | 2338 | return aui()->alert( |
2339 | 2339 | array( |
2340 | 2340 | 'type' => 'warning', |
2341 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
2341 | + 'content' => __('Invoice has already been paid', 'invoicing'), |
|
2342 | 2342 | ) |
2343 | 2343 | ); |
2344 | 2344 | } |
2345 | 2345 | |
2346 | 2346 | // Get the form elements and items. |
2347 | - $form = wpinv_get_default_payment_form(); |
|
2348 | - $elements = $invoicing->form_elements->get_form_elements( $form ); |
|
2349 | - $items = $invoicing->form_elements->convert_checkout_items( $invoice->cart_details, $invoice ); |
|
2347 | + $form = wpinv_get_default_payment_form(); |
|
2348 | + $elements = $invoicing->form_elements->get_form_elements($form); |
|
2349 | + $items = $invoicing->form_elements->convert_checkout_items($invoice->cart_details, $invoice); |
|
2350 | 2350 | |
2351 | 2351 | ob_start(); |
2352 | 2352 | echo "<form class='wpinv_payment_form'>"; |
2353 | - do_action( 'wpinv_payment_form_top' ); |
|
2353 | + do_action('wpinv_payment_form_top'); |
|
2354 | 2354 | echo "<input type='hidden' name='form_id' value='$form'/>"; |
2355 | 2355 | echo "<input type='hidden' name='invoice_id' value='$invoice_id'/>"; |
2356 | - wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
2357 | - wp_nonce_field( 'vat_validation', '_wpi_nonce' ); |
|
2356 | + wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form'); |
|
2357 | + wp_nonce_field('vat_validation', '_wpi_nonce'); |
|
2358 | 2358 | |
2359 | - foreach ( $elements as $element ) { |
|
2360 | - do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form ); |
|
2361 | - do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form ); |
|
2359 | + foreach ($elements as $element) { |
|
2360 | + do_action('wpinv_frontend_render_payment_form_element', $element, $items, $form); |
|
2361 | + do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form); |
|
2362 | 2362 | } |
2363 | 2363 | |
2364 | 2364 | echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>"; |
2365 | - do_action( 'wpinv_payment_form_bottom' ); |
|
2365 | + do_action('wpinv_payment_form_bottom'); |
|
2366 | 2366 | echo '</form>'; |
2367 | 2367 | |
2368 | 2368 | $content = ob_get_clean(); |
2369 | - return str_replace( 'sr-only', '', $content ); |
|
2369 | + return str_replace('sr-only', '', $content); |
|
2370 | 2370 | } |
2371 | 2371 | |
2372 | 2372 | /** |
2373 | 2373 | * Helper function to convert item string to array. |
2374 | 2374 | */ |
2375 | -function getpaid_convert_items_to_array( $items ) { |
|
2376 | - $items = array_filter( array_map( 'trim', explode( ',', $items ) ) ); |
|
2375 | +function getpaid_convert_items_to_array($items) { |
|
2376 | + $items = array_filter(array_map('trim', explode(',', $items))); |
|
2377 | 2377 | $prepared = array(); |
2378 | 2378 | |
2379 | - foreach ( $items as $item ) { |
|
2380 | - $data = array_map( 'trim', explode( '|', $item ) ); |
|
2379 | + foreach ($items as $item) { |
|
2380 | + $data = array_map('trim', explode('|', $item)); |
|
2381 | 2381 | |
2382 | - if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) { |
|
2382 | + if (empty($data[0]) || !is_numeric($data[0])) { |
|
2383 | 2383 | continue; |
2384 | 2384 | } |
2385 | 2385 | |
2386 | 2386 | $quantity = 1; |
2387 | - if ( isset( $data[1] ) && is_numeric( $data[1] ) ) { |
|
2387 | + if (isset($data[1]) && is_numeric($data[1])) { |
|
2388 | 2388 | $quantity = $data[1]; |
2389 | 2389 | } |
2390 | 2390 | |
2391 | - $prepared[ $data[0] ] = $quantity; |
|
2391 | + $prepared[$data[0]] = $quantity; |
|
2392 | 2392 | |
2393 | 2393 | } |
2394 | 2394 | |
@@ -2398,13 +2398,13 @@ discard block |
||
2398 | 2398 | /** |
2399 | 2399 | * Helper function to convert item array to string. |
2400 | 2400 | */ |
2401 | -function getpaid_convert_items_to_string( $items ) { |
|
2401 | +function getpaid_convert_items_to_string($items) { |
|
2402 | 2402 | $prepared = array(); |
2403 | 2403 | |
2404 | - foreach ( $items as $item => $quantity ) { |
|
2404 | + foreach ($items as $item => $quantity) { |
|
2405 | 2405 | $prepared[] = "$item|$quantity"; |
2406 | 2406 | } |
2407 | - return implode( ',', $prepared ); |
|
2407 | + return implode(',', $prepared); |
|
2408 | 2408 | } |
2409 | 2409 | |
2410 | 2410 | /** |
@@ -2412,22 +2412,22 @@ discard block |
||
2412 | 2412 | * |
2413 | 2413 | * Provide a label and one of $form, $items or $invoice. |
2414 | 2414 | */ |
2415 | -function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) { |
|
2416 | - $label = sanitize_text_field( $label ); |
|
2415 | +function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) { |
|
2416 | + $label = sanitize_text_field($label); |
|
2417 | 2417 | $nonce = wp_create_nonce('getpaid_ajax_form'); |
2418 | 2418 | |
2419 | - if ( ! empty( $form ) ) { |
|
2420 | - $form = esc_attr( $form ); |
|
2419 | + if (!empty($form)) { |
|
2420 | + $form = esc_attr($form); |
|
2421 | 2421 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-form='$form'>$label</button>"; |
2422 | 2422 | } |
2423 | 2423 | |
2424 | - if ( ! empty( $items ) ) { |
|
2425 | - $items = esc_attr( $items ); |
|
2424 | + if (!empty($items)) { |
|
2425 | + $items = esc_attr($items); |
|
2426 | 2426 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-item='$items'>$label</button>"; |
2427 | 2427 | } |
2428 | 2428 | |
2429 | - if ( ! empty( $invoice ) ) { |
|
2430 | - $invoice = esc_attr( $invoice ); |
|
2429 | + if (!empty($invoice)) { |
|
2430 | + $invoice = esc_attr($invoice); |
|
2431 | 2431 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-invoice='$invoice'>$label</button>"; |
2432 | 2432 | } |
2433 | 2433 | |
@@ -2438,15 +2438,15 @@ discard block |
||
2438 | 2438 | * |
2439 | 2439 | * @param WPInv_Invoice $invoice |
2440 | 2440 | */ |
2441 | -function getpaid_the_invoice_description( $invoice ) { |
|
2442 | - if ( empty( $invoice->description ) ) { |
|
2441 | +function getpaid_the_invoice_description($invoice) { |
|
2442 | + if (empty($invoice->description)) { |
|
2443 | 2443 | return; |
2444 | 2444 | } |
2445 | 2445 | |
2446 | - $description = wp_kses_post( $invoice->description ); |
|
2446 | + $description = wp_kses_post($invoice->description); |
|
2447 | 2447 | echo "<div style='color: #616161; font-size: 90%; margin-bottom: 20px;'><em>$description</em></div>"; |
2448 | 2448 | } |
2449 | -add_action( 'wpinv_invoice_print_before_line_items', 'getpaid_the_invoice_description' ); |
|
2449 | +add_action('wpinv_invoice_print_before_line_items', 'getpaid_the_invoice_description'); |
|
2450 | 2450 | |
2451 | 2451 | /** |
2452 | 2452 | * Render element on a form. |
@@ -2454,41 +2454,41 @@ discard block |
||
2454 | 2454 | * @param array $element |
2455 | 2455 | * @param GetPaid_Payment_Form $form |
2456 | 2456 | */ |
2457 | -function getpaid_payment_form_element( $element, $form ) { |
|
2457 | +function getpaid_payment_form_element($element, $form) { |
|
2458 | 2458 | |
2459 | 2459 | // Set up the args. |
2460 | - $element_type = trim( $element['type'] ); |
|
2460 | + $element_type = trim($element['type']); |
|
2461 | 2461 | $element['form'] = $form; |
2462 | - extract( $element ); |
|
2462 | + extract($element); |
|
2463 | 2463 | |
2464 | 2464 | // Try to locate the appropriate template. |
2465 | - $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" ); |
|
2465 | + $located = wpinv_locate_template("payment-forms/elements/$element_type.php"); |
|
2466 | 2466 | |
2467 | 2467 | // Abort if this is not our element. |
2468 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
2468 | + if (empty($located) || !file_exists($located)) { |
|
2469 | 2469 | return; |
2470 | 2470 | } |
2471 | 2471 | |
2472 | 2472 | // Generate the class and id of the element. |
2473 | - $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) ); |
|
2474 | - $id = isset( $id ) ? $id : uniqid( 'gp' ); |
|
2473 | + $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type)); |
|
2474 | + $id = isset($id) ? $id : uniqid('gp'); |
|
2475 | 2475 | |
2476 | 2476 | // Echo the opening wrapper. |
2477 | 2477 | echo "<div class='getpaid-payment-form-element $wrapper_class'>"; |
2478 | 2478 | |
2479 | 2479 | // Fires before displaying a given element type's content. |
2480 | - do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form ); |
|
2480 | + do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form); |
|
2481 | 2481 | |
2482 | 2482 | // Include the template for the element. |
2483 | 2483 | include $located; |
2484 | 2484 | |
2485 | 2485 | // Fires after displaying a given element type's content. |
2486 | - do_action( "getpaid_payment_form_{$element_type}_element", $element, $form ); |
|
2486 | + do_action("getpaid_payment_form_{$element_type}_element", $element, $form); |
|
2487 | 2487 | |
2488 | 2488 | // Echo the closing wrapper. |
2489 | 2489 | echo '</div>'; |
2490 | 2490 | } |
2491 | -add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 ); |
|
2491 | +add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2); |
|
2492 | 2492 | |
2493 | 2493 | /** |
2494 | 2494 | * Shows a list of gateways that support recurring payments. |
@@ -2496,16 +2496,16 @@ discard block |
||
2496 | 2496 | function wpinv_get_recurring_gateways_text() { |
2497 | 2497 | $gateways = array(); |
2498 | 2498 | |
2499 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
2500 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
2501 | - $gateways[] = sanitize_text_field( $gateway['admin_label'] ); |
|
2499 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
2500 | + if (wpinv_gateway_support_subscription($key)) { |
|
2501 | + $gateways[] = sanitize_text_field($gateway['admin_label']); |
|
2502 | 2502 | } |
2503 | 2503 | } |
2504 | 2504 | |
2505 | - if ( empty( $gateways ) ) { |
|
2506 | - return "<span class='form-text text-danger'>" . __( 'No active gateway supports subscription payments.', 'invoicing' ) ."</span>"; |
|
2505 | + if (empty($gateways)) { |
|
2506 | + return "<span class='form-text text-danger'>" . __('No active gateway supports subscription payments.', 'invoicing') . "</span>"; |
|
2507 | 2507 | } |
2508 | 2508 | |
2509 | - return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) ."</span>"; |
|
2509 | + return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . "</span>"; |
|
2510 | 2510 | |
2511 | 2511 | } |
@@ -7,60 +7,60 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -$invoice = new WPInv_Invoice( $invoice ); |
|
12 | +$invoice = new WPInv_Invoice($invoice); |
|
13 | 13 | |
14 | 14 | // Fires before printing the line items. |
15 | -do_action( 'getpaid_before_invoice_line_items', $invoice ); |
|
15 | +do_action('getpaid_before_invoice_line_items', $invoice); |
|
16 | 16 | |
17 | 17 | // Line item columns. |
18 | 18 | $columns = apply_filters( |
19 | 19 | 'getpaid_invoice_line_items_table_columns', |
20 | 20 | array( |
21 | - 'name' => __( 'Item', 'invoicing' ), |
|
22 | - 'price' => __( 'Price', 'invoicing' ), |
|
23 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
24 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
21 | + 'name' => __('Item', 'invoicing'), |
|
22 | + 'price' => __('Price', 'invoicing'), |
|
23 | + 'quantity' => __('Quantity', 'invoicing'), |
|
24 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
25 | 25 | ), |
26 | 26 | $form |
27 | 27 | ); |
28 | 28 | |
29 | 29 | // Quantities. |
30 | -if ( isset( $columns[ 'quantity' ] ) ) { |
|
30 | +if (isset($columns['quantity'])) { |
|
31 | 31 | |
32 | - if ( 'amount' == $invoice->get_template() ) { |
|
33 | - unset( $columns[ 'quantity' ] ); |
|
32 | + if ('amount' == $invoice->get_template()) { |
|
33 | + unset($columns['quantity']); |
|
34 | 34 | } |
35 | 35 | |
36 | - if ( 'hours' == $invoice->get_template() ) { |
|
37 | - $columns[ 'quantity' ] = __( 'Hours', 'invoicing' ); |
|
36 | + if ('hours' == $invoice->get_template()) { |
|
37 | + $columns['quantity'] = __('Hours', 'invoicing'); |
|
38 | 38 | } |
39 | 39 | |
40 | - if ( ! wpinv_item_quantities_enabled() ) { |
|
41 | - unset( $columns[ 'quantity' ] ); |
|
40 | + if (!wpinv_item_quantities_enabled()) { |
|
41 | + unset($columns['quantity']); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | } |
45 | 45 | |
46 | 46 | // Price. |
47 | -if ( isset( $columns[ 'price' ] ) ) { |
|
47 | +if (isset($columns['price'])) { |
|
48 | 48 | |
49 | - if ( 'amount' == $invoice->get_template() ) { |
|
50 | - $columns[ 'price' ] = __( 'Amount', 'invoicing' ); |
|
49 | + if ('amount' == $invoice->get_template()) { |
|
50 | + $columns['price'] = __('Amount', 'invoicing'); |
|
51 | 51 | } |
52 | 52 | |
53 | - if ( 'hours' == $invoice->get_template() ) { |
|
54 | - $columns[ 'price' ] = __( 'Rate', 'invoicing' ); |
|
53 | + if ('hours' == $invoice->get_template()) { |
|
54 | + $columns['price'] = __('Rate', 'invoicing'); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | } |
58 | 58 | |
59 | 59 | // Sub total. |
60 | -if ( isset( $columns[ 'subtotal' ] ) ) { |
|
60 | +if (isset($columns['subtotal'])) { |
|
61 | 61 | |
62 | - if ( 'amount' == $invoice->get_template() ) { |
|
63 | - unset( $columns[ 'subtotal' ] ); |
|
62 | + if ('amount' == $invoice->get_template()) { |
|
63 | + unset($columns['subtotal']); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | } |
@@ -69,11 +69,11 @@ discard block |
||
69 | 69 | |
70 | 70 | <table class="table table-sm table-bordered"> |
71 | 71 | <thead> |
72 | - <?php wpinv_get_template( 'line-item-header.php', compact( 'item', 'invoice', 'columns' ) );?> |
|
72 | + <?php wpinv_get_template('line-item-header.php', compact('item', 'invoice', 'columns')); ?> |
|
73 | 73 | </thead> |
74 | 74 | <tbody> |
75 | - <?php foreach ( $invoice->get_items() as $item_id => $item ) : ?> |
|
76 | - <?php wpinv_get_template( 'line-item.php', compact( 'item', 'invoice', 'columns' ) ); ?> |
|
75 | + <?php foreach ($invoice->get_items() as $item_id => $item) : ?> |
|
76 | + <?php wpinv_get_template('line-item.php', compact('item', 'invoice', 'columns')); ?> |
|
77 | 77 | <?php endforeach; ?> |
78 | 78 | </tbody> |
79 | 79 | </table> |
80 | 80 | \ No newline at end of file |
@@ -7,55 +7,55 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | $item_id = (int) $item->get_id(); |
13 | 13 | |
14 | 14 | ?> |
15 | -<tr class="item-<?php echo $item_id; ?> <?php echo sanitize_html_class( $item->get_type() ); ?>" id="wpinv-line-item-<?php echo $item_id; ?>"> |
|
16 | - <?php foreach ( array_keys( $columns ) as $column ): ?> |
|
15 | +<tr class="item-<?php echo $item_id; ?> <?php echo sanitize_html_class($item->get_type()); ?>" id="wpinv-line-item-<?php echo $item_id; ?>"> |
|
16 | + <?php foreach (array_keys($columns) as $column): ?> |
|
17 | 17 | |
18 | - <?php do_action( 'getpaid_line_items_col_body_before_' . $column, $invoice, $item ); ?> |
|
18 | + <?php do_action('getpaid_line_items_col_body_before_' . $column, $invoice, $item); ?> |
|
19 | 19 | <td class='wpinv-line-item-<?php echo esc_attr($column) ?> <?php echo esc_attr($column) ?>' id='wpinv-line-item-<?php echo esc_attr($column) . $item_id ?>'> |
20 | 20 | |
21 | 21 | <?php |
22 | 22 | |
23 | - do_action( "getpaid_line_item_before_$column", $item, $invoice ); |
|
23 | + do_action("getpaid_line_item_before_$column", $item, $invoice); |
|
24 | 24 | |
25 | 25 | // Item name. |
26 | - if ( 'name' == $column ) { |
|
27 | - echo sanitize_text_field( $item->get_name() ); |
|
26 | + if ('name' == $column) { |
|
27 | + echo sanitize_text_field($item->get_name()); |
|
28 | 28 | $description = $item->get_description(); |
29 | 29 | |
30 | - if ( ! empty( $description ) ) { |
|
31 | - $description = wp_kses_post( $description ); |
|
30 | + if (!empty($description)) { |
|
31 | + $description = wp_kses_post($description); |
|
32 | 32 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
33 | 33 | } |
34 | 34 | |
35 | 35 | } |
36 | 36 | |
37 | 37 | // Item price. |
38 | - if ( 'price' == $column ) { |
|
39 | - echo wpinv_price( wpinv_format_amount( $item->get_sub_total() ), $item->get_initial_price() ); |
|
38 | + if ('price' == $column) { |
|
39 | + echo wpinv_price(wpinv_format_amount($item->get_sub_total()), $item->get_initial_price()); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | // Item quantity. |
43 | - if ( 'quantity' == $column ) { |
|
43 | + if ('quantity' == $column) { |
|
44 | 44 | echo (int) $item->get_qantity(); |
45 | 45 | } |
46 | 46 | |
47 | 47 | // Item sub total. |
48 | - if ( 'subtotal' == $key ) { |
|
49 | - echo wpinv_price( wpinv_format_amount( $item->get_sub_total() ), $invoice->get_currency() ); |
|
48 | + if ('subtotal' == $key) { |
|
49 | + echo wpinv_price(wpinv_format_amount($item->get_sub_total()), $invoice->get_currency()); |
|
50 | 50 | } |
51 | 51 | |
52 | - do_action( "getpaid_line_item_$column", $item, $invoice ); |
|
52 | + do_action("getpaid_line_item_$column", $item, $invoice); |
|
53 | 53 | |
54 | - do_action( "getpaid_line_item_after_$column", $item, $invoice ); |
|
54 | + do_action("getpaid_line_item_after_$column", $item, $invoice); |
|
55 | 55 | |
56 | 56 | ?> |
57 | 57 | </td> |
58 | - <?php do_action( 'getpaid_line_items_col_body_before_' . $column, $invoice, $item ); ?> |
|
58 | + <?php do_action('getpaid_line_items_col_body_before_' . $column, $invoice, $item); ?> |
|
59 | 59 | <?php endforeach; ?> |
60 | 60 | </tr> |
61 | 61 | <?php |
@@ -1,62 +1,62 @@ |
||
1 | 1 | <?php |
2 | -if ( !defined('ABSPATH') ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | global $post; |
6 | 6 | $invoice_id = $post->ID; |
7 | -$invoice = wpinv_get_invoice( $invoice_id ); |
|
8 | -if ( empty( $invoice ) ) { |
|
7 | +$invoice = wpinv_get_invoice($invoice_id); |
|
8 | +if (empty($invoice)) { |
|
9 | 9 | exit; |
10 | 10 | } |
11 | -$type = $post->post_type == 'wpi_invoice' ? __( 'Invoice', 'invoicing' ): __( 'Quotation', 'invoicing' ); |
|
12 | -do_action( 'wpinv_invoice_print_before_display', $invoice ); ?> |
|
11 | +$type = $post->post_type == 'wpi_invoice' ? __('Invoice', 'invoicing') : __('Quotation', 'invoicing'); |
|
12 | +do_action('wpinv_invoice_print_before_display', $invoice); ?> |
|
13 | 13 | <!DOCTYPE html> |
14 | 14 | <html <?php language_attributes(); ?>> |
15 | 15 | <head> |
16 | 16 | <meta charset="UTF-8"> |
17 | 17 | <title><?php wp_title() ?></title> |
18 | - <meta charset="<?php bloginfo( 'charset' ); ?>" /> |
|
18 | + <meta charset="<?php bloginfo('charset'); ?>" /> |
|
19 | 19 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
20 | 20 | <meta name="robots" content="noindex,nofollow"> |
21 | 21 | |
22 | - <?php do_action( 'wpinv_invoice_print_head', $invoice ); ?> |
|
22 | + <?php do_action('wpinv_invoice_print_head', $invoice); ?> |
|
23 | 23 | </head> |
24 | 24 | <body class="body wpinv wpinv-print bsui"> |
25 | - <?php do_action( 'getpaid_invoice_top_bar', $invoice ); ?> |
|
26 | - <?php do_action( 'wpinv_invoice_print_body_start', $invoice ); ?> |
|
25 | + <?php do_action('getpaid_invoice_top_bar', $invoice); ?> |
|
26 | + <?php do_action('wpinv_invoice_print_body_start', $invoice); ?> |
|
27 | 27 | <div class="container wpinv-wrap"> |
28 | - <?php if ( $watermark = wpinv_watermark( $invoice_id ) ) { ?> |
|
29 | - <div class="watermark no-print"><p><?php echo esc_html( $watermark ) ?></p></div> |
|
28 | + <?php if ($watermark = wpinv_watermark($invoice_id)) { ?> |
|
29 | + <div class="watermark no-print"><p><?php echo esc_html($watermark) ?></p></div> |
|
30 | 30 | <?php } ?> |
31 | 31 | |
32 | - <?php do_action( 'getpaid_invoice_title', $invoice ); ?> |
|
33 | - <?php do_action( 'getpaid_invoice_details', $invoice ); ?> |
|
34 | - <?php do_action( 'wpinv_invoice_print_middle', $invoice ); ?> |
|
32 | + <?php do_action('getpaid_invoice_title', $invoice); ?> |
|
33 | + <?php do_action('getpaid_invoice_details', $invoice); ?> |
|
34 | + <?php do_action('wpinv_invoice_print_middle', $invoice); ?> |
|
35 | 35 | |
36 | - <?php do_action( 'wpinv_invoice_print_before_line_items', $invoice ); ?> |
|
36 | + <?php do_action('wpinv_invoice_print_before_line_items', $invoice); ?> |
|
37 | 37 | <div class="row wpinv-items"> |
38 | 38 | <div class="col-sm-12 wpinv-line-items"> |
39 | - <?php wpinv_display_line_items( $invoice_id ); ?> |
|
39 | + <?php wpinv_display_line_items($invoice_id); ?> |
|
40 | 40 | </div> |
41 | 41 | </div> |
42 | - <?php do_action( 'wpinv_invoice_print_after_line_items', $invoice ); ?> |
|
42 | + <?php do_action('wpinv_invoice_print_after_line_items', $invoice); ?> |
|
43 | 43 | |
44 | 44 | <!-- ///// Start PDF footer --> |
45 | 45 | <htmlpagefooter name="wpinv-pdf-footer"> |
46 | - <?php do_action( 'wpinv_invoice_print_before_footer', $invoice ); ?> |
|
46 | + <?php do_action('wpinv_invoice_print_before_footer', $invoice); ?> |
|
47 | 47 | <div class="row wpinv-footer"> |
48 | 48 | <div class="col-sm-12"> |
49 | - <?php if ( $term_text = wpinv_get_terms_text() ) { ?> |
|
50 | - <div class="terms-text"><?php echo wpautop( $term_text ); ?></div> |
|
49 | + <?php if ($term_text = wpinv_get_terms_text()) { ?> |
|
50 | + <div class="terms-text"><?php echo wpautop($term_text); ?></div> |
|
51 | 51 | <?php } ?> |
52 | 52 | <div class="footer-text"><?php echo wpinv_get_business_footer(); ?></div> |
53 | - <div class="print-only"><?php _e( 'Page ', 'invoicing' ) ?> {PAGENO}/{nbpg}</div> |
|
53 | + <div class="print-only"><?php _e('Page ', 'invoicing') ?> {PAGENO}/{nbpg}</div> |
|
54 | 54 | </div> |
55 | 55 | </div> |
56 | - <?php do_action( 'wpinv_invoice_print_after_footer', $invoice ); ?> |
|
56 | + <?php do_action('wpinv_invoice_print_after_footer', $invoice); ?> |
|
57 | 57 | </htmlpagefooter> |
58 | 58 | <!-- End PDF footer ///// --> |
59 | 59 | </div><!-- END wpinv-wrap --> |
60 | - <?php do_action( 'wpinv_invoice_print_body_end', $invoice ); ?> |
|
60 | + <?php do_action('wpinv_invoice_print_body_end', $invoice); ?> |
|
61 | 61 | </body> |
62 | 62 | </html> |
63 | 63 | \ No newline at end of file |
@@ -7,13 +7,13 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | <div class="wpinv-from-address"> |
14 | 14 | <?php wpinv_display_from_address(); ?> |
15 | 15 | </div> |
16 | 16 | <div class="wpinv-to-address"> |
17 | - <?php wpinv_display_to_address( $invoice ); ?> |
|
17 | + <?php wpinv_display_to_address($invoice); ?> |
|
18 | 18 | </div> |
19 | 19 | <?php |
@@ -7,17 +7,17 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <div class="wpinv-top-bar-left-actions"> |
15 | - <?php if ( $invoice->is_type( 'invoice' ) && $invoice->needs_payment() ) : ?> |
|
16 | - <a class="btn btn-success" href="<?php echo esc_url( $invoice->get_checkout_payment_url() ); ?>"> |
|
17 | - <?php _e( 'Pay For Invoice', 'invoicing' ); ?> |
|
15 | + <?php if ($invoice->is_type('invoice') && $invoice->needs_payment()) : ?> |
|
16 | + <a class="btn btn-success" href="<?php echo esc_url($invoice->get_checkout_payment_url()); ?>"> |
|
17 | + <?php _e('Pay For Invoice', 'invoicing'); ?> |
|
18 | 18 | </a> |
19 | 19 | <?php endif; ?> |
20 | - <?php do_action('wpinv_invoice_display_left_actions', $invoice ); ?> |
|
20 | + <?php do_action('wpinv_invoice_display_left_actions', $invoice); ?> |
|
21 | 21 | </div> |
22 | 22 | |
23 | 23 | <?php |
@@ -7,25 +7,25 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <!-- ///// Start PDF header --> |
15 | 15 | <htmlpageheader name="wpinv-pdf-header"> |
16 | - <?php do_action( 'wpinv_invoice_print_before_header', $invoice ); ?> |
|
16 | + <?php do_action('wpinv_invoice_print_before_header', $invoice); ?> |
|
17 | 17 | <div class="wpinv-header mt-3 mb-3"> |
18 | 18 | <div class="row"> |
19 | 19 | <div class="col text-left"> |
20 | - <?php do_action( 'getpaid_invoice_title_left', $invoice ); ?> |
|
20 | + <?php do_action('getpaid_invoice_title_left', $invoice); ?> |
|
21 | 21 | </div> |
22 | 22 | |
23 | 23 | <div class="col text-right"> |
24 | - <?php do_action( 'getpaid_invoice_title_right', $invoice ); ?> |
|
24 | + <?php do_action('getpaid_invoice_title_right', $invoice); ?> |
|
25 | 25 | </div> |
26 | 26 | </div> |
27 | 27 | </div> |
28 | - <?php do_action( 'wpinv_invoice_print_after_header', $invoice ); ?> |
|
28 | + <?php do_action('wpinv_invoice_print_after_header', $invoice); ?> |
|
29 | 29 | </htmlpageheader> |
30 | 30 | <!-- End PDF header ///// --> |
31 | 31 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | <div class="container"> |
16 | 16 | <div class="row"> |
17 | 17 | <div class="col text-left"> |
18 | - <?php do_action( 'getpaid_invoice_top_bar_left', $invoice );?> |
|
18 | + <?php do_action('getpaid_invoice_top_bar_left', $invoice); ?> |
|
19 | 19 | </div> |
20 | 20 | <div class="col text-right"> |
21 | - <?php do_action( 'getpaid_invoice_top_bar_right', $invoice );?> |
|
21 | + <?php do_action('getpaid_invoice_top_bar_right', $invoice); ?> |
|
22 | 22 | </div> |
23 | 23 | </div> |
24 | 24 | </div> |
@@ -7,15 +7,15 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | -<a target="_blank" href="<?php echo esc_url( wpinv_get_business_website() ); ?>"> |
|
13 | +<a target="_blank" href="<?php echo esc_url(wpinv_get_business_website()); ?>"> |
|
14 | 14 | |
15 | - <?php if ( $logo = wpinv_get_business_logo() ) { ?> |
|
16 | - <img class="logo" style="max-width:100%;" src="<?php echo esc_url( $logo ); ?>"> |
|
15 | + <?php if ($logo = wpinv_get_business_logo()) { ?> |
|
16 | + <img class="logo" style="max-width:100%;" src="<?php echo esc_url($logo); ?>"> |
|
17 | 17 | <?php } else { ?> |
18 | - <h1><?php echo esc_html( wpinv_get_business_name() ); ?></h1> |
|
18 | + <h1><?php echo esc_html(wpinv_get_business_name()); ?></h1> |
|
19 | 19 | <?php } ?> |
20 | 20 | |
21 | 21 | </a> |