@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | $name = isset( $option['name'] ) ? $option['name'] : ''; |
193 | 193 | $cb = "wpinv_{$option['type']}_callback"; |
194 | 194 | $section = "wpinv_settings_{$tab}_$section"; |
195 | - $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page']; |
|
195 | + $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page']; |
|
196 | 196 | |
197 | - if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) { |
|
198 | - $tip = wpinv_clean( $option['desc'] ); |
|
199 | - $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
|
200 | - unset( $option['desc'] ); |
|
201 | - } |
|
197 | + if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) { |
|
198 | + $tip = wpinv_clean( $option['desc'] ); |
|
199 | + $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
|
200 | + unset( $option['desc'] ); |
|
201 | + } |
|
202 | 202 | |
203 | 203 | // Loop through all tabs. |
204 | 204 | add_settings_field( |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
226 | 226 | 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
227 | 227 | 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
228 | - 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
229 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
230 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
228 | + 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
229 | + 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
230 | + 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
231 | 231 | 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
232 | 232 | 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
233 | 233 | ) |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @return array |
242 | 242 | */ |
243 | 243 | function wpinv_get_registered_settings() { |
244 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
244 | + return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -260,18 +260,18 @@ discard block |
||
260 | 260 | */ |
261 | 261 | function wpinv_settings_sanitize( $input = array() ) { |
262 | 262 | |
263 | - $wpinv_options = wpinv_get_options(); |
|
264 | - $raw_referrer = wp_get_raw_referer(); |
|
263 | + $wpinv_options = wpinv_get_options(); |
|
264 | + $raw_referrer = wp_get_raw_referer(); |
|
265 | 265 | |
266 | 266 | if ( empty( $raw_referrer ) ) { |
267 | - return array_merge( $wpinv_options, $input ); |
|
267 | + return array_merge( $wpinv_options, $input ); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | wp_parse_str( $raw_referrer, $referrer ); |
271 | 271 | |
272 | - if ( in_array( 'gp-setup', $referrer ) ) { |
|
273 | - return array_merge( $wpinv_options, $input ); |
|
274 | - } |
|
272 | + if ( in_array( 'gp-setup', $referrer ) ) { |
|
273 | + return array_merge( $wpinv_options, $input ); |
|
274 | + } |
|
275 | 275 | |
276 | 276 | $settings = wpinv_get_registered_settings(); |
277 | 277 | $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
@@ -293,10 +293,10 @@ discard block |
||
293 | 293 | } |
294 | 294 | |
295 | 295 | // General filter |
296 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
296 | + $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
297 | 297 | |
298 | - // Key specific filter. |
|
299 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
298 | + // Key specific filter. |
|
299 | + $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | // Loop through the whitelist and unset any that are empty for the tab being saved |
@@ -339,14 +339,14 @@ discard block |
||
339 | 339 | |
340 | 340 | foreach ( $new_rates as $rate ) { |
341 | 341 | |
342 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
343 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
344 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
345 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
346 | - $rate['global'] = empty( $rate['state'] ); |
|
347 | - $tax_rates[] = $rate; |
|
342 | + $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
343 | + $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
344 | + $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
345 | + $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
346 | + $rate['global'] = empty( $rate['state'] ); |
|
347 | + $tax_rates[] = $rate; |
|
348 | 348 | |
349 | - } |
|
349 | + } |
|
350 | 350 | |
351 | 351 | update_option( 'wpinv_tax_rates', $tax_rates ); |
352 | 352 | |
@@ -359,11 +359,11 @@ discard block |
||
359 | 359 | $tabs['general'] = __( 'General', 'invoicing' ); |
360 | 360 | $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
361 | 361 | $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
362 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
362 | + $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
363 | 363 | |
364 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
365 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
366 | - } |
|
364 | + if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
365 | + $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
366 | + } |
|
367 | 367 | |
368 | 368 | $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
369 | 369 | $tabs['misc'] = __( 'Misc', 'invoicing' ); |
@@ -394,52 +394,52 @@ discard block |
||
394 | 394 | 'general' => apply_filters( |
395 | 395 | 'wpinv_settings_sections_general', |
396 | 396 | array( |
397 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
398 | - 'page_section' => __( 'Page Settings', 'invoicing' ), |
|
399 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
400 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
397 | + 'main' => __( 'General Settings', 'invoicing' ), |
|
398 | + 'page_section' => __( 'Page Settings', 'invoicing' ), |
|
399 | + 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
400 | + 'labels' => __( 'Label Texts', 'invoicing' ), |
|
401 | 401 | ) |
402 | 402 | ), |
403 | 403 | 'gateways' => apply_filters( |
404 | 404 | 'wpinv_settings_sections_gateways', |
405 | 405 | array( |
406 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
406 | + 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
407 | 407 | ) |
408 | 408 | ), |
409 | 409 | 'taxes' => apply_filters( |
410 | 410 | 'wpinv_settings_sections_taxes', |
411 | 411 | array( |
412 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
413 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
414 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ), |
|
412 | + 'main' => __( 'Tax Settings', 'invoicing' ), |
|
413 | + 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
414 | + 'vat' => __( 'EU VAT Settings', 'invoicing' ), |
|
415 | 415 | ) |
416 | 416 | ), |
417 | 417 | 'emails' => apply_filters( |
418 | 418 | 'wpinv_settings_sections_emails', |
419 | 419 | array( |
420 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
420 | + 'main' => __( 'Email Settings', 'invoicing' ), |
|
421 | 421 | ) |
422 | 422 | ), |
423 | 423 | |
424 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
424 | + 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
425 | 425 | |
426 | 426 | 'privacy' => apply_filters( |
427 | 427 | 'wpinv_settings_sections_privacy', |
428 | 428 | array( |
429 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
429 | + 'main' => __( 'Privacy policy', 'invoicing' ), |
|
430 | 430 | ) |
431 | 431 | ), |
432 | 432 | 'misc' => apply_filters( |
433 | 433 | 'wpinv_settings_sections_misc', |
434 | 434 | array( |
435 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
436 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
435 | + 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
436 | + 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
437 | 437 | ) |
438 | 438 | ), |
439 | 439 | 'tools' => apply_filters( |
440 | 440 | 'wpinv_settings_sections_tools', |
441 | 441 | array( |
442 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
442 | + 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
443 | 443 | ) |
444 | 444 | ), |
445 | 445 | ); |
@@ -450,46 +450,46 @@ discard block |
||
450 | 450 | } |
451 | 451 | |
452 | 452 | function wpinv_get_pages( $with_slug = false, $default_label = null ) { |
453 | - $pages_options = array(); |
|
453 | + $pages_options = array(); |
|
454 | 454 | |
455 | - if ( $default_label !== null && $default_label !== false ) { |
|
456 | - $pages_options = array( '' => $default_label ); // Blank option |
|
457 | - } |
|
455 | + if ( $default_label !== null && $default_label !== false ) { |
|
456 | + $pages_options = array( '' => $default_label ); // Blank option |
|
457 | + } |
|
458 | 458 | |
459 | - $pages = get_pages(); |
|
460 | - if ( $pages ) { |
|
461 | - foreach ( $pages as $page ) { |
|
462 | - $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
459 | + $pages = get_pages(); |
|
460 | + if ( $pages ) { |
|
461 | + foreach ( $pages as $page ) { |
|
462 | + $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
463 | 463 | $pages_options[ $page->ID ] = $title; |
464 | - } |
|
465 | - } |
|
464 | + } |
|
465 | + } |
|
466 | 466 | |
467 | - return $pages_options; |
|
467 | + return $pages_options; |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | function wpinv_header_callback( $args ) { |
471 | - if ( ! empty( $args['desc'] ) ) { |
|
471 | + if ( ! empty( $args['desc'] ) ) { |
|
472 | 472 | echo wp_kses_post( $args['desc'] ); |
473 | 473 | } |
474 | 474 | } |
475 | 475 | |
476 | 476 | function wpinv_hidden_callback( $args ) { |
477 | 477 | |
478 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
479 | - $value = wpinv_get_option( $args['id'], $std ); |
|
478 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
479 | + $value = wpinv_get_option( $args['id'], $std ); |
|
480 | 480 | |
481 | - if ( isset( $args['set_value'] ) ) { |
|
482 | - $value = $args['set_value']; |
|
483 | - } |
|
481 | + if ( isset( $args['set_value'] ) ) { |
|
482 | + $value = $args['set_value']; |
|
483 | + } |
|
484 | 484 | |
485 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
486 | - $args['readonly'] = true; |
|
487 | - $name = ''; |
|
488 | - } else { |
|
489 | - $name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']'; |
|
490 | - } |
|
485 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
486 | + $args['readonly'] = true; |
|
487 | + $name = ''; |
|
488 | + } else { |
|
489 | + $name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']'; |
|
490 | + } |
|
491 | 491 | |
492 | - echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
492 | + echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
493 | 493 | |
494 | 494 | } |
495 | 495 | |
@@ -498,12 +498,12 @@ discard block |
||
498 | 498 | */ |
499 | 499 | function wpinv_checkbox_callback( $args ) { |
500 | 500 | |
501 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
502 | - $std = wpinv_get_option( $args['id'], $std ); |
|
503 | - $id = esc_attr( $args['id'] ); |
|
501 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
502 | + $std = wpinv_get_option( $args['id'], $std ); |
|
503 | + $id = esc_attr( $args['id'] ); |
|
504 | 504 | |
505 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
506 | - ?> |
|
505 | + getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
506 | + ?> |
|
507 | 507 | <fieldset> |
508 | 508 | <label> |
509 | 509 | <input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox"> |
@@ -515,75 +515,75 @@ discard block |
||
515 | 515 | |
516 | 516 | function wpinv_multicheck_callback( $args ) { |
517 | 517 | |
518 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
519 | - $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
518 | + $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
519 | + $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
520 | 520 | |
521 | - if ( ! empty( $args['options'] ) ) { |
|
521 | + if ( ! empty( $args['options'] ) ) { |
|
522 | 522 | |
523 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
524 | - $value = wpinv_get_option( $args['id'], $std ); |
|
523 | + $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
524 | + $value = wpinv_get_option( $args['id'], $std ); |
|
525 | 525 | |
526 | - echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">'; |
|
526 | + echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">'; |
|
527 | 527 | foreach ( $args['options'] as $key => $option ) : |
528 | - $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) ); |
|
529 | - if ( in_array( $sanitize_key, $value ) ) { |
|
530 | - $enabled = $sanitize_key; |
|
531 | - } else { |
|
532 | - $enabled = null; |
|
533 | - } |
|
534 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
535 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
536 | - endforeach; |
|
537 | - echo '</div>'; |
|
538 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
539 | - } |
|
528 | + $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) ); |
|
529 | + if ( in_array( $sanitize_key, $value ) ) { |
|
530 | + $enabled = $sanitize_key; |
|
531 | + } else { |
|
532 | + $enabled = null; |
|
533 | + } |
|
534 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
535 | + echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
536 | + endforeach; |
|
537 | + echo '</div>'; |
|
538 | + echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
539 | + } |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | function wpinv_payment_icons_callback( $args ) { |
543 | 543 | |
544 | 544 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
545 | - $value = wpinv_get_option( $args['id'], false ); |
|
545 | + $value = wpinv_get_option( $args['id'], false ); |
|
546 | 546 | |
547 | - if ( ! empty( $args['options'] ) ) { |
|
548 | - foreach ( $args['options'] as $key => $option ) { |
|
547 | + if ( ! empty( $args['options'] ) ) { |
|
548 | + foreach ( $args['options'] as $key => $option ) { |
|
549 | 549 | $sanitize_key = wpinv_sanitize_key( $key ); |
550 | 550 | |
551 | - if ( empty( $value ) ) { |
|
552 | - $enabled = $option; |
|
553 | - } else { |
|
554 | - $enabled = null; |
|
555 | - } |
|
556 | - |
|
557 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
558 | - |
|
559 | - echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
560 | - |
|
561 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
562 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
563 | - } else { |
|
564 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
565 | - |
|
566 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
567 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
568 | - } else { |
|
569 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
570 | - $content_dir = WP_CONTENT_DIR; |
|
571 | - |
|
572 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
573 | - // Replaces backslashes with forward slashes for Windows systems |
|
574 | - $image = wp_normalize_path( $image ); |
|
575 | - $content_dir = wp_normalize_path( $content_dir ); |
|
576 | - } |
|
577 | - |
|
578 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
579 | - } |
|
580 | - |
|
581 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
582 | - } |
|
583 | - echo wp_kses_post( $option ) . '</label>'; |
|
584 | - } |
|
585 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
586 | - } |
|
551 | + if ( empty( $value ) ) { |
|
552 | + $enabled = $option; |
|
553 | + } else { |
|
554 | + $enabled = null; |
|
555 | + } |
|
556 | + |
|
557 | + echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
558 | + |
|
559 | + echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
560 | + |
|
561 | + if ( wpinv_string_is_image_url( $key ) ) { |
|
562 | + echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
563 | + } else { |
|
564 | + $card = strtolower( str_replace( ' ', '', $option ) ); |
|
565 | + |
|
566 | + if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
567 | + $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
568 | + } else { |
|
569 | + $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
570 | + $content_dir = WP_CONTENT_DIR; |
|
571 | + |
|
572 | + if ( function_exists( 'wp_normalize_path' ) ) { |
|
573 | + // Replaces backslashes with forward slashes for Windows systems |
|
574 | + $image = wp_normalize_path( $image ); |
|
575 | + $content_dir = wp_normalize_path( $content_dir ); |
|
576 | + } |
|
577 | + |
|
578 | + $image = str_replace( $content_dir, content_url(), $image ); |
|
579 | + } |
|
580 | + |
|
581 | + echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
582 | + } |
|
583 | + echo wp_kses_post( $option ) . '</label>'; |
|
584 | + } |
|
585 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
586 | + } |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | /** |
@@ -591,9 +591,9 @@ discard block |
||
591 | 591 | */ |
592 | 592 | function wpinv_radio_callback( $args ) { |
593 | 593 | |
594 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
595 | - $std = wpinv_get_option( $args['id'], $std ); |
|
596 | - ?> |
|
594 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
595 | + $std = wpinv_get_option( $args['id'], $std ); |
|
596 | + ?> |
|
597 | 597 | <fieldset> |
598 | 598 | <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
599 | 599 | <?php foreach ( $args['options'] as $key => $option ) : ?> |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | </ul> |
608 | 608 | </fieldset> |
609 | 609 | <?php |
610 | - getpaid_settings_description_callback( $args ); |
|
610 | + getpaid_settings_description_callback( $args ); |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
@@ -615,10 +615,10 @@ discard block |
||
615 | 615 | */ |
616 | 616 | function getpaid_settings_description_callback( $args ) { |
617 | 617 | |
618 | - if ( ! empty( $args['desc'] ) ) { |
|
619 | - $description = $args['desc']; |
|
620 | - echo wp_kses_post( "<p class='description'>$description</p>" ); |
|
621 | - } |
|
618 | + if ( ! empty( $args['desc'] ) ) { |
|
619 | + $description = $args['desc']; |
|
620 | + echo wp_kses_post( "<p class='description'>$description</p>" ); |
|
621 | + } |
|
622 | 622 | |
623 | 623 | } |
624 | 624 | |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | */ |
628 | 628 | function wpinv_gateways_callback() { |
629 | 629 | |
630 | - ?> |
|
630 | + ?> |
|
631 | 631 | </td> |
632 | 632 | </tr> |
633 | 633 | <tr class="bsui"> |
@@ -641,26 +641,26 @@ discard block |
||
641 | 641 | |
642 | 642 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
643 | 643 | $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
644 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
645 | - $value = wpinv_get_option( $args['id'], $std ); |
|
644 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
645 | + $value = wpinv_get_option( $args['id'], $std ); |
|
646 | 646 | |
647 | - echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >'; |
|
647 | + echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >'; |
|
648 | 648 | |
649 | - foreach ( $args['options'] as $key => $option ) : |
|
649 | + foreach ( $args['options'] as $key => $option ) : |
|
650 | 650 | |
651 | - echo '<option value="' . esc_attr( $key ) . '" '; |
|
651 | + echo '<option value="' . esc_attr( $key ) . '" '; |
|
652 | 652 | |
653 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
653 | + if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
654 | 654 | selected( $key, $args['selected'] ); |
655 | 655 | } else { |
656 | 656 | selected( $key, $value ); |
657 | 657 | } |
658 | 658 | |
659 | - echo '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
660 | - endforeach; |
|
659 | + echo '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
660 | + endforeach; |
|
661 | 661 | |
662 | - echo '</select>'; |
|
663 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
662 | + echo '</select>'; |
|
663 | + echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
@@ -671,29 +671,29 @@ discard block |
||
671 | 671 | */ |
672 | 672 | function wpinv_settings_attrs_helper( $args ) { |
673 | 673 | |
674 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
675 | - $id = esc_attr( $args['id'] ); |
|
676 | - $placeholder = esc_attr( $args['placeholder'] ); |
|
674 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
675 | + $id = esc_attr( $args['id'] ); |
|
676 | + $placeholder = esc_attr( $args['placeholder'] ); |
|
677 | 677 | |
678 | - if ( ! empty( $args['faux'] ) ) { |
|
679 | - $args['readonly'] = true; |
|
680 | - $name = ''; |
|
681 | - } else { |
|
682 | - $value = wpinv_get_option( $args['id'], $value ); |
|
683 | - $name = "wpinv_settings[$id]"; |
|
684 | - } |
|
678 | + if ( ! empty( $args['faux'] ) ) { |
|
679 | + $args['readonly'] = true; |
|
680 | + $name = ''; |
|
681 | + } else { |
|
682 | + $value = wpinv_get_option( $args['id'], $value ); |
|
683 | + $name = "wpinv_settings[$id]"; |
|
684 | + } |
|
685 | 685 | |
686 | - $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
687 | - $class = esc_attr( $args['class'] ); |
|
688 | - $style = esc_attr( $args['style'] ); |
|
689 | - $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
686 | + $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
687 | + $class = esc_attr( $args['class'] ); |
|
688 | + $style = esc_attr( $args['style'] ); |
|
689 | + $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
690 | 690 | |
691 | - $onchange = ''; |
|
691 | + $onchange = ''; |
|
692 | 692 | if ( ! empty( $args['onchange'] ) ) { |
693 | 693 | $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
694 | - } |
|
694 | + } |
|
695 | 695 | |
696 | - return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
|
696 | + return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | /** |
@@ -701,9 +701,9 @@ discard block |
||
701 | 701 | */ |
702 | 702 | function wpinv_text_callback( $args ) { |
703 | 703 | |
704 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
704 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
705 | 705 | |
706 | - ?> |
|
706 | + ?> |
|
707 | 707 | <label style="width: 100%;"> |
708 | 708 | <input type="text" <?php echo wpinv_settings_attrs_helper( $args ); ?>> |
709 | 709 | <?php echo wp_kses_post( $desc ); ?> |
@@ -717,10 +717,10 @@ discard block |
||
717 | 717 | */ |
718 | 718 | function wpinv_number_callback( $args ) { |
719 | 719 | |
720 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
721 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
720 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
721 | + $attr = wpinv_settings_attrs_helper( $args ); |
|
722 | 722 | |
723 | - ?> |
|
723 | + ?> |
|
724 | 724 | <label style="width: 100%;"> |
725 | 725 | <input type="number" step="<?php echo floatval( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php echo $attr; ?>> |
726 | 726 | <?php echo wp_kses_post( $desc ); ?> |
@@ -732,34 +732,34 @@ discard block |
||
732 | 732 | function wpinv_textarea_callback( $args ) { |
733 | 733 | |
734 | 734 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
735 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
736 | - $value = wpinv_get_option( $args['id'], $std ); |
|
735 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
736 | + $value = wpinv_get_option( $args['id'], $std ); |
|
737 | 737 | |
738 | 738 | $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
739 | 739 | $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
740 | 740 | |
741 | - echo '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
742 | - echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
741 | + echo '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
742 | + echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
743 | 743 | |
744 | 744 | } |
745 | 745 | |
746 | 746 | function wpinv_password_callback( $args ) { |
747 | 747 | |
748 | 748 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
749 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
750 | - $value = wpinv_get_option( $args['id'], $std ); |
|
749 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
750 | + $value = wpinv_get_option( $args['id'], $std ); |
|
751 | 751 | |
752 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
753 | - echo '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
754 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
752 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
753 | + echo '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
754 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
755 | 755 | |
756 | 756 | } |
757 | 757 | |
758 | 758 | function wpinv_missing_callback( $args ) { |
759 | - printf( |
|
760 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
761 | - '<strong>' . $args['id'] . '</strong>' |
|
762 | - ); |
|
759 | + printf( |
|
760 | + __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
761 | + '<strong>' . $args['id'] . '</strong>' |
|
762 | + ); |
|
763 | 763 | } |
764 | 764 | |
765 | 765 | /** |
@@ -767,14 +767,14 @@ discard block |
||
767 | 767 | */ |
768 | 768 | function wpinv_select_callback( $args ) { |
769 | 769 | |
770 | - $desc = wp_kses_post( $args['desc'] ); |
|
771 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
772 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
773 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
774 | - $value = wpinv_get_option( $args['id'], $value ); |
|
775 | - $rand = uniqid( 'random_id' ); |
|
770 | + $desc = wp_kses_post( $args['desc'] ); |
|
771 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
772 | + $attr = wpinv_settings_attrs_helper( $args ); |
|
773 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
774 | + $value = wpinv_get_option( $args['id'], $value ); |
|
775 | + $rand = uniqid( 'random_id' ); |
|
776 | 776 | |
777 | - ?> |
|
777 | + ?> |
|
778 | 778 | <label style="width: 100%;"> |
779 | 779 | <select <?php echo $attr; ?> data-allow-clear="true"> |
780 | 780 | <?php foreach ( $args['options'] as $option => $name ) : ?> |
@@ -807,50 +807,50 @@ discard block |
||
807 | 807 | function wpinv_color_select_callback( $args ) { |
808 | 808 | |
809 | 809 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
810 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
811 | - $value = wpinv_get_option( $args['id'], $std ); |
|
810 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
811 | + $value = wpinv_get_option( $args['id'], $std ); |
|
812 | 812 | |
813 | - echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
813 | + echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
814 | 814 | |
815 | - foreach ( $args['options'] as $option => $color ) { |
|
816 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>'; |
|
817 | - } |
|
815 | + foreach ( $args['options'] as $option => $color ) { |
|
816 | + echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>'; |
|
817 | + } |
|
818 | 818 | |
819 | - echo '</select>'; |
|
820 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
819 | + echo '</select>'; |
|
820 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
821 | 821 | |
822 | 822 | } |
823 | 823 | |
824 | 824 | function wpinv_rich_editor_callback( $args ) { |
825 | - global $wp_version; |
|
825 | + global $wp_version; |
|
826 | 826 | |
827 | 827 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
828 | 828 | |
829 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
830 | - $value = wpinv_get_option( $args['id'], $std ); |
|
829 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
830 | + $value = wpinv_get_option( $args['id'], $std ); |
|
831 | 831 | |
832 | - if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
833 | - $value = $std; |
|
834 | - } |
|
832 | + if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
833 | + $value = $std; |
|
834 | + } |
|
835 | 835 | |
836 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
836 | + $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
837 | 837 | |
838 | - echo '<div class="getpaid-settings-editor-input">'; |
|
839 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
840 | - wp_editor( |
|
838 | + echo '<div class="getpaid-settings-editor-input">'; |
|
839 | + if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
840 | + wp_editor( |
|
841 | 841 | stripslashes( $value ), |
842 | 842 | 'wpinv_settings_' . esc_attr( $args['id'] ), |
843 | 843 | array( |
844 | - 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', |
|
845 | - 'textarea_rows' => absint( $rows ), |
|
846 | - 'media_buttons' => false, |
|
844 | + 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', |
|
845 | + 'textarea_rows' => absint( $rows ), |
|
846 | + 'media_buttons' => false, |
|
847 | 847 | ) |
848 | 848 | ); |
849 | - } else { |
|
850 | - echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
851 | - } |
|
849 | + } else { |
|
850 | + echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
851 | + } |
|
852 | 852 | |
853 | - echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
853 | + echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
854 | 854 | |
855 | 855 | } |
856 | 856 | |
@@ -858,51 +858,51 @@ discard block |
||
858 | 858 | |
859 | 859 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
860 | 860 | |
861 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
862 | - $value = wpinv_get_option( $args['id'], $std ); |
|
861 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
862 | + $value = wpinv_get_option( $args['id'], $std ); |
|
863 | 863 | |
864 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
865 | - echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
866 | - echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
867 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
864 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
865 | + echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
866 | + echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
867 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
868 | 868 | |
869 | 869 | } |
870 | 870 | |
871 | 871 | function wpinv_color_callback( $args ) { |
872 | 872 | |
873 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
874 | - $value = wpinv_get_option( $args['id'], $std ); |
|
873 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
874 | + $value = wpinv_get_option( $args['id'], $std ); |
|
875 | 875 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
876 | 876 | |
877 | - echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
878 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
877 | + echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
878 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
879 | 879 | |
880 | 880 | } |
881 | 881 | |
882 | 882 | function wpinv_country_states_callback( $args ) { |
883 | 883 | |
884 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
885 | - $value = wpinv_get_option( $args['id'], $std ); |
|
884 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
885 | + $value = wpinv_get_option( $args['id'], $std ); |
|
886 | 886 | |
887 | 887 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
888 | 888 | |
889 | - if ( isset( $args['placeholder'] ) ) { |
|
890 | - $placeholder = $args['placeholder']; |
|
891 | - } else { |
|
892 | - $placeholder = ''; |
|
893 | - } |
|
889 | + if ( isset( $args['placeholder'] ) ) { |
|
890 | + $placeholder = $args['placeholder']; |
|
891 | + } else { |
|
892 | + $placeholder = ''; |
|
893 | + } |
|
894 | 894 | |
895 | - $states = wpinv_get_country_states(); |
|
895 | + $states = wpinv_get_country_states(); |
|
896 | 896 | |
897 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
898 | - echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
897 | + $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
898 | + echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
899 | 899 | |
900 | - foreach ( $states as $option => $name ) { |
|
901 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>'; |
|
902 | - } |
|
900 | + foreach ( $states as $option => $name ) { |
|
901 | + echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>'; |
|
902 | + } |
|
903 | 903 | |
904 | - echo '</select>'; |
|
905 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
904 | + echo '</select>'; |
|
905 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
906 | 906 | |
907 | 907 | } |
908 | 908 | |
@@ -911,7 +911,7 @@ discard block |
||
911 | 911 | */ |
912 | 912 | function wpinv_tax_rates_callback() { |
913 | 913 | |
914 | - ?> |
|
914 | + ?> |
|
915 | 915 | </td> |
916 | 916 | </tr> |
917 | 917 | <tr class="bsui"> |
@@ -926,17 +926,17 @@ discard block |
||
926 | 926 | * Displays a tax rate' edit row. |
927 | 927 | */ |
928 | 928 | function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) { |
929 | - ob_start(); |
|
929 | + ob_start(); |
|
930 | 930 | |
931 | - $key = sanitize_key( $key ); |
|
932 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
933 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
931 | + $key = sanitize_key( $key ); |
|
932 | + $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
933 | + include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
934 | 934 | |
935 | - if ( $echo ) { |
|
936 | - echo ob_get_clean(); |
|
937 | - } else { |
|
938 | - return ob_get_clean(); |
|
939 | - } |
|
935 | + if ( $echo ) { |
|
936 | + echo ob_get_clean(); |
|
937 | + } else { |
|
938 | + return ob_get_clean(); |
|
939 | + } |
|
940 | 940 | |
941 | 941 | } |
942 | 942 | |
@@ -968,14 +968,14 @@ discard block |
||
968 | 968 | <td> |
969 | 969 | <a href=" |
970 | 970 | <?php |
971 | - echo esc_url( |
|
972 | - wp_nonce_url( |
|
973 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
974 | - 'getpaid-nonce', |
|
975 | - 'getpaid-nonce' |
|
976 | - ) |
|
977 | - ); |
|
978 | - ?> |
|
971 | + echo esc_url( |
|
972 | + wp_nonce_url( |
|
973 | + add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
974 | + 'getpaid-nonce', |
|
975 | + 'getpaid-nonce' |
|
976 | + ) |
|
977 | + ); |
|
978 | + ?> |
|
979 | 979 | " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
980 | 980 | </td> |
981 | 981 | </tr> |
@@ -987,14 +987,14 @@ discard block |
||
987 | 987 | <td> |
988 | 988 | <a href=" |
989 | 989 | <?php |
990 | - echo esc_url( |
|
991 | - wp_nonce_url( |
|
992 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
993 | - 'getpaid-nonce', |
|
994 | - 'getpaid-nonce' |
|
995 | - ) |
|
996 | - ); |
|
997 | - ?> |
|
990 | + echo esc_url( |
|
991 | + wp_nonce_url( |
|
992 | + add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
993 | + 'getpaid-nonce', |
|
994 | + 'getpaid-nonce' |
|
995 | + ) |
|
996 | + ); |
|
997 | + ?> |
|
998 | 998 | " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
999 | 999 | </td> |
1000 | 1000 | </tr> |
@@ -1006,14 +1006,14 @@ discard block |
||
1006 | 1006 | <td> |
1007 | 1007 | <a href=" |
1008 | 1008 | <?php |
1009 | - echo esc_url( |
|
1010 | - wp_nonce_url( |
|
1011 | - add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
1012 | - 'getpaid-nonce', |
|
1013 | - 'getpaid-nonce' |
|
1014 | - ) |
|
1015 | - ); |
|
1016 | - ?> |
|
1009 | + echo esc_url( |
|
1010 | + wp_nonce_url( |
|
1011 | + add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
1012 | + 'getpaid-nonce', |
|
1013 | + 'getpaid-nonce' |
|
1014 | + ) |
|
1015 | + ); |
|
1016 | + ?> |
|
1017 | 1017 | " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
1018 | 1018 | </td> |
1019 | 1019 | </tr> |
@@ -1026,14 +1026,14 @@ discard block |
||
1026 | 1026 | <td> |
1027 | 1027 | <a href=" |
1028 | 1028 | <?php |
1029 | - echo esc_url( |
|
1030 | - wp_nonce_url( |
|
1031 | - add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
1032 | - 'getpaid-nonce', |
|
1033 | - 'getpaid-nonce' |
|
1034 | - ) |
|
1035 | - ); |
|
1036 | - ?> |
|
1029 | + echo esc_url( |
|
1030 | + wp_nonce_url( |
|
1031 | + add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
1032 | + 'getpaid-nonce', |
|
1033 | + 'getpaid-nonce' |
|
1034 | + ) |
|
1035 | + ); |
|
1036 | + ?> |
|
1037 | 1037 | " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
1038 | 1038 | </td> |
1039 | 1039 | </tr> |
@@ -1046,8 +1046,8 @@ discard block |
||
1046 | 1046 | <td> |
1047 | 1047 | <a href=" |
1048 | 1048 | <?php |
1049 | - echo esc_url( admin_url( 'index.php?page=gp-setup' ) ); |
|
1050 | - ?> |
|
1049 | + echo esc_url( admin_url( 'index.php?page=gp-setup' ) ); |
|
1050 | + ?> |
|
1051 | 1051 | " class="button button-primary"><?php esc_html_e( 'Launch', 'invoicing' ); ?></a> |
1052 | 1052 | </td> |
1053 | 1053 | </tr> |
@@ -1061,19 +1061,19 @@ discard block |
||
1061 | 1061 | |
1062 | 1062 | |
1063 | 1063 | function wpinv_descriptive_text_callback( $args ) { |
1064 | - echo wp_kses_post( $args['desc'] ); |
|
1064 | + echo wp_kses_post( $args['desc'] ); |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | 1067 | function wpinv_raw_html_callback( $args ) { |
1068 | - echo wp_kses_post( $args['desc'] ); |
|
1068 | + echo wp_kses_post( $args['desc'] ); |
|
1069 | 1069 | } |
1070 | 1070 | |
1071 | 1071 | function wpinv_hook_callback( $args ) { |
1072 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1072 | + do_action( 'wpinv_' . $args['id'], $args ); |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | function wpinv_set_settings_cap() { |
1076 | - return wpinv_get_capability(); |
|
1076 | + return wpinv_get_capability(); |
|
1077 | 1077 | } |
1078 | 1078 | add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
1079 | 1079 | |
@@ -1097,15 +1097,15 @@ discard block |
||
1097 | 1097 | */ |
1098 | 1098 | function wpinv_get_merge_tags_help_text( $subscription = false ) { |
1099 | 1099 | |
1100 | - $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
|
1101 | - $link = sprintf( |
|
1102 | - '<strong><a href="%s" target="_blank">%s</a></strong>', |
|
1103 | - $url, |
|
1104 | - esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
1105 | - ); |
|
1100 | + $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
|
1101 | + $link = sprintf( |
|
1102 | + '<strong><a href="%s" target="_blank">%s</a></strong>', |
|
1103 | + $url, |
|
1104 | + esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
1105 | + ); |
|
1106 | 1106 | |
1107 | - $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
1107 | + $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
1108 | 1108 | |
1109 | - return "$description $link"; |
|
1109 | + return "$description $link"; |
|
1110 | 1110 | |
1111 | 1111 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 1.0.0 |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Retrieves all default settings. |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | function wpinv_get_settings() { |
17 | 17 | $defaults = array(); |
18 | 18 | |
19 | - foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) { |
|
19 | + foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) { |
|
20 | 20 | |
21 | - foreach ( array_values( $tab_settings ) as $section_settings ) { |
|
21 | + foreach (array_values($tab_settings) as $section_settings) { |
|
22 | 22 | |
23 | - foreach ( $section_settings as $key => $setting ) { |
|
24 | - if ( isset( $setting['std'] ) ) { |
|
25 | - $defaults[ $key ] = $setting['std']; |
|
23 | + foreach ($section_settings as $key => $setting) { |
|
24 | + if (isset($setting['std'])) { |
|
25 | + $defaults[$key] = $setting['std']; |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | } |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | global $wpinv_options; |
42 | 42 | |
43 | 43 | // Try fetching the saved options. |
44 | - if ( empty( $wpinv_options ) ) { |
|
45 | - $wpinv_options = get_option( 'wpinv_settings' ); |
|
44 | + if (empty($wpinv_options)) { |
|
45 | + $wpinv_options = get_option('wpinv_settings'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | // If that fails, don't fetch the default settings to prevent a loop. |
49 | - if ( ! is_array( $wpinv_options ) ) { |
|
49 | + if (!is_array($wpinv_options)) { |
|
50 | 50 | $wpinv_options = array(); |
51 | 51 | } |
52 | 52 | |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | * @param mixed $default The default value to use if the setting has not been set. |
61 | 61 | * @return mixed |
62 | 62 | */ |
63 | -function wpinv_get_option( $key = '', $default = false ) { |
|
63 | +function wpinv_get_option($key = '', $default = false) { |
|
64 | 64 | |
65 | 65 | $options = wpinv_get_options(); |
66 | - $value = isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
67 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
66 | + $value = isset($options[$key]) ? $options[$key] : $default; |
|
67 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
68 | 68 | |
69 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
69 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | * @param array $options the new options. |
76 | 76 | * @return bool |
77 | 77 | */ |
78 | -function wpinv_update_options( $options ) { |
|
78 | +function wpinv_update_options($options) { |
|
79 | 79 | global $wpinv_options; |
80 | 80 | |
81 | 81 | // update the option. |
82 | - if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) { |
|
82 | + if (is_array($options) && update_option('wpinv_settings', $options)) { |
|
83 | 83 | $wpinv_options = $options; |
84 | 84 | return true; |
85 | 85 | } |
@@ -94,24 +94,24 @@ discard block |
||
94 | 94 | * @param mixed $value The setting value. |
95 | 95 | * @return bool |
96 | 96 | */ |
97 | -function wpinv_update_option( $key = '', $value = false ) { |
|
97 | +function wpinv_update_option($key = '', $value = false) { |
|
98 | 98 | |
99 | 99 | // If no key, exit. |
100 | - if ( empty( $key ) ) { |
|
100 | + if (empty($key)) { |
|
101 | 101 | return false; |
102 | 102 | } |
103 | 103 | |
104 | 104 | // Maybe delete the option instead. |
105 | - if ( is_null( $value ) ) { |
|
106 | - return wpinv_delete_option( $key ); |
|
105 | + if (is_null($value)) { |
|
106 | + return wpinv_delete_option($key); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | // Prepare the new options. |
110 | 110 | $options = wpinv_get_options(); |
111 | - $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key ); |
|
111 | + $options[$key] = apply_filters('wpinv_update_option', $value, $key); |
|
112 | 112 | |
113 | 113 | // Save the new options. |
114 | - return wpinv_update_options( $options ); |
|
114 | + return wpinv_update_options($options); |
|
115 | 115 | |
116 | 116 | } |
117 | 117 | |
@@ -121,18 +121,18 @@ discard block |
||
121 | 121 | * @param string $key the setting key. |
122 | 122 | * @return bool |
123 | 123 | */ |
124 | -function wpinv_delete_option( $key = '' ) { |
|
124 | +function wpinv_delete_option($key = '') { |
|
125 | 125 | |
126 | 126 | // If no key, exit |
127 | - if ( empty( $key ) ) { |
|
127 | + if (empty($key)) { |
|
128 | 128 | return false; |
129 | 129 | } |
130 | 130 | |
131 | 131 | $options = wpinv_get_options(); |
132 | 132 | |
133 | - if ( isset( $options[ $key ] ) ) { |
|
134 | - unset( $options[ $key ] ); |
|
135 | - return wpinv_update_options( $options ); |
|
133 | + if (isset($options[$key])) { |
|
134 | + unset($options[$key]); |
|
135 | + return wpinv_update_options($options); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | return true; |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | function wpinv_register_settings() { |
147 | 147 | |
148 | 148 | // Loop through all tabs. |
149 | - foreach ( wpinv_get_registered_settings() as $tab => $sections ) { |
|
149 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
150 | 150 | |
151 | 151 | // In each tab, loop through sections. |
152 | - foreach ( $sections as $section => $settings ) { |
|
152 | + foreach ($sections as $section => $settings) { |
|
153 | 153 | |
154 | 154 | // Check for backwards compatibility |
155 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
156 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
155 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
156 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
157 | 157 | $section = 'main'; |
158 | 158 | $settings = $sections; |
159 | 159 | } |
@@ -166,18 +166,18 @@ discard block |
||
166 | 166 | 'wpinv_settings_' . $tab . '_' . $section |
167 | 167 | ); |
168 | 168 | |
169 | - foreach ( $settings as $option ) { |
|
170 | - if ( ! empty( $option['id'] ) ) { |
|
171 | - wpinv_register_settings_option( $tab, $section, $option ); |
|
169 | + foreach ($settings as $option) { |
|
170 | + if (!empty($option['id'])) { |
|
171 | + wpinv_register_settings_option($tab, $section, $option); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | 177 | // Creates our settings in the options table. |
178 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
178 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
179 | 179 | } |
180 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
180 | +add_action('admin_init', 'wpinv_register_settings'); |
|
181 | 181 | |
182 | 182 | /** |
183 | 183 | * Register a single settings option. |
@@ -187,49 +187,49 @@ discard block |
||
187 | 187 | * @param string $option |
188 | 188 | * |
189 | 189 | */ |
190 | -function wpinv_register_settings_option( $tab, $section, $option ) { |
|
190 | +function wpinv_register_settings_option($tab, $section, $option) { |
|
191 | 191 | |
192 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
192 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
193 | 193 | $cb = "wpinv_{$option['type']}_callback"; |
194 | 194 | $section = "wpinv_settings_{$tab}_$section"; |
195 | - $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page']; |
|
195 | + $is_wizzard = is_admin() && isset($_GET['page']) && 'gp-setup' == $_GET['page']; |
|
196 | 196 | |
197 | - if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) { |
|
198 | - $tip = wpinv_clean( $option['desc'] ); |
|
197 | + if (isset($option['desc']) && (!$is_wizzard && !empty($option['help-tip']))) { |
|
198 | + $tip = wpinv_clean($option['desc']); |
|
199 | 199 | $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
200 | - unset( $option['desc'] ); |
|
200 | + unset($option['desc']); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | // Loop through all tabs. |
204 | 204 | add_settings_field( |
205 | 205 | 'wpinv_settings[' . $option['id'] . ']', |
206 | 206 | $name, |
207 | - function_exists( $cb ) ? $cb : 'wpinv_missing_callback', |
|
207 | + function_exists($cb) ? $cb : 'wpinv_missing_callback', |
|
208 | 208 | $section, |
209 | 209 | $section, |
210 | 210 | array( |
211 | 211 | 'section' => $section, |
212 | - 'id' => isset( $option['id'] ) ? $option['id'] : uniqid( 'wpinv-' ), |
|
213 | - 'desc' => isset( $option['desc'] ) ? $option['desc'] : '', |
|
212 | + 'id' => isset($option['id']) ? $option['id'] : uniqid('wpinv-'), |
|
213 | + 'desc' => isset($option['desc']) ? $option['desc'] : '', |
|
214 | 214 | 'name' => $name, |
215 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
216 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
217 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
218 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
219 | - 'min' => isset( $option['min'] ) ? $option['min'] : 0, |
|
220 | - 'max' => isset( $option['max'] ) ? $option['max'] : 999999, |
|
221 | - 'step' => isset( $option['step'] ) ? $option['step'] : 1, |
|
222 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
223 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
224 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
225 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
226 | - 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
|
227 | - 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
|
228 | - 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
229 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
230 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
231 | - 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
232 | - 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
215 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
216 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
217 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
218 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
219 | + 'min' => isset($option['min']) ? $option['min'] : 0, |
|
220 | + 'max' => isset($option['max']) ? $option['max'] : 999999, |
|
221 | + 'step' => isset($option['step']) ? $option['step'] : 1, |
|
222 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
223 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
224 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
225 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
226 | + 'onchange' => isset($option['onchange']) ? $option['onchange'] : '', |
|
227 | + 'custom' => isset($option['custom']) ? $option['custom'] : '', |
|
228 | + 'default_content' => isset($option['default_content']) ? $option['default_content'] : '', |
|
229 | + 'class' => isset($option['class']) ? $option['class'] : '', |
|
230 | + 'style' => isset($option['style']) ? $option['style'] : '', |
|
231 | + 'cols' => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
232 | + 'rows' => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
233 | 233 | ) |
234 | 234 | ); |
235 | 235 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @return array |
242 | 242 | */ |
243 | 243 | function wpinv_get_registered_settings() { |
244 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
244 | + return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings'))); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @return array |
251 | 251 | */ |
252 | 252 | function getpaid_get_integration_settings() { |
253 | - return apply_filters( 'getpaid_integration_settings', array() ); |
|
253 | + return apply_filters('getpaid_integration_settings', array()); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -258,126 +258,126 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return array |
260 | 260 | */ |
261 | -function wpinv_settings_sanitize( $input = array() ) { |
|
261 | +function wpinv_settings_sanitize($input = array()) { |
|
262 | 262 | |
263 | 263 | $wpinv_options = wpinv_get_options(); |
264 | 264 | $raw_referrer = wp_get_raw_referer(); |
265 | 265 | |
266 | - if ( empty( $raw_referrer ) ) { |
|
267 | - return array_merge( $wpinv_options, $input ); |
|
266 | + if (empty($raw_referrer)) { |
|
267 | + return array_merge($wpinv_options, $input); |
|
268 | 268 | } |
269 | 269 | |
270 | - wp_parse_str( $raw_referrer, $referrer ); |
|
270 | + wp_parse_str($raw_referrer, $referrer); |
|
271 | 271 | |
272 | - if ( in_array( 'gp-setup', $referrer ) ) { |
|
273 | - return array_merge( $wpinv_options, $input ); |
|
272 | + if (in_array('gp-setup', $referrer)) { |
|
273 | + return array_merge($wpinv_options, $input); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | $settings = wpinv_get_registered_settings(); |
277 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
278 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
277 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
278 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
279 | 279 | |
280 | 280 | $input = $input ? $input : array(); |
281 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
282 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
281 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
282 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
283 | 283 | |
284 | 284 | // Loop through each setting being saved and pass it through a sanitization filter |
285 | - foreach ( $input as $key => $value ) { |
|
285 | + foreach ($input as $key => $value) { |
|
286 | 286 | |
287 | 287 | // Get the setting type (checkbox, select, etc) |
288 | - $type = isset( $settings[ $tab ][ $section ][ $key ]['type'] ) ? $settings[ $tab ][ $section ][ $key ]['type'] : false; |
|
288 | + $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false; |
|
289 | 289 | |
290 | - if ( $type ) { |
|
290 | + if ($type) { |
|
291 | 291 | // Field type specific filter |
292 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$type", $value, $key ); |
|
292 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$type", $value, $key); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | // General filter |
296 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
296 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
297 | 297 | |
298 | 298 | // Key specific filter. |
299 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
299 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | // Loop through the whitelist and unset any that are empty for the tab being saved |
303 | - $main_settings = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
304 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
303 | + $main_settings = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
304 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
305 | 305 | |
306 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
306 | + $found_settings = array_merge($main_settings, $section_settings); |
|
307 | 307 | |
308 | - if ( ! empty( $found_settings ) ) { |
|
309 | - foreach ( $found_settings as $key => $value ) { |
|
308 | + if (!empty($found_settings)) { |
|
309 | + foreach ($found_settings as $key => $value) { |
|
310 | 310 | |
311 | 311 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
312 | - if ( is_numeric( $key ) ) { |
|
312 | + if (is_numeric($key)) { |
|
313 | 313 | $key = $value['id']; |
314 | 314 | } |
315 | 315 | |
316 | - if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) { |
|
317 | - unset( $wpinv_options[ $key ] ); |
|
316 | + if (!isset($input[$key]) && isset($wpinv_options[$key])) { |
|
317 | + unset($wpinv_options[$key]); |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
322 | 322 | // Merge our new settings with the existing |
323 | - $output = array_merge( $wpinv_options, $input ); |
|
323 | + $output = array_merge($wpinv_options, $input); |
|
324 | 324 | |
325 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
325 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
326 | 326 | |
327 | 327 | return $output; |
328 | 328 | } |
329 | -add_filter( 'wpinv_settings_sanitize_text', 'trim', 10, 1 ); |
|
330 | -add_filter( 'wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount' ); |
|
329 | +add_filter('wpinv_settings_sanitize_text', 'trim', 10, 1); |
|
330 | +add_filter('wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount'); |
|
331 | 331 | |
332 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
333 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
332 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
333 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
334 | 334 | return $input; |
335 | 335 | } |
336 | 336 | |
337 | - $new_rates = ! empty( $_POST['tax_rates'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rates'] ) ) : array(); |
|
337 | + $new_rates = !empty($_POST['tax_rates']) ? wp_kses_post_deep(array_values($_POST['tax_rates'])) : array(); |
|
338 | 338 | $tax_rates = array(); |
339 | 339 | |
340 | - foreach ( $new_rates as $rate ) { |
|
340 | + foreach ($new_rates as $rate) { |
|
341 | 341 | |
342 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
343 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
344 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
345 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
346 | - $rate['global'] = empty( $rate['state'] ); |
|
342 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate']); |
|
343 | + $rate['name'] = sanitize_text_field($rate['name']); |
|
344 | + $rate['state'] = sanitize_text_field($rate['state']); |
|
345 | + $rate['country'] = sanitize_text_field($rate['country']); |
|
346 | + $rate['global'] = empty($rate['state']); |
|
347 | 347 | $tax_rates[] = $rate; |
348 | 348 | |
349 | 349 | } |
350 | 350 | |
351 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
351 | + update_option('wpinv_tax_rates', $tax_rates); |
|
352 | 352 | |
353 | 353 | return $input; |
354 | 354 | } |
355 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
355 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
356 | 356 | |
357 | 357 | function wpinv_get_settings_tabs() { |
358 | 358 | $tabs = array(); |
359 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
360 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
361 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
362 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
359 | + $tabs['general'] = __('General', 'invoicing'); |
|
360 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
361 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
362 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
363 | 363 | |
364 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
365 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
364 | + if (count(getpaid_get_integration_settings()) > 0) { |
|
365 | + $tabs['integrations'] = __('Integrations', 'invoicing'); |
|
366 | 366 | } |
367 | 367 | |
368 | - $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
|
369 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
370 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
368 | + $tabs['privacy'] = __('Privacy', 'invoicing'); |
|
369 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
370 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
371 | 371 | |
372 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
372 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
373 | 373 | } |
374 | 374 | |
375 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
375 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
376 | 376 | $tabs = false; |
377 | 377 | $sections = wpinv_get_registered_settings_sections(); |
378 | 378 | |
379 | - if ( $tab && ! empty( $sections[ $tab ] ) ) { |
|
380 | - $tabs = $sections[ $tab ]; |
|
379 | + if ($tab && !empty($sections[$tab])) { |
|
380 | + $tabs = $sections[$tab]; |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | return $tabs; |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | function wpinv_get_registered_settings_sections() { |
387 | 387 | static $sections = false; |
388 | 388 | |
389 | - if ( false !== $sections ) { |
|
389 | + if (false !== $sections) { |
|
390 | 390 | return $sections; |
391 | 391 | } |
392 | 392 | |
@@ -394,230 +394,230 @@ discard block |
||
394 | 394 | 'general' => apply_filters( |
395 | 395 | 'wpinv_settings_sections_general', |
396 | 396 | array( |
397 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
398 | - 'page_section' => __( 'Page Settings', 'invoicing' ), |
|
399 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
400 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
397 | + 'main' => __('General Settings', 'invoicing'), |
|
398 | + 'page_section' => __('Page Settings', 'invoicing'), |
|
399 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
400 | + 'labels' => __('Label Texts', 'invoicing'), |
|
401 | 401 | ) |
402 | 402 | ), |
403 | 403 | 'gateways' => apply_filters( |
404 | 404 | 'wpinv_settings_sections_gateways', |
405 | 405 | array( |
406 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
406 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
407 | 407 | ) |
408 | 408 | ), |
409 | 409 | 'taxes' => apply_filters( |
410 | 410 | 'wpinv_settings_sections_taxes', |
411 | 411 | array( |
412 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
413 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
414 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ), |
|
412 | + 'main' => __('Tax Settings', 'invoicing'), |
|
413 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
414 | + 'vat' => __('EU VAT Settings', 'invoicing'), |
|
415 | 415 | ) |
416 | 416 | ), |
417 | 417 | 'emails' => apply_filters( |
418 | 418 | 'wpinv_settings_sections_emails', |
419 | 419 | array( |
420 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
420 | + 'main' => __('Email Settings', 'invoicing'), |
|
421 | 421 | ) |
422 | 422 | ), |
423 | 423 | |
424 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
424 | + 'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'), |
|
425 | 425 | |
426 | 426 | 'privacy' => apply_filters( |
427 | 427 | 'wpinv_settings_sections_privacy', |
428 | 428 | array( |
429 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
429 | + 'main' => __('Privacy policy', 'invoicing'), |
|
430 | 430 | ) |
431 | 431 | ), |
432 | 432 | 'misc' => apply_filters( |
433 | 433 | 'wpinv_settings_sections_misc', |
434 | 434 | array( |
435 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
436 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
435 | + 'main' => __('Miscellaneous', 'invoicing'), |
|
436 | + 'custom-css' => __('Custom CSS', 'invoicing'), |
|
437 | 437 | ) |
438 | 438 | ), |
439 | 439 | 'tools' => apply_filters( |
440 | 440 | 'wpinv_settings_sections_tools', |
441 | 441 | array( |
442 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
442 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
443 | 443 | ) |
444 | 444 | ), |
445 | 445 | ); |
446 | 446 | |
447 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
447 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
448 | 448 | |
449 | 449 | return $sections; |
450 | 450 | } |
451 | 451 | |
452 | -function wpinv_get_pages( $with_slug = false, $default_label = null ) { |
|
452 | +function wpinv_get_pages($with_slug = false, $default_label = null) { |
|
453 | 453 | $pages_options = array(); |
454 | 454 | |
455 | - if ( $default_label !== null && $default_label !== false ) { |
|
456 | - $pages_options = array( '' => $default_label ); // Blank option |
|
455 | + if ($default_label !== null && $default_label !== false) { |
|
456 | + $pages_options = array('' => $default_label); // Blank option |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | $pages = get_pages(); |
460 | - if ( $pages ) { |
|
461 | - foreach ( $pages as $page ) { |
|
460 | + if ($pages) { |
|
461 | + foreach ($pages as $page) { |
|
462 | 462 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
463 | - $pages_options[ $page->ID ] = $title; |
|
463 | + $pages_options[$page->ID] = $title; |
|
464 | 464 | } |
465 | 465 | } |
466 | 466 | |
467 | 467 | return $pages_options; |
468 | 468 | } |
469 | 469 | |
470 | -function wpinv_header_callback( $args ) { |
|
471 | - if ( ! empty( $args['desc'] ) ) { |
|
472 | - echo wp_kses_post( $args['desc'] ); |
|
470 | +function wpinv_header_callback($args) { |
|
471 | + if (!empty($args['desc'])) { |
|
472 | + echo wp_kses_post($args['desc']); |
|
473 | 473 | } |
474 | 474 | } |
475 | 475 | |
476 | -function wpinv_hidden_callback( $args ) { |
|
476 | +function wpinv_hidden_callback($args) { |
|
477 | 477 | |
478 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
479 | - $value = wpinv_get_option( $args['id'], $std ); |
|
478 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
479 | + $value = wpinv_get_option($args['id'], $std); |
|
480 | 480 | |
481 | - if ( isset( $args['set_value'] ) ) { |
|
481 | + if (isset($args['set_value'])) { |
|
482 | 482 | $value = $args['set_value']; |
483 | 483 | } |
484 | 484 | |
485 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
485 | + if (isset($args['faux']) && true === $args['faux']) { |
|
486 | 486 | $args['readonly'] = true; |
487 | - $name = ''; |
|
487 | + $name = ''; |
|
488 | 488 | } else { |
489 | - $name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']'; |
|
489 | + $name = 'wpinv_settings[' . esc_attr($args['id']) . ']'; |
|
490 | 490 | } |
491 | 491 | |
492 | - echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
492 | + echo '<input type="hidden" id="wpinv_settings[' . esc_attr($args['id']) . ']" name="' . esc_attr($name) . '" value="' . esc_attr(stripslashes($value)) . '" />'; |
|
493 | 493 | |
494 | 494 | } |
495 | 495 | |
496 | 496 | /** |
497 | 497 | * Displays a checkbox settings callback. |
498 | 498 | */ |
499 | -function wpinv_checkbox_callback( $args ) { |
|
499 | +function wpinv_checkbox_callback($args) { |
|
500 | 500 | |
501 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
502 | - $std = wpinv_get_option( $args['id'], $std ); |
|
503 | - $id = esc_attr( $args['id'] ); |
|
501 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
502 | + $std = wpinv_get_option($args['id'], $std); |
|
503 | + $id = esc_attr($args['id']); |
|
504 | 504 | |
505 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
505 | + getpaid_hidden_field("wpinv_settings[$id]", '0'); |
|
506 | 506 | ?> |
507 | 507 | <fieldset> |
508 | 508 | <label> |
509 | - <input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox"> |
|
510 | - <?php echo wp_kses_post( $args['desc'] ); ?> |
|
509 | + <input id="wpinv-settings-<?php echo esc_attr($id); ?>" name="wpinv_settings[<?php echo esc_attr($id); ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox"> |
|
510 | + <?php echo wp_kses_post($args['desc']); ?> |
|
511 | 511 | </label> |
512 | 512 | </fieldset> |
513 | 513 | <?php |
514 | 514 | } |
515 | 515 | |
516 | -function wpinv_multicheck_callback( $args ) { |
|
516 | +function wpinv_multicheck_callback($args) { |
|
517 | 517 | |
518 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
519 | - $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
518 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
519 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
520 | 520 | |
521 | - if ( ! empty( $args['options'] ) ) { |
|
521 | + if (!empty($args['options'])) { |
|
522 | 522 | |
523 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
524 | - $value = wpinv_get_option( $args['id'], $std ); |
|
523 | + $std = isset($args['std']) ? $args['std'] : array(); |
|
524 | + $value = wpinv_get_option($args['id'], $std); |
|
525 | 525 | |
526 | - echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">'; |
|
527 | - foreach ( $args['options'] as $key => $option ) : |
|
528 | - $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) ); |
|
529 | - if ( in_array( $sanitize_key, $value ) ) { |
|
526 | + echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr($sanitize_id . $class) . '">'; |
|
527 | + foreach ($args['options'] as $key => $option) : |
|
528 | + $sanitize_key = esc_attr(wpinv_sanitize_key($key)); |
|
529 | + if (in_array($sanitize_key, $value)) { |
|
530 | 530 | $enabled = $sanitize_key; |
531 | 531 | } else { |
532 | 532 | $enabled = null; |
533 | 533 | } |
534 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
535 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
534 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
535 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']">' . wp_kses_post($option) . '</label></div>'; |
|
536 | 536 | endforeach; |
537 | 537 | echo '</div>'; |
538 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
538 | + echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>'; |
|
539 | 539 | } |
540 | 540 | } |
541 | 541 | |
542 | -function wpinv_payment_icons_callback( $args ) { |
|
542 | +function wpinv_payment_icons_callback($args) { |
|
543 | 543 | |
544 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
545 | - $value = wpinv_get_option( $args['id'], false ); |
|
544 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
545 | + $value = wpinv_get_option($args['id'], false); |
|
546 | 546 | |
547 | - if ( ! empty( $args['options'] ) ) { |
|
548 | - foreach ( $args['options'] as $key => $option ) { |
|
549 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
547 | + if (!empty($args['options'])) { |
|
548 | + foreach ($args['options'] as $key => $option) { |
|
549 | + $sanitize_key = wpinv_sanitize_key($key); |
|
550 | 550 | |
551 | - if ( empty( $value ) ) { |
|
551 | + if (empty($value)) { |
|
552 | 552 | $enabled = $option; |
553 | 553 | } else { |
554 | 554 | $enabled = null; |
555 | 555 | } |
556 | 556 | |
557 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
557 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
558 | 558 | |
559 | - echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
559 | + echo '<input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
560 | 560 | |
561 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
562 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
561 | + if (wpinv_string_is_image_url($key)) { |
|
562 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
563 | 563 | } else { |
564 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
564 | + $card = strtolower(str_replace(' ', '', $option)); |
|
565 | 565 | |
566 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
567 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
566 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
567 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
568 | 568 | } else { |
569 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
569 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
570 | 570 | $content_dir = WP_CONTENT_DIR; |
571 | 571 | |
572 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
572 | + if (function_exists('wp_normalize_path')) { |
|
573 | 573 | // Replaces backslashes with forward slashes for Windows systems |
574 | - $image = wp_normalize_path( $image ); |
|
575 | - $content_dir = wp_normalize_path( $content_dir ); |
|
574 | + $image = wp_normalize_path($image); |
|
575 | + $content_dir = wp_normalize_path($content_dir); |
|
576 | 576 | } |
577 | 577 | |
578 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
578 | + $image = str_replace($content_dir, content_url(), $image); |
|
579 | 579 | } |
580 | 580 | |
581 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
581 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
582 | 582 | } |
583 | - echo wp_kses_post( $option ) . '</label>'; |
|
583 | + echo wp_kses_post($option) . '</label>'; |
|
584 | 584 | } |
585 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
585 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
586 | 586 | } |
587 | 587 | } |
588 | 588 | |
589 | 589 | /** |
590 | 590 | * Displays a radio settings field. |
591 | 591 | */ |
592 | -function wpinv_radio_callback( $args ) { |
|
592 | +function wpinv_radio_callback($args) { |
|
593 | 593 | |
594 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
595 | - $std = wpinv_get_option( $args['id'], $std ); |
|
594 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
595 | + $std = wpinv_get_option($args['id'], $std); |
|
596 | 596 | ?> |
597 | 597 | <fieldset> |
598 | - <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
|
599 | - <?php foreach ( $args['options'] as $key => $option ) : ?> |
|
598 | + <ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;"> |
|
599 | + <?php foreach ($args['options'] as $key => $option) : ?> |
|
600 | 600 | <li> |
601 | 601 | <label> |
602 | - <input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio"> |
|
603 | - <?php echo wp_kses_post( $option ); ?> |
|
602 | + <input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio"> |
|
603 | + <?php echo wp_kses_post($option); ?> |
|
604 | 604 | </label> |
605 | 605 | </li> |
606 | 606 | <?php endforeach; ?> |
607 | 607 | </ul> |
608 | 608 | </fieldset> |
609 | 609 | <?php |
610 | - getpaid_settings_description_callback( $args ); |
|
610 | + getpaid_settings_description_callback($args); |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
614 | 614 | * Displays a description if available. |
615 | 615 | */ |
616 | -function getpaid_settings_description_callback( $args ) { |
|
616 | +function getpaid_settings_description_callback($args) { |
|
617 | 617 | |
618 | - if ( ! empty( $args['desc'] ) ) { |
|
618 | + if (!empty($args['desc'])) { |
|
619 | 619 | $description = $args['desc']; |
620 | - echo wp_kses_post( "<p class='description'>$description</p>" ); |
|
620 | + echo wp_kses_post("<p class='description'>$description</p>"); |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | } |
@@ -632,35 +632,35 @@ discard block |
||
632 | 632 | </tr> |
633 | 633 | <tr class="bsui"> |
634 | 634 | <td colspan="2" class="p-0"> |
635 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?> |
|
635 | + <?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?> |
|
636 | 636 | |
637 | 637 | <?php |
638 | 638 | } |
639 | 639 | |
640 | -function wpinv_gateway_select_callback( $args ) { |
|
640 | +function wpinv_gateway_select_callback($args) { |
|
641 | 641 | |
642 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
643 | - $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
644 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
645 | - $value = wpinv_get_option( $args['id'], $std ); |
|
642 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
643 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
644 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
645 | + $value = wpinv_get_option($args['id'], $std); |
|
646 | 646 | |
647 | - echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >'; |
|
647 | + echo '<select name="wpinv_settings[' . esc_attr($sanitize_id) . ']"" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" class="' . esc_attr($class) . '" >'; |
|
648 | 648 | |
649 | - foreach ( $args['options'] as $key => $option ) : |
|
649 | + foreach ($args['options'] as $key => $option) : |
|
650 | 650 | |
651 | - echo '<option value="' . esc_attr( $key ) . '" '; |
|
651 | + echo '<option value="' . esc_attr($key) . '" '; |
|
652 | 652 | |
653 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
654 | - selected( $key, $args['selected'] ); |
|
653 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
654 | + selected($key, $args['selected']); |
|
655 | 655 | } else { |
656 | - selected( $key, $value ); |
|
656 | + selected($key, $value); |
|
657 | 657 | } |
658 | 658 | |
659 | - echo '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
659 | + echo '>' . esc_html($option['admin_label']) . '</option>'; |
|
660 | 660 | endforeach; |
661 | 661 | |
662 | 662 | echo '</select>'; |
663 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
663 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
@@ -669,28 +669,28 @@ discard block |
||
669 | 669 | * @param array $args |
670 | 670 | * @return string |
671 | 671 | */ |
672 | -function wpinv_settings_attrs_helper( $args ) { |
|
672 | +function wpinv_settings_attrs_helper($args) { |
|
673 | 673 | |
674 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
675 | - $id = esc_attr( $args['id'] ); |
|
676 | - $placeholder = esc_attr( $args['placeholder'] ); |
|
674 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
675 | + $id = esc_attr($args['id']); |
|
676 | + $placeholder = esc_attr($args['placeholder']); |
|
677 | 677 | |
678 | - if ( ! empty( $args['faux'] ) ) { |
|
678 | + if (!empty($args['faux'])) { |
|
679 | 679 | $args['readonly'] = true; |
680 | 680 | $name = ''; |
681 | 681 | } else { |
682 | - $value = wpinv_get_option( $args['id'], $value ); |
|
682 | + $value = wpinv_get_option($args['id'], $value); |
|
683 | 683 | $name = "wpinv_settings[$id]"; |
684 | 684 | } |
685 | 685 | |
686 | - $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
687 | - $class = esc_attr( $args['class'] ); |
|
688 | - $style = esc_attr( $args['style'] ); |
|
689 | - $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
686 | + $value = is_scalar($value) ? esc_attr($value) : ''; |
|
687 | + $class = esc_attr($args['class']); |
|
688 | + $style = esc_attr($args['style']); |
|
689 | + $readonly = empty($args['readonly']) ? '' : 'readonly onclick="this.select()"'; |
|
690 | 690 | |
691 | 691 | $onchange = ''; |
692 | - if ( ! empty( $args['onchange'] ) ) { |
|
693 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
692 | + if (!empty($args['onchange'])) { |
|
693 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
694 | 694 | } |
695 | 695 | |
696 | 696 | return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
@@ -699,14 +699,14 @@ discard block |
||
699 | 699 | /** |
700 | 700 | * Displays a text input settings callback. |
701 | 701 | */ |
702 | -function wpinv_text_callback( $args ) { |
|
702 | +function wpinv_text_callback($args) { |
|
703 | 703 | |
704 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
704 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
705 | 705 | |
706 | 706 | ?> |
707 | 707 | <label style="width: 100%;"> |
708 | - <input type="text" <?php echo wpinv_settings_attrs_helper( $args ); ?>> |
|
709 | - <?php echo wp_kses_post( $desc ); ?> |
|
708 | + <input type="text" <?php echo wpinv_settings_attrs_helper($args); ?>> |
|
709 | + <?php echo wp_kses_post($desc); ?> |
|
710 | 710 | </label> |
711 | 711 | <?php |
712 | 712 | |
@@ -715,49 +715,49 @@ discard block |
||
715 | 715 | /** |
716 | 716 | * Displays a number input settings callback. |
717 | 717 | */ |
718 | -function wpinv_number_callback( $args ) { |
|
718 | +function wpinv_number_callback($args) { |
|
719 | 719 | |
720 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
721 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
720 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
721 | + $attr = wpinv_settings_attrs_helper($args); |
|
722 | 722 | |
723 | 723 | ?> |
724 | 724 | <label style="width: 100%;"> |
725 | - <input type="number" step="<?php echo floatval( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php echo $attr; ?>> |
|
726 | - <?php echo wp_kses_post( $desc ); ?> |
|
725 | + <input type="number" step="<?php echo floatval($args['step']); ?>" max="<?php echo intval($args['max']); ?>" min="<?php echo intval($args['min']); ?>" <?php echo $attr; ?>> |
|
726 | + <?php echo wp_kses_post($desc); ?> |
|
727 | 727 | </label> |
728 | 728 | <?php |
729 | 729 | |
730 | 730 | } |
731 | 731 | |
732 | -function wpinv_textarea_callback( $args ) { |
|
732 | +function wpinv_textarea_callback($args) { |
|
733 | 733 | |
734 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
735 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
736 | - $value = wpinv_get_option( $args['id'], $std ); |
|
734 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
735 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
736 | + $value = wpinv_get_option($args['id'], $std); |
|
737 | 737 | |
738 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
739 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
738 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
739 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
740 | 740 | |
741 | - echo '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
742 | - echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
741 | + echo '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
742 | + echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
743 | 743 | |
744 | 744 | } |
745 | 745 | |
746 | -function wpinv_password_callback( $args ) { |
|
746 | +function wpinv_password_callback($args) { |
|
747 | 747 | |
748 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
749 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
750 | - $value = wpinv_get_option( $args['id'], $std ); |
|
748 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
749 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
750 | + $value = wpinv_get_option($args['id'], $std); |
|
751 | 751 | |
752 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
753 | - echo '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
754 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
752 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
753 | + echo '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
754 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
755 | 755 | |
756 | 756 | } |
757 | 757 | |
758 | -function wpinv_missing_callback( $args ) { |
|
758 | +function wpinv_missing_callback($args) { |
|
759 | 759 | printf( |
760 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
760 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
761 | 761 | '<strong>' . $args['id'] . '</strong>' |
762 | 762 | ); |
763 | 763 | } |
@@ -765,35 +765,35 @@ discard block |
||
765 | 765 | /** |
766 | 766 | * Displays a number input settings callback. |
767 | 767 | */ |
768 | -function wpinv_select_callback( $args ) { |
|
768 | +function wpinv_select_callback($args) { |
|
769 | 769 | |
770 | - $desc = wp_kses_post( $args['desc'] ); |
|
771 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
772 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
773 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
774 | - $value = wpinv_get_option( $args['id'], $value ); |
|
775 | - $rand = uniqid( 'random_id' ); |
|
770 | + $desc = wp_kses_post($args['desc']); |
|
771 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
772 | + $attr = wpinv_settings_attrs_helper($args); |
|
773 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
774 | + $value = wpinv_get_option($args['id'], $value); |
|
775 | + $rand = uniqid('random_id'); |
|
776 | 776 | |
777 | 777 | ?> |
778 | 778 | <label style="width: 100%;"> |
779 | 779 | <select <?php echo $attr; ?> data-allow-clear="true"> |
780 | - <?php foreach ( $args['options'] as $option => $name ) : ?> |
|
781 | - <option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo wpinv_clean( $name ); ?></option> |
|
780 | + <?php foreach ($args['options'] as $option => $name) : ?> |
|
781 | + <option value="<?php echo esc_attr($option); ?>" <?php echo selected($option, $value); ?>><?php echo wpinv_clean($name); ?></option> |
|
782 | 782 | <?php endforeach; ?> |
783 | 783 | </select> |
784 | 784 | |
785 | - <?php if ( substr( $args['id'], -5 ) === '_page' && is_numeric( $value ) ) : ?> |
|
786 | - <a href="<?php echo get_edit_post_link( $value ); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e( 'Edit Page', 'invoicing' ); ?></a> |
|
785 | + <?php if (substr($args['id'], -5) === '_page' && is_numeric($value)) : ?> |
|
786 | + <a href="<?php echo get_edit_post_link($value); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e('Edit Page', 'invoicing'); ?></a> |
|
787 | 787 | <?php endif; ?> |
788 | 788 | |
789 | - <?php if ( substr( $args['id'], -5 ) === '_page' && ! empty( $args['default_content'] ) ) : ?> |
|
790 | - <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e( 'View Default Content', 'invoicing' ); ?></a> |
|
789 | + <?php if (substr($args['id'], -5) === '_page' && !empty($args['default_content'])) : ?> |
|
790 | + <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e('View Default Content', 'invoicing'); ?></a> |
|
791 | 791 | <div id='<?php echo $rand; ?>' style='display:none;'> |
792 | 792 | <div> |
793 | - <h3><?php esc_html_e( 'Original Content', 'invoicing' ); ?></h3> |
|
794 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines( wp_kses_post( $args['default_content'] ) ); ?></textarea> |
|
795 | - <h3><?php esc_html_e( 'Current Content', 'invoicing' ); ?></h3> |
|
796 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post( $value ); echo empty( $_post ) ? '' : gepaid_trim_lines( wp_kses_post( $_post->post_content ) ); ?></textarea> |
|
793 | + <h3><?php esc_html_e('Original Content', 'invoicing'); ?></h3> |
|
794 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines(wp_kses_post($args['default_content'])); ?></textarea> |
|
795 | + <h3><?php esc_html_e('Current Content', 'invoicing'); ?></h3> |
|
796 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post($value); echo empty($_post) ? '' : gepaid_trim_lines(wp_kses_post($_post->post_content)); ?></textarea> |
|
797 | 797 | </div> |
798 | 798 | </div> |
799 | 799 | <?php endif; ?> |
@@ -804,89 +804,89 @@ discard block |
||
804 | 804 | |
805 | 805 | } |
806 | 806 | |
807 | -function wpinv_color_select_callback( $args ) { |
|
807 | +function wpinv_color_select_callback($args) { |
|
808 | 808 | |
809 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
810 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
811 | - $value = wpinv_get_option( $args['id'], $std ); |
|
809 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
810 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
811 | + $value = wpinv_get_option($args['id'], $std); |
|
812 | 812 | |
813 | - echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
813 | + echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
814 | 814 | |
815 | - foreach ( $args['options'] as $option => $color ) { |
|
816 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>'; |
|
815 | + foreach ($args['options'] as $option => $color) { |
|
816 | + echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($color['label']) . '</option>'; |
|
817 | 817 | } |
818 | 818 | |
819 | 819 | echo '</select>'; |
820 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
820 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
821 | 821 | |
822 | 822 | } |
823 | 823 | |
824 | -function wpinv_rich_editor_callback( $args ) { |
|
824 | +function wpinv_rich_editor_callback($args) { |
|
825 | 825 | global $wp_version; |
826 | 826 | |
827 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
827 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
828 | 828 | |
829 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
830 | - $value = wpinv_get_option( $args['id'], $std ); |
|
829 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
830 | + $value = wpinv_get_option($args['id'], $std); |
|
831 | 831 | |
832 | - if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
832 | + if (!empty($args['allow_blank']) && empty($value)) { |
|
833 | 833 | $value = $std; |
834 | 834 | } |
835 | 835 | |
836 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
836 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
837 | 837 | |
838 | 838 | echo '<div class="getpaid-settings-editor-input">'; |
839 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
839 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
840 | 840 | wp_editor( |
841 | - stripslashes( $value ), |
|
842 | - 'wpinv_settings_' . esc_attr( $args['id'] ), |
|
841 | + stripslashes($value), |
|
842 | + 'wpinv_settings_' . esc_attr($args['id']), |
|
843 | 843 | array( |
844 | - 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', |
|
845 | - 'textarea_rows' => absint( $rows ), |
|
844 | + 'textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', |
|
845 | + 'textarea_rows' => absint($rows), |
|
846 | 846 | 'media_buttons' => false, |
847 | 847 | ) |
848 | 848 | ); |
849 | 849 | } else { |
850 | - echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
850 | + echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
851 | 851 | } |
852 | 852 | |
853 | - echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
853 | + echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
854 | 854 | |
855 | 855 | } |
856 | 856 | |
857 | -function wpinv_upload_callback( $args ) { |
|
857 | +function wpinv_upload_callback($args) { |
|
858 | 858 | |
859 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
859 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
860 | 860 | |
861 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
862 | - $value = wpinv_get_option( $args['id'], $std ); |
|
861 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
862 | + $value = wpinv_get_option($args['id'], $std); |
|
863 | 863 | |
864 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
865 | - echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
866 | - echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
867 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
864 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
865 | + echo '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
866 | + echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
867 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
868 | 868 | |
869 | 869 | } |
870 | 870 | |
871 | -function wpinv_color_callback( $args ) { |
|
871 | +function wpinv_color_callback($args) { |
|
872 | 872 | |
873 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
874 | - $value = wpinv_get_option( $args['id'], $std ); |
|
875 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
873 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
874 | + $value = wpinv_get_option($args['id'], $std); |
|
875 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
876 | 876 | |
877 | - echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
878 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
877 | + echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($std) . '" />'; |
|
878 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
879 | 879 | |
880 | 880 | } |
881 | 881 | |
882 | -function wpinv_country_states_callback( $args ) { |
|
882 | +function wpinv_country_states_callback($args) { |
|
883 | 883 | |
884 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
885 | - $value = wpinv_get_option( $args['id'], $std ); |
|
884 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
885 | + $value = wpinv_get_option($args['id'], $std); |
|
886 | 886 | |
887 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
887 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
888 | 888 | |
889 | - if ( isset( $args['placeholder'] ) ) { |
|
889 | + if (isset($args['placeholder'])) { |
|
890 | 890 | $placeholder = $args['placeholder']; |
891 | 891 | } else { |
892 | 892 | $placeholder = ''; |
@@ -894,15 +894,15 @@ discard block |
||
894 | 894 | |
895 | 895 | $states = wpinv_get_country_states(); |
896 | 896 | |
897 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
898 | - echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
897 | + $class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
898 | + echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
899 | 899 | |
900 | - foreach ( $states as $option => $name ) { |
|
901 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>'; |
|
900 | + foreach ($states as $option => $name) { |
|
901 | + echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($name) . '</option>'; |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | echo '</select>'; |
905 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
905 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
906 | 906 | |
907 | 907 | } |
908 | 908 | |
@@ -916,7 +916,7 @@ discard block |
||
916 | 916 | </tr> |
917 | 917 | <tr class="bsui"> |
918 | 918 | <td colspan="2" class="p-0"> |
919 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?> |
|
919 | + <?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?> |
|
920 | 920 | |
921 | 921 | <?php |
922 | 922 | |
@@ -925,14 +925,14 @@ discard block |
||
925 | 925 | /** |
926 | 926 | * Displays a tax rate' edit row. |
927 | 927 | */ |
928 | -function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) { |
|
928 | +function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) { |
|
929 | 929 | ob_start(); |
930 | 930 | |
931 | - $key = sanitize_key( $key ); |
|
932 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
933 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
931 | + $key = sanitize_key($key); |
|
932 | + $tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate']; |
|
933 | + include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php'; |
|
934 | 934 | |
935 | - if ( $echo ) { |
|
935 | + if ($echo) { |
|
936 | 936 | echo ob_get_clean(); |
937 | 937 | } else { |
938 | 938 | return ob_get_clean(); |
@@ -941,152 +941,152 @@ discard block |
||
941 | 941 | } |
942 | 942 | |
943 | 943 | |
944 | -function wpinv_tools_callback( $args ) { |
|
944 | +function wpinv_tools_callback($args) { |
|
945 | 945 | ?> |
946 | 946 | </td><tr> |
947 | 947 | <td colspan="2" class="wpinv_tools_tdbox"> |
948 | 948 | <?php |
949 | - if ( $args['desc'] ) { |
|
949 | + if ($args['desc']) { |
|
950 | 950 | ?> |
951 | 951 | <p><?php echo $args['desc']; ?></p><?php } ?> |
952 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
952 | + <?php do_action('wpinv_tools_before'); ?> |
|
953 | 953 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
954 | 954 | <thead> |
955 | 955 | <tr> |
956 | - <th scope="col" class="wpinv-th-tool"><?php esc_html_e( 'Tool', 'invoicing' ); ?></th> |
|
957 | - <th scope="col" class="wpinv-th-desc"><?php esc_html_e( 'Description', 'invoicing' ); ?></th> |
|
958 | - <th scope="col" class="wpinv-th-action"><?php esc_html_e( 'Action', 'invoicing' ); ?></th> |
|
956 | + <th scope="col" class="wpinv-th-tool"><?php esc_html_e('Tool', 'invoicing'); ?></th> |
|
957 | + <th scope="col" class="wpinv-th-desc"><?php esc_html_e('Description', 'invoicing'); ?></th> |
|
958 | + <th scope="col" class="wpinv-th-action"><?php esc_html_e('Action', 'invoicing'); ?></th> |
|
959 | 959 | </tr> |
960 | 960 | </thead> |
961 | 961 | |
962 | 962 | <tbody> |
963 | 963 | <tr> |
964 | - <td><?php esc_html_e( 'Check Pages', 'invoicing' ); ?></td> |
|
964 | + <td><?php esc_html_e('Check Pages', 'invoicing'); ?></td> |
|
965 | 965 | <td> |
966 | - <small><?php esc_html_e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small> |
|
966 | + <small><?php esc_html_e('Creates any missing GetPaid pages.', 'invoicing'); ?></small> |
|
967 | 967 | </td> |
968 | 968 | <td> |
969 | 969 | <a href=" |
970 | 970 | <?php |
971 | 971 | echo esc_url( |
972 | 972 | wp_nonce_url( |
973 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
973 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
974 | 974 | 'getpaid-nonce', |
975 | 975 | 'getpaid-nonce' |
976 | 976 | ) |
977 | 977 | ); |
978 | 978 | ?> |
979 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
979 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
980 | 980 | </td> |
981 | 981 | </tr> |
982 | 982 | <tr> |
983 | - <td><?php esc_html_e( 'Create Database Tables', 'invoicing' ); ?></td> |
|
983 | + <td><?php esc_html_e('Create Database Tables', 'invoicing'); ?></td> |
|
984 | 984 | <td> |
985 | - <small><?php esc_html_e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small> |
|
985 | + <small><?php esc_html_e('Run this tool to create any missing database tables.', 'invoicing'); ?></small> |
|
986 | 986 | </td> |
987 | 987 | <td> |
988 | 988 | <a href=" |
989 | 989 | <?php |
990 | 990 | echo esc_url( |
991 | 991 | wp_nonce_url( |
992 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
992 | + add_query_arg('getpaid-admin-action', 'create_missing_tables'), |
|
993 | 993 | 'getpaid-nonce', |
994 | 994 | 'getpaid-nonce' |
995 | 995 | ) |
996 | 996 | ); |
997 | 997 | ?> |
998 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
998 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
999 | 999 | </td> |
1000 | 1000 | </tr> |
1001 | 1001 | <tr> |
1002 | - <td><?php esc_html_e( 'Migrate old invoices', 'invoicing' ); ?></td> |
|
1002 | + <td><?php esc_html_e('Migrate old invoices', 'invoicing'); ?></td> |
|
1003 | 1003 | <td> |
1004 | - <small><?php esc_html_e( 'If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing' ); ?></small> |
|
1004 | + <small><?php esc_html_e('If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing'); ?></small> |
|
1005 | 1005 | </td> |
1006 | 1006 | <td> |
1007 | 1007 | <a href=" |
1008 | 1008 | <?php |
1009 | 1009 | echo esc_url( |
1010 | 1010 | wp_nonce_url( |
1011 | - add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
1011 | + add_query_arg('getpaid-admin-action', 'migrate_old_invoices'), |
|
1012 | 1012 | 'getpaid-nonce', |
1013 | 1013 | 'getpaid-nonce' |
1014 | 1014 | ) |
1015 | 1015 | ); |
1016 | 1016 | ?> |
1017 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1017 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1018 | 1018 | </td> |
1019 | 1019 | </tr> |
1020 | 1020 | |
1021 | 1021 | <tr> |
1022 | - <td><?php esc_html_e( 'Recalculate Discounts', 'invoicing' ); ?></td> |
|
1022 | + <td><?php esc_html_e('Recalculate Discounts', 'invoicing'); ?></td> |
|
1023 | 1023 | <td> |
1024 | - <small><?php esc_html_e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small> |
|
1024 | + <small><?php esc_html_e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small> |
|
1025 | 1025 | </td> |
1026 | 1026 | <td> |
1027 | 1027 | <a href=" |
1028 | 1028 | <?php |
1029 | 1029 | echo esc_url( |
1030 | 1030 | wp_nonce_url( |
1031 | - add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
1031 | + add_query_arg('getpaid-admin-action', 'recalculate_discounts'), |
|
1032 | 1032 | 'getpaid-nonce', |
1033 | 1033 | 'getpaid-nonce' |
1034 | 1034 | ) |
1035 | 1035 | ); |
1036 | 1036 | ?> |
1037 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1037 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1038 | 1038 | </td> |
1039 | 1039 | </tr> |
1040 | 1040 | |
1041 | 1041 | <tr> |
1042 | - <td><?php esc_html_e( 'Set-up Wizard', 'invoicing' ); ?></td> |
|
1042 | + <td><?php esc_html_e('Set-up Wizard', 'invoicing'); ?></td> |
|
1043 | 1043 | <td> |
1044 | - <small><?php esc_html_e( 'Launch the quick set-up wizard.', 'invoicing' ); ?></small> |
|
1044 | + <small><?php esc_html_e('Launch the quick set-up wizard.', 'invoicing'); ?></small> |
|
1045 | 1045 | </td> |
1046 | 1046 | <td> |
1047 | 1047 | <a href=" |
1048 | 1048 | <?php |
1049 | - echo esc_url( admin_url( 'index.php?page=gp-setup' ) ); |
|
1049 | + echo esc_url(admin_url('index.php?page=gp-setup')); |
|
1050 | 1050 | ?> |
1051 | - " class="button button-primary"><?php esc_html_e( 'Launch', 'invoicing' ); ?></a> |
|
1051 | + " class="button button-primary"><?php esc_html_e('Launch', 'invoicing'); ?></a> |
|
1052 | 1052 | </td> |
1053 | 1053 | </tr> |
1054 | 1054 | |
1055 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
1055 | + <?php do_action('wpinv_tools_row'); ?> |
|
1056 | 1056 | </tbody> |
1057 | 1057 | </table> |
1058 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
1058 | + <?php do_action('wpinv_tools_after'); ?> |
|
1059 | 1059 | <?php |
1060 | 1060 | } |
1061 | 1061 | |
1062 | 1062 | |
1063 | -function wpinv_descriptive_text_callback( $args ) { |
|
1064 | - echo wp_kses_post( $args['desc'] ); |
|
1063 | +function wpinv_descriptive_text_callback($args) { |
|
1064 | + echo wp_kses_post($args['desc']); |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | -function wpinv_raw_html_callback( $args ) { |
|
1068 | - echo wp_kses_post( $args['desc'] ); |
|
1067 | +function wpinv_raw_html_callback($args) { |
|
1068 | + echo wp_kses_post($args['desc']); |
|
1069 | 1069 | } |
1070 | 1070 | |
1071 | -function wpinv_hook_callback( $args ) { |
|
1072 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1071 | +function wpinv_hook_callback($args) { |
|
1072 | + do_action('wpinv_' . $args['id'], $args); |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | function wpinv_set_settings_cap() { |
1076 | 1076 | return wpinv_get_capability(); |
1077 | 1077 | } |
1078 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
1078 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
1079 | 1079 | |
1080 | 1080 | |
1081 | -function wpinv_on_update_settings( $old_value, $value, $option ) { |
|
1082 | - $old = ! empty( $old_value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1083 | - $new = ! empty( $value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1081 | +function wpinv_on_update_settings($old_value, $value, $option) { |
|
1082 | + $old = !empty($old_value['remove_data_on_unistall']) ? 1 : ''; |
|
1083 | + $new = !empty($value['remove_data_on_unistall']) ? 1 : ''; |
|
1084 | 1084 | |
1085 | - if ( $old != $new ) { |
|
1086 | - update_option( 'wpinv_remove_data_on_invoice_unistall', $new ); |
|
1085 | + if ($old != $new) { |
|
1086 | + update_option('wpinv_remove_data_on_invoice_unistall', $new); |
|
1087 | 1087 | } |
1088 | 1088 | } |
1089 | -add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 ); |
|
1089 | +add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3); |
|
1090 | 1090 | |
1091 | 1091 | /** |
1092 | 1092 | * Returns the merge tags help text. |
@@ -1095,16 +1095,16 @@ discard block |
||
1095 | 1095 | * |
1096 | 1096 | * @return string |
1097 | 1097 | */ |
1098 | -function wpinv_get_merge_tags_help_text( $subscription = false ) { |
|
1098 | +function wpinv_get_merge_tags_help_text($subscription = false) { |
|
1099 | 1099 | |
1100 | 1100 | $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
1101 | 1101 | $link = sprintf( |
1102 | 1102 | '<strong><a href="%s" target="_blank">%s</a></strong>', |
1103 | 1103 | $url, |
1104 | - esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
1104 | + esc_html__('View available merge tags.', 'wpinv-quotes') |
|
1105 | 1105 | ); |
1106 | 1106 | |
1107 | - $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
1107 | + $description = esc_html__('The content of the email (Merge Tags and HTML are allowed).', 'invoicing'); |
|
1108 | 1108 | |
1109 | 1109 | return "$description $link"; |
1110 | 1110 |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Abstaract Payment Gateway class. |
@@ -139,50 +139,50 @@ discard block |
||
139 | 139 | public function __construct() { |
140 | 140 | |
141 | 141 | // Register gateway. |
142 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
142 | + add_filter('wpinv_payment_gateways', array($this, 'register_gateway')); |
|
143 | 143 | |
144 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
144 | + $this->enabled = wpinv_is_gateway_active($this->id); |
|
145 | 145 | |
146 | 146 | // Add support for various features. |
147 | - foreach ( $this->supports as $feature ) { |
|
148 | - add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' ); |
|
149 | - add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' ); |
|
150 | - add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
147 | + foreach ($this->supports as $feature) { |
|
148 | + add_filter("wpinv_{$this->id}_support_{$feature}", '__return_true'); |
|
149 | + add_filter("getpaid_{$this->id}_support_{$feature}", '__return_true'); |
|
150 | + add_filter("getpaid_{$this->id}_supports_{$feature}", '__return_true'); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // Invoice addons. |
154 | - if ( $this->supports( 'addons' ) ) { |
|
155 | - add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
154 | + if ($this->supports('addons')) { |
|
155 | + add_action("getpaid_process_{$this->id}_invoice_addons", array($this, 'process_addons'), 10, 2); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | // Gateway settings. |
159 | - add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
159 | + add_filter("wpinv_gateway_settings_{$this->id}", array($this, 'admin_settings')); |
|
160 | 160 | |
161 | 161 | // Gateway checkout fiellds. |
162 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
162 | + add_action("wpinv_{$this->id}_cc_form", array($this, 'payment_fields'), 10, 2); |
|
163 | 163 | |
164 | 164 | // Process payment. |
165 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
165 | + add_action("getpaid_gateway_{$this->id}", array($this, 'process_payment'), 10, 3); |
|
166 | 166 | |
167 | 167 | // Change the checkout button text. |
168 | - if ( ! empty( $this->checkout_button_text ) ) { |
|
169 | - add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
168 | + if (!empty($this->checkout_button_text)) { |
|
169 | + add_filter("getpaid_gateway_{$this->id}_checkout_button_label", array($this, 'rename_checkout_button')); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | // Check if a gateway is valid for a given currency. |
173 | - add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
173 | + add_filter("getpaid_gateway_{$this->id}_is_valid_for_currency", array($this, 'validate_currency'), 10, 2); |
|
174 | 174 | |
175 | 175 | // Generate the transaction url. |
176 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
176 | + add_filter("getpaid_gateway_{$this->id}_transaction_url", array($this, 'filter_transaction_url'), 10, 2); |
|
177 | 177 | |
178 | 178 | // Generate the subscription url. |
179 | - add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
179 | + add_filter('getpaid_remote_subscription_profile_url', array($this, 'generate_subscription_url'), 10, 2); |
|
180 | 180 | |
181 | 181 | // Confirm payments. |
182 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
182 | + add_filter("wpinv_payment_confirm_{$this->id}", array($this, 'confirm_payment'), 10, 2); |
|
183 | 183 | |
184 | 184 | // Verify IPNs. |
185 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
185 | + add_action("wpinv_verify_{$this->id}_ipn", array($this, 'verify_ipn')); |
|
186 | 186 | |
187 | 187 | } |
188 | 188 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @since 1.0.19 |
193 | 193 | * @return bool |
194 | 194 | */ |
195 | - public function is( $gateway ) { |
|
195 | + public function is($gateway) { |
|
196 | 196 | return $gateway == $this->id; |
197 | 197 | } |
198 | 198 | |
@@ -202,23 +202,23 @@ discard block |
||
202 | 202 | * @since 1.0.19 |
203 | 203 | * @return array |
204 | 204 | */ |
205 | - public function get_tokens( $sandbox = null ) { |
|
205 | + public function get_tokens($sandbox = null) { |
|
206 | 206 | |
207 | - if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
208 | - $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
207 | + if (is_user_logged_in() && $this->supports('tokens') && 0 == count($this->tokens)) { |
|
208 | + $tokens = get_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", true); |
|
209 | 209 | |
210 | - if ( is_array( $tokens ) ) { |
|
210 | + if (is_array($tokens)) { |
|
211 | 211 | $this->tokens = $tokens; |
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | - if ( ! is_bool( $sandbox ) ) { |
|
215 | + if (!is_bool($sandbox)) { |
|
216 | 216 | return $this->tokens; |
217 | 217 | } |
218 | 218 | |
219 | 219 | // Filter tokens. |
220 | - $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
221 | - return wp_list_filter( $this->tokens, $args ); |
|
220 | + $args = array('type' => $sandbox ? 'sandbox' : 'live'); |
|
221 | + return wp_list_filter($this->tokens, $args); |
|
222 | 222 | |
223 | 223 | } |
224 | 224 | |
@@ -227,12 +227,12 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @since 1.0.19 |
229 | 229 | */ |
230 | - public function save_token( $token ) { |
|
230 | + public function save_token($token) { |
|
231 | 231 | |
232 | 232 | $tokens = $this->get_tokens(); |
233 | 233 | $tokens[] = $token; |
234 | 234 | |
235 | - update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
235 | + update_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens); |
|
236 | 236 | |
237 | 237 | $this->tokens = $tokens; |
238 | 238 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @return string |
245 | 245 | */ |
246 | 246 | public function get_method_title() { |
247 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
247 | + return apply_filters('getpaid_gateway_method_title', $this->method_title, $this); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * @return string |
254 | 254 | */ |
255 | 255 | public function get_method_description() { |
256 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
256 | + return apply_filters('getpaid_gateway_method_description', $this->method_description, $this); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @param WPInv_Invoice $invoice Invoice object. |
263 | 263 | * @return string |
264 | 264 | */ |
265 | - public function get_return_url( $invoice ) { |
|
265 | + public function get_return_url($invoice) { |
|
266 | 266 | |
267 | 267 | // Payment success url |
268 | 268 | $return_url = add_query_arg( |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | wpinv_get_success_page_uri() |
275 | 275 | ); |
276 | 276 | |
277 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
277 | + return apply_filters('getpaid_gateway_success_url', $return_url, $invoice, $this); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -283,24 +283,24 @@ discard block |
||
283 | 283 | * @param string $content Success page content. |
284 | 284 | * @return string |
285 | 285 | */ |
286 | - public function confirm_payment( $content ) { |
|
286 | + public function confirm_payment($content) { |
|
287 | 287 | |
288 | 288 | // Retrieve the invoice. |
289 | 289 | $invoice_id = getpaid_get_current_invoice_id(); |
290 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
290 | + $invoice = wpinv_get_invoice($invoice_id); |
|
291 | 291 | |
292 | 292 | // Ensure that it exists and that it is pending payment. |
293 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
293 | + if (empty($invoice_id) || !$invoice->needs_payment()) { |
|
294 | 294 | return $content; |
295 | 295 | } |
296 | 296 | |
297 | 297 | // Can the user view this invoice?? |
298 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
298 | + if (!wpinv_user_can_view_invoice($invoice)) { |
|
299 | 299 | return $content; |
300 | 300 | } |
301 | 301 | |
302 | 302 | // Show payment processing indicator. |
303 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
303 | + return wpinv_get_template_html('wpinv-payment-processing.php', compact('invoice')); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | /** |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | * @param GetPaid_Form_Item[] $items |
318 | 318 | * @return WPInv_Invoice |
319 | 319 | */ |
320 | - public function process_addons( $invoice, $items ) { |
|
320 | + public function process_addons($invoice, $items) { |
|
321 | 321 | |
322 | 322 | } |
323 | 323 | |
@@ -328,14 +328,14 @@ discard block |
||
328 | 328 | * @param WPInv_Invoice $invoice Invoice object. |
329 | 329 | * @return string transaction URL, or empty string. |
330 | 330 | */ |
331 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
331 | + public function filter_transaction_url($transaction_url, $invoice) { |
|
332 | 332 | |
333 | - $transaction_id = $invoice->get_transaction_id(); |
|
333 | + $transaction_id = $invoice->get_transaction_id(); |
|
334 | 334 | |
335 | - if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
336 | - $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
337 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
338 | - $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
335 | + if (!empty($this->view_transaction_url) && !empty($transaction_id)) { |
|
336 | + $transaction_url = sprintf($this->view_transaction_url, $transaction_id); |
|
337 | + $replace = $this->is_sandbox($invoice) ? 'sandbox' : ''; |
|
338 | + $transaction_url = str_replace('{sandbox}', $replace, $transaction_url); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | return $transaction_url; |
@@ -348,15 +348,15 @@ discard block |
||
348 | 348 | * @param WPInv_Subscription $subscription Subscription objectt. |
349 | 349 | * @return string subscription URL, or empty string. |
350 | 350 | */ |
351 | - public function generate_subscription_url( $subscription_url, $subscription ) { |
|
351 | + public function generate_subscription_url($subscription_url, $subscription) { |
|
352 | 352 | |
353 | - $profile_id = $subscription->get_profile_id(); |
|
353 | + $profile_id = $subscription->get_profile_id(); |
|
354 | 354 | |
355 | - if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
355 | + if ($this->id == $subscription->get_gateway() && !empty($this->view_subscription_url) && !empty($profile_id)) { |
|
356 | 356 | |
357 | - $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
358 | - $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
359 | - $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
357 | + $subscription_url = sprintf($this->view_subscription_url, $profile_id); |
|
358 | + $replace = $this->is_sandbox($subscription->get_parent_invoice()) ? 'sandbox' : ''; |
|
359 | + $subscription_url = str_replace('{sandbox}', $replace, $subscription_url); |
|
360 | 360 | |
361 | 361 | } |
362 | 362 | |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * @return bool |
370 | 370 | */ |
371 | 371 | public function is_available() { |
372 | - return ! empty( $this->enabled ); |
|
372 | + return !empty($this->enabled); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | /** |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * @return string |
379 | 379 | */ |
380 | 380 | public function get_title() { |
381 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
381 | + return apply_filters('getpaid_gateway_title', $this->title, $this); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | /** |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | * @return string |
388 | 388 | */ |
389 | 389 | public function get_description() { |
390 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
390 | + return apply_filters('getpaid_gateway_description', $this->description, $this); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | /** |
@@ -399,9 +399,9 @@ discard block |
||
399 | 399 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
400 | 400 | * @return void |
401 | 401 | */ |
402 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
402 | + public function process_payment($invoice, $submission_data, $submission) { |
|
403 | 403 | // Process the payment then either redirect to the success page or the gateway. |
404 | - do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
404 | + do_action('getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
@@ -415,8 +415,8 @@ discard block |
||
415 | 415 | * @param string $reason Refund reason. |
416 | 416 | * @return WP_Error|bool True or false based on success, or a WP_Error object. |
417 | 417 | */ |
418 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
419 | - return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
418 | + public function process_refund($invoice, $amount = null, $reason = '') { |
|
419 | + return apply_filters('getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | /** |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | * @param int $invoice_id 0 or invoice id. |
426 | 426 | * @param GetPaid_Payment_Form $form Current payment form. |
427 | 427 | */ |
428 | - public function payment_fields( $invoice_id, $form ) { |
|
429 | - do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
428 | + public function payment_fields($invoice_id, $form) { |
|
429 | + do_action('getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | /** |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | * |
435 | 435 | * @param array $admin_settings |
436 | 436 | */ |
437 | - public function admin_settings( $admin_settings ) { |
|
437 | + public function admin_settings($admin_settings) { |
|
438 | 438 | return $admin_settings; |
439 | 439 | } |
440 | 440 | |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | * |
444 | 444 | * @param string $option |
445 | 445 | */ |
446 | - public function get_option( $option, $default = false ) { |
|
447 | - return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
446 | + public function get_option($option, $default = false) { |
|
447 | + return wpinv_get_option($this->id . '_' . $option, $default); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | /** |
@@ -457,8 +457,8 @@ discard block |
||
457 | 457 | * @return bool True if the gateway supports the feature, false otherwise. |
458 | 458 | * @since 1.0.19 |
459 | 459 | */ |
460 | - public function supports( $feature ) { |
|
461 | - return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
460 | + public function supports($feature) { |
|
461 | + return getpaid_payment_gateway_supports($this->id, $feature); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | /** |
@@ -466,36 +466,36 @@ discard block |
||
466 | 466 | * |
467 | 467 | * @param bool $save whether or not to display the save button. |
468 | 468 | */ |
469 | - public function get_cc_form( $save = false ) { |
|
469 | + public function get_cc_form($save = false) { |
|
470 | 470 | |
471 | 471 | ob_start(); |
472 | 472 | |
473 | - $id_prefix = esc_attr( uniqid( $this->id ) ); |
|
473 | + $id_prefix = esc_attr(uniqid($this->id)); |
|
474 | 474 | |
475 | 475 | $months = array( |
476 | - '01' => __( 'January', 'invoicing' ), |
|
477 | - '02' => __( 'February', 'invoicing' ), |
|
478 | - '03' => __( 'March', 'invoicing' ), |
|
479 | - '04' => __( 'April', 'invoicing' ), |
|
480 | - '05' => __( 'May', 'invoicing' ), |
|
481 | - '06' => __( 'June', 'invoicing' ), |
|
482 | - '07' => __( 'July', 'invoicing' ), |
|
483 | - '08' => __( 'August', 'invoicing' ), |
|
484 | - '09' => __( 'September', 'invoicing' ), |
|
485 | - '10' => __( 'October', 'invoicing' ), |
|
486 | - '11' => __( 'November', 'invoicing' ), |
|
487 | - '12' => __( 'December', 'invoicing' ), |
|
476 | + '01' => __('January', 'invoicing'), |
|
477 | + '02' => __('February', 'invoicing'), |
|
478 | + '03' => __('March', 'invoicing'), |
|
479 | + '04' => __('April', 'invoicing'), |
|
480 | + '05' => __('May', 'invoicing'), |
|
481 | + '06' => __('June', 'invoicing'), |
|
482 | + '07' => __('July', 'invoicing'), |
|
483 | + '08' => __('August', 'invoicing'), |
|
484 | + '09' => __('September', 'invoicing'), |
|
485 | + '10' => __('October', 'invoicing'), |
|
486 | + '11' => __('November', 'invoicing'), |
|
487 | + '12' => __('December', 'invoicing'), |
|
488 | 488 | ); |
489 | 489 | |
490 | - $year = (int) date( 'Y', current_time( 'timestamp' ) ); |
|
490 | + $year = (int) date('Y', current_time('timestamp')); |
|
491 | 491 | $years = array(); |
492 | 492 | |
493 | - for ( $i = 0; $i <= 10; $i++ ) { |
|
494 | - $years[ $year + $i ] = $year + $i; |
|
493 | + for ($i = 0; $i <= 10; $i++) { |
|
494 | + $years[$year + $i] = $year + $i; |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | ?> |
498 | - <div class="<?php echo esc_attr( $this->id ); ?>-cc-form getpaid-cc-form mt-1"> |
|
498 | + <div class="<?php echo esc_attr($this->id); ?>-cc-form getpaid-cc-form mt-1"> |
|
499 | 499 | |
500 | 500 | |
501 | 501 | <div class="getpaid-cc-card-inner"> |
@@ -504,14 +504,14 @@ discard block |
||
504 | 504 | <div class="col-12"> |
505 | 505 | |
506 | 506 | <div class="form-group"> |
507 | - <label for="<?php echo esc_attr( "$id_prefix-cc-number" ); ?>"><?php esc_html_e( 'Card number', 'invoicing' ); ?></label> |
|
507 | + <label for="<?php echo esc_attr("$id_prefix-cc-number"); ?>"><?php esc_html_e('Card number', 'invoicing'); ?></label> |
|
508 | 508 | <div class="input-group input-group-sm"> |
509 | 509 | <div class="input-group-prepend "> |
510 | 510 | <span class="input-group-text"> |
511 | 511 | <i class="fa fa-credit-card"></i> |
512 | 512 | </span> |
513 | 513 | </div> |
514 | - <input type="text" name="<?php echo esc_attr( $this->id . '[cc_number]' ); ?>" id="<?php echo esc_attr( "$id_prefix-cc-number" ); ?>" class="form-control form-control-sm" autocomplete="cc-number"> |
|
514 | + <input type="text" name="<?php echo esc_attr($this->id . '[cc_number]'); ?>" id="<?php echo esc_attr("$id_prefix-cc-number"); ?>" class="form-control form-control-sm" autocomplete="cc-number"> |
|
515 | 515 | </div> |
516 | 516 | </div> |
517 | 517 | |
@@ -519,17 +519,17 @@ discard block |
||
519 | 519 | |
520 | 520 | <div class="col-12"> |
521 | 521 | <div class="form-group"> |
522 | - <label><?php esc_html_e( 'Expiration', 'invoicing' ); ?></label> |
|
522 | + <label><?php esc_html_e('Expiration', 'invoicing'); ?></label> |
|
523 | 523 | <div class="form-row"> |
524 | 524 | |
525 | 525 | <div class="col"> |
526 | - <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr( $this->id ); ?>[cc_expire_month]"> |
|
527 | - <option disabled selected="selected"><?php esc_html_e( 'MM', 'invoicing' ); ?></option> |
|
526 | + <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr($this->id); ?>[cc_expire_month]"> |
|
527 | + <option disabled selected="selected"><?php esc_html_e('MM', 'invoicing'); ?></option> |
|
528 | 528 | |
529 | 529 | <?php |
530 | - foreach ( $months as $key => $month ) { |
|
531 | - $key = esc_attr( $key ); |
|
532 | - $month = esc_html( $month ); |
|
530 | + foreach ($months as $key => $month) { |
|
531 | + $key = esc_attr($key); |
|
532 | + $month = esc_html($month); |
|
533 | 533 | echo "<option value='$key'>$month</option>" . PHP_EOL; |
534 | 534 | } |
535 | 535 | ?> |
@@ -538,13 +538,13 @@ discard block |
||
538 | 538 | </div> |
539 | 539 | |
540 | 540 | <div class="col"> |
541 | - <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr( $this->id ); ?>[cc_expire_year]"> |
|
542 | - <option disabled selected="selected"><?php esc_html_e( 'YY', 'invoicing' ); ?></option> |
|
541 | + <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr($this->id); ?>[cc_expire_year]"> |
|
542 | + <option disabled selected="selected"><?php esc_html_e('YY', 'invoicing'); ?></option> |
|
543 | 543 | |
544 | 544 | <?php |
545 | - foreach ( $years as $key => $year ) { |
|
546 | - $key = esc_attr( $key ); |
|
547 | - $year = esc_html( $year ); |
|
545 | + foreach ($years as $key => $year) { |
|
546 | + $key = esc_attr($key); |
|
547 | + $year = esc_html($year); |
|
548 | 548 | echo "<option value='$key'>$year</option>" . PHP_EOL; |
549 | 549 | } |
550 | 550 | ?> |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | array( |
563 | 563 | 'name' => $this->id . '[cc_cvv2]', |
564 | 564 | 'id' => "$id_prefix-cc-cvv2", |
565 | - 'label' => __( 'CCV', 'invoicing' ), |
|
565 | + 'label' => __('CCV', 'invoicing'), |
|
566 | 566 | 'label_type' => 'vertical', |
567 | 567 | 'class' => 'form-control-sm', |
568 | 568 | 'extra_attributes' => array( |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | |
578 | 578 | <?php |
579 | 579 | |
580 | - if ( $save ) { |
|
580 | + if ($save) { |
|
581 | 581 | echo $this->save_payment_method_checkbox(); |
582 | 582 | } |
583 | 583 | |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | * |
597 | 597 | * @since 1.0.19 |
598 | 598 | */ |
599 | - public function new_payment_method_entry( $form ) { |
|
599 | + public function new_payment_method_entry($form) { |
|
600 | 600 | echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
601 | 601 | } |
602 | 602 | |
@@ -606,16 +606,16 @@ discard block |
||
606 | 606 | * @since 1.0.19 |
607 | 607 | */ |
608 | 608 | public function saved_payment_methods() { |
609 | - $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
609 | + $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr(count($this->get_tokens($this->is_sandbox()))) . '">'; |
|
610 | 610 | |
611 | - foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
612 | - $html .= $this->get_saved_payment_method_option_html( $token ); |
|
611 | + foreach ($this->get_tokens($this->is_sandbox()) as $token) { |
|
612 | + $html .= $this->get_saved_payment_method_option_html($token); |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | $html .= $this->get_new_payment_method_option_html(); |
616 | 616 | $html .= '</ul>'; |
617 | 617 | |
618 | - echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
618 | + echo apply_filters('getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | /** |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | * @param array $token Payment Token. |
626 | 626 | * @return string Generated payment method HTML |
627 | 627 | */ |
628 | - public function get_saved_payment_method_option_html( $token ) { |
|
628 | + public function get_saved_payment_method_option_html($token) { |
|
629 | 629 | |
630 | 630 | return sprintf( |
631 | 631 | '<li class="getpaid-payment-method form-group"> |
@@ -634,11 +634,11 @@ discard block |
||
634 | 634 | <span>%3$s</span> |
635 | 635 | </label> |
636 | 636 | </li>', |
637 | - esc_attr( $this->id ), |
|
638 | - esc_attr( $token['id'] ), |
|
639 | - esc_html( $token['name'] ), |
|
640 | - checked( empty( $token['default'] ), false, false ), |
|
641 | - empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
637 | + esc_attr($this->id), |
|
638 | + esc_attr($token['id']), |
|
639 | + esc_html($token['name']), |
|
640 | + checked(empty($token['default']), false, false), |
|
641 | + empty($token['currency']) ? 'none' : esc_attr($token['currency']) |
|
642 | 642 | ); |
643 | 643 | |
644 | 644 | } |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | */ |
651 | 651 | public function get_new_payment_method_option_html() { |
652 | 652 | |
653 | - $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
653 | + $label = apply_filters('getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __('Use a new payment method', 'invoicing'), $this); |
|
654 | 654 | |
655 | 655 | return sprintf( |
656 | 656 | '<li class="getpaid-new-payment-method"> |
@@ -659,8 +659,8 @@ discard block |
||
659 | 659 | <span>%2$s</span> |
660 | 660 | </label> |
661 | 661 | </li>', |
662 | - esc_attr( $this->id ), |
|
663 | - esc_html( $label ) |
|
662 | + esc_attr($this->id), |
|
663 | + esc_html($label) |
|
664 | 664 | ); |
665 | 665 | |
666 | 666 | } |
@@ -675,10 +675,10 @@ discard block |
||
675 | 675 | return aui()->input( |
676 | 676 | array( |
677 | 677 | 'type' => 'checkbox', |
678 | - 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
679 | - 'id' => esc_attr( uniqid( $this->id ) ), |
|
678 | + 'name' => esc_attr("getpaid-$this->id-new-payment-method"), |
|
679 | + 'id' => esc_attr(uniqid($this->id)), |
|
680 | 680 | 'required' => false, |
681 | - 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
681 | + 'label' => esc_html__('Save payment method', 'invoicing'), |
|
682 | 682 | 'value' => 'true', |
683 | 683 | 'checked' => true, |
684 | 684 | 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
@@ -692,9 +692,9 @@ discard block |
||
692 | 692 | * |
693 | 693 | * @return array |
694 | 694 | */ |
695 | - public function register_gateway( $gateways ) { |
|
695 | + public function register_gateway($gateways) { |
|
696 | 696 | |
697 | - $gateways[ $this->id ] = array( |
|
697 | + $gateways[$this->id] = array( |
|
698 | 698 | |
699 | 699 | 'admin_label' => $this->method_title, |
700 | 700 | 'checkout_label' => $this->title, |
@@ -712,13 +712,13 @@ discard block |
||
712 | 712 | * @param WPInv_Invoice|null $invoice Invoice object or null. |
713 | 713 | * @return bool |
714 | 714 | */ |
715 | - public function is_sandbox( $invoice = null ) { |
|
715 | + public function is_sandbox($invoice = null) { |
|
716 | 716 | |
717 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
717 | + if (!empty($invoice) && !$invoice->needs_payment()) { |
|
718 | 718 | return $invoice->get_mode() == 'test'; |
719 | 719 | } |
720 | 720 | |
721 | - return wpinv_is_test_mode( $this->id ); |
|
721 | + return wpinv_is_test_mode($this->id); |
|
722 | 722 | |
723 | 723 | } |
724 | 724 | |
@@ -736,15 +736,15 @@ discard block |
||
736 | 736 | * |
737 | 737 | * @return bool |
738 | 738 | */ |
739 | - public function validate_currency( $validation, $currency ) { |
|
739 | + public function validate_currency($validation, $currency) { |
|
740 | 740 | |
741 | 741 | // Required currencies. |
742 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
742 | + if (!empty($this->currencies) && !in_array($currency, $this->currencies)) { |
|
743 | 743 | return false; |
744 | 744 | } |
745 | 745 | |
746 | 746 | // Excluded currencies. |
747 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
747 | + if (!empty($this->exclude_currencies) && in_array($currency, $this->exclude_currencies)) { |
|
748 | 748 | return false; |
749 | 749 | } |
750 | 750 | |
@@ -755,13 +755,13 @@ discard block |
||
755 | 755 | * Displays an error |
756 | 756 | * |
757 | 757 | */ |
758 | - public function show_error( $code, $message, $type ) { |
|
758 | + public function show_error($code, $message, $type) { |
|
759 | 759 | |
760 | - if ( is_admin() ) { |
|
761 | - getpaid_admin()->{"show_$type"}( $message ); |
|
760 | + if (is_admin()) { |
|
761 | + getpaid_admin()->{"show_$type"}($message); |
|
762 | 762 | } |
763 | 763 | |
764 | - wpinv_set_error( $code, $message, $type ); |
|
764 | + wpinv_set_error($code, $message, $type); |
|
765 | 765 | |
766 | 766 | } |
767 | 767 |
@@ -13,462 +13,462 @@ discard block |
||
13 | 13 | */ |
14 | 14 | abstract class GetPaid_Payment_Gateway { |
15 | 15 | |
16 | - /** |
|
17 | - * Set if the place checkout button should be renamed on selection. |
|
18 | - * |
|
19 | - * @var string |
|
20 | - */ |
|
21 | - public $checkout_button_text; |
|
22 | - |
|
23 | - /** |
|
24 | - * Boolean whether the method is enabled. |
|
25 | - * |
|
26 | - * @var bool |
|
27 | - */ |
|
28 | - public $enabled = true; |
|
29 | - |
|
30 | - /** |
|
31 | - * Payment method id. |
|
32 | - * |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - public $id; |
|
36 | - |
|
37 | - /** |
|
38 | - * Payment method order. |
|
39 | - * |
|
40 | - * @var int |
|
41 | - */ |
|
42 | - public $order = 10; |
|
43 | - |
|
44 | - /** |
|
45 | - * Payment method title for the frontend. |
|
46 | - * |
|
47 | - * @var string |
|
48 | - */ |
|
49 | - public $title; |
|
50 | - |
|
51 | - /** |
|
52 | - * Payment method description for the frontend. |
|
53 | - * |
|
54 | - * @var string |
|
55 | - */ |
|
56 | - public $description; |
|
57 | - |
|
58 | - /** |
|
59 | - * Gateway title. |
|
60 | - * |
|
61 | - * @var string |
|
62 | - */ |
|
63 | - public $method_title = ''; |
|
64 | - |
|
65 | - /** |
|
66 | - * Gateway description. |
|
67 | - * |
|
68 | - * @var string |
|
69 | - */ |
|
70 | - public $method_description = ''; |
|
71 | - |
|
72 | - /** |
|
73 | - * Countries this gateway is allowed for. |
|
74 | - * |
|
75 | - * @var array |
|
76 | - */ |
|
77 | - public $countries; |
|
78 | - |
|
79 | - /** |
|
80 | - * Currencies this gateway is allowed for. |
|
81 | - * |
|
82 | - * @var array |
|
83 | - */ |
|
84 | - public $currencies; |
|
85 | - |
|
86 | - /** |
|
87 | - * Currencies this gateway is not allowed for. |
|
88 | - * |
|
89 | - * @var array |
|
90 | - */ |
|
91 | - public $exclude_currencies; |
|
92 | - |
|
93 | - /** |
|
94 | - * Maximum transaction amount, zero does not define a maximum. |
|
95 | - * |
|
96 | - * @var int |
|
97 | - */ |
|
98 | - public $max_amount = 0; |
|
99 | - |
|
100 | - /** |
|
101 | - * Optional URL to view a transaction. |
|
102 | - * |
|
103 | - * @var string |
|
104 | - */ |
|
105 | - public $view_transaction_url = ''; |
|
106 | - |
|
107 | - /** |
|
108 | - * Optional URL to view a subscription. |
|
109 | - * |
|
110 | - * @var string |
|
111 | - */ |
|
112 | - public $view_subscription_url = ''; |
|
113 | - |
|
114 | - /** |
|
115 | - * Optional label to show for "new payment method" in the payment |
|
116 | - * method/token selection radio selection. |
|
117 | - * |
|
118 | - * @var string |
|
119 | - */ |
|
120 | - public $new_method_label = ''; |
|
121 | - |
|
122 | - /** |
|
123 | - * Contains a user's saved tokens for this gateway. |
|
124 | - * |
|
125 | - * @var array |
|
126 | - */ |
|
127 | - protected $tokens = array(); |
|
128 | - |
|
129 | - /** |
|
130 | - * An array of features that this gateway supports. |
|
131 | - * |
|
132 | - * @var array |
|
133 | - */ |
|
134 | - protected $supports = array(); |
|
135 | - |
|
136 | - /** |
|
137 | - * Class constructor. |
|
138 | - */ |
|
139 | - public function __construct() { |
|
140 | - |
|
141 | - // Register gateway. |
|
142 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
143 | - |
|
144 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
145 | - |
|
146 | - // Add support for various features. |
|
147 | - foreach ( $this->supports as $feature ) { |
|
148 | - add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' ); |
|
149 | - add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' ); |
|
150 | - add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
151 | - } |
|
152 | - |
|
153 | - // Invoice addons. |
|
154 | - if ( $this->supports( 'addons' ) ) { |
|
155 | - add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
156 | - } |
|
157 | - |
|
158 | - // Gateway settings. |
|
159 | - add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
160 | - |
|
161 | - // Gateway checkout fiellds. |
|
162 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
163 | - |
|
164 | - // Process payment. |
|
165 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
166 | - |
|
167 | - // Change the checkout button text. |
|
168 | - if ( ! empty( $this->checkout_button_text ) ) { |
|
169 | - add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
170 | - } |
|
171 | - |
|
172 | - // Check if a gateway is valid for a given currency. |
|
173 | - add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
174 | - |
|
175 | - // Generate the transaction url. |
|
176 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
177 | - |
|
178 | - // Generate the subscription url. |
|
179 | - add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
180 | - |
|
181 | - // Confirm payments. |
|
182 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
183 | - |
|
184 | - // Verify IPNs. |
|
185 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
186 | - |
|
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * Checks if this gateway is a given gateway. |
|
191 | - * |
|
192 | - * @since 1.0.19 |
|
193 | - * @return bool |
|
194 | - */ |
|
195 | - public function is( $gateway ) { |
|
196 | - return $gateway == $this->id; |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * Returns a users saved tokens for this gateway. |
|
201 | - * |
|
202 | - * @since 1.0.19 |
|
203 | - * @return array |
|
204 | - */ |
|
205 | - public function get_tokens( $sandbox = null ) { |
|
206 | - |
|
207 | - if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
208 | - $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
209 | - |
|
210 | - if ( is_array( $tokens ) ) { |
|
211 | - $this->tokens = $tokens; |
|
212 | - } |
|
16 | + /** |
|
17 | + * Set if the place checkout button should be renamed on selection. |
|
18 | + * |
|
19 | + * @var string |
|
20 | + */ |
|
21 | + public $checkout_button_text; |
|
22 | + |
|
23 | + /** |
|
24 | + * Boolean whether the method is enabled. |
|
25 | + * |
|
26 | + * @var bool |
|
27 | + */ |
|
28 | + public $enabled = true; |
|
29 | + |
|
30 | + /** |
|
31 | + * Payment method id. |
|
32 | + * |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + public $id; |
|
36 | + |
|
37 | + /** |
|
38 | + * Payment method order. |
|
39 | + * |
|
40 | + * @var int |
|
41 | + */ |
|
42 | + public $order = 10; |
|
43 | + |
|
44 | + /** |
|
45 | + * Payment method title for the frontend. |
|
46 | + * |
|
47 | + * @var string |
|
48 | + */ |
|
49 | + public $title; |
|
50 | + |
|
51 | + /** |
|
52 | + * Payment method description for the frontend. |
|
53 | + * |
|
54 | + * @var string |
|
55 | + */ |
|
56 | + public $description; |
|
57 | + |
|
58 | + /** |
|
59 | + * Gateway title. |
|
60 | + * |
|
61 | + * @var string |
|
62 | + */ |
|
63 | + public $method_title = ''; |
|
64 | + |
|
65 | + /** |
|
66 | + * Gateway description. |
|
67 | + * |
|
68 | + * @var string |
|
69 | + */ |
|
70 | + public $method_description = ''; |
|
71 | + |
|
72 | + /** |
|
73 | + * Countries this gateway is allowed for. |
|
74 | + * |
|
75 | + * @var array |
|
76 | + */ |
|
77 | + public $countries; |
|
78 | + |
|
79 | + /** |
|
80 | + * Currencies this gateway is allowed for. |
|
81 | + * |
|
82 | + * @var array |
|
83 | + */ |
|
84 | + public $currencies; |
|
85 | + |
|
86 | + /** |
|
87 | + * Currencies this gateway is not allowed for. |
|
88 | + * |
|
89 | + * @var array |
|
90 | + */ |
|
91 | + public $exclude_currencies; |
|
92 | + |
|
93 | + /** |
|
94 | + * Maximum transaction amount, zero does not define a maximum. |
|
95 | + * |
|
96 | + * @var int |
|
97 | + */ |
|
98 | + public $max_amount = 0; |
|
99 | + |
|
100 | + /** |
|
101 | + * Optional URL to view a transaction. |
|
102 | + * |
|
103 | + * @var string |
|
104 | + */ |
|
105 | + public $view_transaction_url = ''; |
|
106 | + |
|
107 | + /** |
|
108 | + * Optional URL to view a subscription. |
|
109 | + * |
|
110 | + * @var string |
|
111 | + */ |
|
112 | + public $view_subscription_url = ''; |
|
113 | + |
|
114 | + /** |
|
115 | + * Optional label to show for "new payment method" in the payment |
|
116 | + * method/token selection radio selection. |
|
117 | + * |
|
118 | + * @var string |
|
119 | + */ |
|
120 | + public $new_method_label = ''; |
|
121 | + |
|
122 | + /** |
|
123 | + * Contains a user's saved tokens for this gateway. |
|
124 | + * |
|
125 | + * @var array |
|
126 | + */ |
|
127 | + protected $tokens = array(); |
|
128 | + |
|
129 | + /** |
|
130 | + * An array of features that this gateway supports. |
|
131 | + * |
|
132 | + * @var array |
|
133 | + */ |
|
134 | + protected $supports = array(); |
|
135 | + |
|
136 | + /** |
|
137 | + * Class constructor. |
|
138 | + */ |
|
139 | + public function __construct() { |
|
140 | + |
|
141 | + // Register gateway. |
|
142 | + add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
143 | + |
|
144 | + $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
145 | + |
|
146 | + // Add support for various features. |
|
147 | + foreach ( $this->supports as $feature ) { |
|
148 | + add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' ); |
|
149 | + add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' ); |
|
150 | + add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
151 | + } |
|
152 | + |
|
153 | + // Invoice addons. |
|
154 | + if ( $this->supports( 'addons' ) ) { |
|
155 | + add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
156 | + } |
|
157 | + |
|
158 | + // Gateway settings. |
|
159 | + add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
160 | + |
|
161 | + // Gateway checkout fiellds. |
|
162 | + add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
163 | + |
|
164 | + // Process payment. |
|
165 | + add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
166 | + |
|
167 | + // Change the checkout button text. |
|
168 | + if ( ! empty( $this->checkout_button_text ) ) { |
|
169 | + add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
170 | + } |
|
171 | + |
|
172 | + // Check if a gateway is valid for a given currency. |
|
173 | + add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
174 | + |
|
175 | + // Generate the transaction url. |
|
176 | + add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
177 | + |
|
178 | + // Generate the subscription url. |
|
179 | + add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
180 | + |
|
181 | + // Confirm payments. |
|
182 | + add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
183 | + |
|
184 | + // Verify IPNs. |
|
185 | + add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
186 | + |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * Checks if this gateway is a given gateway. |
|
191 | + * |
|
192 | + * @since 1.0.19 |
|
193 | + * @return bool |
|
194 | + */ |
|
195 | + public function is( $gateway ) { |
|
196 | + return $gateway == $this->id; |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * Returns a users saved tokens for this gateway. |
|
201 | + * |
|
202 | + * @since 1.0.19 |
|
203 | + * @return array |
|
204 | + */ |
|
205 | + public function get_tokens( $sandbox = null ) { |
|
206 | + |
|
207 | + if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
208 | + $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
209 | + |
|
210 | + if ( is_array( $tokens ) ) { |
|
211 | + $this->tokens = $tokens; |
|
212 | + } |
|
213 | 213 | } |
214 | 214 | |
215 | - if ( ! is_bool( $sandbox ) ) { |
|
216 | - return $this->tokens; |
|
217 | - } |
|
218 | - |
|
219 | - // Filter tokens. |
|
220 | - $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
221 | - return wp_list_filter( $this->tokens, $args ); |
|
222 | - |
|
223 | - } |
|
224 | - |
|
225 | - /** |
|
226 | - * Saves a token for this gateway. |
|
227 | - * |
|
228 | - * @since 1.0.19 |
|
229 | - */ |
|
230 | - public function save_token( $token ) { |
|
231 | - |
|
232 | - $tokens = $this->get_tokens(); |
|
233 | - $tokens[] = $token; |
|
234 | - |
|
235 | - update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
236 | - |
|
237 | - $this->tokens = $tokens; |
|
238 | - |
|
239 | - } |
|
240 | - |
|
241 | - /** |
|
242 | - * Return the title for admin screens. |
|
243 | - * |
|
244 | - * @return string |
|
245 | - */ |
|
246 | - public function get_method_title() { |
|
247 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
248 | - } |
|
249 | - |
|
250 | - /** |
|
251 | - * Return the description for admin screens. |
|
252 | - * |
|
253 | - * @return string |
|
254 | - */ |
|
255 | - public function get_method_description() { |
|
256 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * Get the success url. |
|
261 | - * |
|
262 | - * @param WPInv_Invoice $invoice Invoice object. |
|
263 | - * @return string |
|
264 | - */ |
|
265 | - public function get_return_url( $invoice ) { |
|
266 | - |
|
267 | - // Payment success url |
|
268 | - $return_url = add_query_arg( |
|
269 | - array( |
|
270 | - 'payment-confirm' => $this->id, |
|
271 | - 'invoice_key' => $invoice->get_key(), |
|
272 | - 'utm_nooverride' => 1, |
|
273 | - ), |
|
274 | - wpinv_get_success_page_uri() |
|
275 | - ); |
|
276 | - |
|
277 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
278 | - } |
|
279 | - |
|
280 | - /** |
|
281 | - * Confirms payments when rendering the success page. |
|
282 | - * |
|
283 | - * @param string $content Success page content. |
|
284 | - * @return string |
|
285 | - */ |
|
286 | - public function confirm_payment( $content ) { |
|
287 | - |
|
288 | - // Retrieve the invoice. |
|
289 | - $invoice_id = getpaid_get_current_invoice_id(); |
|
290 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
291 | - |
|
292 | - // Ensure that it exists and that it is pending payment. |
|
293 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
294 | - return $content; |
|
295 | - } |
|
296 | - |
|
297 | - // Can the user view this invoice?? |
|
298 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
299 | - return $content; |
|
300 | - } |
|
301 | - |
|
302 | - // Show payment processing indicator. |
|
303 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
304 | - } |
|
305 | - |
|
306 | - /** |
|
307 | - * Processes ipns and marks payments as complete. |
|
308 | - * |
|
309 | - * @return void |
|
310 | - */ |
|
311 | - public function verify_ipn() {} |
|
312 | - |
|
313 | - /** |
|
314 | - * Processes invoice addons. |
|
315 | - * |
|
316 | - * @param WPInv_Invoice $invoice |
|
317 | - * @param GetPaid_Form_Item[] $items |
|
318 | - * @return WPInv_Invoice |
|
319 | - */ |
|
320 | - public function process_addons( $invoice, $items ) { |
|
321 | - |
|
322 | - } |
|
323 | - |
|
324 | - /** |
|
325 | - * Get a link to the transaction on the 3rd party gateway site (if applicable). |
|
326 | - * |
|
327 | - * @param string $transaction_url transaction url. |
|
328 | - * @param WPInv_Invoice $invoice Invoice object. |
|
329 | - * @return string transaction URL, or empty string. |
|
330 | - */ |
|
331 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
332 | - |
|
333 | - $transaction_id = $invoice->get_transaction_id(); |
|
334 | - |
|
335 | - if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
336 | - $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
337 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
338 | - $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
339 | - } |
|
340 | - |
|
341 | - return $transaction_url; |
|
342 | - } |
|
343 | - |
|
344 | - /** |
|
345 | - * Get a link to the subscription on the 3rd party gateway site (if applicable). |
|
346 | - * |
|
347 | - * @param string $subscription_url transaction url. |
|
348 | - * @param WPInv_Subscription $subscription Subscription objectt. |
|
349 | - * @return string subscription URL, or empty string. |
|
350 | - */ |
|
351 | - public function generate_subscription_url( $subscription_url, $subscription ) { |
|
352 | - |
|
353 | - $profile_id = $subscription->get_profile_id(); |
|
354 | - |
|
355 | - if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
356 | - |
|
357 | - $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
358 | - $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
359 | - $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
360 | - |
|
361 | - } |
|
362 | - |
|
363 | - return $subscription_url; |
|
364 | - } |
|
365 | - |
|
366 | - /** |
|
367 | - * Check if the gateway is available for use. |
|
368 | - * |
|
369 | - * @return bool |
|
370 | - */ |
|
371 | - public function is_available() { |
|
372 | - return ! empty( $this->enabled ); |
|
373 | - } |
|
374 | - |
|
375 | - /** |
|
376 | - * Return the gateway's title. |
|
377 | - * |
|
378 | - * @return string |
|
379 | - */ |
|
380 | - public function get_title() { |
|
381 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
382 | - } |
|
383 | - |
|
384 | - /** |
|
385 | - * Return the gateway's description. |
|
386 | - * |
|
387 | - * @return string |
|
388 | - */ |
|
389 | - public function get_description() { |
|
390 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
391 | - } |
|
392 | - |
|
393 | - /** |
|
394 | - * Process Payment. |
|
395 | - * |
|
396 | - * |
|
397 | - * @param WPInv_Invoice $invoice Invoice. |
|
398 | - * @param array $submission_data Posted checkout fields. |
|
399 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
400 | - * @return void |
|
401 | - */ |
|
402 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
403 | - // Process the payment then either redirect to the success page or the gateway. |
|
404 | - do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
405 | - } |
|
406 | - |
|
407 | - /** |
|
408 | - * Process refund. |
|
409 | - * |
|
410 | - * If the gateway declares 'refunds' support, this will allow it to refund. |
|
411 | - * a passed in amount. |
|
412 | - * |
|
413 | - * @param WPInv_Invoice $invoice Invoice. |
|
414 | - * @param float $amount Refund amount. |
|
415 | - * @param string $reason Refund reason. |
|
416 | - * @return WP_Error|bool True or false based on success, or a WP_Error object. |
|
417 | - */ |
|
418 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
419 | - return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
420 | - } |
|
421 | - |
|
422 | - /** |
|
423 | - * Displays the payment fields, credit cards etc. |
|
424 | - * |
|
425 | - * @param int $invoice_id 0 or invoice id. |
|
426 | - * @param GetPaid_Payment_Form $form Current payment form. |
|
427 | - */ |
|
428 | - public function payment_fields( $invoice_id, $form ) { |
|
429 | - do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
430 | - } |
|
431 | - |
|
432 | - /** |
|
433 | - * Filters the gateway settings. |
|
434 | - * |
|
435 | - * @param array $admin_settings |
|
436 | - */ |
|
437 | - public function admin_settings( $admin_settings ) { |
|
438 | - return $admin_settings; |
|
439 | - } |
|
440 | - |
|
441 | - /** |
|
442 | - * Retrieves the value of a gateway setting. |
|
443 | - * |
|
444 | - * @param string $option |
|
445 | - */ |
|
446 | - public function get_option( $option, $default = false ) { |
|
447 | - return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
448 | - } |
|
449 | - |
|
450 | - /** |
|
451 | - * Check if a gateway supports a given feature. |
|
452 | - * |
|
453 | - * Gateways should override this to declare support (or lack of support) for a feature. |
|
454 | - * For backward compatibility, gateways support 'products' by default, but nothing else. |
|
455 | - * |
|
456 | - * @param string $feature string The name of a feature to test support for. |
|
457 | - * @return bool True if the gateway supports the feature, false otherwise. |
|
458 | - * @since 1.0.19 |
|
459 | - */ |
|
460 | - public function supports( $feature ) { |
|
461 | - return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
462 | - } |
|
463 | - |
|
464 | - /** |
|
465 | - * Returns the credit card form html. |
|
466 | - * |
|
467 | - * @param bool $save whether or not to display the save button. |
|
468 | - */ |
|
215 | + if ( ! is_bool( $sandbox ) ) { |
|
216 | + return $this->tokens; |
|
217 | + } |
|
218 | + |
|
219 | + // Filter tokens. |
|
220 | + $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
221 | + return wp_list_filter( $this->tokens, $args ); |
|
222 | + |
|
223 | + } |
|
224 | + |
|
225 | + /** |
|
226 | + * Saves a token for this gateway. |
|
227 | + * |
|
228 | + * @since 1.0.19 |
|
229 | + */ |
|
230 | + public function save_token( $token ) { |
|
231 | + |
|
232 | + $tokens = $this->get_tokens(); |
|
233 | + $tokens[] = $token; |
|
234 | + |
|
235 | + update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
236 | + |
|
237 | + $this->tokens = $tokens; |
|
238 | + |
|
239 | + } |
|
240 | + |
|
241 | + /** |
|
242 | + * Return the title for admin screens. |
|
243 | + * |
|
244 | + * @return string |
|
245 | + */ |
|
246 | + public function get_method_title() { |
|
247 | + return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
248 | + } |
|
249 | + |
|
250 | + /** |
|
251 | + * Return the description for admin screens. |
|
252 | + * |
|
253 | + * @return string |
|
254 | + */ |
|
255 | + public function get_method_description() { |
|
256 | + return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * Get the success url. |
|
261 | + * |
|
262 | + * @param WPInv_Invoice $invoice Invoice object. |
|
263 | + * @return string |
|
264 | + */ |
|
265 | + public function get_return_url( $invoice ) { |
|
266 | + |
|
267 | + // Payment success url |
|
268 | + $return_url = add_query_arg( |
|
269 | + array( |
|
270 | + 'payment-confirm' => $this->id, |
|
271 | + 'invoice_key' => $invoice->get_key(), |
|
272 | + 'utm_nooverride' => 1, |
|
273 | + ), |
|
274 | + wpinv_get_success_page_uri() |
|
275 | + ); |
|
276 | + |
|
277 | + return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
278 | + } |
|
279 | + |
|
280 | + /** |
|
281 | + * Confirms payments when rendering the success page. |
|
282 | + * |
|
283 | + * @param string $content Success page content. |
|
284 | + * @return string |
|
285 | + */ |
|
286 | + public function confirm_payment( $content ) { |
|
287 | + |
|
288 | + // Retrieve the invoice. |
|
289 | + $invoice_id = getpaid_get_current_invoice_id(); |
|
290 | + $invoice = wpinv_get_invoice( $invoice_id ); |
|
291 | + |
|
292 | + // Ensure that it exists and that it is pending payment. |
|
293 | + if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
294 | + return $content; |
|
295 | + } |
|
296 | + |
|
297 | + // Can the user view this invoice?? |
|
298 | + if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
299 | + return $content; |
|
300 | + } |
|
301 | + |
|
302 | + // Show payment processing indicator. |
|
303 | + return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
304 | + } |
|
305 | + |
|
306 | + /** |
|
307 | + * Processes ipns and marks payments as complete. |
|
308 | + * |
|
309 | + * @return void |
|
310 | + */ |
|
311 | + public function verify_ipn() {} |
|
312 | + |
|
313 | + /** |
|
314 | + * Processes invoice addons. |
|
315 | + * |
|
316 | + * @param WPInv_Invoice $invoice |
|
317 | + * @param GetPaid_Form_Item[] $items |
|
318 | + * @return WPInv_Invoice |
|
319 | + */ |
|
320 | + public function process_addons( $invoice, $items ) { |
|
321 | + |
|
322 | + } |
|
323 | + |
|
324 | + /** |
|
325 | + * Get a link to the transaction on the 3rd party gateway site (if applicable). |
|
326 | + * |
|
327 | + * @param string $transaction_url transaction url. |
|
328 | + * @param WPInv_Invoice $invoice Invoice object. |
|
329 | + * @return string transaction URL, or empty string. |
|
330 | + */ |
|
331 | + public function filter_transaction_url( $transaction_url, $invoice ) { |
|
332 | + |
|
333 | + $transaction_id = $invoice->get_transaction_id(); |
|
334 | + |
|
335 | + if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
336 | + $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
337 | + $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
338 | + $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
339 | + } |
|
340 | + |
|
341 | + return $transaction_url; |
|
342 | + } |
|
343 | + |
|
344 | + /** |
|
345 | + * Get a link to the subscription on the 3rd party gateway site (if applicable). |
|
346 | + * |
|
347 | + * @param string $subscription_url transaction url. |
|
348 | + * @param WPInv_Subscription $subscription Subscription objectt. |
|
349 | + * @return string subscription URL, or empty string. |
|
350 | + */ |
|
351 | + public function generate_subscription_url( $subscription_url, $subscription ) { |
|
352 | + |
|
353 | + $profile_id = $subscription->get_profile_id(); |
|
354 | + |
|
355 | + if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
356 | + |
|
357 | + $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
358 | + $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
359 | + $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
360 | + |
|
361 | + } |
|
362 | + |
|
363 | + return $subscription_url; |
|
364 | + } |
|
365 | + |
|
366 | + /** |
|
367 | + * Check if the gateway is available for use. |
|
368 | + * |
|
369 | + * @return bool |
|
370 | + */ |
|
371 | + public function is_available() { |
|
372 | + return ! empty( $this->enabled ); |
|
373 | + } |
|
374 | + |
|
375 | + /** |
|
376 | + * Return the gateway's title. |
|
377 | + * |
|
378 | + * @return string |
|
379 | + */ |
|
380 | + public function get_title() { |
|
381 | + return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
382 | + } |
|
383 | + |
|
384 | + /** |
|
385 | + * Return the gateway's description. |
|
386 | + * |
|
387 | + * @return string |
|
388 | + */ |
|
389 | + public function get_description() { |
|
390 | + return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
391 | + } |
|
392 | + |
|
393 | + /** |
|
394 | + * Process Payment. |
|
395 | + * |
|
396 | + * |
|
397 | + * @param WPInv_Invoice $invoice Invoice. |
|
398 | + * @param array $submission_data Posted checkout fields. |
|
399 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
400 | + * @return void |
|
401 | + */ |
|
402 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
403 | + // Process the payment then either redirect to the success page or the gateway. |
|
404 | + do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
405 | + } |
|
406 | + |
|
407 | + /** |
|
408 | + * Process refund. |
|
409 | + * |
|
410 | + * If the gateway declares 'refunds' support, this will allow it to refund. |
|
411 | + * a passed in amount. |
|
412 | + * |
|
413 | + * @param WPInv_Invoice $invoice Invoice. |
|
414 | + * @param float $amount Refund amount. |
|
415 | + * @param string $reason Refund reason. |
|
416 | + * @return WP_Error|bool True or false based on success, or a WP_Error object. |
|
417 | + */ |
|
418 | + public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
419 | + return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
420 | + } |
|
421 | + |
|
422 | + /** |
|
423 | + * Displays the payment fields, credit cards etc. |
|
424 | + * |
|
425 | + * @param int $invoice_id 0 or invoice id. |
|
426 | + * @param GetPaid_Payment_Form $form Current payment form. |
|
427 | + */ |
|
428 | + public function payment_fields( $invoice_id, $form ) { |
|
429 | + do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
430 | + } |
|
431 | + |
|
432 | + /** |
|
433 | + * Filters the gateway settings. |
|
434 | + * |
|
435 | + * @param array $admin_settings |
|
436 | + */ |
|
437 | + public function admin_settings( $admin_settings ) { |
|
438 | + return $admin_settings; |
|
439 | + } |
|
440 | + |
|
441 | + /** |
|
442 | + * Retrieves the value of a gateway setting. |
|
443 | + * |
|
444 | + * @param string $option |
|
445 | + */ |
|
446 | + public function get_option( $option, $default = false ) { |
|
447 | + return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
448 | + } |
|
449 | + |
|
450 | + /** |
|
451 | + * Check if a gateway supports a given feature. |
|
452 | + * |
|
453 | + * Gateways should override this to declare support (or lack of support) for a feature. |
|
454 | + * For backward compatibility, gateways support 'products' by default, but nothing else. |
|
455 | + * |
|
456 | + * @param string $feature string The name of a feature to test support for. |
|
457 | + * @return bool True if the gateway supports the feature, false otherwise. |
|
458 | + * @since 1.0.19 |
|
459 | + */ |
|
460 | + public function supports( $feature ) { |
|
461 | + return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
462 | + } |
|
463 | + |
|
464 | + /** |
|
465 | + * Returns the credit card form html. |
|
466 | + * |
|
467 | + * @param bool $save whether or not to display the save button. |
|
468 | + */ |
|
469 | 469 | public function get_cc_form( $save = false ) { |
470 | 470 | |
471 | - ob_start(); |
|
471 | + ob_start(); |
|
472 | 472 | |
473 | 473 | $id_prefix = esc_attr( uniqid( $this->id ) ); |
474 | 474 | |
@@ -528,9 +528,9 @@ discard block |
||
528 | 528 | |
529 | 529 | <?php |
530 | 530 | foreach ( $months as $key => $month ) { |
531 | - $key = esc_attr( $key ); |
|
532 | - $month = esc_html( $month ); |
|
533 | - echo "<option value='$key'>$month</option>" . PHP_EOL; |
|
531 | + $key = esc_attr( $key ); |
|
532 | + $month = esc_html( $month ); |
|
533 | + echo "<option value='$key'>$month</option>" . PHP_EOL; |
|
534 | 534 | } |
535 | 535 | ?> |
536 | 536 | |
@@ -543,9 +543,9 @@ discard block |
||
543 | 543 | |
544 | 544 | <?php |
545 | 545 | foreach ( $years as $key => $year ) { |
546 | - $key = esc_attr( $key ); |
|
547 | - $year = esc_html( $year ); |
|
548 | - echo "<option value='$key'>$year</option>" . PHP_EOL; |
|
546 | + $key = esc_attr( $key ); |
|
547 | + $year = esc_html( $year ); |
|
548 | + echo "<option value='$key'>$year</option>" . PHP_EOL; |
|
549 | 549 | } |
550 | 550 | ?> |
551 | 551 | |
@@ -563,13 +563,13 @@ discard block |
||
563 | 563 | 'name' => $this->id . '[cc_cvv2]', |
564 | 564 | 'id' => "$id_prefix-cc-cvv2", |
565 | 565 | 'label' => __( 'CCV', 'invoicing' ), |
566 | - 'label_type' => 'vertical', |
|
567 | - 'class' => 'form-control-sm', |
|
568 | - 'extra_attributes' => array( |
|
569 | - 'autocomplete' => 'cc-csc', |
|
570 | - ), |
|
566 | + 'label_type' => 'vertical', |
|
567 | + 'class' => 'form-control-sm', |
|
568 | + 'extra_attributes' => array( |
|
569 | + 'autocomplete' => 'cc-csc', |
|
570 | + ), |
|
571 | 571 | ), |
572 | - true |
|
572 | + true |
|
573 | 573 | ); |
574 | 574 | ?> |
575 | 575 | </div> |
@@ -578,192 +578,192 @@ discard block |
||
578 | 578 | |
579 | 579 | <?php |
580 | 580 | |
581 | - if ( $save ) { |
|
582 | - echo $this->save_payment_method_checkbox(); |
|
583 | - } |
|
581 | + if ( $save ) { |
|
582 | + echo $this->save_payment_method_checkbox(); |
|
583 | + } |
|
584 | 584 | |
585 | - ?> |
|
585 | + ?> |
|
586 | 586 | </div> |
587 | 587 | |
588 | 588 | </div> |
589 | 589 | <?php |
590 | 590 | |
591 | - return ob_get_clean(); |
|
591 | + return ob_get_clean(); |
|
592 | + |
|
593 | + } |
|
594 | + |
|
595 | + /** |
|
596 | + * Displays a new payment method entry form. |
|
597 | + * |
|
598 | + * @since 1.0.19 |
|
599 | + */ |
|
600 | + public function new_payment_method_entry( $form ) { |
|
601 | + echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
|
602 | + } |
|
603 | + |
|
604 | + /** |
|
605 | + * Grab and display our saved payment methods. |
|
606 | + * |
|
607 | + * @since 1.0.19 |
|
608 | + */ |
|
609 | + public function saved_payment_methods() { |
|
610 | + $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
611 | + |
|
612 | + foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
613 | + $html .= $this->get_saved_payment_method_option_html( $token ); |
|
614 | + } |
|
615 | + |
|
616 | + $html .= $this->get_new_payment_method_option_html(); |
|
617 | + $html .= '</ul>'; |
|
592 | 618 | |
619 | + echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
593 | 620 | } |
594 | 621 | |
595 | - /** |
|
596 | - * Displays a new payment method entry form. |
|
597 | - * |
|
598 | - * @since 1.0.19 |
|
599 | - */ |
|
600 | - public function new_payment_method_entry( $form ) { |
|
601 | - echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
|
602 | - } |
|
603 | - |
|
604 | - /** |
|
605 | - * Grab and display our saved payment methods. |
|
606 | - * |
|
607 | - * @since 1.0.19 |
|
608 | - */ |
|
609 | - public function saved_payment_methods() { |
|
610 | - $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
611 | - |
|
612 | - foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
613 | - $html .= $this->get_saved_payment_method_option_html( $token ); |
|
614 | - } |
|
615 | - |
|
616 | - $html .= $this->get_new_payment_method_option_html(); |
|
617 | - $html .= '</ul>'; |
|
618 | - |
|
619 | - echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
620 | - } |
|
621 | - |
|
622 | - /** |
|
623 | - * Gets saved payment method HTML from a token. |
|
624 | - * |
|
625 | - * @since 1.0.19 |
|
626 | - * @param array $token Payment Token. |
|
627 | - * @return string Generated payment method HTML |
|
628 | - */ |
|
629 | - public function get_saved_payment_method_option_html( $token ) { |
|
630 | - |
|
631 | - return sprintf( |
|
632 | - '<li class="getpaid-payment-method form-group"> |
|
622 | + /** |
|
623 | + * Gets saved payment method HTML from a token. |
|
624 | + * |
|
625 | + * @since 1.0.19 |
|
626 | + * @param array $token Payment Token. |
|
627 | + * @return string Generated payment method HTML |
|
628 | + */ |
|
629 | + public function get_saved_payment_method_option_html( $token ) { |
|
630 | + |
|
631 | + return sprintf( |
|
632 | + '<li class="getpaid-payment-method form-group"> |
|
633 | 633 | <label> |
634 | 634 | <input name="getpaid-%1$s-payment-method" type="radio" value="%2$s" data-currency="%5$s" style="width:auto;" class="getpaid-saved-payment-method-token-input" %4$s /> |
635 | 635 | <span>%3$s</span> |
636 | 636 | </label> |
637 | 637 | </li>', |
638 | - esc_attr( $this->id ), |
|
639 | - esc_attr( $token['id'] ), |
|
640 | - esc_html( $token['name'] ), |
|
641 | - checked( empty( $token['default'] ), false, false ), |
|
642 | - empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
643 | - ); |
|
644 | - |
|
645 | - } |
|
646 | - |
|
647 | - /** |
|
648 | - * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method. |
|
649 | - * |
|
650 | - * @since 1.0.19 |
|
651 | - */ |
|
652 | - public function get_new_payment_method_option_html() { |
|
653 | - |
|
654 | - $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
655 | - |
|
656 | - return sprintf( |
|
657 | - '<li class="getpaid-new-payment-method"> |
|
638 | + esc_attr( $this->id ), |
|
639 | + esc_attr( $token['id'] ), |
|
640 | + esc_html( $token['name'] ), |
|
641 | + checked( empty( $token['default'] ), false, false ), |
|
642 | + empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
643 | + ); |
|
644 | + |
|
645 | + } |
|
646 | + |
|
647 | + /** |
|
648 | + * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method. |
|
649 | + * |
|
650 | + * @since 1.0.19 |
|
651 | + */ |
|
652 | + public function get_new_payment_method_option_html() { |
|
653 | + |
|
654 | + $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
655 | + |
|
656 | + return sprintf( |
|
657 | + '<li class="getpaid-new-payment-method"> |
|
658 | 658 | <label> |
659 | 659 | <input name="getpaid-%1$s-payment-method" type="radio" data-currency="none" value="new" style="width:auto;" /> |
660 | 660 | <span>%2$s</span> |
661 | 661 | </label> |
662 | 662 | </li>', |
663 | - esc_attr( $this->id ), |
|
664 | - esc_html( $label ) |
|
665 | - ); |
|
666 | - |
|
667 | - } |
|
668 | - |
|
669 | - /** |
|
670 | - * Outputs a checkbox for saving a new payment method to the database. |
|
671 | - * |
|
672 | - * @since 1.0.19 |
|
673 | - */ |
|
674 | - public function save_payment_method_checkbox() { |
|
675 | - |
|
676 | - return aui()->input( |
|
677 | - array( |
|
678 | - 'type' => 'checkbox', |
|
679 | - 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
680 | - 'id' => esc_attr( uniqid( $this->id ) ), |
|
681 | - 'required' => false, |
|
682 | - 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
683 | - 'value' => 'true', |
|
684 | - 'checked' => true, |
|
685 | - 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
|
686 | - ) |
|
687 | - ); |
|
688 | - |
|
689 | - } |
|
690 | - |
|
691 | - /** |
|
692 | - * Registers the gateway. |
|
693 | - * |
|
694 | - * @return array |
|
695 | - */ |
|
696 | - public function register_gateway( $gateways ) { |
|
697 | - |
|
698 | - $gateways[ $this->id ] = array( |
|
699 | - |
|
700 | - 'admin_label' => $this->method_title, |
|
663 | + esc_attr( $this->id ), |
|
664 | + esc_html( $label ) |
|
665 | + ); |
|
666 | + |
|
667 | + } |
|
668 | + |
|
669 | + /** |
|
670 | + * Outputs a checkbox for saving a new payment method to the database. |
|
671 | + * |
|
672 | + * @since 1.0.19 |
|
673 | + */ |
|
674 | + public function save_payment_method_checkbox() { |
|
675 | + |
|
676 | + return aui()->input( |
|
677 | + array( |
|
678 | + 'type' => 'checkbox', |
|
679 | + 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
680 | + 'id' => esc_attr( uniqid( $this->id ) ), |
|
681 | + 'required' => false, |
|
682 | + 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
683 | + 'value' => 'true', |
|
684 | + 'checked' => true, |
|
685 | + 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
|
686 | + ) |
|
687 | + ); |
|
688 | + |
|
689 | + } |
|
690 | + |
|
691 | + /** |
|
692 | + * Registers the gateway. |
|
693 | + * |
|
694 | + * @return array |
|
695 | + */ |
|
696 | + public function register_gateway( $gateways ) { |
|
697 | + |
|
698 | + $gateways[ $this->id ] = array( |
|
699 | + |
|
700 | + 'admin_label' => $this->method_title, |
|
701 | 701 | 'checkout_label' => $this->title, |
702 | - 'ordering' => $this->order, |
|
702 | + 'ordering' => $this->order, |
|
703 | 703 | |
704 | - ); |
|
704 | + ); |
|
705 | 705 | |
706 | - return $gateways; |
|
706 | + return $gateways; |
|
707 | 707 | |
708 | - } |
|
708 | + } |
|
709 | 709 | |
710 | - /** |
|
711 | - * Checks whether or not this is a sandbox request. |
|
712 | - * |
|
713 | - * @param WPInv_Invoice|null $invoice Invoice object or null. |
|
714 | - * @return bool |
|
715 | - */ |
|
716 | - public function is_sandbox( $invoice = null ) { |
|
710 | + /** |
|
711 | + * Checks whether or not this is a sandbox request. |
|
712 | + * |
|
713 | + * @param WPInv_Invoice|null $invoice Invoice object or null. |
|
714 | + * @return bool |
|
715 | + */ |
|
716 | + public function is_sandbox( $invoice = null ) { |
|
717 | 717 | |
718 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
719 | - return $invoice->get_mode() == 'test'; |
|
720 | - } |
|
718 | + if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
719 | + return $invoice->get_mode() == 'test'; |
|
720 | + } |
|
721 | 721 | |
722 | - return wpinv_is_test_mode( $this->id ); |
|
722 | + return wpinv_is_test_mode( $this->id ); |
|
723 | 723 | |
724 | - } |
|
724 | + } |
|
725 | 725 | |
726 | - /** |
|
727 | - * Renames the checkout button |
|
728 | - * |
|
729 | - * @return string |
|
730 | - */ |
|
731 | - public function rename_checkout_button() { |
|
732 | - return $this->checkout_button_text; |
|
733 | - } |
|
726 | + /** |
|
727 | + * Renames the checkout button |
|
728 | + * |
|
729 | + * @return string |
|
730 | + */ |
|
731 | + public function rename_checkout_button() { |
|
732 | + return $this->checkout_button_text; |
|
733 | + } |
|
734 | 734 | |
735 | - /** |
|
736 | - * Validate gateway currency |
|
737 | - * |
|
738 | - * @return bool |
|
739 | - */ |
|
740 | - public function validate_currency( $validation, $currency ) { |
|
735 | + /** |
|
736 | + * Validate gateway currency |
|
737 | + * |
|
738 | + * @return bool |
|
739 | + */ |
|
740 | + public function validate_currency( $validation, $currency ) { |
|
741 | 741 | |
742 | - // Required currencies. |
|
743 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
744 | - return false; |
|
745 | - } |
|
742 | + // Required currencies. |
|
743 | + if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
744 | + return false; |
|
745 | + } |
|
746 | 746 | |
747 | - // Excluded currencies. |
|
748 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
749 | - return false; |
|
750 | - } |
|
747 | + // Excluded currencies. |
|
748 | + if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
749 | + return false; |
|
750 | + } |
|
751 | 751 | |
752 | - return $validation; |
|
753 | - } |
|
752 | + return $validation; |
|
753 | + } |
|
754 | 754 | |
755 | - /** |
|
756 | - * Displays an error |
|
757 | - * |
|
758 | - */ |
|
759 | - public function show_error( $code, $message, $type ) { |
|
755 | + /** |
|
756 | + * Displays an error |
|
757 | + * |
|
758 | + */ |
|
759 | + public function show_error( $code, $message, $type ) { |
|
760 | 760 | |
761 | - if ( is_admin() ) { |
|
762 | - getpaid_admin()->{"show_$type"}( $message ); |
|
763 | - } |
|
761 | + if ( is_admin() ) { |
|
762 | + getpaid_admin()->{"show_$type"}( $message ); |
|
763 | + } |
|
764 | 764 | |
765 | - wpinv_set_error( $code, $message, $type ); |
|
765 | + wpinv_set_error( $code, $message, $type ); |
|
766 | 766 | |
767 | - } |
|
767 | + } |
|
768 | 768 | |
769 | 769 | } |
@@ -7,49 +7,49 @@ |
||
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='form-group'> |
15 | 15 | <label class="d-block"> |
16 | - <span><?php esc_html_e( 'Field Label', 'invoicing' ); ?></span> |
|
16 | + <span><?php esc_html_e('Field Label', 'invoicing'); ?></span> |
|
17 | 17 | <input v-model='active_form_element.label' class='form-control' type="text"/> |
18 | 18 | </label> |
19 | 19 | </div> |
20 | 20 | |
21 | 21 | <div class='form-group'> |
22 | 22 | <label class="d-block"> |
23 | - <span><?php esc_html_e( 'Placeholder text', 'invoicing' ); ?></span> |
|
23 | + <span><?php esc_html_e('Placeholder text', 'invoicing'); ?></span> |
|
24 | 24 | <input v-model='active_form_element.placeholder' class='form-control' type="text"/> |
25 | 25 | </label> |
26 | 26 | </div> |
27 | 27 | |
28 | 28 | <div class='form-group'> |
29 | 29 | <label class="d-block"> |
30 | - <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span> |
|
31 | - <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea> |
|
32 | - <small class="form-text text-muted"><?php esc_html_e( 'HTML is allowed', 'invoicing' ); ?></small> |
|
30 | + <span><?php esc_html_e('Help Text', 'invoicing'); ?></span> |
|
31 | + <textarea placeholder='<?php esc_attr_e('Add some help text for this field', 'invoicing'); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea> |
|
32 | + <small class="form-text text-muted"><?php esc_html_e('HTML is allowed', 'invoicing'); ?></small> |
|
33 | 33 | </label> |
34 | 34 | </div> |
35 | 35 | |
36 | 36 | <div class='form-group form-check'> |
37 | 37 | <input :id="active_form_element.id + '_edit'" v-model='active_form_element.required' type='checkbox' class='form-check-input' /> |
38 | - <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e( 'Is this field required?', 'invoicing' ); ?></label> |
|
38 | + <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e('Is this field required?', 'invoicing'); ?></label> |
|
39 | 39 | </div> |
40 | 40 | |
41 | 41 | <div class='form-group form-check'> |
42 | 42 | <input :id="active_form_element.id + '_add_meta'" v-model='active_form_element.add_meta' type='checkbox' class='form-check-input' /> |
43 | - <label class='form-check-label' :for="active_form_element.id + '_add_meta'"><?php esc_html_e( 'Show this field in receipts and emails?', 'invoicing' ); ?></label> |
|
43 | + <label class='form-check-label' :for="active_form_element.id + '_add_meta'"><?php esc_html_e('Show this field in receipts and emails?', 'invoicing'); ?></label> |
|
44 | 44 | </div> |
45 | 45 | |
46 | 46 | <hr class='featurette-divider mt-4'> |
47 | 47 | |
48 | 48 | <div class='form-group'> |
49 | 49 | <label class="d-block"> |
50 | - <span><?php esc_html_e( 'Email Merge Tag', 'invoicing' ); ?></span> |
|
50 | + <span><?php esc_html_e('Email Merge Tag', 'invoicing'); ?></span> |
|
51 | 51 | <input :value='active_form_element.label | formatMergeTag' class='form-control bg-white' type="text" readonly onclick="this.select()" /> |
52 | - <span class="form-text text-muted"><?php esc_html_e( 'You can use this merge tag in notification emails', 'invoicing' ); ?></span> |
|
52 | + <span class="form-text text-muted"><?php esc_html_e('You can use this merge tag in notification emails', 'invoicing'); ?></span> |
|
53 | 53 | </label> |
54 | 54 | </div> |
55 | 55 |
@@ -7,49 +7,49 @@ |
||
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='form-group'> |
15 | 15 | <label class="d-block"> |
16 | - <span><?php esc_html_e( 'Field Label', 'invoicing' ); ?></span> |
|
16 | + <span><?php esc_html_e('Field Label', 'invoicing'); ?></span> |
|
17 | 17 | <input v-model='active_form_element.label' class='form-control' type="text"/> |
18 | 18 | </label> |
19 | 19 | </div> |
20 | 20 | |
21 | 21 | <div class='form-group'> |
22 | 22 | <label class="d-block"> |
23 | - <span><?php esc_html_e( 'Placeholder text', 'invoicing' ); ?></span> |
|
23 | + <span><?php esc_html_e('Placeholder text', 'invoicing'); ?></span> |
|
24 | 24 | <input v-model='active_form_element.placeholder' class='form-control' type="text"/> |
25 | 25 | </label> |
26 | 26 | </div> |
27 | 27 | |
28 | 28 | <div class='form-group'> |
29 | 29 | <label class="d-block"> |
30 | - <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span> |
|
31 | - <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea> |
|
32 | - <small class="form-text text-muted"><?php esc_html_e( 'HTML is allowed', 'invoicing' ); ?></small> |
|
30 | + <span><?php esc_html_e('Help Text', 'invoicing'); ?></span> |
|
31 | + <textarea placeholder='<?php esc_attr_e('Add some help text for this field', 'invoicing'); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea> |
|
32 | + <small class="form-text text-muted"><?php esc_html_e('HTML is allowed', 'invoicing'); ?></small> |
|
33 | 33 | </label> |
34 | 34 | </div> |
35 | 35 | |
36 | 36 | <div class='form-group form-check'> |
37 | 37 | <input :id="active_form_element.id + '_edit'" v-model='active_form_element.required' type='checkbox' class='form-check-input' /> |
38 | - <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e( 'Is this field required?', 'invoicing' ); ?></label> |
|
38 | + <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e('Is this field required?', 'invoicing'); ?></label> |
|
39 | 39 | </div> |
40 | 40 | |
41 | 41 | <div class='form-group form-check'> |
42 | 42 | <input :id="active_form_element.id + '_add_meta'" v-model='active_form_element.add_meta' type='checkbox' class='form-check-input' /> |
43 | - <label class='form-check-label' :for="active_form_element.id + '_add_meta'"><?php esc_html_e( 'Show this field in receipts and emails?', 'invoicing' ); ?></label> |
|
43 | + <label class='form-check-label' :for="active_form_element.id + '_add_meta'"><?php esc_html_e('Show this field in receipts and emails?', 'invoicing'); ?></label> |
|
44 | 44 | </div> |
45 | 45 | |
46 | 46 | <hr class='featurette-divider mt-4'> |
47 | 47 | |
48 | 48 | <div class='form-group'> |
49 | 49 | <label class="d-block"> |
50 | - <span><?php esc_html_e( 'Email Merge Tag', 'invoicing' ); ?></span> |
|
50 | + <span><?php esc_html_e('Email Merge Tag', 'invoicing'); ?></span> |
|
51 | 51 | <input :value='active_form_element.label | formatMergeTag' class='form-control bg-white' type="text" readonly onclick="this.select()" /> |
52 | - <span class="form-text text-muted"><?php esc_html_e( 'You can use this merge tag in notification emails', 'invoicing' ); ?></span> |
|
52 | + <span class="form-text text-muted"><?php esc_html_e('You can use this merge tag in notification emails', 'invoicing'); ?></span> |
|
53 | 53 | </label> |
54 | 54 | </div> |
55 | 55 |
@@ -7,49 +7,49 @@ |
||
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='form-group'> |
15 | 15 | <label class="d-block"> |
16 | - <span><?php esc_html_e( 'Field Label', 'invoicing' ); ?></span> |
|
16 | + <span><?php esc_html_e('Field Label', 'invoicing'); ?></span> |
|
17 | 17 | <input v-model='active_form_element.label' class='form-control' type="text"/> |
18 | 18 | </label> |
19 | 19 | </div> |
20 | 20 | |
21 | 21 | <div class='form-group'> |
22 | 22 | <label class="d-block"> |
23 | - <span><?php esc_html_e( 'Placeholder text', 'invoicing' ); ?></span> |
|
23 | + <span><?php esc_html_e('Placeholder text', 'invoicing'); ?></span> |
|
24 | 24 | <input v-model='active_form_element.placeholder' class='form-control' type="text"/> |
25 | 25 | </label> |
26 | 26 | </div> |
27 | 27 | |
28 | 28 | <div class='form-group'> |
29 | 29 | <label class="d-block"> |
30 | - <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span> |
|
31 | - <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea> |
|
32 | - <small class="form-text text-muted"><?php esc_html_e( 'HTML is allowed', 'invoicing' ); ?></small> |
|
30 | + <span><?php esc_html_e('Help Text', 'invoicing'); ?></span> |
|
31 | + <textarea placeholder='<?php esc_attr_e('Add some help text for this field', 'invoicing'); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea> |
|
32 | + <small class="form-text text-muted"><?php esc_html_e('HTML is allowed', 'invoicing'); ?></small> |
|
33 | 33 | </label> |
34 | 34 | </div> |
35 | 35 | |
36 | 36 | <div class='form-group form-check'> |
37 | 37 | <input :id="active_form_element.id + '_edit'" v-model='active_form_element.required' type='checkbox' class='form-check-input' /> |
38 | - <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e( 'Is this field required?', 'invoicing' ); ?></label> |
|
38 | + <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e('Is this field required?', 'invoicing'); ?></label> |
|
39 | 39 | </div> |
40 | 40 | |
41 | 41 | <div class='form-group form-check'> |
42 | 42 | <input :id="active_form_element.id + '_add_meta'" v-model='active_form_element.add_meta' type='checkbox' class='form-check-input' /> |
43 | - <label class='form-check-label' :for="active_form_element.id + '_add_meta'"><?php esc_html_e( 'Show this field in receipts and emails?', 'invoicing' ); ?></label> |
|
43 | + <label class='form-check-label' :for="active_form_element.id + '_add_meta'"><?php esc_html_e('Show this field in receipts and emails?', 'invoicing'); ?></label> |
|
44 | 44 | </div> |
45 | 45 | |
46 | 46 | <hr class='featurette-divider mt-4'> |
47 | 47 | |
48 | 48 | <div class='form-group'> |
49 | 49 | <label class="d-block"> |
50 | - <span><?php esc_html_e( 'Email Merge Tag', 'invoicing' ); ?></span> |
|
50 | + <span><?php esc_html_e('Email Merge Tag', 'invoicing'); ?></span> |
|
51 | 51 | <input :value='active_form_element.label | formatMergeTag' class='form-control bg-white' type="text" readonly onclick="this.select()" /> |
52 | - <span class="form-text text-muted"><?php esc_html_e( 'You can use this merge tag in notification emails', 'invoicing' ); ?></span> |
|
52 | + <span class="form-text text-muted"><?php esc_html_e('You can use this merge tag in notification emails', 'invoicing'); ?></span> |
|
53 | 53 | </label> |
54 | 54 | </div> |
55 | 55 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
3 | +if (!defined('ABSPATH')) { |
|
4 | 4 | exit; // Exit if accessed directly |
5 | 5 | } |
6 | 6 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @return AUI|null |
36 | 36 | */ |
37 | 37 | public static function instance() { |
38 | - if ( self::$instance == null ) { |
|
38 | + if (self::$instance == null) { |
|
39 | 39 | self::$instance = new AUI(); |
40 | 40 | } |
41 | 41 | |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | * @since 1.0.0 |
49 | 49 | */ |
50 | 50 | private function __construct() { |
51 | - if ( function_exists( "__autoload" ) ) { |
|
52 | - spl_autoload_register( "__autoload" ); |
|
51 | + if (function_exists("__autoload")) { |
|
52 | + spl_autoload_register("__autoload"); |
|
53 | 53 | } |
54 | - spl_autoload_register( array( $this, 'autoload' ) ); |
|
54 | + spl_autoload_register(array($this, 'autoload')); |
|
55 | 55 | |
56 | 56 | // load options |
57 | 57 | self::$options = get_option('aui_options'); |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @param $classname |
66 | 66 | */ |
67 | - private function autoload( $classname ) { |
|
68 | - $class = str_replace( '_', '-', strtolower( $classname ) ); |
|
69 | - $file_path = trailingslashit( dirname( __FILE__ ) ) . "components/class-" . $class . '.php'; |
|
70 | - if ( $file_path && is_readable( $file_path ) ) { |
|
71 | - include_once( $file_path ); |
|
67 | + private function autoload($classname) { |
|
68 | + $class = str_replace('_', '-', strtolower($classname)); |
|
69 | + $file_path = trailingslashit(dirname(__FILE__)) . "components/class-" . $class . '.php'; |
|
70 | + if ($file_path && is_readable($file_path)) { |
|
71 | + include_once($file_path); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
@@ -79,34 +79,34 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return string|void |
81 | 81 | */ |
82 | - public function get_option( $option ){ |
|
82 | + public function get_option($option) { |
|
83 | 83 | $result = isset(self::$options[$option]) ? esc_attr(self::$options[$option]) : ''; |
84 | 84 | |
85 | - if ( ! $result && $option) { |
|
86 | - if( $option == 'color_primary' ){ |
|
85 | + if (!$result && $option) { |
|
86 | + if ($option == 'color_primary') { |
|
87 | 87 | $result = AUI_PRIMARY_COLOR; |
88 | - }elseif( $option == 'color_secondary' ){ |
|
88 | + }elseif ($option == 'color_secondary') { |
|
89 | 89 | $result = AUI_SECONDARY_COLOR; |
90 | 90 | } |
91 | 91 | } |
92 | 92 | return $result; |
93 | 93 | } |
94 | 94 | |
95 | - public function render( $items = array(), $echo = false ) { |
|
95 | + public function render($items = array(), $echo = false) { |
|
96 | 96 | $output = ''; |
97 | 97 | |
98 | - if ( ! empty( $items ) ) { |
|
99 | - foreach ( $items as $args ) { |
|
100 | - $render = isset( $args['render'] ) ? $args['render'] : ''; |
|
101 | - if ( $render && method_exists( __CLASS__, $render ) ) { |
|
102 | - $output .= $this->$render( $args ); |
|
98 | + if (!empty($items)) { |
|
99 | + foreach ($items as $args) { |
|
100 | + $render = isset($args['render']) ? $args['render'] : ''; |
|
101 | + if ($render && method_exists(__CLASS__, $render)) { |
|
102 | + $output .= $this->$render($args); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | - if ( $echo ) { |
|
107 | + if ($echo) { |
|
108 | 108 | echo $output; |
109 | - }else{ |
|
109 | + } else { |
|
110 | 110 | return $output; |
111 | 111 | } |
112 | 112 | |
@@ -122,12 +122,12 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return string The rendered component. |
124 | 124 | */ |
125 | - public function alert( $args = array(), $echo = false ) { |
|
126 | - $output = AUI_Component_Alert::get( $args ); |
|
125 | + public function alert($args = array(), $echo = false) { |
|
126 | + $output = AUI_Component_Alert::get($args); |
|
127 | 127 | |
128 | - if ( $echo ) { |
|
128 | + if ($echo) { |
|
129 | 129 | echo $output; |
130 | - }else{ |
|
130 | + } else { |
|
131 | 131 | return $output; |
132 | 132 | } |
133 | 133 | } |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @return string The rendered component. |
144 | 144 | */ |
145 | - public function input( $args = array(), $echo = false ) { |
|
146 | - $output = AUI_Component_Input::input( $args ); |
|
145 | + public function input($args = array(), $echo = false) { |
|
146 | + $output = AUI_Component_Input::input($args); |
|
147 | 147 | |
148 | - if ( $echo ) { |
|
148 | + if ($echo) { |
|
149 | 149 | echo $output; |
150 | - }else{ |
|
150 | + } else { |
|
151 | 151 | return $output; |
152 | 152 | } |
153 | 153 | } |
@@ -162,12 +162,12 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return string The rendered component. |
164 | 164 | */ |
165 | - public function textarea( $args = array(), $echo = false ) { |
|
166 | - $output = AUI_Component_Input::textarea( $args ); |
|
165 | + public function textarea($args = array(), $echo = false) { |
|
166 | + $output = AUI_Component_Input::textarea($args); |
|
167 | 167 | |
168 | - if ( $echo ) { |
|
168 | + if ($echo) { |
|
169 | 169 | echo $output; |
170 | - }else{ |
|
170 | + } else { |
|
171 | 171 | return $output; |
172 | 172 | } |
173 | 173 | } |
@@ -182,12 +182,12 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @return string The rendered component. |
184 | 184 | */ |
185 | - public function button( $args = array(), $echo = false ) { |
|
186 | - $output = AUI_Component_Button::get( $args ); |
|
185 | + public function button($args = array(), $echo = false) { |
|
186 | + $output = AUI_Component_Button::get($args); |
|
187 | 187 | |
188 | - if ( $echo ) { |
|
188 | + if ($echo) { |
|
189 | 189 | echo $output; |
190 | - }else{ |
|
190 | + } else { |
|
191 | 191 | return $output; |
192 | 192 | } |
193 | 193 | } |
@@ -202,26 +202,26 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @return string The rendered component. |
204 | 204 | */ |
205 | - public function badge( $args = array(), $echo = false ) { |
|
205 | + public function badge($args = array(), $echo = false) { |
|
206 | 206 | $defaults = array( |
207 | 207 | 'class' => 'badge badge-primary align-middle', |
208 | 208 | ); |
209 | 209 | |
210 | 210 | // maybe set type. |
211 | - if ( empty( $args['href'] ) ) { |
|
211 | + if (empty($args['href'])) { |
|
212 | 212 | $defaults['type'] = 'badge'; |
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
216 | 216 | * Parse incoming $args into an array and merge it with $defaults |
217 | 217 | */ |
218 | - $args = wp_parse_args( $args, $defaults ); |
|
218 | + $args = wp_parse_args($args, $defaults); |
|
219 | 219 | |
220 | - $output = AUI_Component_Button::get( $args ); |
|
220 | + $output = AUI_Component_Button::get($args); |
|
221 | 221 | |
222 | - if ( $echo ) { |
|
222 | + if ($echo) { |
|
223 | 223 | echo $output; |
224 | - }else{ |
|
224 | + } else { |
|
225 | 225 | return $output; |
226 | 226 | } |
227 | 227 | } |
@@ -236,12 +236,12 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @return string The rendered component. |
238 | 238 | */ |
239 | - public function dropdown( $args = array(), $echo = false ) { |
|
240 | - $output = AUI_Component_Dropdown::get( $args ); |
|
239 | + public function dropdown($args = array(), $echo = false) { |
|
240 | + $output = AUI_Component_Dropdown::get($args); |
|
241 | 241 | |
242 | - if ( $echo ) { |
|
242 | + if ($echo) { |
|
243 | 243 | echo $output; |
244 | - }else{ |
|
244 | + } else { |
|
245 | 245 | return $output; |
246 | 246 | } |
247 | 247 | } |
@@ -256,12 +256,12 @@ discard block |
||
256 | 256 | * |
257 | 257 | * @return string The rendered component. |
258 | 258 | */ |
259 | - public function select( $args = array(), $echo = false ) { |
|
260 | - $output = AUI_Component_Input::select( $args ); |
|
259 | + public function select($args = array(), $echo = false) { |
|
260 | + $output = AUI_Component_Input::select($args); |
|
261 | 261 | |
262 | - if ( $echo ) { |
|
262 | + if ($echo) { |
|
263 | 263 | echo $output; |
264 | - }else{ |
|
264 | + } else { |
|
265 | 265 | return $output; |
266 | 266 | } |
267 | 267 | } |
@@ -276,12 +276,12 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @return string The rendered component. |
278 | 278 | */ |
279 | - public function radio( $args = array(), $echo = false ) { |
|
280 | - $output = AUI_Component_Input::radio( $args ); |
|
279 | + public function radio($args = array(), $echo = false) { |
|
280 | + $output = AUI_Component_Input::radio($args); |
|
281 | 281 | |
282 | - if ( $echo ) { |
|
282 | + if ($echo) { |
|
283 | 283 | echo $output; |
284 | - }else{ |
|
284 | + } else { |
|
285 | 285 | return $output; |
286 | 286 | } |
287 | 287 | } |
@@ -296,12 +296,12 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @return string The rendered component. |
298 | 298 | */ |
299 | - public function pagination( $args = array(), $echo = false ) { |
|
300 | - $output = AUI_Component_Pagination::get( $args ); |
|
299 | + public function pagination($args = array(), $echo = false) { |
|
300 | + $output = AUI_Component_Pagination::get($args); |
|
301 | 301 | |
302 | - if ( $echo ) { |
|
302 | + if ($echo) { |
|
303 | 303 | echo $output; |
304 | - }else{ |
|
304 | + } else { |
|
305 | 305 | return $output; |
306 | 306 | } |
307 | 307 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | if ( ! $result && $option) { |
86 | 86 | if( $option == 'color_primary' ){ |
87 | 87 | $result = AUI_PRIMARY_COLOR; |
88 | - }elseif( $option == 'color_secondary' ){ |
|
88 | + } elseif( $option == 'color_secondary' ){ |
|
89 | 89 | $result = AUI_SECONDARY_COLOR; |
90 | 90 | } |
91 | 91 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | if ( $echo ) { |
108 | 108 | echo $output; |
109 | - }else{ |
|
109 | + } else{ |
|
110 | 110 | return $output; |
111 | 111 | } |
112 | 112 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | |
128 | 128 | if ( $echo ) { |
129 | 129 | echo $output; |
130 | - }else{ |
|
130 | + } else{ |
|
131 | 131 | return $output; |
132 | 132 | } |
133 | 133 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | |
148 | 148 | if ( $echo ) { |
149 | 149 | echo $output; |
150 | - }else{ |
|
150 | + } else{ |
|
151 | 151 | return $output; |
152 | 152 | } |
153 | 153 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | |
168 | 168 | if ( $echo ) { |
169 | 169 | echo $output; |
170 | - }else{ |
|
170 | + } else{ |
|
171 | 171 | return $output; |
172 | 172 | } |
173 | 173 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | |
188 | 188 | if ( $echo ) { |
189 | 189 | echo $output; |
190 | - }else{ |
|
190 | + } else{ |
|
191 | 191 | return $output; |
192 | 192 | } |
193 | 193 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | |
222 | 222 | if ( $echo ) { |
223 | 223 | echo $output; |
224 | - }else{ |
|
224 | + } else{ |
|
225 | 225 | return $output; |
226 | 226 | } |
227 | 227 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | if ( $echo ) { |
243 | 243 | echo $output; |
244 | - }else{ |
|
244 | + } else{ |
|
245 | 245 | return $output; |
246 | 246 | } |
247 | 247 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | |
262 | 262 | if ( $echo ) { |
263 | 263 | echo $output; |
264 | - }else{ |
|
264 | + } else{ |
|
265 | 265 | return $output; |
266 | 266 | } |
267 | 267 | } |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | |
282 | 282 | if ( $echo ) { |
283 | 283 | echo $output; |
284 | - }else{ |
|
284 | + } else{ |
|
285 | 285 | return $output; |
286 | 286 | } |
287 | 287 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | |
302 | 302 | if ( $echo ) { |
303 | 303 | echo $output; |
304 | - }else{ |
|
304 | + } else{ |
|
305 | 305 | return $output; |
306 | 306 | } |
307 | 307 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if ( ! defined( 'ABSPATH' ) ) { |
4 | - exit; // Exit if accessed directly |
|
4 | + exit; // Exit if accessed directly |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -11,299 +11,299 @@ discard block |
||
11 | 11 | */ |
12 | 12 | class AUI { |
13 | 13 | |
14 | - /** |
|
15 | - * Holds the class instance. |
|
16 | - * |
|
17 | - * @since 1.0.0 |
|
18 | - * @var null |
|
19 | - */ |
|
20 | - private static $instance = null; |
|
21 | - |
|
22 | - /** |
|
23 | - * Holds the current AUI version number. |
|
24 | - * |
|
25 | - * @var string $ver The current version number. |
|
26 | - */ |
|
27 | - public static $ver = '0.1.70'; |
|
28 | - |
|
29 | - public static $options = null; |
|
30 | - |
|
31 | - /** |
|
32 | - * There can be only one. |
|
33 | - * |
|
34 | - * @since 1.0.0 |
|
35 | - * @return AUI|null |
|
36 | - */ |
|
37 | - public static function instance() { |
|
38 | - if ( self::$instance == null ) { |
|
39 | - self::$instance = new AUI(); |
|
40 | - } |
|
41 | - |
|
42 | - return self::$instance; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * AUI constructor. |
|
47 | - * |
|
48 | - * @since 1.0.0 |
|
49 | - */ |
|
50 | - private function __construct() { |
|
51 | - if ( function_exists( "__autoload" ) ) { |
|
52 | - spl_autoload_register( "__autoload" ); |
|
53 | - } |
|
54 | - spl_autoload_register( array( $this, 'autoload' ) ); |
|
55 | - |
|
56 | - // load options |
|
57 | - self::$options = get_option('aui_options'); |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * Autoload any components on the fly. |
|
62 | - * |
|
63 | - * @since 1.0.0 |
|
64 | - * |
|
65 | - * @param $classname |
|
66 | - */ |
|
67 | - private function autoload( $classname ) { |
|
68 | - $class = str_replace( '_', '-', strtolower( $classname ) ); |
|
69 | - $file_path = trailingslashit( dirname( __FILE__ ) ) . "components/class-" . $class . '.php'; |
|
70 | - if ( $file_path && is_readable( $file_path ) ) { |
|
71 | - include_once( $file_path ); |
|
72 | - } |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * Get the AUI options. |
|
77 | - * |
|
78 | - * @param $option |
|
79 | - * |
|
80 | - * @return string|void |
|
81 | - */ |
|
82 | - public function get_option( $option ){ |
|
83 | - $result = isset(self::$options[$option]) ? esc_attr(self::$options[$option]) : ''; |
|
84 | - |
|
85 | - if ( ! $result && $option) { |
|
86 | - if( $option == 'color_primary' ){ |
|
87 | - $result = AUI_PRIMARY_COLOR; |
|
88 | - }elseif( $option == 'color_secondary' ){ |
|
89 | - $result = AUI_SECONDARY_COLOR; |
|
90 | - } |
|
91 | - } |
|
92 | - return $result; |
|
93 | - } |
|
94 | - |
|
95 | - public function render( $items = array(), $echo = false ) { |
|
96 | - $output = ''; |
|
97 | - |
|
98 | - if ( ! empty( $items ) ) { |
|
99 | - foreach ( $items as $args ) { |
|
100 | - $render = isset( $args['render'] ) ? $args['render'] : ''; |
|
101 | - if ( $render && method_exists( __CLASS__, $render ) ) { |
|
102 | - $output .= $this->$render( $args ); |
|
103 | - } |
|
104 | - } |
|
105 | - } |
|
106 | - |
|
107 | - if ( $echo ) { |
|
108 | - echo $output; |
|
109 | - }else{ |
|
110 | - return $output; |
|
111 | - } |
|
112 | - |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * Render and return a bootstrap alert component. |
|
117 | - * |
|
118 | - * @since 1.0.0 |
|
119 | - * |
|
120 | - * @param array $args The function arguments. |
|
121 | - * @param bool $echo If we should return or echo. |
|
122 | - * |
|
123 | - * @return string The rendered component. |
|
124 | - */ |
|
125 | - public function alert( $args = array(), $echo = false ) { |
|
126 | - $output = AUI_Component_Alert::get( $args ); |
|
127 | - |
|
128 | - if ( $echo ) { |
|
129 | - echo $output; |
|
130 | - }else{ |
|
131 | - return $output; |
|
132 | - } |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * Render and return a bootstrap input component. |
|
137 | - * |
|
138 | - * @since 1.0.0 |
|
139 | - * |
|
140 | - * @param array $args The function arguments. |
|
141 | - * @param bool $echo If we should return or echo. |
|
142 | - * |
|
143 | - * @return string The rendered component. |
|
144 | - */ |
|
145 | - public function input( $args = array(), $echo = false ) { |
|
146 | - $output = AUI_Component_Input::input( $args ); |
|
147 | - |
|
148 | - if ( $echo ) { |
|
149 | - echo $output; |
|
150 | - }else{ |
|
151 | - return $output; |
|
152 | - } |
|
153 | - } |
|
154 | - |
|
155 | - /** |
|
156 | - * Render and return a bootstrap textarea component. |
|
157 | - * |
|
158 | - * @since 1.0.0 |
|
159 | - * |
|
160 | - * @param array $args The function arguments. |
|
161 | - * @param bool $echo If we should return or echo. |
|
162 | - * |
|
163 | - * @return string The rendered component. |
|
164 | - */ |
|
165 | - public function textarea( $args = array(), $echo = false ) { |
|
166 | - $output = AUI_Component_Input::textarea( $args ); |
|
167 | - |
|
168 | - if ( $echo ) { |
|
169 | - echo $output; |
|
170 | - }else{ |
|
171 | - return $output; |
|
172 | - } |
|
173 | - } |
|
174 | - |
|
175 | - /** |
|
176 | - * Render and return a bootstrap button component. |
|
177 | - * |
|
178 | - * @since 1.0.0 |
|
179 | - * |
|
180 | - * @param array $args The function arguments. |
|
181 | - * @param bool $echo If we should return or echo. |
|
182 | - * |
|
183 | - * @return string The rendered component. |
|
184 | - */ |
|
185 | - public function button( $args = array(), $echo = false ) { |
|
186 | - $output = AUI_Component_Button::get( $args ); |
|
187 | - |
|
188 | - if ( $echo ) { |
|
189 | - echo $output; |
|
190 | - }else{ |
|
191 | - return $output; |
|
192 | - } |
|
193 | - } |
|
194 | - |
|
195 | - /** |
|
196 | - * Render and return a bootstrap button component. |
|
197 | - * |
|
198 | - * @since 1.0.0 |
|
199 | - * |
|
200 | - * @param array $args The function arguments. |
|
201 | - * @param bool $echo If we should return or echo. |
|
202 | - * |
|
203 | - * @return string The rendered component. |
|
204 | - */ |
|
205 | - public function badge( $args = array(), $echo = false ) { |
|
206 | - $defaults = array( |
|
207 | - 'class' => 'badge badge-primary align-middle', |
|
208 | - ); |
|
209 | - |
|
210 | - // maybe set type. |
|
211 | - if ( empty( $args['href'] ) ) { |
|
212 | - $defaults['type'] = 'badge'; |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * Parse incoming $args into an array and merge it with $defaults |
|
217 | - */ |
|
218 | - $args = wp_parse_args( $args, $defaults ); |
|
219 | - |
|
220 | - $output = AUI_Component_Button::get( $args ); |
|
221 | - |
|
222 | - if ( $echo ) { |
|
223 | - echo $output; |
|
224 | - }else{ |
|
225 | - return $output; |
|
226 | - } |
|
227 | - } |
|
228 | - |
|
229 | - /** |
|
230 | - * Render and return a bootstrap dropdown component. |
|
231 | - * |
|
232 | - * @since 1.0.0 |
|
233 | - * |
|
234 | - * @param array $args The function arguments. |
|
235 | - * @param bool $echo If we should return or echo. |
|
236 | - * |
|
237 | - * @return string The rendered component. |
|
238 | - */ |
|
239 | - public function dropdown( $args = array(), $echo = false ) { |
|
240 | - $output = AUI_Component_Dropdown::get( $args ); |
|
241 | - |
|
242 | - if ( $echo ) { |
|
243 | - echo $output; |
|
244 | - }else{ |
|
245 | - return $output; |
|
246 | - } |
|
247 | - } |
|
248 | - |
|
249 | - /** |
|
250 | - * Render and return a bootstrap select component. |
|
251 | - * |
|
252 | - * @since 1.0.0 |
|
253 | - * |
|
254 | - * @param array $args The function arguments. |
|
255 | - * @param bool $echo If we should return or echo. |
|
256 | - * |
|
257 | - * @return string The rendered component. |
|
258 | - */ |
|
259 | - public function select( $args = array(), $echo = false ) { |
|
260 | - $output = AUI_Component_Input::select( $args ); |
|
261 | - |
|
262 | - if ( $echo ) { |
|
263 | - echo $output; |
|
264 | - }else{ |
|
265 | - return $output; |
|
266 | - } |
|
267 | - } |
|
268 | - |
|
269 | - /** |
|
270 | - * Render and return a bootstrap radio component. |
|
271 | - * |
|
272 | - * @since 1.0.0 |
|
273 | - * |
|
274 | - * @param array $args The function arguments. |
|
275 | - * @param bool $echo If we should return or echo. |
|
276 | - * |
|
277 | - * @return string The rendered component. |
|
278 | - */ |
|
279 | - public function radio( $args = array(), $echo = false ) { |
|
280 | - $output = AUI_Component_Input::radio( $args ); |
|
281 | - |
|
282 | - if ( $echo ) { |
|
283 | - echo $output; |
|
284 | - }else{ |
|
285 | - return $output; |
|
286 | - } |
|
287 | - } |
|
288 | - |
|
289 | - /** |
|
290 | - * Render and return a bootstrap pagination component. |
|
291 | - * |
|
292 | - * @since 1.0.0 |
|
293 | - * |
|
294 | - * @param array $args The function arguments. |
|
295 | - * @param bool $echo If we should return or echo. |
|
296 | - * |
|
297 | - * @return string The rendered component. |
|
298 | - */ |
|
299 | - public function pagination( $args = array(), $echo = false ) { |
|
300 | - $output = AUI_Component_Pagination::get( $args ); |
|
301 | - |
|
302 | - if ( $echo ) { |
|
303 | - echo $output; |
|
304 | - }else{ |
|
305 | - return $output; |
|
306 | - } |
|
307 | - } |
|
14 | + /** |
|
15 | + * Holds the class instance. |
|
16 | + * |
|
17 | + * @since 1.0.0 |
|
18 | + * @var null |
|
19 | + */ |
|
20 | + private static $instance = null; |
|
21 | + |
|
22 | + /** |
|
23 | + * Holds the current AUI version number. |
|
24 | + * |
|
25 | + * @var string $ver The current version number. |
|
26 | + */ |
|
27 | + public static $ver = '0.1.70'; |
|
28 | + |
|
29 | + public static $options = null; |
|
30 | + |
|
31 | + /** |
|
32 | + * There can be only one. |
|
33 | + * |
|
34 | + * @since 1.0.0 |
|
35 | + * @return AUI|null |
|
36 | + */ |
|
37 | + public static function instance() { |
|
38 | + if ( self::$instance == null ) { |
|
39 | + self::$instance = new AUI(); |
|
40 | + } |
|
41 | + |
|
42 | + return self::$instance; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * AUI constructor. |
|
47 | + * |
|
48 | + * @since 1.0.0 |
|
49 | + */ |
|
50 | + private function __construct() { |
|
51 | + if ( function_exists( "__autoload" ) ) { |
|
52 | + spl_autoload_register( "__autoload" ); |
|
53 | + } |
|
54 | + spl_autoload_register( array( $this, 'autoload' ) ); |
|
55 | + |
|
56 | + // load options |
|
57 | + self::$options = get_option('aui_options'); |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * Autoload any components on the fly. |
|
62 | + * |
|
63 | + * @since 1.0.0 |
|
64 | + * |
|
65 | + * @param $classname |
|
66 | + */ |
|
67 | + private function autoload( $classname ) { |
|
68 | + $class = str_replace( '_', '-', strtolower( $classname ) ); |
|
69 | + $file_path = trailingslashit( dirname( __FILE__ ) ) . "components/class-" . $class . '.php'; |
|
70 | + if ( $file_path && is_readable( $file_path ) ) { |
|
71 | + include_once( $file_path ); |
|
72 | + } |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * Get the AUI options. |
|
77 | + * |
|
78 | + * @param $option |
|
79 | + * |
|
80 | + * @return string|void |
|
81 | + */ |
|
82 | + public function get_option( $option ){ |
|
83 | + $result = isset(self::$options[$option]) ? esc_attr(self::$options[$option]) : ''; |
|
84 | + |
|
85 | + if ( ! $result && $option) { |
|
86 | + if( $option == 'color_primary' ){ |
|
87 | + $result = AUI_PRIMARY_COLOR; |
|
88 | + }elseif( $option == 'color_secondary' ){ |
|
89 | + $result = AUI_SECONDARY_COLOR; |
|
90 | + } |
|
91 | + } |
|
92 | + return $result; |
|
93 | + } |
|
94 | + |
|
95 | + public function render( $items = array(), $echo = false ) { |
|
96 | + $output = ''; |
|
97 | + |
|
98 | + if ( ! empty( $items ) ) { |
|
99 | + foreach ( $items as $args ) { |
|
100 | + $render = isset( $args['render'] ) ? $args['render'] : ''; |
|
101 | + if ( $render && method_exists( __CLASS__, $render ) ) { |
|
102 | + $output .= $this->$render( $args ); |
|
103 | + } |
|
104 | + } |
|
105 | + } |
|
106 | + |
|
107 | + if ( $echo ) { |
|
108 | + echo $output; |
|
109 | + }else{ |
|
110 | + return $output; |
|
111 | + } |
|
112 | + |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * Render and return a bootstrap alert component. |
|
117 | + * |
|
118 | + * @since 1.0.0 |
|
119 | + * |
|
120 | + * @param array $args The function arguments. |
|
121 | + * @param bool $echo If we should return or echo. |
|
122 | + * |
|
123 | + * @return string The rendered component. |
|
124 | + */ |
|
125 | + public function alert( $args = array(), $echo = false ) { |
|
126 | + $output = AUI_Component_Alert::get( $args ); |
|
127 | + |
|
128 | + if ( $echo ) { |
|
129 | + echo $output; |
|
130 | + }else{ |
|
131 | + return $output; |
|
132 | + } |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * Render and return a bootstrap input component. |
|
137 | + * |
|
138 | + * @since 1.0.0 |
|
139 | + * |
|
140 | + * @param array $args The function arguments. |
|
141 | + * @param bool $echo If we should return or echo. |
|
142 | + * |
|
143 | + * @return string The rendered component. |
|
144 | + */ |
|
145 | + public function input( $args = array(), $echo = false ) { |
|
146 | + $output = AUI_Component_Input::input( $args ); |
|
147 | + |
|
148 | + if ( $echo ) { |
|
149 | + echo $output; |
|
150 | + }else{ |
|
151 | + return $output; |
|
152 | + } |
|
153 | + } |
|
154 | + |
|
155 | + /** |
|
156 | + * Render and return a bootstrap textarea component. |
|
157 | + * |
|
158 | + * @since 1.0.0 |
|
159 | + * |
|
160 | + * @param array $args The function arguments. |
|
161 | + * @param bool $echo If we should return or echo. |
|
162 | + * |
|
163 | + * @return string The rendered component. |
|
164 | + */ |
|
165 | + public function textarea( $args = array(), $echo = false ) { |
|
166 | + $output = AUI_Component_Input::textarea( $args ); |
|
167 | + |
|
168 | + if ( $echo ) { |
|
169 | + echo $output; |
|
170 | + }else{ |
|
171 | + return $output; |
|
172 | + } |
|
173 | + } |
|
174 | + |
|
175 | + /** |
|
176 | + * Render and return a bootstrap button component. |
|
177 | + * |
|
178 | + * @since 1.0.0 |
|
179 | + * |
|
180 | + * @param array $args The function arguments. |
|
181 | + * @param bool $echo If we should return or echo. |
|
182 | + * |
|
183 | + * @return string The rendered component. |
|
184 | + */ |
|
185 | + public function button( $args = array(), $echo = false ) { |
|
186 | + $output = AUI_Component_Button::get( $args ); |
|
187 | + |
|
188 | + if ( $echo ) { |
|
189 | + echo $output; |
|
190 | + }else{ |
|
191 | + return $output; |
|
192 | + } |
|
193 | + } |
|
194 | + |
|
195 | + /** |
|
196 | + * Render and return a bootstrap button component. |
|
197 | + * |
|
198 | + * @since 1.0.0 |
|
199 | + * |
|
200 | + * @param array $args The function arguments. |
|
201 | + * @param bool $echo If we should return or echo. |
|
202 | + * |
|
203 | + * @return string The rendered component. |
|
204 | + */ |
|
205 | + public function badge( $args = array(), $echo = false ) { |
|
206 | + $defaults = array( |
|
207 | + 'class' => 'badge badge-primary align-middle', |
|
208 | + ); |
|
209 | + |
|
210 | + // maybe set type. |
|
211 | + if ( empty( $args['href'] ) ) { |
|
212 | + $defaults['type'] = 'badge'; |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * Parse incoming $args into an array and merge it with $defaults |
|
217 | + */ |
|
218 | + $args = wp_parse_args( $args, $defaults ); |
|
219 | + |
|
220 | + $output = AUI_Component_Button::get( $args ); |
|
221 | + |
|
222 | + if ( $echo ) { |
|
223 | + echo $output; |
|
224 | + }else{ |
|
225 | + return $output; |
|
226 | + } |
|
227 | + } |
|
228 | + |
|
229 | + /** |
|
230 | + * Render and return a bootstrap dropdown component. |
|
231 | + * |
|
232 | + * @since 1.0.0 |
|
233 | + * |
|
234 | + * @param array $args The function arguments. |
|
235 | + * @param bool $echo If we should return or echo. |
|
236 | + * |
|
237 | + * @return string The rendered component. |
|
238 | + */ |
|
239 | + public function dropdown( $args = array(), $echo = false ) { |
|
240 | + $output = AUI_Component_Dropdown::get( $args ); |
|
241 | + |
|
242 | + if ( $echo ) { |
|
243 | + echo $output; |
|
244 | + }else{ |
|
245 | + return $output; |
|
246 | + } |
|
247 | + } |
|
248 | + |
|
249 | + /** |
|
250 | + * Render and return a bootstrap select component. |
|
251 | + * |
|
252 | + * @since 1.0.0 |
|
253 | + * |
|
254 | + * @param array $args The function arguments. |
|
255 | + * @param bool $echo If we should return or echo. |
|
256 | + * |
|
257 | + * @return string The rendered component. |
|
258 | + */ |
|
259 | + public function select( $args = array(), $echo = false ) { |
|
260 | + $output = AUI_Component_Input::select( $args ); |
|
261 | + |
|
262 | + if ( $echo ) { |
|
263 | + echo $output; |
|
264 | + }else{ |
|
265 | + return $output; |
|
266 | + } |
|
267 | + } |
|
268 | + |
|
269 | + /** |
|
270 | + * Render and return a bootstrap radio component. |
|
271 | + * |
|
272 | + * @since 1.0.0 |
|
273 | + * |
|
274 | + * @param array $args The function arguments. |
|
275 | + * @param bool $echo If we should return or echo. |
|
276 | + * |
|
277 | + * @return string The rendered component. |
|
278 | + */ |
|
279 | + public function radio( $args = array(), $echo = false ) { |
|
280 | + $output = AUI_Component_Input::radio( $args ); |
|
281 | + |
|
282 | + if ( $echo ) { |
|
283 | + echo $output; |
|
284 | + }else{ |
|
285 | + return $output; |
|
286 | + } |
|
287 | + } |
|
288 | + |
|
289 | + /** |
|
290 | + * Render and return a bootstrap pagination component. |
|
291 | + * |
|
292 | + * @since 1.0.0 |
|
293 | + * |
|
294 | + * @param array $args The function arguments. |
|
295 | + * @param bool $echo If we should return or echo. |
|
296 | + * |
|
297 | + * @return string The rendered component. |
|
298 | + */ |
|
299 | + public function pagination( $args = array(), $echo = false ) { |
|
300 | + $output = AUI_Component_Pagination::get( $args ); |
|
301 | + |
|
302 | + if ( $echo ) { |
|
303 | + echo $output; |
|
304 | + }else{ |
|
305 | + return $output; |
|
306 | + } |
|
307 | + } |
|
308 | 308 | |
309 | 309 | } |
310 | 310 | \ No newline at end of file |
@@ -7,40 +7,40 @@ |
||
7 | 7 | * Bail if we are not in WP. |
8 | 8 | */ |
9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
10 | - exit; |
|
10 | + exit; |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Set the version only if its the current newest while loading. |
15 | 15 | */ |
16 | 16 | add_action('after_setup_theme', function () { |
17 | - global $ayecode_ui_version,$ayecode_ui_file_key; |
|
18 | - $this_version = "0.1.70"; |
|
19 | - if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){ |
|
20 | - $ayecode_ui_version = $this_version ; |
|
21 | - $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
22 | - } |
|
17 | + global $ayecode_ui_version,$ayecode_ui_file_key; |
|
18 | + $this_version = "0.1.70"; |
|
19 | + if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){ |
|
20 | + $ayecode_ui_version = $this_version ; |
|
21 | + $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
22 | + } |
|
23 | 23 | },0); |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Load this version of WP Bootstrap Settings only if the file hash is the current one. |
27 | 27 | */ |
28 | 28 | add_action('after_setup_theme', function () { |
29 | - global $ayecode_ui_file_key; |
|
30 | - if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
31 | - include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
32 | - include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
33 | - } |
|
29 | + global $ayecode_ui_file_key; |
|
30 | + if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
31 | + include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
32 | + include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
33 | + } |
|
34 | 34 | },1); |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Add the function that calls the class. |
38 | 38 | */ |
39 | 39 | if(!function_exists('aui')){ |
40 | - function aui(){ |
|
41 | - if(!class_exists("AUI",false)){ |
|
42 | - return false; |
|
43 | - } |
|
44 | - return AUI::instance(); |
|
45 | - } |
|
40 | + function aui(){ |
|
41 | + if(!class_exists("AUI",false)){ |
|
42 | + return false; |
|
43 | + } |
|
44 | + return AUI::instance(); |
|
45 | + } |
|
46 | 46 | } |
47 | 47 | \ No newline at end of file |
@@ -6,39 +6,39 @@ |
||
6 | 6 | /** |
7 | 7 | * Bail if we are not in WP. |
8 | 8 | */ |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if (!defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Set the version only if its the current newest while loading. |
15 | 15 | */ |
16 | -add_action('after_setup_theme', function () { |
|
17 | - global $ayecode_ui_version,$ayecode_ui_file_key; |
|
16 | +add_action('after_setup_theme', function() { |
|
17 | + global $ayecode_ui_version, $ayecode_ui_file_key; |
|
18 | 18 | $this_version = "0.1.70"; |
19 | - if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){ |
|
20 | - $ayecode_ui_version = $this_version ; |
|
21 | - $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
19 | + if (empty($ayecode_ui_version) || version_compare($this_version, $ayecode_ui_version, '>')) { |
|
20 | + $ayecode_ui_version = $this_version; |
|
21 | + $ayecode_ui_file_key = wp_hash(__FILE__); |
|
22 | 22 | } |
23 | 23 | },0); |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Load this version of WP Bootstrap Settings only if the file hash is the current one. |
27 | 27 | */ |
28 | -add_action('after_setup_theme', function () { |
|
28 | +add_action('after_setup_theme', function() { |
|
29 | 29 | global $ayecode_ui_file_key; |
30 | - if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
31 | - include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
32 | - include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
30 | + if ($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash(__FILE__)) { |
|
31 | + include_once(dirname(__FILE__) . '/includes/class-aui.php'); |
|
32 | + include_once(dirname(__FILE__) . '/includes/ayecode-ui-settings.php'); |
|
33 | 33 | } |
34 | 34 | },1); |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Add the function that calls the class. |
38 | 38 | */ |
39 | -if(!function_exists('aui')){ |
|
40 | - function aui(){ |
|
41 | - if(!class_exists("AUI",false)){ |
|
39 | +if (!function_exists('aui')) { |
|
40 | + function aui() { |
|
41 | + if (!class_exists("AUI", false)) { |
|
42 | 42 | return false; |
43 | 43 | } |
44 | 44 | return AUI::instance(); |
@@ -14,143 +14,143 @@ discard block |
||
14 | 14 | */ |
15 | 15 | class WPInv_Subscriptions_Widget extends WP_Super_Duper { |
16 | 16 | |
17 | - /** |
|
18 | - * Register the widget with WordPress. |
|
19 | - * |
|
20 | - */ |
|
21 | - public function __construct() { |
|
22 | - |
|
23 | - $options = array( |
|
24 | - 'textdomain' => 'invoicing', |
|
25 | - 'block-icon' => 'controls-repeat', |
|
26 | - 'block-category' => 'widgets', |
|
27 | - 'block-keywords' => "['invoicing','subscriptions', 'getpaid']", |
|
28 | - 'class_name' => __CLASS__, |
|
29 | - 'base_id' => 'wpinv_subscriptions', |
|
30 | - 'name' => __( 'GetPaid > Subscriptions', 'invoicing' ), |
|
31 | - 'widget_ops' => array( |
|
32 | - 'classname' => 'getpaid-subscriptions bsui', |
|
33 | - 'description' => esc_html__( "Displays the current user's subscriptions.", 'invoicing' ), |
|
34 | - ), |
|
35 | - 'arguments' => array( |
|
36 | - 'title' => array( |
|
37 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
38 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
39 | - 'type' => 'text', |
|
40 | - 'desc_tip' => true, |
|
41 | - 'default' => '', |
|
42 | - 'advanced' => false, |
|
43 | - ), |
|
44 | - ), |
|
45 | - |
|
46 | - ); |
|
47 | - |
|
48 | - parent::__construct( $options ); |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * Retrieves current user's subscriptions. |
|
53 | - * |
|
54 | - * @return GetPaid_Subscriptions_Query |
|
55 | - */ |
|
56 | - public function get_subscriptions() { |
|
57 | - |
|
58 | - // Prepare license args. |
|
59 | - $args = array( |
|
60 | - 'customer_in' => get_current_user_id(), |
|
61 | - 'paged' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
62 | - ); |
|
63 | - |
|
64 | - return new GetPaid_Subscriptions_Query( $args ); |
|
65 | - |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * The Super block output function. |
|
70 | - * |
|
71 | - * @param array $args |
|
72 | - * @param array $widget_args |
|
73 | - * @param string $content |
|
74 | - * |
|
75 | - * @return mixed|string|bool |
|
76 | - */ |
|
77 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
78 | - |
|
79 | - // Ensure that the user is logged in. |
|
80 | - if ( ! is_user_logged_in() ) { |
|
81 | - |
|
82 | - return aui()->alert( |
|
83 | - array( |
|
84 | - 'content' => wp_kses_post( __( 'You need to log-in or create an account to view this section.', 'invoicing' ) ), |
|
85 | - 'type' => 'error', |
|
86 | - ) |
|
87 | - ); |
|
88 | - |
|
89 | - } |
|
90 | - |
|
91 | - // Are we displaying a single subscription? |
|
92 | - if ( isset( $_GET['subscription'] ) ) { |
|
93 | - return $this->display_single_subscription( intval( $_GET['subscription'] ) ); |
|
94 | - } |
|
95 | - |
|
96 | - // Retrieve the user's subscriptions. |
|
97 | - $subscriptions = $this->get_subscriptions(); |
|
98 | - |
|
99 | - // Start the output buffer. |
|
100 | - ob_start(); |
|
101 | - |
|
102 | - // Backwards compatibility. |
|
103 | - do_action( 'wpinv_before_user_subscriptions' ); |
|
104 | - |
|
105 | - // Display errors and notices. |
|
106 | - wpinv_print_errors(); |
|
107 | - |
|
108 | - do_action( 'getpaid_license_manager_before_subscriptions', $subscriptions ); |
|
109 | - |
|
110 | - // Print the table header. |
|
111 | - $this->print_table_header(); |
|
112 | - |
|
113 | - // Print table body. |
|
114 | - $this->print_table_body( $subscriptions->get_results() ); |
|
115 | - |
|
116 | - // Print table footer. |
|
117 | - $this->print_table_footer(); |
|
118 | - |
|
119 | - // Print the navigation. |
|
120 | - $this->print_navigation( $subscriptions->get_total() ); |
|
121 | - |
|
122 | - // Backwards compatibility. |
|
123 | - do_action( 'wpinv_after_user_subscriptions' ); |
|
124 | - |
|
125 | - // Return the output. |
|
126 | - return ob_get_clean(); |
|
127 | - |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * Retrieves the subscription columns. |
|
132 | - * |
|
133 | - * @return array |
|
134 | - */ |
|
135 | - public function get_subscriptions_table_columns() { |
|
17 | + /** |
|
18 | + * Register the widget with WordPress. |
|
19 | + * |
|
20 | + */ |
|
21 | + public function __construct() { |
|
22 | + |
|
23 | + $options = array( |
|
24 | + 'textdomain' => 'invoicing', |
|
25 | + 'block-icon' => 'controls-repeat', |
|
26 | + 'block-category' => 'widgets', |
|
27 | + 'block-keywords' => "['invoicing','subscriptions', 'getpaid']", |
|
28 | + 'class_name' => __CLASS__, |
|
29 | + 'base_id' => 'wpinv_subscriptions', |
|
30 | + 'name' => __( 'GetPaid > Subscriptions', 'invoicing' ), |
|
31 | + 'widget_ops' => array( |
|
32 | + 'classname' => 'getpaid-subscriptions bsui', |
|
33 | + 'description' => esc_html__( "Displays the current user's subscriptions.", 'invoicing' ), |
|
34 | + ), |
|
35 | + 'arguments' => array( |
|
36 | + 'title' => array( |
|
37 | + 'title' => __( 'Widget title', 'invoicing' ), |
|
38 | + 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
39 | + 'type' => 'text', |
|
40 | + 'desc_tip' => true, |
|
41 | + 'default' => '', |
|
42 | + 'advanced' => false, |
|
43 | + ), |
|
44 | + ), |
|
45 | + |
|
46 | + ); |
|
47 | + |
|
48 | + parent::__construct( $options ); |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * Retrieves current user's subscriptions. |
|
53 | + * |
|
54 | + * @return GetPaid_Subscriptions_Query |
|
55 | + */ |
|
56 | + public function get_subscriptions() { |
|
57 | + |
|
58 | + // Prepare license args. |
|
59 | + $args = array( |
|
60 | + 'customer_in' => get_current_user_id(), |
|
61 | + 'paged' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
62 | + ); |
|
63 | + |
|
64 | + return new GetPaid_Subscriptions_Query( $args ); |
|
65 | + |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * The Super block output function. |
|
70 | + * |
|
71 | + * @param array $args |
|
72 | + * @param array $widget_args |
|
73 | + * @param string $content |
|
74 | + * |
|
75 | + * @return mixed|string|bool |
|
76 | + */ |
|
77 | + public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
78 | + |
|
79 | + // Ensure that the user is logged in. |
|
80 | + if ( ! is_user_logged_in() ) { |
|
81 | + |
|
82 | + return aui()->alert( |
|
83 | + array( |
|
84 | + 'content' => wp_kses_post( __( 'You need to log-in or create an account to view this section.', 'invoicing' ) ), |
|
85 | + 'type' => 'error', |
|
86 | + ) |
|
87 | + ); |
|
88 | + |
|
89 | + } |
|
90 | + |
|
91 | + // Are we displaying a single subscription? |
|
92 | + if ( isset( $_GET['subscription'] ) ) { |
|
93 | + return $this->display_single_subscription( intval( $_GET['subscription'] ) ); |
|
94 | + } |
|
95 | + |
|
96 | + // Retrieve the user's subscriptions. |
|
97 | + $subscriptions = $this->get_subscriptions(); |
|
98 | + |
|
99 | + // Start the output buffer. |
|
100 | + ob_start(); |
|
101 | + |
|
102 | + // Backwards compatibility. |
|
103 | + do_action( 'wpinv_before_user_subscriptions' ); |
|
104 | + |
|
105 | + // Display errors and notices. |
|
106 | + wpinv_print_errors(); |
|
107 | + |
|
108 | + do_action( 'getpaid_license_manager_before_subscriptions', $subscriptions ); |
|
109 | + |
|
110 | + // Print the table header. |
|
111 | + $this->print_table_header(); |
|
112 | + |
|
113 | + // Print table body. |
|
114 | + $this->print_table_body( $subscriptions->get_results() ); |
|
115 | + |
|
116 | + // Print table footer. |
|
117 | + $this->print_table_footer(); |
|
118 | + |
|
119 | + // Print the navigation. |
|
120 | + $this->print_navigation( $subscriptions->get_total() ); |
|
121 | + |
|
122 | + // Backwards compatibility. |
|
123 | + do_action( 'wpinv_after_user_subscriptions' ); |
|
124 | + |
|
125 | + // Return the output. |
|
126 | + return ob_get_clean(); |
|
127 | + |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * Retrieves the subscription columns. |
|
132 | + * |
|
133 | + * @return array |
|
134 | + */ |
|
135 | + public function get_subscriptions_table_columns() { |
|
136 | 136 | |
137 | - $columns = array( |
|
138 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
139 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
140 | - 'renewal-date' => __( 'Next payment', 'invoicing' ), |
|
141 | - 'status' => __( 'Status', 'invoicing' ), |
|
142 | - ); |
|
137 | + $columns = array( |
|
138 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
139 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
140 | + 'renewal-date' => __( 'Next payment', 'invoicing' ), |
|
141 | + 'status' => __( 'Status', 'invoicing' ), |
|
142 | + ); |
|
143 | 143 | |
144 | - return apply_filters( 'getpaid_frontend_subscriptions_table_columns', $columns ); |
|
145 | - } |
|
144 | + return apply_filters( 'getpaid_frontend_subscriptions_table_columns', $columns ); |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * Displays the table header. |
|
149 | - * |
|
150 | - */ |
|
151 | - public function print_table_header() { |
|
147 | + /** |
|
148 | + * Displays the table header. |
|
149 | + * |
|
150 | + */ |
|
151 | + public function print_table_header() { |
|
152 | 152 | |
153 | - ?> |
|
153 | + ?> |
|
154 | 154 | |
155 | 155 | <table class="table table-bordered table-striped"> |
156 | 156 | |
@@ -166,122 +166,122 @@ discard block |
||
166 | 166 | |
167 | 167 | <?php |
168 | 168 | |
169 | - } |
|
169 | + } |
|
170 | 170 | |
171 | - /** |
|
172 | - * Displays the table body. |
|
173 | - * |
|
174 | - * @param WPInv_Subscription[] $subscriptions |
|
175 | - */ |
|
176 | - public function print_table_body( $subscriptions ) { |
|
171 | + /** |
|
172 | + * Displays the table body. |
|
173 | + * |
|
174 | + * @param WPInv_Subscription[] $subscriptions |
|
175 | + */ |
|
176 | + public function print_table_body( $subscriptions ) { |
|
177 | 177 | |
178 | - if ( empty( $subscriptions ) ) { |
|
179 | - $this->print_table_body_no_subscriptions(); |
|
180 | - } else { |
|
181 | - $this->print_table_body_subscriptions( $subscriptions ); |
|
182 | - } |
|
178 | + if ( empty( $subscriptions ) ) { |
|
179 | + $this->print_table_body_no_subscriptions(); |
|
180 | + } else { |
|
181 | + $this->print_table_body_subscriptions( $subscriptions ); |
|
182 | + } |
|
183 | 183 | |
184 | - } |
|
184 | + } |
|
185 | 185 | |
186 | - /** |
|
187 | - * Displays the table body if no subscriptions were found. |
|
188 | - * |
|
189 | - */ |
|
190 | - public function print_table_body_no_subscriptions() { |
|
186 | + /** |
|
187 | + * Displays the table body if no subscriptions were found. |
|
188 | + * |
|
189 | + */ |
|
190 | + public function print_table_body_no_subscriptions() { |
|
191 | 191 | |
192 | - ?> |
|
192 | + ?> |
|
193 | 193 | <tbody> |
194 | 194 | |
195 | 195 | <tr> |
196 | 196 | <td colspan="<?php echo count( $this->get_subscriptions_table_columns() ); ?>"> |
197 | 197 | |
198 | 198 | <?php |
199 | - aui()->alert( |
|
200 | - array( |
|
201 | - 'content' => wp_kses_post( __( 'No subscriptions found.', 'invoicing' ) ), |
|
202 | - 'type' => 'warning', |
|
203 | - ), |
|
199 | + aui()->alert( |
|
200 | + array( |
|
201 | + 'content' => wp_kses_post( __( 'No subscriptions found.', 'invoicing' ) ), |
|
202 | + 'type' => 'warning', |
|
203 | + ), |
|
204 | 204 | true |
205 | - ); |
|
206 | - ?> |
|
205 | + ); |
|
206 | + ?> |
|
207 | 207 | |
208 | 208 | </td> |
209 | 209 | </tr> |
210 | 210 | |
211 | 211 | </tbody> |
212 | 212 | <?php |
213 | - } |
|
213 | + } |
|
214 | 214 | |
215 | - /** |
|
216 | - * Displays the table body if subscriptions were found. |
|
217 | - * |
|
218 | - * @param WPInv_Subscription[] $subscriptions |
|
219 | - */ |
|
220 | - public function print_table_body_subscriptions( $subscriptions ) { |
|
215 | + /** |
|
216 | + * Displays the table body if subscriptions were found. |
|
217 | + * |
|
218 | + * @param WPInv_Subscription[] $subscriptions |
|
219 | + */ |
|
220 | + public function print_table_body_subscriptions( $subscriptions ) { |
|
221 | 221 | |
222 | - ?> |
|
222 | + ?> |
|
223 | 223 | <tbody> |
224 | 224 | |
225 | 225 | <?php foreach ( $subscriptions as $subscription ) : ?> |
226 | 226 | <tr class="getpaid-subscriptions-table-row subscription-<?php echo (int) $subscription->get_id(); ?>"> |
227 | 227 | <?php |
228 | - wpinv_get_template( |
|
229 | - 'subscriptions/subscriptions-table-row.php', |
|
230 | - array( |
|
231 | - 'subscription' => $subscription, |
|
232 | - 'widget' => $this, |
|
233 | - ) |
|
234 | - ); |
|
235 | - ?> |
|
228 | + wpinv_get_template( |
|
229 | + 'subscriptions/subscriptions-table-row.php', |
|
230 | + array( |
|
231 | + 'subscription' => $subscription, |
|
232 | + 'widget' => $this, |
|
233 | + ) |
|
234 | + ); |
|
235 | + ?> |
|
236 | 236 | </tr> |
237 | 237 | <?php endforeach; ?> |
238 | 238 | |
239 | 239 | </tbody> |
240 | 240 | <?php |
241 | - } |
|
242 | - |
|
243 | - /** |
|
244 | - * Adds row actions to a column |
|
245 | - * |
|
246 | - * @param string $content column content |
|
247 | - * @param WPInv_Subscription $subscription |
|
248 | - * @since 1.0.0 |
|
249 | - * @return string |
|
250 | - */ |
|
251 | - public function add_row_actions( $content, $subscription ) { |
|
252 | - |
|
253 | - // Prepare row actions. |
|
254 | - $actions = array(); |
|
255 | - |
|
256 | - // View subscription action. |
|
257 | - $view_url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
258 | - $view_url = esc_url( add_query_arg( 'subscription', (int) $subscription->get_id(), $view_url ) ); |
|
259 | - $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
260 | - |
|
261 | - // Filter the actions. |
|
262 | - $actions = apply_filters( 'getpaid_subscriptions_table_subscription_actions', $actions, $subscription ); |
|
263 | - |
|
264 | - $sanitized = array(); |
|
265 | - foreach ( $actions as $key => $action ) { |
|
266 | - $key = sanitize_html_class( $key ); |
|
267 | - $action = wp_kses_post( $action ); |
|
268 | - $sanitized[] = "<span class='$key'>$action</span>"; |
|
269 | - } |
|
270 | - |
|
271 | - $row_actions = "<small class='form-text getpaid-subscription-item-actions'>"; |
|
272 | - $row_actions .= implode( ' | ', $sanitized ); |
|
273 | - $row_actions .= '</small>'; |
|
274 | - |
|
275 | - return $content . $row_actions; |
|
276 | - } |
|
277 | - |
|
278 | - /** |
|
279 | - * Displays the table footer. |
|
280 | - * |
|
281 | - */ |
|
282 | - public function print_table_footer() { |
|
283 | - |
|
284 | - ?> |
|
241 | + } |
|
242 | + |
|
243 | + /** |
|
244 | + * Adds row actions to a column |
|
245 | + * |
|
246 | + * @param string $content column content |
|
247 | + * @param WPInv_Subscription $subscription |
|
248 | + * @since 1.0.0 |
|
249 | + * @return string |
|
250 | + */ |
|
251 | + public function add_row_actions( $content, $subscription ) { |
|
252 | + |
|
253 | + // Prepare row actions. |
|
254 | + $actions = array(); |
|
255 | + |
|
256 | + // View subscription action. |
|
257 | + $view_url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
258 | + $view_url = esc_url( add_query_arg( 'subscription', (int) $subscription->get_id(), $view_url ) ); |
|
259 | + $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
260 | + |
|
261 | + // Filter the actions. |
|
262 | + $actions = apply_filters( 'getpaid_subscriptions_table_subscription_actions', $actions, $subscription ); |
|
263 | + |
|
264 | + $sanitized = array(); |
|
265 | + foreach ( $actions as $key => $action ) { |
|
266 | + $key = sanitize_html_class( $key ); |
|
267 | + $action = wp_kses_post( $action ); |
|
268 | + $sanitized[] = "<span class='$key'>$action</span>"; |
|
269 | + } |
|
270 | + |
|
271 | + $row_actions = "<small class='form-text getpaid-subscription-item-actions'>"; |
|
272 | + $row_actions .= implode( ' | ', $sanitized ); |
|
273 | + $row_actions .= '</small>'; |
|
274 | + |
|
275 | + return $content . $row_actions; |
|
276 | + } |
|
277 | + |
|
278 | + /** |
|
279 | + * Displays the table footer. |
|
280 | + * |
|
281 | + */ |
|
282 | + public function print_table_footer() { |
|
283 | + |
|
284 | + ?> |
|
285 | 285 | |
286 | 286 | <tfoot> |
287 | 287 | <tr> |
@@ -296,144 +296,144 @@ discard block |
||
296 | 296 | </table> |
297 | 297 | <?php |
298 | 298 | |
299 | - } |
|
299 | + } |
|
300 | 300 | |
301 | - /** |
|
302 | - * Displays the navigation. |
|
303 | - * |
|
304 | - * @param int $total |
|
305 | - */ |
|
306 | - public function print_navigation( $total ) { |
|
301 | + /** |
|
302 | + * Displays the navigation. |
|
303 | + * |
|
304 | + * @param int $total |
|
305 | + */ |
|
306 | + public function print_navigation( $total ) { |
|
307 | 307 | |
308 | - if ( $total < 1 ) { |
|
308 | + if ( $total < 1 ) { |
|
309 | 309 | |
310 | - // Out-of-bounds, run the query again without LIMIT for total count. |
|
311 | - $args = array( |
|
312 | - 'customer_in' => get_current_user_id(), |
|
313 | - 'fields' => 'id', |
|
314 | - ); |
|
310 | + // Out-of-bounds, run the query again without LIMIT for total count. |
|
311 | + $args = array( |
|
312 | + 'customer_in' => get_current_user_id(), |
|
313 | + 'fields' => 'id', |
|
314 | + ); |
|
315 | 315 | |
316 | - $count_query = new GetPaid_Subscriptions_Query( $args ); |
|
317 | - $total = $count_query->get_total(); |
|
318 | - } |
|
316 | + $count_query = new GetPaid_Subscriptions_Query( $args ); |
|
317 | + $total = $count_query->get_total(); |
|
318 | + } |
|
319 | 319 | |
320 | - // Abort if we do not have pages. |
|
321 | - if ( 2 > $total ) { |
|
322 | - return; |
|
323 | - } |
|
320 | + // Abort if we do not have pages. |
|
321 | + if ( 2 > $total ) { |
|
322 | + return; |
|
323 | + } |
|
324 | 324 | |
325 | - ?> |
|
325 | + ?> |
|
326 | 326 | |
327 | 327 | <div class="getpaid-subscriptions-pagination"> |
328 | 328 | <?php |
329 | - $big = 999999; |
|
330 | - |
|
331 | - echo wp_kses_post( |
|
332 | - getpaid_paginate_links( |
|
333 | - array( |
|
334 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
335 | - 'format' => '?paged=%#%', |
|
336 | - 'total' => (int) ceil( $total / 10 ), |
|
337 | - ) |
|
338 | - ) |
|
339 | - ); |
|
340 | - ?> |
|
329 | + $big = 999999; |
|
330 | + |
|
331 | + echo wp_kses_post( |
|
332 | + getpaid_paginate_links( |
|
333 | + array( |
|
334 | + 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
335 | + 'format' => '?paged=%#%', |
|
336 | + 'total' => (int) ceil( $total / 10 ), |
|
337 | + ) |
|
338 | + ) |
|
339 | + ); |
|
340 | + ?> |
|
341 | 341 | </div> |
342 | 342 | |
343 | 343 | <?php |
344 | - } |
|
345 | - |
|
346 | - /** |
|
347 | - * Returns a single subscription's columns. |
|
348 | - * |
|
349 | - * @param WPInv_Subscription $subscription |
|
350 | - * |
|
351 | - * @return array |
|
352 | - */ |
|
353 | - public function get_single_subscription_columns( $subscription ) { |
|
354 | - |
|
355 | - // Prepare subscription detail columns. |
|
356 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
357 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
358 | - $fields = apply_filters( |
|
359 | - 'getpaid_single_subscription_details_fields', |
|
360 | - array( |
|
361 | - 'status' => __( 'Status', 'invoicing' ), |
|
362 | - 'initial_amount' => __( 'Initial amount', 'invoicing' ), |
|
363 | - 'recurring_amount' => __( 'Recurring amount', 'invoicing' ), |
|
364 | - 'start_date' => __( 'Start date', 'invoicing' ), |
|
365 | - 'expiry_date' => __( 'Next payment', 'invoicing' ), |
|
366 | - 'payments' => __( 'Payments', 'invoicing' ), |
|
367 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
368 | - ), |
|
369 | - $subscription |
|
370 | - ); |
|
371 | - |
|
372 | - if ( isset( $fields['expiry_date'] ) ) { |
|
373 | - |
|
374 | - if ( ! $subscription->is_active() || $subscription->is_last_renewal() ) { |
|
375 | - $fields['expiry_date'] = __( 'End date', 'invoicing' ); |
|
376 | - } |
|
377 | - |
|
378 | - if ( 'pending' == $subscription->get_status() ) { |
|
379 | - unset( $fields['expiry_date'] ); |
|
380 | - } |
|
344 | + } |
|
345 | + |
|
346 | + /** |
|
347 | + * Returns a single subscription's columns. |
|
348 | + * |
|
349 | + * @param WPInv_Subscription $subscription |
|
350 | + * |
|
351 | + * @return array |
|
352 | + */ |
|
353 | + public function get_single_subscription_columns( $subscription ) { |
|
354 | + |
|
355 | + // Prepare subscription detail columns. |
|
356 | + $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
357 | + $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
358 | + $fields = apply_filters( |
|
359 | + 'getpaid_single_subscription_details_fields', |
|
360 | + array( |
|
361 | + 'status' => __( 'Status', 'invoicing' ), |
|
362 | + 'initial_amount' => __( 'Initial amount', 'invoicing' ), |
|
363 | + 'recurring_amount' => __( 'Recurring amount', 'invoicing' ), |
|
364 | + 'start_date' => __( 'Start date', 'invoicing' ), |
|
365 | + 'expiry_date' => __( 'Next payment', 'invoicing' ), |
|
366 | + 'payments' => __( 'Payments', 'invoicing' ), |
|
367 | + 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
368 | + ), |
|
369 | + $subscription |
|
370 | + ); |
|
371 | + |
|
372 | + if ( isset( $fields['expiry_date'] ) ) { |
|
373 | + |
|
374 | + if ( ! $subscription->is_active() || $subscription->is_last_renewal() ) { |
|
375 | + $fields['expiry_date'] = __( 'End date', 'invoicing' ); |
|
376 | + } |
|
377 | + |
|
378 | + if ( 'pending' == $subscription->get_status() ) { |
|
379 | + unset( $fields['expiry_date'] ); |
|
380 | + } |
|
381 | 381 | } |
382 | 382 | |
383 | - if ( isset( $fields['start_date'] ) && 'pending' == $subscription->get_status() ) { |
|
384 | - unset( $fields['start_date'] ); |
|
385 | - } |
|
386 | - |
|
387 | - if ( $subscription->get_initial_amount() == $subscription->get_recurring_amount() ) { |
|
388 | - unset( $fields['initial_amount'] ); |
|
389 | - } |
|
390 | - |
|
391 | - return $fields; |
|
392 | - } |
|
393 | - |
|
394 | - /** |
|
395 | - * Displays a single subscription. |
|
396 | - * |
|
397 | - * @param string $subscription |
|
398 | - * |
|
399 | - * @return string |
|
400 | - */ |
|
401 | - public function display_single_subscription( $subscription ) { |
|
402 | - |
|
403 | - // Fetch the subscription. |
|
404 | - $subscription = new WPInv_Subscription( (int) $subscription ); |
|
405 | - |
|
406 | - if ( ! $subscription->exists() ) { |
|
407 | - |
|
408 | - return aui()->alert( |
|
409 | - array( |
|
410 | - 'content' => wp_kses_post( __( 'Subscription not found.', 'invoicing' ) ), |
|
411 | - 'type' => 'error', |
|
412 | - ) |
|
413 | - ); |
|
414 | - |
|
415 | - } |
|
416 | - |
|
417 | - // Ensure that the user owns this subscription key. |
|
418 | - if ( get_current_user_id() != $subscription->get_customer_id() && ! wpinv_current_user_can_manage_invoicing() ) { |
|
419 | - |
|
420 | - return aui()->alert( |
|
421 | - array( |
|
422 | - 'content' => wp_kses_post( __( 'You do not have permission to view this subscription. Ensure that you are logged in to the account that owns the subscription.', 'invoicing' ) ), |
|
423 | - 'type' => 'error', |
|
424 | - ) |
|
425 | - ); |
|
426 | - |
|
427 | - } |
|
428 | - |
|
429 | - return wpinv_get_template_html( |
|
430 | - 'subscriptions/subscription-details.php', |
|
431 | - array( |
|
432 | - 'subscription' => $subscription, |
|
433 | - 'widget' => $this, |
|
434 | - ) |
|
435 | - ); |
|
436 | - |
|
437 | - } |
|
383 | + if ( isset( $fields['start_date'] ) && 'pending' == $subscription->get_status() ) { |
|
384 | + unset( $fields['start_date'] ); |
|
385 | + } |
|
386 | + |
|
387 | + if ( $subscription->get_initial_amount() == $subscription->get_recurring_amount() ) { |
|
388 | + unset( $fields['initial_amount'] ); |
|
389 | + } |
|
390 | + |
|
391 | + return $fields; |
|
392 | + } |
|
393 | + |
|
394 | + /** |
|
395 | + * Displays a single subscription. |
|
396 | + * |
|
397 | + * @param string $subscription |
|
398 | + * |
|
399 | + * @return string |
|
400 | + */ |
|
401 | + public function display_single_subscription( $subscription ) { |
|
402 | + |
|
403 | + // Fetch the subscription. |
|
404 | + $subscription = new WPInv_Subscription( (int) $subscription ); |
|
405 | + |
|
406 | + if ( ! $subscription->exists() ) { |
|
407 | + |
|
408 | + return aui()->alert( |
|
409 | + array( |
|
410 | + 'content' => wp_kses_post( __( 'Subscription not found.', 'invoicing' ) ), |
|
411 | + 'type' => 'error', |
|
412 | + ) |
|
413 | + ); |
|
414 | + |
|
415 | + } |
|
416 | + |
|
417 | + // Ensure that the user owns this subscription key. |
|
418 | + if ( get_current_user_id() != $subscription->get_customer_id() && ! wpinv_current_user_can_manage_invoicing() ) { |
|
419 | + |
|
420 | + return aui()->alert( |
|
421 | + array( |
|
422 | + 'content' => wp_kses_post( __( 'You do not have permission to view this subscription. Ensure that you are logged in to the account that owns the subscription.', 'invoicing' ) ), |
|
423 | + 'type' => 'error', |
|
424 | + ) |
|
425 | + ); |
|
426 | + |
|
427 | + } |
|
428 | + |
|
429 | + return wpinv_get_template_html( |
|
430 | + 'subscriptions/subscription-details.php', |
|
431 | + array( |
|
432 | + 'subscription' => $subscription, |
|
433 | + 'widget' => $this, |
|
434 | + ) |
|
435 | + ); |
|
436 | + |
|
437 | + } |
|
438 | 438 | |
439 | 439 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * @version 1.0.0 |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Contains the subscriptions widget. |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | 'block-keywords' => "['invoicing','subscriptions', 'getpaid']", |
28 | 28 | 'class_name' => __CLASS__, |
29 | 29 | 'base_id' => 'wpinv_subscriptions', |
30 | - 'name' => __( 'GetPaid > Subscriptions', 'invoicing' ), |
|
30 | + 'name' => __('GetPaid > Subscriptions', 'invoicing'), |
|
31 | 31 | 'widget_ops' => array( |
32 | 32 | 'classname' => 'getpaid-subscriptions bsui', |
33 | - 'description' => esc_html__( "Displays the current user's subscriptions.", 'invoicing' ), |
|
33 | + 'description' => esc_html__("Displays the current user's subscriptions.", 'invoicing'), |
|
34 | 34 | ), |
35 | 35 | 'arguments' => array( |
36 | 36 | 'title' => array( |
37 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
38 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
37 | + 'title' => __('Widget title', 'invoicing'), |
|
38 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
39 | 39 | 'type' => 'text', |
40 | 40 | 'desc_tip' => true, |
41 | 41 | 'default' => '', |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | ); |
47 | 47 | |
48 | - parent::__construct( $options ); |
|
48 | + parent::__construct($options); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | public function get_subscriptions() { |
57 | 57 | |
58 | 58 | // Prepare license args. |
59 | - $args = array( |
|
59 | + $args = array( |
|
60 | 60 | 'customer_in' => get_current_user_id(), |
61 | - 'paged' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
61 | + 'paged' => (get_query_var('paged')) ? absint(get_query_var('paged')) : 1, |
|
62 | 62 | ); |
63 | 63 | |
64 | - return new GetPaid_Subscriptions_Query( $args ); |
|
64 | + return new GetPaid_Subscriptions_Query($args); |
|
65 | 65 | |
66 | 66 | } |
67 | 67 | |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @return mixed|string|bool |
76 | 76 | */ |
77 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
77 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
78 | 78 | |
79 | 79 | // Ensure that the user is logged in. |
80 | - if ( ! is_user_logged_in() ) { |
|
80 | + if (!is_user_logged_in()) { |
|
81 | 81 | |
82 | 82 | return aui()->alert( |
83 | 83 | array( |
84 | - 'content' => wp_kses_post( __( 'You need to log-in or create an account to view this section.', 'invoicing' ) ), |
|
84 | + 'content' => wp_kses_post(__('You need to log-in or create an account to view this section.', 'invoicing')), |
|
85 | 85 | 'type' => 'error', |
86 | 86 | ) |
87 | 87 | ); |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | // Are we displaying a single subscription? |
92 | - if ( isset( $_GET['subscription'] ) ) { |
|
93 | - return $this->display_single_subscription( intval( $_GET['subscription'] ) ); |
|
92 | + if (isset($_GET['subscription'])) { |
|
93 | + return $this->display_single_subscription(intval($_GET['subscription'])); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | // Retrieve the user's subscriptions. |
@@ -100,27 +100,27 @@ discard block |
||
100 | 100 | ob_start(); |
101 | 101 | |
102 | 102 | // Backwards compatibility. |
103 | - do_action( 'wpinv_before_user_subscriptions' ); |
|
103 | + do_action('wpinv_before_user_subscriptions'); |
|
104 | 104 | |
105 | 105 | // Display errors and notices. |
106 | 106 | wpinv_print_errors(); |
107 | 107 | |
108 | - do_action( 'getpaid_license_manager_before_subscriptions', $subscriptions ); |
|
108 | + do_action('getpaid_license_manager_before_subscriptions', $subscriptions); |
|
109 | 109 | |
110 | 110 | // Print the table header. |
111 | 111 | $this->print_table_header(); |
112 | 112 | |
113 | 113 | // Print table body. |
114 | - $this->print_table_body( $subscriptions->get_results() ); |
|
114 | + $this->print_table_body($subscriptions->get_results()); |
|
115 | 115 | |
116 | 116 | // Print table footer. |
117 | 117 | $this->print_table_footer(); |
118 | 118 | |
119 | 119 | // Print the navigation. |
120 | - $this->print_navigation( $subscriptions->get_total() ); |
|
120 | + $this->print_navigation($subscriptions->get_total()); |
|
121 | 121 | |
122 | 122 | // Backwards compatibility. |
123 | - do_action( 'wpinv_after_user_subscriptions' ); |
|
123 | + do_action('wpinv_after_user_subscriptions'); |
|
124 | 124 | |
125 | 125 | // Return the output. |
126 | 126 | return ob_get_clean(); |
@@ -135,13 +135,13 @@ discard block |
||
135 | 135 | public function get_subscriptions_table_columns() { |
136 | 136 | |
137 | 137 | $columns = array( |
138 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
139 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
140 | - 'renewal-date' => __( 'Next payment', 'invoicing' ), |
|
141 | - 'status' => __( 'Status', 'invoicing' ), |
|
138 | + 'subscription' => __('Subscription', 'invoicing'), |
|
139 | + 'amount' => __('Amount', 'invoicing'), |
|
140 | + 'renewal-date' => __('Next payment', 'invoicing'), |
|
141 | + 'status' => __('Status', 'invoicing'), |
|
142 | 142 | ); |
143 | 143 | |
144 | - return apply_filters( 'getpaid_frontend_subscriptions_table_columns', $columns ); |
|
144 | + return apply_filters('getpaid_frontend_subscriptions_table_columns', $columns); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | |
157 | 157 | <thead> |
158 | 158 | <tr> |
159 | - <?php foreach ( $this->get_subscriptions_table_columns() as $key => $label ) : ?> |
|
160 | - <th scope="col" class="font-weight-bold getpaid-subscriptions-table-<?php echo sanitize_html_class( $key ); ?>"> |
|
161 | - <?php echo esc_html( $label ); ?> |
|
159 | + <?php foreach ($this->get_subscriptions_table_columns() as $key => $label) : ?> |
|
160 | + <th scope="col" class="font-weight-bold getpaid-subscriptions-table-<?php echo sanitize_html_class($key); ?>"> |
|
161 | + <?php echo esc_html($label); ?> |
|
162 | 162 | </th> |
163 | 163 | <?php endforeach; ?> |
164 | 164 | </tr> |
@@ -173,12 +173,12 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @param WPInv_Subscription[] $subscriptions |
175 | 175 | */ |
176 | - public function print_table_body( $subscriptions ) { |
|
176 | + public function print_table_body($subscriptions) { |
|
177 | 177 | |
178 | - if ( empty( $subscriptions ) ) { |
|
178 | + if (empty($subscriptions)) { |
|
179 | 179 | $this->print_table_body_no_subscriptions(); |
180 | 180 | } else { |
181 | - $this->print_table_body_subscriptions( $subscriptions ); |
|
181 | + $this->print_table_body_subscriptions($subscriptions); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | } |
@@ -193,12 +193,12 @@ discard block |
||
193 | 193 | <tbody> |
194 | 194 | |
195 | 195 | <tr> |
196 | - <td colspan="<?php echo count( $this->get_subscriptions_table_columns() ); ?>"> |
|
196 | + <td colspan="<?php echo count($this->get_subscriptions_table_columns()); ?>"> |
|
197 | 197 | |
198 | 198 | <?php |
199 | 199 | aui()->alert( |
200 | 200 | array( |
201 | - 'content' => wp_kses_post( __( 'No subscriptions found.', 'invoicing' ) ), |
|
201 | + 'content' => wp_kses_post(__('No subscriptions found.', 'invoicing')), |
|
202 | 202 | 'type' => 'warning', |
203 | 203 | ), |
204 | 204 | true |
@@ -217,12 +217,12 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @param WPInv_Subscription[] $subscriptions |
219 | 219 | */ |
220 | - public function print_table_body_subscriptions( $subscriptions ) { |
|
220 | + public function print_table_body_subscriptions($subscriptions) { |
|
221 | 221 | |
222 | 222 | ?> |
223 | 223 | <tbody> |
224 | 224 | |
225 | - <?php foreach ( $subscriptions as $subscription ) : ?> |
|
225 | + <?php foreach ($subscriptions as $subscription) : ?> |
|
226 | 226 | <tr class="getpaid-subscriptions-table-row subscription-<?php echo (int) $subscription->get_id(); ?>"> |
227 | 227 | <?php |
228 | 228 | wpinv_get_template( |
@@ -248,28 +248,28 @@ discard block |
||
248 | 248 | * @since 1.0.0 |
249 | 249 | * @return string |
250 | 250 | */ |
251 | - public function add_row_actions( $content, $subscription ) { |
|
251 | + public function add_row_actions($content, $subscription) { |
|
252 | 252 | |
253 | 253 | // Prepare row actions. |
254 | 254 | $actions = array(); |
255 | 255 | |
256 | 256 | // View subscription action. |
257 | - $view_url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
258 | - $view_url = esc_url( add_query_arg( 'subscription', (int) $subscription->get_id(), $view_url ) ); |
|
259 | - $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
257 | + $view_url = getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page'))); |
|
258 | + $view_url = esc_url(add_query_arg('subscription', (int) $subscription->get_id(), $view_url)); |
|
259 | + $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __('Manage Subscription', 'invoicing') . '</a>'; |
|
260 | 260 | |
261 | 261 | // Filter the actions. |
262 | - $actions = apply_filters( 'getpaid_subscriptions_table_subscription_actions', $actions, $subscription ); |
|
262 | + $actions = apply_filters('getpaid_subscriptions_table_subscription_actions', $actions, $subscription); |
|
263 | 263 | |
264 | - $sanitized = array(); |
|
265 | - foreach ( $actions as $key => $action ) { |
|
266 | - $key = sanitize_html_class( $key ); |
|
267 | - $action = wp_kses_post( $action ); |
|
264 | + $sanitized = array(); |
|
265 | + foreach ($actions as $key => $action) { |
|
266 | + $key = sanitize_html_class($key); |
|
267 | + $action = wp_kses_post($action); |
|
268 | 268 | $sanitized[] = "<span class='$key'>$action</span>"; |
269 | 269 | } |
270 | 270 | |
271 | 271 | $row_actions = "<small class='form-text getpaid-subscription-item-actions'>"; |
272 | - $row_actions .= implode( ' | ', $sanitized ); |
|
272 | + $row_actions .= implode(' | ', $sanitized); |
|
273 | 273 | $row_actions .= '</small>'; |
274 | 274 | |
275 | 275 | return $content . $row_actions; |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | |
286 | 286 | <tfoot> |
287 | 287 | <tr> |
288 | - <?php foreach ( $this->get_subscriptions_table_columns() as $key => $label ) : ?> |
|
289 | - <th class="font-weight-bold getpaid-subscriptions-<?php echo sanitize_html_class( $key ); ?>"> |
|
290 | - <?php echo esc_html( $label ); ?> |
|
288 | + <?php foreach ($this->get_subscriptions_table_columns() as $key => $label) : ?> |
|
289 | + <th class="font-weight-bold getpaid-subscriptions-<?php echo sanitize_html_class($key); ?>"> |
|
290 | + <?php echo esc_html($label); ?> |
|
291 | 291 | </th> |
292 | 292 | <?php endforeach; ?> |
293 | 293 | </tr> |
@@ -303,22 +303,22 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @param int $total |
305 | 305 | */ |
306 | - public function print_navigation( $total ) { |
|
306 | + public function print_navigation($total) { |
|
307 | 307 | |
308 | - if ( $total < 1 ) { |
|
308 | + if ($total < 1) { |
|
309 | 309 | |
310 | 310 | // Out-of-bounds, run the query again without LIMIT for total count. |
311 | - $args = array( |
|
311 | + $args = array( |
|
312 | 312 | 'customer_in' => get_current_user_id(), |
313 | 313 | 'fields' => 'id', |
314 | 314 | ); |
315 | 315 | |
316 | - $count_query = new GetPaid_Subscriptions_Query( $args ); |
|
316 | + $count_query = new GetPaid_Subscriptions_Query($args); |
|
317 | 317 | $total = $count_query->get_total(); |
318 | 318 | } |
319 | 319 | |
320 | 320 | // Abort if we do not have pages. |
321 | - if ( 2 > $total ) { |
|
321 | + if (2 > $total) { |
|
322 | 322 | return; |
323 | 323 | } |
324 | 324 | |
@@ -331,9 +331,9 @@ discard block |
||
331 | 331 | echo wp_kses_post( |
332 | 332 | getpaid_paginate_links( |
333 | 333 | array( |
334 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
334 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
335 | 335 | 'format' => '?paged=%#%', |
336 | - 'total' => (int) ceil( $total / 10 ), |
|
336 | + 'total' => (int) ceil($total / 10), |
|
337 | 337 | ) |
338 | 338 | ) |
339 | 339 | ); |
@@ -350,42 +350,42 @@ discard block |
||
350 | 350 | * |
351 | 351 | * @return array |
352 | 352 | */ |
353 | - public function get_single_subscription_columns( $subscription ) { |
|
353 | + public function get_single_subscription_columns($subscription) { |
|
354 | 354 | |
355 | 355 | // Prepare subscription detail columns. |
356 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
357 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
356 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_invoice_id(), $subscription->get_id()); |
|
357 | + $items_count = empty($subscription_group) ? 1 : count($subscription_group['items']); |
|
358 | 358 | $fields = apply_filters( |
359 | 359 | 'getpaid_single_subscription_details_fields', |
360 | 360 | array( |
361 | - 'status' => __( 'Status', 'invoicing' ), |
|
362 | - 'initial_amount' => __( 'Initial amount', 'invoicing' ), |
|
363 | - 'recurring_amount' => __( 'Recurring amount', 'invoicing' ), |
|
364 | - 'start_date' => __( 'Start date', 'invoicing' ), |
|
365 | - 'expiry_date' => __( 'Next payment', 'invoicing' ), |
|
366 | - 'payments' => __( 'Payments', 'invoicing' ), |
|
367 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
361 | + 'status' => __('Status', 'invoicing'), |
|
362 | + 'initial_amount' => __('Initial amount', 'invoicing'), |
|
363 | + 'recurring_amount' => __('Recurring amount', 'invoicing'), |
|
364 | + 'start_date' => __('Start date', 'invoicing'), |
|
365 | + 'expiry_date' => __('Next payment', 'invoicing'), |
|
366 | + 'payments' => __('Payments', 'invoicing'), |
|
367 | + 'item' => _n('Item', 'Items', $items_count, 'invoicing'), |
|
368 | 368 | ), |
369 | 369 | $subscription |
370 | 370 | ); |
371 | 371 | |
372 | - if ( isset( $fields['expiry_date'] ) ) { |
|
372 | + if (isset($fields['expiry_date'])) { |
|
373 | 373 | |
374 | - if ( ! $subscription->is_active() || $subscription->is_last_renewal() ) { |
|
375 | - $fields['expiry_date'] = __( 'End date', 'invoicing' ); |
|
374 | + if (!$subscription->is_active() || $subscription->is_last_renewal()) { |
|
375 | + $fields['expiry_date'] = __('End date', 'invoicing'); |
|
376 | 376 | } |
377 | 377 | |
378 | - if ( 'pending' == $subscription->get_status() ) { |
|
379 | - unset( $fields['expiry_date'] ); |
|
378 | + if ('pending' == $subscription->get_status()) { |
|
379 | + unset($fields['expiry_date']); |
|
380 | 380 | } |
381 | 381 | } |
382 | 382 | |
383 | - if ( isset( $fields['start_date'] ) && 'pending' == $subscription->get_status() ) { |
|
384 | - unset( $fields['start_date'] ); |
|
383 | + if (isset($fields['start_date']) && 'pending' == $subscription->get_status()) { |
|
384 | + unset($fields['start_date']); |
|
385 | 385 | } |
386 | 386 | |
387 | - if ( $subscription->get_initial_amount() == $subscription->get_recurring_amount() ) { |
|
388 | - unset( $fields['initial_amount'] ); |
|
387 | + if ($subscription->get_initial_amount() == $subscription->get_recurring_amount()) { |
|
388 | + unset($fields['initial_amount']); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | return $fields; |
@@ -398,16 +398,16 @@ discard block |
||
398 | 398 | * |
399 | 399 | * @return string |
400 | 400 | */ |
401 | - public function display_single_subscription( $subscription ) { |
|
401 | + public function display_single_subscription($subscription) { |
|
402 | 402 | |
403 | 403 | // Fetch the subscription. |
404 | - $subscription = new WPInv_Subscription( (int) $subscription ); |
|
404 | + $subscription = new WPInv_Subscription((int) $subscription); |
|
405 | 405 | |
406 | - if ( ! $subscription->exists() ) { |
|
406 | + if (!$subscription->exists()) { |
|
407 | 407 | |
408 | 408 | return aui()->alert( |
409 | 409 | array( |
410 | - 'content' => wp_kses_post( __( 'Subscription not found.', 'invoicing' ) ), |
|
410 | + 'content' => wp_kses_post(__('Subscription not found.', 'invoicing')), |
|
411 | 411 | 'type' => 'error', |
412 | 412 | ) |
413 | 413 | ); |
@@ -415,11 +415,11 @@ discard block |
||
415 | 415 | } |
416 | 416 | |
417 | 417 | // Ensure that the user owns this subscription key. |
418 | - if ( get_current_user_id() != $subscription->get_customer_id() && ! wpinv_current_user_can_manage_invoicing() ) { |
|
418 | + if (get_current_user_id() != $subscription->get_customer_id() && !wpinv_current_user_can_manage_invoicing()) { |
|
419 | 419 | |
420 | 420 | return aui()->alert( |
421 | 421 | array( |
422 | - 'content' => wp_kses_post( __( 'You do not have permission to view this subscription. Ensure that you are logged in to the account that owns the subscription.', 'invoicing' ) ), |
|
422 | + 'content' => wp_kses_post(__('You do not have permission to view this subscription. Ensure that you are logged in to the account that owns the subscription.', 'invoicing')), |
|
423 | 423 | 'type' => 'error', |
424 | 424 | ) |
425 | 425 | ); |
@@ -7,10 +7,10 @@ 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 ); |
|
13 | -$address_row = wpinv_get_invoice_address_markup( $invoice->get_user_info() ); |
|
12 | +$invoice = new WPInv_Invoice($invoice); |
|
13 | +$address_row = wpinv_get_invoice_address_markup($invoice->get_user_info()); |
|
14 | 14 | $phone = $invoice->get_phone(); |
15 | 15 | $email = $invoice->get_email(); |
16 | 16 | $vat_number = $invoice->get_vat_number(); |
@@ -22,47 +22,47 @@ discard block |
||
22 | 22 | |
23 | 23 | |
24 | 24 | <div class="invoice-billing-address-label col-2"> |
25 | - <strong><?php esc_html_e( 'To:', 'invoicing' ); ?></strong> |
|
25 | + <strong><?php esc_html_e('To:', 'invoicing'); ?></strong> |
|
26 | 26 | </div> |
27 | 27 | |
28 | 28 | |
29 | 29 | <div class="invoice-billing-address-value col-10"> |
30 | 30 | |
31 | - <?php do_action( 'getpaid_billing_address_top' ); ?> |
|
31 | + <?php do_action('getpaid_billing_address_top'); ?> |
|
32 | 32 | |
33 | - <?php if ( ! empty( $address_row ) ) : ?> |
|
33 | + <?php if (!empty($address_row)) : ?> |
|
34 | 34 | <div class="billing-address"> |
35 | - <?php echo wp_kses_post( $address_row ); ?> |
|
35 | + <?php echo wp_kses_post($address_row); ?> |
|
36 | 36 | </div> |
37 | 37 | <?php endif; ?> |
38 | 38 | |
39 | 39 | |
40 | - <?php if ( ! empty( $phone ) ) : ?> |
|
40 | + <?php if (!empty($phone)) : ?> |
|
41 | 41 | <div class="billing-phone"> |
42 | - <?php echo wp_sprintf( esc_html__( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ); ?> |
|
42 | + <?php echo wp_sprintf(esc_html__('Phone: %s', 'invoicing'), esc_html($phone)); ?> |
|
43 | 43 | </div> |
44 | 44 | <?php endif; ?> |
45 | 45 | |
46 | 46 | |
47 | - <?php if ( ! empty( $email ) ) : ?> |
|
47 | + <?php if (!empty($email)) : ?> |
|
48 | 48 | <div class="billing-email"> |
49 | - <?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), sanitize_email( $email ) ); ?> |
|
49 | + <?php echo wp_sprintf(__('Email: %s', 'invoicing'), sanitize_email($email)); ?> |
|
50 | 50 | </div> |
51 | 51 | <?php endif; ?> |
52 | 52 | |
53 | - <?php if ( ! empty( $vat_number ) ) : ?> |
|
53 | + <?php if (!empty($vat_number)) : ?> |
|
54 | 54 | <div class="vat-number"> |
55 | - <?php echo wp_sprintf( __( 'Vat Number: %s', 'invoicing' ), esc_html( $vat_number ) ); ?> |
|
55 | + <?php echo wp_sprintf(__('Vat Number: %s', 'invoicing'), esc_html($vat_number)); ?> |
|
56 | 56 | </div> |
57 | 57 | <?php endif; ?> |
58 | 58 | |
59 | - <?php if ( ! empty( $company_id ) ) : ?> |
|
59 | + <?php if (!empty($company_id)) : ?> |
|
60 | 60 | <div class="company-id"> |
61 | - <?php echo wp_sprintf( __( 'Company ID: %s', 'invoicing' ), esc_html( $company_id ) ); ?> |
|
61 | + <?php echo wp_sprintf(__('Company ID: %s', 'invoicing'), esc_html($company_id)); ?> |
|
62 | 62 | </div> |
63 | 63 | <?php endif; ?> |
64 | 64 | |
65 | - <?php do_action( 'getpaid_billing_address_bottom' ); ?> |
|
65 | + <?php do_action('getpaid_billing_address_bottom'); ?> |
|
66 | 66 | |
67 | 67 | </div> |
68 | 68 |