@@ -7,11 +7,11 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | // Fetch the invoice. |
| 13 | -if ( empty( $invoice ) ) { |
|
| 14 | - $invoice = new WPInv_Invoice( $GLOBALS['post'] ); |
|
| 13 | +if (empty($invoice)) { |
|
| 14 | + $invoice = new WPInv_Invoice($GLOBALS['post']); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | ?><!DOCTYPE html> |
@@ -21,16 +21,16 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | <head> |
| 23 | 23 | |
| 24 | - <meta charset="<?php bloginfo( 'charset' ); ?>"> |
|
| 24 | + <meta charset="<?php bloginfo('charset'); ?>"> |
|
| 25 | 25 | <meta name="viewport" content="width=device-width, initial-scale=1.0" > |
| 26 | 26 | |
| 27 | 27 | <meta name="robots" content="noindex,nofollow"> |
| 28 | 28 | |
| 29 | 29 | <link rel="profile" href="https://gmpg.org/xfn/11"> |
| 30 | 30 | |
| 31 | - <title><?php _e( 'Invalid Access', 'invoicing' ); ?></title> |
|
| 31 | + <title><?php _e('Invalid Access', 'invoicing'); ?></title> |
|
| 32 | 32 | |
| 33 | - <?php do_action( 'wpinv_invoice_print_head', $invoice ); ?> |
|
| 33 | + <?php do_action('wpinv_invoice_print_head', $invoice); ?> |
|
| 34 | 34 | |
| 35 | 35 | </head> |
| 36 | 36 | |
@@ -39,15 +39,15 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | <?php |
| 41 | 41 | |
| 42 | - if ( ! $invoice->exists() || $invoice->is_draft() ) { |
|
| 43 | - $error = __( 'This invoice was deleted or is not visible.', 'invoicing' ); |
|
| 42 | + if (!$invoice->exists() || $invoice->is_draft()) { |
|
| 43 | + $error = __('This invoice was deleted or is not visible.', 'invoicing'); |
|
| 44 | 44 | } else { |
| 45 | 45 | |
| 46 | 46 | $user_id = get_current_user_id(); |
| 47 | - if ( wpinv_require_login_to_checkout() && empty( $user_id ) ) { |
|
| 48 | - $error = __( 'You must be logged in to view this invoice.', 'invoicing' ); |
|
| 47 | + if (wpinv_require_login_to_checkout() && empty($user_id)) { |
|
| 48 | + $error = __('You must be logged in to view this invoice.', 'invoicing'); |
|
| 49 | 49 | } else { |
| 50 | - $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' ); |
|
| 50 | + $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing'); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | <div class="container"> |
| 58 | 58 | <div class="alert alert-danger m-5" role="alert"> |
| 59 | - <h4 class="alert-heading"><?php _e( 'Access Denied', 'invoicing' ); ?></h4> |
|
| 59 | + <h4 class="alert-heading"><?php _e('Access Denied', 'invoicing'); ?></h4> |
|
| 60 | 60 | <p><?php echo $error; ?>.</p> |
| 61 | 61 | </div> |
| 62 | 62 | </div> |
@@ -8,25 +8,25 @@ |
||
| 8 | 8 | * @var WPInv_Invoice $invoice |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | ?> |
| 14 | 14 | |
| 15 | 15 | <div class="getpaid-header-left-actions"> |
| 16 | 16 | |
| 17 | - <?php if ( $invoice->is_type( 'invoice' ) && $invoice->needs_payment() && ! $invoice->is_held() ): ?> |
|
| 18 | - <a class="btn btn-sm btn-primary m-1 d-inline-block invoice-action-pay" href="<?php echo esc_url( $invoice->get_checkout_payment_url() ); ?>"> |
|
| 19 | - <?php _e( 'Pay For Invoice', 'invoicing' ); ?> |
|
| 17 | + <?php if ($invoice->is_type('invoice') && $invoice->needs_payment() && !$invoice->is_held()): ?> |
|
| 18 | + <a class="btn btn-sm btn-primary m-1 d-inline-block invoice-action-pay" href="<?php echo esc_url($invoice->get_checkout_payment_url()); ?>"> |
|
| 19 | + <?php _e('Pay For Invoice', 'invoicing'); ?> |
|
| 20 | 20 | </a> |
| 21 | 21 | <?php endif; ?> |
| 22 | 22 | |
| 23 | - <?php if ( $invoice->is_type( 'invoice' ) && $invoice->is_paid() ): ?> |
|
| 24 | - <a class="btn btn-sm btn-info m-1 d-inline-block invoice-action-receipt" href="<?php echo esc_url( $invoice->get_receipt_url() ); ?>"> |
|
| 25 | - <?php _e( 'View Receipt', 'invoicing' ); ?> |
|
| 23 | + <?php if ($invoice->is_type('invoice') && $invoice->is_paid()): ?> |
|
| 24 | + <a class="btn btn-sm btn-info m-1 d-inline-block invoice-action-receipt" href="<?php echo esc_url($invoice->get_receipt_url()); ?>"> |
|
| 25 | + <?php _e('View Receipt', 'invoicing'); ?> |
|
| 26 | 26 | </a> |
| 27 | 27 | <?php endif; ?> |
| 28 | 28 | |
| 29 | - <?php do_action( 'wpinv_invoice_display_left_actions', $invoice ); ?> |
|
| 29 | + <?php do_action('wpinv_invoice_display_left_actions', $invoice); ?> |
|
| 30 | 30 | |
| 31 | 31 | </div> |
| 32 | 32 | |
@@ -7,16 +7,16 @@ |
||
| 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="border-top pt-4 bg-white"> |
| 15 | 15 | <div class="container pr-0 pl-0"> |
| 16 | 16 | |
| 17 | - <?php if ( $term_text = wpinv_get_terms_text() ) : ?> |
|
| 17 | + <?php if ($term_text = wpinv_get_terms_text()) : ?> |
|
| 18 | 18 | <div class="terms-text"> |
| 19 | - <?php echo wpautop( $term_text ); ?> |
|
| 19 | + <?php echo wpautop($term_text); ?> |
|
| 20 | 20 | </div> |
| 21 | 21 | <?php endif; ?> |
| 22 | 22 | |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * @var WPInv_Invoice $invoice |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | ?> |
| 14 | 14 | |
@@ -21,43 +21,43 @@ discard block |
||
| 21 | 21 | $actions[] = sprintf( |
| 22 | 22 | '<a href="javascript:void(0)" class="btn btn-sm m-1 d-inline-block btn-secondary invoice-action-print d-none d-lg-inline-block" onclick="window.print();">%s</a>', |
| 23 | 23 | sprintf( |
| 24 | - __( 'Print %s', 'invoicing' ), |
|
| 25 | - ucfirst( $invoice->get_type() ) |
|
| 24 | + __('Print %s', 'invoicing'), |
|
| 25 | + ucfirst($invoice->get_type()) |
|
| 26 | 26 | ) |
| 27 | 27 | ); |
| 28 | 28 | |
| 29 | - if ( is_user_logged_in() ) { |
|
| 29 | + if (is_user_logged_in()) { |
|
| 30 | 30 | |
| 31 | 31 | $actions[] = sprintf( |
| 32 | 32 | '<a href="%s" class="btn btn-sm btn-secondary m-1 d-inline-block invoice-action-history">%s</a>', |
| 33 | - esc_url( wpinv_get_history_page_uri( $invoice->get_post_type() ) ), |
|
| 33 | + esc_url(wpinv_get_history_page_uri($invoice->get_post_type())), |
|
| 34 | 34 | sprintf( |
| 35 | - __( '%s History', 'invoicing' ), |
|
| 36 | - ucfirst( $invoice->get_type() ) |
|
| 35 | + __('%s History', 'invoicing'), |
|
| 36 | + ucfirst($invoice->get_type()) |
|
| 37 | 37 | ) |
| 38 | 38 | ); |
| 39 | 39 | |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - if ( wpinv_current_user_can_manage_invoicing() ) { |
|
| 42 | + if (wpinv_current_user_can_manage_invoicing()) { |
|
| 43 | 43 | |
| 44 | 44 | $actions[] = sprintf( |
| 45 | 45 | '<a href="%s" class="btn btn-sm btn-secondary m-1 d-inline-block invoice-action-edit">%s</a>', |
| 46 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
| 46 | + esc_url(get_edit_post_link($invoice->get_id())), |
|
| 47 | 47 | sprintf( |
| 48 | - __( 'Edit %s', 'invoicing' ), |
|
| 49 | - ucfirst( $invoice->get_type() ) |
|
| 48 | + __('Edit %s', 'invoicing'), |
|
| 49 | + ucfirst($invoice->get_type()) |
|
| 50 | 50 | ) |
| 51 | 51 | ); |
| 52 | 52 | |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - $actions = apply_filters( 'getpaid_invoice_header_right_actions_array', $actions, $invoice ); |
|
| 56 | - echo implode( '', $actions ); |
|
| 55 | + $actions = apply_filters('getpaid_invoice_header_right_actions_array', $actions, $invoice); |
|
| 56 | + echo implode('', $actions); |
|
| 57 | 57 | |
| 58 | 58 | ?> |
| 59 | 59 | |
| 60 | - <?php do_action('wpinv_invoice_display_right_actions', $invoice ); ?> |
|
| 60 | + <?php do_action('wpinv_invoice_display_right_actions', $invoice); ?> |
|
| 61 | 61 | </div> |
| 62 | 62 | |
| 63 | 63 | <?php |
@@ -9,26 +9,26 @@ discard block |
||
| 9 | 9 | * @var WPInv_Invoice $invoice |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -defined( 'ABSPATH' ) || exit; |
|
| 12 | +defined('ABSPATH') || exit; |
|
| 13 | 13 | |
| 14 | 14 | // Totals rows. |
| 15 | -$totals = getpaid_invoice_totals_rows( $invoice ); |
|
| 15 | +$totals = getpaid_invoice_totals_rows($invoice); |
|
| 16 | 16 | |
| 17 | -do_action( 'getpaid_before_invoice_line_totals', $invoice, $totals ); |
|
| 17 | +do_action('getpaid_before_invoice_line_totals', $invoice, $totals); |
|
| 18 | 18 | |
| 19 | 19 | ?> |
| 20 | 20 | <div class='getpaid-invoice-line-totals'> |
| 21 | 21 | <div class="row"> |
| 22 | 22 | <div class="col-12 offset-sm-6 col-sm-6 border-sm-left pl-sm-0"> |
| 23 | 23 | |
| 24 | - <?php foreach ( $totals as $key => $label ) : ?> |
|
| 24 | + <?php foreach ($totals as $key => $label) : ?> |
|
| 25 | 25 | |
| 26 | - <div class="getpaid-invoice-line-totals-col <?php echo sanitize_html_class( $key ); ?>"> |
|
| 26 | + <div class="getpaid-invoice-line-totals-col <?php echo sanitize_html_class($key); ?>"> |
|
| 27 | 27 | |
| 28 | 28 | <div class="row"> |
| 29 | 29 | |
| 30 | 30 | <div class="col-8 getpaid-invoice-line-totals-label"> |
| 31 | - <?php echo sanitize_text_field( $label ); ?> |
|
| 31 | + <?php echo sanitize_text_field($label); ?> |
|
| 32 | 32 | </div> |
| 33 | 33 | |
| 34 | 34 | <div class="col-2 getpaid-invoice-line-totals-value"> |
@@ -36,32 +36,32 @@ discard block |
||
| 36 | 36 | <?php |
| 37 | 37 | |
| 38 | 38 | // Total tax. |
| 39 | - if ( 'tax' == $key ) { |
|
| 40 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total_tax() ), $invoice->get_currency() ); |
|
| 39 | + if ('tax' == $key) { |
|
| 40 | + echo wpinv_price(wpinv_format_amount($invoice->get_total_tax()), $invoice->get_currency()); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // Total Fee. |
| 44 | - if ( 'fee' == $key ) { |
|
| 45 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total_fees() ), $invoice->get_currency() ); |
|
| 44 | + if ('fee' == $key) { |
|
| 45 | + echo wpinv_price(wpinv_format_amount($invoice->get_total_fees()), $invoice->get_currency()); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | // Total discount. |
| 49 | - if ( 'discount' == $key ) { |
|
| 50 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total_discount() ), $invoice->get_currency() ); |
|
| 49 | + if ('discount' == $key) { |
|
| 50 | + echo wpinv_price(wpinv_format_amount($invoice->get_total_discount()), $invoice->get_currency()); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | // Sub total. |
| 54 | - if ( 'subtotal' == $key ) { |
|
| 55 | - echo wpinv_price( wpinv_format_amount( $invoice->get_subtotal() ), $invoice->get_currency() ); |
|
| 54 | + if ('subtotal' == $key) { |
|
| 55 | + echo wpinv_price(wpinv_format_amount($invoice->get_subtotal()), $invoice->get_currency()); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | // Total. |
| 59 | - if ( 'total' == $key ) { |
|
| 60 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ); |
|
| 59 | + if ('total' == $key) { |
|
| 60 | + echo wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // Fires when printing a cart total. |
| 64 | - do_action( "getpaid_invoice_cart_totals_$key", $invoice ); |
|
| 64 | + do_action("getpaid_invoice_cart_totals_$key", $invoice); |
|
| 65 | 65 | |
| 66 | 66 | ?> |
| 67 | 67 | |
@@ -75,4 +75,4 @@ discard block |
||
| 75 | 75 | </div> |
| 76 | 76 | </div> <!-- end .getpaid-invoice-line-totals --> |
| 77 | 77 | |
| 78 | -<?php do_action( 'getpaid_after_invoice_line_totals', $invoice, $totals ); ?> |
|
| 78 | +<?php do_action('getpaid_after_invoice_line_totals', $invoice, $totals); ?> |
|
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
@@ -16,11 +16,11 @@ discard block |
||
| 16 | 16 | <div class="row"> |
| 17 | 17 | |
| 18 | 18 | <div class="col-12 col-sm-6 text-sm-left pl-sm-0"> |
| 19 | - <?php do_action( 'getpaid_invoice_header_left', $invoice );?> |
|
| 19 | + <?php do_action('getpaid_invoice_header_left', $invoice); ?> |
|
| 20 | 20 | </div> |
| 21 | 21 | |
| 22 | 22 | <div class="col-12 col-sm-6 text-sm-right pr-sm-0"> |
| 23 | - <?php do_action( 'getpaid_invoice_header_right', $invoice );?> |
|
| 23 | + <?php do_action('getpaid_invoice_header_right', $invoice); ?> |
|
| 24 | 24 | </div> |
| 25 | 25 | |
| 26 | 26 | </div> |
@@ -7,50 +7,50 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | -$class = ! is_singular( 'page' ) ? 'px-1' : ''; |
|
| 12 | +$class = !is_singular('page') ? 'px-1' : ''; |
|
| 13 | 13 | ?> |
| 14 | 14 | |
| 15 | - <?php do_action( 'getpaid_before_invoice_meta', $invoice ); ?> |
|
| 15 | + <?php do_action('getpaid_before_invoice_meta', $invoice); ?> |
|
| 16 | 16 | <div class="getpaid-invoice-meta-data"> |
| 17 | 17 | |
| 18 | - <?php do_action( 'getpaid_before_invoice_meta_table', $invoice ); ?> |
|
| 18 | + <?php do_action('getpaid_before_invoice_meta_table', $invoice); ?> |
|
| 19 | 19 | <table class="table table-bordered"> |
| 20 | 20 | <tbody> |
| 21 | 21 | |
| 22 | - <?php do_action( "getpaid_before_invoice_meta_rows", $invoice ); ?> |
|
| 23 | - <?php foreach ( $meta as $key => $data ) : ?> |
|
| 22 | + <?php do_action("getpaid_before_invoice_meta_rows", $invoice); ?> |
|
| 23 | + <?php foreach ($meta as $key => $data) : ?> |
|
| 24 | 24 | |
| 25 | - <?php if ( ! empty( $data['value'] ) ) : ?> |
|
| 25 | + <?php if (!empty($data['value'])) : ?> |
|
| 26 | 26 | |
| 27 | - <?php do_action( "getpaid_before_invoice_meta_$key", $invoice, $data ); ?> |
|
| 27 | + <?php do_action("getpaid_before_invoice_meta_$key", $invoice, $data); ?> |
|
| 28 | 28 | |
| 29 | - <tr class="getpaid-invoice-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
| 29 | + <tr class="getpaid-invoice-meta-<?php echo sanitize_html_class($key); ?>"> |
|
| 30 | 30 | |
| 31 | 31 | <th class="<?php echo $class; ?> w-50"> |
| 32 | - <?php echo sanitize_text_field( $data['label'] ); ?> |
|
| 32 | + <?php echo sanitize_text_field($data['label']); ?> |
|
| 33 | 33 | </th> |
| 34 | 34 | |
| 35 | 35 | <td class="<?php echo $class; ?> text-break w-50"> |
| 36 | - <span class="getpaid-invoice-meta-<?php echo sanitize_html_class( $key ); ?>-value"><?php echo wp_kses_post( $data['value'] ); ?></span> |
|
| 36 | + <span class="getpaid-invoice-meta-<?php echo sanitize_html_class($key); ?>-value"><?php echo wp_kses_post($data['value']); ?></span> |
|
| 37 | 37 | </td> |
| 38 | 38 | |
| 39 | 39 | </tr> |
| 40 | 40 | |
| 41 | - <?php do_action( "getpaid_after_invoice_meta_$key", $invoice, $data ); ?> |
|
| 41 | + <?php do_action("getpaid_after_invoice_meta_$key", $invoice, $data); ?> |
|
| 42 | 42 | |
| 43 | 43 | <?php endif; ?> |
| 44 | 44 | |
| 45 | 45 | <?php endforeach; ?> |
| 46 | - <?php do_action( "getpaid_after_invoice_meta_rows", $invoice ); ?> |
|
| 46 | + <?php do_action("getpaid_after_invoice_meta_rows", $invoice); ?> |
|
| 47 | 47 | |
| 48 | 48 | </tbody> |
| 49 | 49 | </table> |
| 50 | - <?php do_action( 'getpaid_after_invoice_meta_table', $invoice ); ?> |
|
| 50 | + <?php do_action('getpaid_after_invoice_meta_table', $invoice); ?> |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | </div> |
| 54 | - <?php do_action( 'getpaid_after_invoice_meta', $invoice ); ?> |
|
| 54 | + <?php do_action('getpaid_after_invoice_meta', $invoice); ?> |
|
| 55 | 55 | |
| 56 | 56 | <?php |
@@ -7,24 +7,24 @@ |
||
| 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 | - <?php do_action( 'getpaid_before_invoice_details_top', $invoice ); ?> |
|
| 14 | + <?php do_action('getpaid_before_invoice_details_top', $invoice); ?> |
|
| 15 | 15 | |
| 16 | 16 | <div class="getpaid-invoice-details-top mb-5"> |
| 17 | 17 | <div class="row"> |
| 18 | 18 | <div class="col-12 col-sm-6 text-sm-left"> |
| 19 | - <?php do_action( 'getpaid_invoice_details_top_left', $invoice ); ?> |
|
| 19 | + <?php do_action('getpaid_invoice_details_top_left', $invoice); ?> |
|
| 20 | 20 | </div> |
| 21 | 21 | |
| 22 | 22 | <div class="col-12 col-sm-6 text-sm-right"> |
| 23 | - <?php do_action( 'getpaid_invoice_details_top_right', $invoice ); ?> |
|
| 23 | + <?php do_action('getpaid_invoice_details_top_right', $invoice); ?> |
|
| 24 | 24 | </div> |
| 25 | 25 | </div> |
| 26 | 26 | </div> |
| 27 | 27 | |
| 28 | - <?php do_action( 'getpaid_after_invoice_details_top', $invoice ); ?> |
|
| 28 | + <?php do_action('getpaid_after_invoice_details_top', $invoice); ?> |
|
| 29 | 29 | |
| 30 | 30 | <?php |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | * Contains gateway functions. |
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | -defined( 'ABSPATH' ) || exit; |
|
| 6 | +defined('ABSPATH') || exit; |
|
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * Returns an array of payment gateways. |
@@ -11,82 +11,82 @@ discard block |
||
| 11 | 11 | * @return array |
| 12 | 12 | */ |
| 13 | 13 | function wpinv_get_payment_gateways() { |
| 14 | - return apply_filters( 'wpinv_payment_gateways', array() ); |
|
| 14 | + return apply_filters('wpinv_payment_gateways', array()); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | -function wpinv_payment_gateway_titles( $all_gateways ) { |
|
| 17 | +function wpinv_payment_gateway_titles($all_gateways) { |
|
| 18 | 18 | global $wpinv_options; |
| 19 | 19 | |
| 20 | 20 | $gateways = array(); |
| 21 | - foreach ( $all_gateways as $key => $gateway ) { |
|
| 22 | - if ( !empty( $wpinv_options[$key . '_title'] ) ) { |
|
| 23 | - $all_gateways[$key]['checkout_label'] = __( $wpinv_options[$key . '_title'], 'invoicing' ); |
|
| 21 | + foreach ($all_gateways as $key => $gateway) { |
|
| 22 | + if (!empty($wpinv_options[$key . '_title'])) { |
|
| 23 | + $all_gateways[$key]['checkout_label'] = __($wpinv_options[$key . '_title'], 'invoicing'); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - $gateways[$key] = isset( $wpinv_options[$key . '_ordering'] ) ? $wpinv_options[$key . '_ordering'] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' ); |
|
| 26 | + $gateways[$key] = isset($wpinv_options[$key . '_ordering']) ? $wpinv_options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : ''); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - asort( $gateways ); |
|
| 29 | + asort($gateways); |
|
| 30 | 30 | |
| 31 | - foreach ( $gateways as $gateway => $key ) { |
|
| 31 | + foreach ($gateways as $gateway => $key) { |
|
| 32 | 32 | $gateways[$gateway] = $all_gateways[$gateway]; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | return $gateways; |
| 36 | 36 | } |
| 37 | -add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 ); |
|
| 37 | +add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1); |
|
| 38 | 38 | |
| 39 | -function wpinv_get_enabled_payment_gateways( $sort = false ) { |
|
| 39 | +function wpinv_get_enabled_payment_gateways($sort = false) { |
|
| 40 | 40 | $gateways = wpinv_get_payment_gateways(); |
| 41 | - $enabled = wpinv_get_option( 'gateways', false ); |
|
| 41 | + $enabled = wpinv_get_option('gateways', false); |
|
| 42 | 42 | |
| 43 | 43 | $gateway_list = array(); |
| 44 | 44 | |
| 45 | - foreach ( $gateways as $key => $gateway ) { |
|
| 46 | - if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) { |
|
| 47 | - $gateway_list[ $key ] = $gateway; |
|
| 45 | + foreach ($gateways as $key => $gateway) { |
|
| 46 | + if (isset($enabled[$key]) && $enabled[$key] == 1) { |
|
| 47 | + $gateway_list[$key] = $gateway; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - if ( true === $sort ) { |
|
| 52 | - uasort( $gateway_list, 'wpinv_sort_gateway_order' ); |
|
| 51 | + if (true === $sort) { |
|
| 52 | + uasort($gateway_list, 'wpinv_sort_gateway_order'); |
|
| 53 | 53 | |
| 54 | 54 | // Reorder our gateways so the default is first |
| 55 | 55 | $default_gateway_id = wpinv_get_default_gateway(); |
| 56 | 56 | |
| 57 | - if ( wpinv_is_gateway_active( $default_gateway_id ) ) { |
|
| 58 | - $default_gateway = array( $default_gateway_id => $gateway_list[ $default_gateway_id ] ); |
|
| 59 | - unset( $gateway_list[ $default_gateway_id ] ); |
|
| 57 | + if (wpinv_is_gateway_active($default_gateway_id)) { |
|
| 58 | + $default_gateway = array($default_gateway_id => $gateway_list[$default_gateway_id]); |
|
| 59 | + unset($gateway_list[$default_gateway_id]); |
|
| 60 | 60 | |
| 61 | - $gateway_list = array_merge( $default_gateway, $gateway_list ); |
|
| 61 | + $gateway_list = array_merge($default_gateway, $gateway_list); |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - return apply_filters( 'wpinv_enabled_payment_gateways', $gateway_list ); |
|
| 65 | + return apply_filters('wpinv_enabled_payment_gateways', $gateway_list); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | -function wpinv_sort_gateway_order( $a, $b ) { |
|
| 68 | +function wpinv_sort_gateway_order($a, $b) { |
|
| 69 | 69 | return $a['ordering'] - $b['ordering']; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | -function wpinv_is_gateway_active( $gateway ) { |
|
| 72 | +function wpinv_is_gateway_active($gateway) { |
|
| 73 | 73 | $gateways = wpinv_get_enabled_payment_gateways(); |
| 74 | 74 | |
| 75 | - $ret = is_array($gateways) && $gateway ? array_key_exists( $gateway, $gateways ) : false; |
|
| 75 | + $ret = is_array($gateways) && $gateway ? array_key_exists($gateway, $gateways) : false; |
|
| 76 | 76 | |
| 77 | - return apply_filters( 'wpinv_is_gateway_active', $ret, $gateway, $gateways ); |
|
| 77 | + return apply_filters('wpinv_is_gateway_active', $ret, $gateway, $gateways); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | function wpinv_get_default_gateway() { |
| 81 | - $default = wpinv_get_option( 'default_gateway', 'paypal' ); |
|
| 81 | + $default = wpinv_get_option('default_gateway', 'paypal'); |
|
| 82 | 82 | |
| 83 | - if ( !wpinv_is_gateway_active( $default ) ) { |
|
| 83 | + if (!wpinv_is_gateway_active($default)) { |
|
| 84 | 84 | $gateways = wpinv_get_enabled_payment_gateways(); |
| 85 | - $gateways = array_keys( $gateways ); |
|
| 86 | - $default = reset( $gateways ); |
|
| 85 | + $gateways = array_keys($gateways); |
|
| 86 | + $default = reset($gateways); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - return apply_filters( 'wpinv_default_gateway', $default ); |
|
| 89 | + return apply_filters('wpinv_default_gateway', $default); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -95,17 +95,17 @@ discard block |
||
| 95 | 95 | * @param string $gateway The gateway to key. |
| 96 | 96 | * @return string |
| 97 | 97 | */ |
| 98 | -function wpinv_get_gateway_admin_label( $gateway ) { |
|
| 98 | +function wpinv_get_gateway_admin_label($gateway) { |
|
| 99 | 99 | |
| 100 | - if ( empty( $gateway ) || 'none' == $gateway ) { |
|
| 101 | - return esc_html__( 'No Gateway', 'invoicing' ); |
|
| 100 | + if (empty($gateway) || 'none' == $gateway) { |
|
| 101 | + return esc_html__('No Gateway', 'invoicing'); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | $gateways = wpinv_get_payment_gateways(); |
| 105 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
| 106 | - $gateway = apply_filters( 'wpinv_gateway_admin_label', $label, $gateway ); |
|
| 105 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
| 106 | + $gateway = apply_filters('wpinv_gateway_admin_label', $label, $gateway); |
|
| 107 | 107 | |
| 108 | - return wpinv_clean( $gateway ); |
|
| 108 | + return wpinv_clean($gateway); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -113,49 +113,49 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @param string $gateway |
| 115 | 115 | */ |
| 116 | -function wpinv_get_gateway_description( $gateway ) { |
|
| 116 | +function wpinv_get_gateway_description($gateway) { |
|
| 117 | 117 | global $wpinv_options; |
| 118 | 118 | |
| 119 | - $description = ! empty( $wpinv_options[$gateway . '_desc'] ) ? $wpinv_options[$gateway . '_desc'] : ''; |
|
| 119 | + $description = !empty($wpinv_options[$gateway . '_desc']) ? $wpinv_options[$gateway . '_desc'] : ''; |
|
| 120 | 120 | |
| 121 | - return apply_filters( 'wpinv_gateway_description', $description, $gateway ); |
|
| 121 | + return apply_filters('wpinv_gateway_description', $description, $gateway); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | -function wpinv_get_gateway_button_label( $gateway ) { |
|
| 125 | - return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' ); |
|
| 124 | +function wpinv_get_gateway_button_label($gateway) { |
|
| 125 | + return apply_filters('wpinv_gateway_' . $gateway . '_button_label', ''); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | -function wpinv_get_gateway_checkout_label( $gateway ) { |
|
| 128 | +function wpinv_get_gateway_checkout_label($gateway) { |
|
| 129 | 129 | $gateways = wpinv_get_payment_gateways(); |
| 130 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
| 130 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
| 131 | 131 | |
| 132 | - if ( $gateway == 'none' ) { |
|
| 133 | - $label = __( 'None', 'invoicing' ); |
|
| 132 | + if ($gateway == 'none') { |
|
| 133 | + $label = __('None', 'invoicing'); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - return apply_filters( 'wpinv_gateway_checkout_label', ucfirst( $label ), $gateway ); |
|
| 136 | + return apply_filters('wpinv_gateway_checkout_label', ucfirst($label), $gateway); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | -function wpinv_settings_sections_gateways( $settings ) { |
|
| 139 | +function wpinv_settings_sections_gateways($settings) { |
|
| 140 | 140 | $gateways = wpinv_get_payment_gateways(); |
| 141 | 141 | |
| 142 | 142 | if (!empty($gateways)) { |
| 143 | - foreach ($gateways as $key => $gateway) { |
|
| 143 | + foreach ($gateways as $key => $gateway) { |
|
| 144 | 144 | $settings[$key] = $gateway['admin_label']; |
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | return $settings; |
| 149 | 149 | } |
| 150 | -add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 ); |
|
| 150 | +add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1); |
|
| 151 | 151 | |
| 152 | 152 | /** |
| 153 | 153 | * Adds GateWay settings. |
| 154 | 154 | */ |
| 155 | -function wpinv_settings_gateways( $settings ) { |
|
| 155 | +function wpinv_settings_gateways($settings) { |
|
| 156 | 156 | |
| 157 | 157 | // Loop through each gateway. |
| 158 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
| 158 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
| 159 | 159 | |
| 160 | 160 | $gateway_settings = array( |
| 161 | 161 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | "{$key}_header" => array( |
| 164 | 164 | |
| 165 | 165 | 'id' => "{$key}_gateway_header", |
| 166 | - 'name' => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>', |
|
| 166 | + 'name' => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>', |
|
| 167 | 167 | 'custom' => $key, |
| 168 | 168 | 'type' => 'gateway_header', |
| 169 | 169 | |
@@ -172,16 +172,16 @@ discard block |
||
| 172 | 172 | // Activate/Deactivate a gateway. |
| 173 | 173 | "{$key}_active" => array( |
| 174 | 174 | 'id' => $key . '_active', |
| 175 | - 'name' => __( 'Activate', 'invoicing' ), |
|
| 176 | - 'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ), |
|
| 175 | + 'name' => __('Activate', 'invoicing'), |
|
| 176 | + 'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']), |
|
| 177 | 177 | 'type' => 'checkbox', |
| 178 | 178 | ), |
| 179 | 179 | |
| 180 | 180 | // Activate/Deactivate sandbox. |
| 181 | 181 | "{$key}_sandbox" => array( |
| 182 | 182 | 'id' => $key . '_sandbox', |
| 183 | - 'name' => __( 'Sandbox', 'invoicing' ), |
|
| 184 | - 'desc' => __( 'Enable sandbox to test payments', 'invoicing' ), |
|
| 183 | + 'name' => __('Sandbox', 'invoicing'), |
|
| 184 | + 'desc' => __('Enable sandbox to test payments', 'invoicing'), |
|
| 185 | 185 | 'type' => 'checkbox', |
| 186 | 186 | 'std' => '1', |
| 187 | 187 | ), |
@@ -189,40 +189,40 @@ discard block |
||
| 189 | 189 | // Checkout title. |
| 190 | 190 | "{$key}_title" => array( |
| 191 | 191 | 'id' => $key . '_title', |
| 192 | - 'name' => __( 'Checkout Title', 'invoicing' ), |
|
| 193 | - 'std' => isset( $gateway['checkout_label'] ) ? $gateway['checkout_label'] : '', |
|
| 192 | + 'name' => __('Checkout Title', 'invoicing'), |
|
| 193 | + 'std' => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : '', |
|
| 194 | 194 | 'type' => 'text', |
| 195 | 195 | ), |
| 196 | 196 | |
| 197 | 197 | // Checkout description. |
| 198 | 198 | "{$key}_desc" => array( |
| 199 | 199 | 'id' => $key . '_desc', |
| 200 | - 'name' => __( 'Checkout Description', 'invoicing' ), |
|
| 201 | - 'std' => apply_filters( "getpaid_default_{$key}_checkout_description", '' ), |
|
| 200 | + 'name' => __('Checkout Description', 'invoicing'), |
|
| 201 | + 'std' => apply_filters("getpaid_default_{$key}_checkout_description", ''), |
|
| 202 | 202 | 'type' => 'text', |
| 203 | 203 | ), |
| 204 | 204 | |
| 205 | 205 | // Checkout order. |
| 206 | 206 | "{$key}_ordering" => array( |
| 207 | 207 | 'id' => $key . '_ordering', |
| 208 | - 'name' => __( 'Priority', 'invoicing' ), |
|
| 209 | - 'std' => apply_filters( "getpaid_default_{$key}_checkout_description", '' ), |
|
| 208 | + 'name' => __('Priority', 'invoicing'), |
|
| 209 | + 'std' => apply_filters("getpaid_default_{$key}_checkout_description", ''), |
|
| 210 | 210 | 'type' => 'number', |
| 211 | 211 | 'step' => '1', |
| 212 | 212 | 'min' => '-100000', |
| 213 | 213 | 'max' => '100000', |
| 214 | - 'std' => isset( $gateway['ordering'] ) ? $gateway['ordering'] : '10', |
|
| 214 | + 'std' => isset($gateway['ordering']) ? $gateway['ordering'] : '10', |
|
| 215 | 215 | ), |
| 216 | 216 | |
| 217 | 217 | ); |
| 218 | 218 | |
| 219 | 219 | // Maybe remove the sandbox. |
| 220 | - if ( ! apply_filters( "wpinv_{$key}_supports_sandbox", false ) ) { |
|
| 221 | - unset( $gateway_settings["{$key}_sandbox"] ); |
|
| 220 | + if (!apply_filters("wpinv_{$key}_supports_sandbox", false)) { |
|
| 221 | + unset($gateway_settings["{$key}_sandbox"]); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - $gateway_settings = apply_filters( 'wpinv_gateway_settings', $gateway_settings, $key, $gateway ); |
|
| 225 | - $gateway_settings = apply_filters( 'wpinv_gateway_settings_' . $key, $gateway_settings, $gateway ); |
|
| 224 | + $gateway_settings = apply_filters('wpinv_gateway_settings', $gateway_settings, $key, $gateway); |
|
| 225 | + $gateway_settings = apply_filters('wpinv_gateway_settings_' . $key, $gateway_settings, $gateway); |
|
| 226 | 226 | |
| 227 | 227 | $settings[$key] = $gateway_settings; |
| 228 | 228 | } |
@@ -230,57 +230,57 @@ discard block |
||
| 230 | 230 | return $settings; |
| 231 | 231 | |
| 232 | 232 | } |
| 233 | -add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 ); |
|
| 233 | +add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1); |
|
| 234 | 234 | |
| 235 | -function wpinv_gateway_header_callback( $args ) { |
|
| 236 | - echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />'; |
|
| 235 | +function wpinv_gateway_header_callback($args) { |
|
| 236 | + echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />'; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | -function wpinv_get_gateway_supports( $gateway ) { |
|
| 239 | +function wpinv_get_gateway_supports($gateway) { |
|
| 240 | 240 | $gateways = wpinv_get_enabled_payment_gateways(); |
| 241 | - $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array(); |
|
| 242 | - return apply_filters( 'wpinv_gateway_supports', $supports, $gateway ); |
|
| 241 | + $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array(); |
|
| 242 | + return apply_filters('wpinv_gateway_supports', $supports, $gateway); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | -function wpinv_get_chosen_gateway( $invoice_id = 0 ) { |
|
| 246 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
| 245 | +function wpinv_get_chosen_gateway($invoice_id = 0) { |
|
| 246 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
| 247 | 247 | |
| 248 | 248 | $chosen = false; |
| 249 | - if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) { |
|
| 249 | + if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) { |
|
| 250 | 250 | $chosen = $invoice->get_gateway(); |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
| 253 | + $chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen; |
|
| 254 | 254 | |
| 255 | - if ( false !== $chosen ) { |
|
| 256 | - $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
| 255 | + if (false !== $chosen) { |
|
| 256 | + $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - if ( ! empty ( $chosen ) ) { |
|
| 260 | - $enabled_gateway = urldecode( $chosen ); |
|
| 261 | - } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
| 259 | + if (!empty ($chosen)) { |
|
| 260 | + $enabled_gateway = urldecode($chosen); |
|
| 261 | + } else if (!empty($invoice) && (float) $invoice->get_subtotal() <= 0) { |
|
| 262 | 262 | $enabled_gateway = 'manual'; |
| 263 | 263 | } else { |
| 264 | 264 | $enabled_gateway = wpinv_get_default_gateway(); |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) { |
|
| 268 | - if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){ |
|
| 267 | + if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) { |
|
| 268 | + if (wpinv_is_gateway_active(wpinv_get_default_gateway())) { |
|
| 269 | 269 | $enabled_gateway = wpinv_get_default_gateway(); |
| 270 | - }else{ |
|
| 270 | + } else { |
|
| 271 | 271 | $enabled_gateway = $gateways[0]; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
| 276 | + return apply_filters('wpinv_chosen_gateway', $enabled_gateway); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | -function wpinv_record_gateway_error( $title = '', $message = '' ) { |
|
| 280 | - return wpinv_error_log( $message, $title ); |
|
| 279 | +function wpinv_record_gateway_error($title = '', $message = '') { |
|
| 280 | + return wpinv_error_log($message, $title); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | -function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
| 283 | +function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
| 284 | 284 | $ret = 0; |
| 285 | 285 | $args = array( |
| 286 | 286 | 'meta_key' => '_wpinv_gateway', |
@@ -291,48 +291,48 @@ discard block |
||
| 291 | 291 | 'fields' => 'ids' |
| 292 | 292 | ); |
| 293 | 293 | |
| 294 | - $payments = new WP_Query( $args ); |
|
| 294 | + $payments = new WP_Query($args); |
|
| 295 | 295 | |
| 296 | - if( $payments ) |
|
| 296 | + if ($payments) |
|
| 297 | 297 | $ret = $payments->post_count; |
| 298 | 298 | return $ret; |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | -function wpinv_settings_update_gateways( $input ) { |
|
| 301 | +function wpinv_settings_update_gateways($input) { |
|
| 302 | 302 | global $wpinv_options; |
| 303 | 303 | |
| 304 | - if ( !empty( $input['save_gateway'] ) ) { |
|
| 305 | - $gateways = wpinv_get_option( 'gateways', false ); |
|
| 304 | + if (!empty($input['save_gateway'])) { |
|
| 305 | + $gateways = wpinv_get_option('gateways', false); |
|
| 306 | 306 | $gateways = !empty($gateways) ? $gateways : array(); |
| 307 | 307 | $gateway = $input['save_gateway']; |
| 308 | 308 | |
| 309 | - if ( !empty( $input[$gateway . '_active'] ) ) { |
|
| 309 | + if (!empty($input[$gateway . '_active'])) { |
|
| 310 | 310 | $gateways[$gateway] = 1; |
| 311 | 311 | } else { |
| 312 | - if ( isset( $gateways[$gateway] ) ) { |
|
| 313 | - unset( $gateways[$gateway] ); |
|
| 312 | + if (isset($gateways[$gateway])) { |
|
| 313 | + unset($gateways[$gateway]); |
|
| 314 | 314 | } |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | $input['gateways'] = $gateways; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - if ( !empty( $input['default_gateway'] ) ) { |
|
| 320 | + if (!empty($input['default_gateway'])) { |
|
| 321 | 321 | $gateways = wpinv_get_payment_gateways(); |
| 322 | 322 | |
| 323 | - foreach ( $gateways as $key => $gateway ) { |
|
| 324 | - $active = 0; |
|
| 325 | - if ( !empty( $input['gateways'] ) && !empty( $input['gateways'][$key] ) ) { |
|
| 323 | + foreach ($gateways as $key => $gateway) { |
|
| 324 | + $active = 0; |
|
| 325 | + if (!empty($input['gateways']) && !empty($input['gateways'][$key])) { |
|
| 326 | 326 | $active = 1; |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | $input[$key . '_active'] = $active; |
| 330 | 330 | |
| 331 | - if ( empty( $wpinv_options[$key . '_title'] ) ) { |
|
| 331 | + if (empty($wpinv_options[$key . '_title'])) { |
|
| 332 | 332 | $input[$key . '_title'] = $gateway['checkout_label']; |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - if ( !isset( $wpinv_options[$key . '_ordering'] ) && isset( $gateway['ordering'] ) ) { |
|
| 335 | + if (!isset($wpinv_options[$key . '_ordering']) && isset($gateway['ordering'])) { |
|
| 336 | 336 | $input[$key . '_ordering'] = $gateway['ordering']; |
| 337 | 337 | } |
| 338 | 338 | } |
@@ -340,27 +340,27 @@ discard block |
||
| 340 | 340 | |
| 341 | 341 | return $input; |
| 342 | 342 | } |
| 343 | -add_filter( 'wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1 ); |
|
| 343 | +add_filter('wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1); |
|
| 344 | 344 | |
| 345 | 345 | // PayPal Standard settings |
| 346 | -function wpinv_gateway_settings_paypal( $setting ) { |
|
| 347 | - $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing' ); |
|
| 348 | - $setting['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' ); |
|
| 346 | +function wpinv_gateway_settings_paypal($setting) { |
|
| 347 | + $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __('( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing'); |
|
| 348 | + $setting['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing'); |
|
| 349 | 349 | |
| 350 | 350 | $setting['paypal_sandbox'] = array( |
| 351 | 351 | 'type' => 'checkbox', |
| 352 | 352 | 'id' => 'paypal_sandbox', |
| 353 | - 'name' => __( 'PayPal Sandbox', 'invoicing' ), |
|
| 354 | - 'desc' => __( 'PayPal sandbox can be used to test payments.', 'invoicing' ), |
|
| 353 | + 'name' => __('PayPal Sandbox', 'invoicing'), |
|
| 354 | + 'desc' => __('PayPal sandbox can be used to test payments.', 'invoicing'), |
|
| 355 | 355 | 'std' => 1 |
| 356 | 356 | ); |
| 357 | 357 | |
| 358 | 358 | $setting['paypal_email'] = array( |
| 359 | 359 | 'type' => 'text', |
| 360 | 360 | 'id' => 'paypal_email', |
| 361 | - 'name' => __( 'PayPal Email', 'invoicing' ), |
|
| 362 | - 'desc' => __( 'Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing' ), |
|
| 363 | - 'std' => __( '[email protected]', 'invoicing' ), |
|
| 361 | + 'name' => __('PayPal Email', 'invoicing'), |
|
| 362 | + 'desc' => __('Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing'), |
|
| 363 | + 'std' => __('[email protected]', 'invoicing'), |
|
| 364 | 364 | ); |
| 365 | 365 | /* |
| 366 | 366 | $setting['paypal_ipn_url'] = array( |
@@ -374,18 +374,18 @@ discard block |
||
| 374 | 374 | |
| 375 | 375 | return $setting; |
| 376 | 376 | } |
| 377 | -add_filter( 'wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1 ); |
|
| 377 | +add_filter('wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1); |
|
| 378 | 378 | |
| 379 | 379 | /** |
| 380 | 380 | * Displays the ipn url field. |
| 381 | 381 | */ |
| 382 | -function wpinv_ipn_url_callback( $args ) { |
|
| 383 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 382 | +function wpinv_ipn_url_callback($args) { |
|
| 383 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 384 | 384 | |
| 385 | 385 | $attrs = $args['readonly'] ? ' readonly' : ''; |
| 386 | 386 | |
| 387 | - $html = '<input class="regular-text" type="text" ' . $attrs . ' value="' . esc_attr( $args['std'] ) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" onClick="this.select()">'; |
|
| 388 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
| 387 | + $html = '<input class="regular-text" type="text" ' . $attrs . ' value="' . esc_attr($args['std']) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" onClick="this.select()">'; |
|
| 388 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
| 389 | 389 | |
| 390 | 390 | echo $html; |
| 391 | 391 | } |
@@ -397,10 +397,10 @@ discard block |
||
| 397 | 397 | * |
| 398 | 398 | * @return bool |
| 399 | 399 | */ |
| 400 | -function wpinv_is_test_mode( $gateway = '' ) { |
|
| 401 | - $sandbox = empty( $gateway ) ? false : wpinv_get_option( "{$gateway}_sandbox", true ); |
|
| 402 | - $supports = apply_filters( "wpinv_{$gateway}_supports_sandbox", false ); |
|
| 403 | - return apply_filters( 'wpinv_is_test_mode', $sandbox && $supports, $gateway ); |
|
| 400 | +function wpinv_is_test_mode($gateway = '') { |
|
| 401 | + $sandbox = empty($gateway) ? false : wpinv_get_option("{$gateway}_sandbox", true); |
|
| 402 | + $supports = apply_filters("wpinv_{$gateway}_supports_sandbox", false); |
|
| 403 | + return apply_filters('wpinv_is_test_mode', $sandbox && $supports, $gateway); |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | /** |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | * |
| 412 | 412 | * @return string |
| 413 | 413 | */ |
| 414 | -function wpinv_get_ipn_url( $gateway = false, $args = array() ) { |
|
| 414 | +function wpinv_get_ipn_url($gateway = false, $args = array()) { |
|
| 415 | 415 | $args = wp_parse_args( |
| 416 | 416 | array( |
| 417 | 417 | 'wpi-listener' => 'IPN', |
@@ -420,37 +420,37 @@ discard block |
||
| 420 | 420 | $args |
| 421 | 421 | ); |
| 422 | 422 | |
| 423 | - return apply_filters( 'wpinv_ipn_url', add_query_arg( $args, home_url( 'index.php' ) ), $gateway, $args ); |
|
| 423 | + return apply_filters('wpinv_ipn_url', add_query_arg($args, home_url('index.php')), $gateway, $args); |
|
| 424 | 424 | |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | /** |
| 428 | 428 | * Retrieves request data with slashes removed slashes. |
| 429 | 429 | */ |
| 430 | -function wpinv_get_post_data( $method = 'request' ) { |
|
| 430 | +function wpinv_get_post_data($method = 'request') { |
|
| 431 | 431 | |
| 432 | - if ( $method == 'post' ) { |
|
| 433 | - return wp_unslash( $_POST ); |
|
| 432 | + if ($method == 'post') { |
|
| 433 | + return wp_unslash($_POST); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - if ( $method == 'get' ) { |
|
| 437 | - return wp_unslash( $_GET ); |
|
| 436 | + if ($method == 'get') { |
|
| 437 | + return wp_unslash($_GET); |
|
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - return wp_unslash( $_REQUEST ); |
|
| 440 | + return wp_unslash($_REQUEST); |
|
| 441 | 441 | |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | /** |
| 445 | 445 | * Checks if a given gateway supports subscription payments. |
| 446 | 446 | */ |
| 447 | -function wpinv_gateway_support_subscription( $gateway ) { |
|
| 447 | +function wpinv_gateway_support_subscription($gateway) { |
|
| 448 | 448 | $supports = false; |
| 449 | 449 | |
| 450 | - if ( wpinv_is_gateway_active( $gateway ) ) { |
|
| 451 | - $supports = apply_filters( 'wpinv_' . $gateway . '_support_subscription', $supports ); |
|
| 450 | + if (wpinv_is_gateway_active($gateway)) { |
|
| 451 | + $supports = apply_filters('wpinv_' . $gateway . '_support_subscription', $supports); |
|
| 452 | 452 | |
| 453 | - $supports = apply_filters( 'getapid_gateway_supports_subscription', $supports, $gateway ); |
|
| 453 | + $supports = apply_filters('getapid_gateway_supports_subscription', $supports, $gateway); |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | return $supports; |
@@ -462,14 +462,14 @@ discard block |
||
| 462 | 462 | * @param array $gateways an array of gateways. |
| 463 | 463 | * @param GetPaid_Payment_Form $form payment form. |
| 464 | 464 | */ |
| 465 | -function wpinv_payment_gateways_on_cart( $gateways, $form ) { |
|
| 465 | +function wpinv_payment_gateways_on_cart($gateways, $form) { |
|
| 466 | 466 | |
| 467 | - if ( $form->is_recurring() ) { |
|
| 467 | + if ($form->is_recurring()) { |
|
| 468 | 468 | |
| 469 | - foreach ( array_keys( $gateways ) as $gateway ) { |
|
| 469 | + foreach (array_keys($gateways) as $gateway) { |
|
| 470 | 470 | |
| 471 | - if ( ! wpinv_gateway_support_subscription( $gateway ) ) { |
|
| 472 | - unset( $gateways[$gateway] ); |
|
| 471 | + if (!wpinv_gateway_support_subscription($gateway)) { |
|
| 472 | + unset($gateways[$gateway]); |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | } |
@@ -478,4 +478,4 @@ discard block |
||
| 478 | 478 | |
| 479 | 479 | return $gateways; |
| 480 | 480 | } |
| 481 | -add_filter( 'getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2 ); |
|
| 481 | +add_filter('getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2); |
|