Passed
Pull Request — master (#191)
by
unknown
04:15
created
templates/emails/wpinv-email-invoice-details.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if ( !defined('ABSPATH') ) {
4 4
     die('-1');
5
+}
5 6
 
6 7
 global $wpinv_euvat;
7 8
 
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,68 +1,68 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6 6
 global $wpinv_euvat;
7 7
 
8
-$sent_to_admin  = !empty( $sent_to_admin ) ? true : false;
9
-$invoice_url = $invoice->get_view_url( true );
8
+$sent_to_admin = !empty($sent_to_admin) ? true : false;
9
+$invoice_url = $invoice->get_view_url(true);
10 10
 $use_taxes = wpinv_use_taxes();
11 11
 $vat_name = $wpinv_euvat->get_vat_name();
12 12
 
13
-do_action( 'wpinv_email_before_invoice_details', $invoice, $sent_to_admin ); ?>
13
+do_action('wpinv_email_before_invoice_details', $invoice, $sent_to_admin); ?>
14 14
 <div id="wpinv-email-details">
15
-    <h3 class="wpinv-details-t"><?php echo apply_filters( 'wpinv_email_details_title', __( 'Invoice Details', 'invoicing' ), $invoice ); ?></h3>
15
+    <h3 class="wpinv-details-t"><?php echo apply_filters('wpinv_email_details_title', __('Invoice Details', 'invoicing'), $invoice); ?></h3>
16 16
     <table class="table table-bordered table-sm">
17
-        <?php if ( $invoice_number = $invoice->get_number() ) { ?>
17
+        <?php if ($invoice_number = $invoice->get_number()) { ?>
18 18
             <tr>
19
-                <td><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></td>
20
-                <td><a href="<?php echo esc_url( $invoice_url ) ;?>"><?php echo $invoice_number; ?></a></td>
19
+                <td><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></td>
20
+                <td><a href="<?php echo esc_url($invoice_url); ?>"><?php echo $invoice_number; ?></a></td>
21 21
             </tr>
22 22
         <?php } ?>
23 23
         <tr>
24
-            <td><?php echo apply_filters( 'wpinv_invoice_status_label', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></td>
25
-            <td><?php echo $invoice->get_status( true ); ?></td>
24
+            <td><?php echo apply_filters('wpinv_invoice_status_label', __('Invoice Status', 'invoicing'), $invoice); ?></td>
25
+            <td><?php echo $invoice->get_status(true); ?></td>
26 26
         </tr>
27
-        <?php if ( $invoice->is_renewal() ) { ?>
27
+        <?php if ($invoice->is_renewal()) { ?>
28 28
         <tr>
29
-            <td><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></td>
30
-            <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td>
29
+            <td><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></td>
30
+            <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td>
31 31
         </tr>
32 32
         <?php } ?>
33
-        <?php if ( ( $gateway_title = $invoice->get_gateway_title() ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?>
34
-            <td><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></td>
33
+        <?php if (($gateway_title = $invoice->get_gateway_title()) && ($invoice->is_paid() || $invoice->is_refunded())) { ?>
34
+            <td><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></td>
35 35
             <td><?php echo $gateway_title; ?></td>
36 36
         <?php } ?>
37
-        <?php if ( $invoice_date = $invoice->get_invoice_date( false ) ) { ?>
37
+        <?php if ($invoice_date = $invoice->get_invoice_date(false)) { ?>
38 38
             <tr>
39
-                <td><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></td>
40
-                <td><?php echo wp_sprintf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $invoice_date ) ), $invoice->get_invoice_date() ); ?></td>
39
+                <td><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></td>
40
+                <td><?php echo wp_sprintf('<time datetime="%s">%s</time>', date_i18n('c', strtotime($invoice_date)), $invoice->get_invoice_date()); ?></td>
41 41
             </tr>
42 42
         <?php } ?>
43
-        <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date() ) ) { ?>
43
+        <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date())) { ?>
44 44
             <tr>
45
-                <td><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></td>
46
-                <td><?php echo wp_sprintf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $due_date ) ), $invoice->get_due_date( true ) ); ?></td>
45
+                <td><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></td>
46
+                <td><?php echo wp_sprintf('<time datetime="%s">%s</time>', date_i18n('c', strtotime($due_date)), $invoice->get_due_date(true)); ?></td>
47 47
             </tr>
48 48
         <?php } ?>
49
-        <?php do_action( 'wpinv_email_invoice_details_after_due_date', $invoice->ID ); ?>
50
-        <?php if ( empty( $sent_to_admin ) && ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) ) { ?>
49
+        <?php do_action('wpinv_email_invoice_details_after_due_date', $invoice->ID); ?>
50
+        <?php if (empty($sent_to_admin) && ($owner_vat_number = $wpinv_euvat->get_vat_number())) { ?>
51 51
             <tr>
52
-                <td><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></td>
52
+                <td><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></td>
53 53
                 <td><?php echo $owner_vat_number; ?></td>
54 54
             </tr>
55 55
         <?php } ?>
56
-        <?php if ( $use_taxes && ( $user_vat_number = $invoice->vat_number ) ) { ?>
56
+        <?php if ($use_taxes && ($user_vat_number = $invoice->vat_number)) { ?>
57 57
             <tr>
58
-                <td><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></td>
58
+                <td><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></td>
59 59
                 <td><?php echo $user_vat_number; ?></td>
60 60
             </tr>
61 61
         <?php } ?>
62 62
         <tr class="table-active">
63
-            <td><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></td>
64
-            <td><strong><?php echo $invoice->get_total( true ); ?></strong></td>
63
+            <td><strong><?php _e('Total Amount', 'invoicing') ?></strong></td>
64
+            <td><strong><?php echo $invoice->get_total(true); ?></strong></td>
65 65
         </tr>
66 66
     </table>
67 67
 </div>
68
-<?php do_action( 'wpinv_email_after_invoice_details', $invoice, $sent_to_admin ); ?>
69 68
\ No newline at end of file
69
+<?php do_action('wpinv_email_after_invoice_details', $invoice, $sent_to_admin); ?>
70 70
\ No newline at end of file
Please login to merge, or discard this patch.
templates/wpinv-payment-processing.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,11 +2,11 @@
 block discarded – undo
2 2
 global $wpi_invoice;
3 3
 
4 4
 $success_page_uri = wpinv_get_success_page_uri();
5
-if ( !empty( $wpi_invoice ) ) {
6
-    $success_page_uri = add_query_arg( 'invoice_key', $wpi_invoice->get_key(), $success_page_uri );
5
+if (!empty($wpi_invoice)) {
6
+    $success_page_uri = add_query_arg('invoice_key', $wpi_invoice->get_key(), $success_page_uri);
7 7
 }
8 8
 ?>
9 9
 <div id="wpinv-payment-processing">
10
-    <p><?php echo wp_sprintf( __( 'Your payment is processing. This page will reload automatically in 10 seconds. If it does not, click <a href="%s">here</a>.', 'invoicing' ), $success_page_uri ); ?> <i class="fa fa-spin fa-refresh"></i></p>
10
+    <p><?php echo wp_sprintf(__('Your payment is processing. This page will reload automatically in 10 seconds. If it does not, click <a href="%s">here</a>.', 'invoicing'), $success_page_uri); ?> <i class="fa fa-spin fa-refresh"></i></p>
11 11
     <script type="text/javascript">setTimeout(function(){ window.location = '<?php echo $success_page_uri; ?>'; }, 10000);</script>
12 12
 </div>
13 13
\ No newline at end of file
Please login to merge, or discard this patch.
templates/wpinv-invoice-receipt.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -4,17 +4,17 @@  discard block
 block discarded – undo
4 4
  */
5 5
 global $wpinv_receipt_args;
6 6
 
7
-$invoice   = get_post( $wpinv_receipt_args['id'] );
7
+$invoice = get_post($wpinv_receipt_args['id']);
8 8
 
9
-if( empty( $invoice ) ) {
9
+if (empty($invoice)) {
10 10
     ?>
11 11
     <div class="wpinv_errors alert wpi-alert-error">
12
-        <?php _e( 'The specified receipt ID appears to be invalid', 'invoicing' ); ?>
12
+        <?php _e('The specified receipt ID appears to be invalid', 'invoicing'); ?>
13 13
     </div>
14 14
     <?php
15 15
     return;
16 16
 }
17
-$invoice = wpinv_get_invoice( $invoice->ID );
17
+$invoice = wpinv_get_invoice($invoice->ID);
18 18
 
19 19
 global $ajax_cart_details;
20 20
 $ajax_cart_details = $invoice->get_cart_details();
@@ -24,18 +24,18 @@  discard block
 block discarded – undo
24 24
 $quantities_enabled = wpinv_item_quantities_enabled();
25 25
 $use_taxes          = wpinv_use_taxes();
26 26
 $zero_tax           = !(float)$invoice->get_tax() > 0 ? true : false;
27
-$tax_label          = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? __( '(Tax Incl.)', 'invoicing' ) : __( '(Tax Excl.)', 'invoicing' ) ) : '';
27
+$tax_label          = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? __('(Tax Incl.)', 'invoicing') : __('(Tax Excl.)', 'invoicing')) : '';
28 28
 ?>
29
-<?php do_action( 'wpinv_before_receipt', $invoice ); ?>
29
+<?php do_action('wpinv_before_receipt', $invoice); ?>
30 30
 <div class="wpinv-receipt">
31
-    <?php do_action( 'wpinv_receipt_start', $invoice ); ?>
32
-    <div class="wpinv-receipt-message"><?php _e( 'Thank you for your payment!', 'invoicing' ); ?></div>
33
-    <?php do_action( 'wpinv_before_receipt_details', $invoice ); ?>
31
+    <?php do_action('wpinv_receipt_start', $invoice); ?>
32
+    <div class="wpinv-receipt-message"><?php _e('Thank you for your payment!', 'invoicing'); ?></div>
33
+    <?php do_action('wpinv_before_receipt_details', $invoice); ?>
34 34
     <div class="wpinv-receipt-details">
35
-        <h3 class="wpinv-details-t"><?php echo apply_filters( 'wpinv_receipt_details_title', __( 'Invoice Details', 'invoicing' ) ); ?></h3>
36
-        <?php wpinv_display_invoice_details( $invoice ); ?>
35
+        <h3 class="wpinv-details-t"><?php echo apply_filters('wpinv_receipt_details_title', __('Invoice Details', 'invoicing')); ?></h3>
36
+        <?php wpinv_display_invoice_details($invoice); ?>
37 37
     </div>
38
-    <?php do_action( 'wpinv_after_receipt_details', $invoice ); ?>
39
-    <?php do_action( 'wpinv_receipt_end', $invoice ); ?>
38
+    <?php do_action('wpinv_after_receipt_details', $invoice); ?>
39
+    <?php do_action('wpinv_receipt_end', $invoice); ?>
40 40
 </div>
41
-<?php do_action( 'wpinv_after_receipt', $invoice ); ?>
42 41
\ No newline at end of file
42
+<?php do_action('wpinv_after_receipt', $invoice); ?>
43 43
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv-bp-core.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -348,7 +348,7 @@
 block discarded – undo
348 348
 
349 349
         $query_args     = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true );
350 350
         if ( !empty( $status ) && $status != 'all' ) {
351
-           $query_args['status'] = $status;
351
+            $query_args['status'] = $status;
352 352
         }
353 353
         $invoices  = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) );
354 354
         
Please login to merge, or discard this patch.
Spacing   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit; // Exit if accessed directly
4 4
 }
5 5
 
@@ -11,60 +11,60 @@  discard block
 block discarded – undo
11 11
     public function __construct() {
12 12
         global $bp;
13 13
         
14
-        if ( !defined( 'WPINV_BP_SLUG' ) ) {
15
-            define( 'WPINV_BP_SLUG', 'invoices' );
14
+        if (!defined('WPINV_BP_SLUG')) {
15
+            define('WPINV_BP_SLUG', 'invoices');
16 16
         }
17 17
         
18
-        $position       = wpinv_get_option( 'wpinv_menu_position' );
18
+        $position       = wpinv_get_option('wpinv_menu_position');
19 19
         $position       = $position !== '' && $position !== false ? $position : 91;
20
-        $this->position = apply_filters( 'wpinv_bp_nav_position', $position );
20
+        $this->position = apply_filters('wpinv_bp_nav_position', $position);
21 21
         $this->slug     = WPINV_BP_SLUG;
22 22
         
23 23
         parent::start(
24 24
             'invoicing',
25
-            _x( 'Invoices', 'Invoices screen page <title>', 'invoicing' ),
26
-            trailingslashit( dirname( __FILE__ ) ),
25
+            _x('Invoices', 'Invoices screen page <title>', 'invoicing'),
26
+            trailingslashit(dirname(__FILE__)),
27 27
             array(
28 28
                 'adminbar_myaccount_order' => $this->position
29 29
             )
30 30
         );
31 31
     }
32 32
     
33
-    public function includes( $includes = array() ) {
34
-        parent::includes( $includes );
33
+    public function includes($includes = array()) {
34
+        parent::includes($includes);
35 35
     }
36 36
     
37
-    public function setup_globals( $args = array() ) {
37
+    public function setup_globals($args = array()) {
38 38
         global $bp;
39 39
 
40 40
         $args = array(
41 41
             'slug' => $this->slug,
42 42
         );
43 43
 
44
-        parent::setup_globals( $args );
44
+        parent::setup_globals($args);
45 45
     }
46 46
     
47
-    public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
48
-        if ( !bp_is_my_profile() ) {
47
+    public function setup_nav($main_nav = array(), $sub_nav = array()) {
48
+        if (!bp_is_my_profile()) {
49 49
             return;
50 50
         }
51 51
         
52
-        if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) {
52
+        if (wpinv_get_option('wpinv_bp_hide_menu')) {
53 53
             return;
54 54
         }
55 55
         
56 56
         $this->setup_invoice_count();
57 57
 
58 58
         $user_domain    = bp_loggedin_user_domain();
59
-        $invoices_link  = trailingslashit( $user_domain . $this->slug );
60
-        $class          = ( 0 === $this->count ) ? 'no-count' : 'count';
59
+        $invoices_link  = trailingslashit($user_domain . $this->slug);
60
+        $class          = (0 === $this->count) ? 'no-count' : 'count';
61 61
 
62 62
         $main_nav_name = sprintf(
63
-            __( 'My Invoices %s', 'invoicing' ),
63
+            __('My Invoices %s', 'invoicing'),
64 64
             sprintf(
65 65
                 '<span class="%s">%s</span>',
66
-                esc_attr( $class ),
67
-                bp_core_number_format( $this->count )
66
+                esc_attr($class),
67
+                bp_core_number_format($this->count)
68 68
             )
69 69
         );
70 70
 
@@ -72,54 +72,54 @@  discard block
 block discarded – undo
72 72
             'name'                => $main_nav_name,
73 73
             'slug'                => $this->slug,
74 74
             'position'            => $this->position,
75
-            'screen_function'     => array( $this, 'invoices_screen' ),
75
+            'screen_function'     => array($this, 'invoices_screen'),
76 76
             'default_subnav_slug' => 'invoices',
77 77
             'item_css_id'         => $this->id
78 78
         );
79 79
         
80 80
         $sub_nav[] = array(
81
-            'name'            => _x( 'My Invoices', 'Invoices screen sub nav', 'invoicing' ),
81
+            'name'            => _x('My Invoices', 'Invoices screen sub nav', 'invoicing'),
82 82
             'slug'            => 'invoices',
83 83
             'parent_url'      => $invoices_link,
84 84
             'parent_slug'     => $this->slug,
85
-            'screen_function' => array( $this, 'invoices_screen' ),
85
+            'screen_function' => array($this, 'invoices_screen'),
86 86
             'position'        => 10,
87 87
             'item_css_id'     => 'invoices-my-invoices'
88 88
         );
89 89
 
90
-        parent::setup_nav( $main_nav, $sub_nav );
90
+        parent::setup_nav($main_nav, $sub_nav);
91 91
     }
92 92
     
93 93
     public function setup_title() {
94 94
         // Adjust title.
95
-        if ( (bool)bp_is_current_component( 'invoicing' ) ) {
95
+        if ((bool)bp_is_current_component('invoicing')) {
96 96
             global $bp;
97 97
             
98
-            $bp->bp_options_title = __( 'My Invoices', 'invoicing' );
98
+            $bp->bp_options_title = __('My Invoices', 'invoicing');
99 99
         }
100 100
 
101 101
         parent::setup_title();
102 102
     }
103 103
     
104 104
     public function invoices_screen() {
105
-        if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) {
105
+        if (wpinv_get_option('wpinv_bp_hide_menu')) {
106 106
             return;
107 107
         }
108 108
         
109 109
         global $bp;
110 110
         
111
-        add_action( 'bp_template_content', array( $this, 'invoices_content' ) );
111
+        add_action('bp_template_content', array($this, 'invoices_content'));
112 112
 
113
-        $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' );
113
+        $template = apply_filters('bp_core_template_plugin', 'members/single/plugins');
114 114
         
115
-        bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) );
115
+        bp_core_load_template(apply_filters('wpinv_bp_core_template_plugin', $template));
116 116
     }
117 117
     
118 118
     public function invoices_content() {
119
-        if ( $this->has_invoices( bp_ajax_querystring( 'invoices' ) ) ) {
119
+        if ($this->has_invoices(bp_ajax_querystring('invoices'))) {
120 120
             global $invoices_template;
121 121
             
122
-            do_action( 'wpinv_bp_invoices_before_content' );
122
+            do_action('wpinv_bp_invoices_before_content');
123 123
             ?>
124 124
             <div class="wpi-bp-invoices invoices invoicing" style="position:relative">
125 125
                 <div id="pag-top" class="pagination">
@@ -133,61 +133,61 @@  discard block
 block discarded – undo
133 133
                 <table class="table table-bordered table-hover wpi-user-invoices" style="margin:0">
134 134
                     <thead>
135 135
                         <tr>
136
-                            <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
137
-                                <th class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>"><span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span></th>
136
+                            <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?>
137
+                                <th class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>"><span class="nobr"><?php echo esc_html($column_name['title']); ?></span></th>
138 138
                             <?php endforeach; ?>
139 139
                         </tr>
140 140
                     </thead>
141 141
                     <tbody>
142
-                        <?php foreach ( $invoices_template->invoices as $invoice ) {
142
+                        <?php foreach ($invoices_template->invoices as $invoice) {
143 143
                             ?>
144 144
                             <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>">
145
-                                <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
146
-                                    <td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>">
147
-                                        <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?>
148
-                                            <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?>
149
-
150
-                                        <?php elseif ( 'invoice-number' === $column_id ) : ?>
151
-                                            <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>">
152
-                                                <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?>
145
+                                <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?>
146
+                                    <td class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>" data-title="<?php echo esc_attr($column_name['title']); ?>">
147
+                                        <?php if (has_action('wpinv_user_invoices_column_' . $column_id)) : ?>
148
+                                            <?php do_action('wpinv_user_invoices_column_' . $column_id, $invoice); ?>
149
+
150
+                                        <?php elseif ('invoice-number' === $column_id) : ?>
151
+                                            <a href="<?php echo esc_url($invoice->get_view_url()); ?>">
152
+                                                <?php echo _x('#', 'hash before invoice number', 'invoicing') . $invoice->get_number(); ?>
153 153
                                             </a>
154 154
 
155
-                                        <?php elseif ( 'created-date' === $column_id ) : $date = wpinv_get_date_created( $invoice->ID ); $dateYMD = wpinv_get_date_created( $invoice->ID, 'Y-m-d H:i:s' ); ?>
156
-                                            <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
155
+                                        <?php elseif ('created-date' === $column_id) : $date = wpinv_get_date_created($invoice->ID); $dateYMD = wpinv_get_date_created($invoice->ID, 'Y-m-d H:i:s'); ?>
156
+                                            <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
157 157
 
158
-                                        <?php elseif ( 'payment-date' === $column_id ) : $date = wpinv_get_invoice_date( $invoice->ID, '', false ); $dateYMD = wpinv_get_invoice_date( $invoice->ID, 'Y-m-d H:i:s', false ); ?>
159
-                                            <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
158
+                                        <?php elseif ('payment-date' === $column_id) : $date = wpinv_get_invoice_date($invoice->ID, '', false); $dateYMD = wpinv_get_invoice_date($invoice->ID, 'Y-m-d H:i:s', false); ?>
159
+                                            <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
160 160
 
161
-                                        <?php elseif ( 'invoice-status' === $column_id ) : ?>
162
-                                            <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?>
161
+                                        <?php elseif ('invoice-status' === $column_id) : ?>
162
+                                            <?php echo wpinv_invoice_status_label($invoice_status, $invoice->get_status(true)); ?>
163 163
 
164
-                                        <?php elseif ( 'invoice-total' === $column_id ) : ?>
165
-                                            <?php echo $invoice->get_total( true ); ?>
164
+                                        <?php elseif ('invoice-total' === $column_id) : ?>
165
+                                            <?php echo $invoice->get_total(true); ?>
166 166
 
167
-                                        <?php elseif ( 'invoice-actions' === $column_id ) : ?>
167
+                                        <?php elseif ('invoice-actions' === $column_id) : ?>
168 168
                                             <?php
169 169
                                                 $actions = array(
170 170
                                                     'pay'    => array(
171 171
                                                         'url'  => $invoice->get_checkout_payment_url(),
172
-                                                        'name' => __( 'Pay Now', 'invoicing' ),
172
+                                                        'name' => __('Pay Now', 'invoicing'),
173 173
                                                         'class' => 'btn-success'
174 174
                                                     ),
175 175
                                                     'print'   => array(
176 176
                                                         'url'  => $invoice->get_view_url(),
177
-                                                        'name' => __( 'Print', 'invoicing' ),
177
+                                                        'name' => __('Print', 'invoicing'),
178 178
                                                         'class' => 'btn-primary',
179 179
                                                         'attrs' => 'target="_blank"'
180 180
                                                     )
181 181
                                                 );
182 182
 
183
-                                                if ( ! $invoice->needs_payment() ) {
184
-                                                    unset( $actions['pay'] );
183
+                                                if (!$invoice->needs_payment()) {
184
+                                                    unset($actions['pay']);
185 185
                                                 }
186 186
 
187
-                                                if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) {
188
-                                                    foreach ( $actions as $key => $action ) {
187
+                                                if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) {
188
+                                                    foreach ($actions as $key => $action) {
189 189
                                                         $class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
190
-                                                        echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
190
+                                                        echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>';
191 191
                                                     }
192 192
                                                 }
193 193
                                             ?>
@@ -215,64 +215,64 @@  discard block
 block discarded – undo
215 215
             </div>
216 216
             <?php
217 217
         
218
-            do_action( 'wpinv_bp_invoices_after_content' );
218
+            do_action('wpinv_bp_invoices_after_content');
219 219
         } else {
220 220
             ?>
221 221
             <div id="message" class="info">
222
-                <p><?php _e( 'No invoice has been made yet.', 'invoicing' ); ?></p>
222
+                <p><?php _e('No invoice has been made yet.', 'invoicing'); ?></p>
223 223
             </div>
224 224
             <?php
225 225
         }
226 226
         
227
-        if ( defined( 'DOING_AJAX' ) ) {
227
+        if (defined('DOING_AJAX')) {
228 228
             exit;
229 229
         }
230 230
     }
231 231
     
232
-    public function has_invoices( $args = '' ) {
232
+    public function has_invoices($args = '') {
233 233
         global $invoices_template;
234 234
 
235
-        $per_page = absint( wpinv_get_option( 'wpinv_bp_per_page' ) );
235
+        $per_page = absint(wpinv_get_option('wpinv_bp_per_page'));
236 236
         // Parse arguments.
237
-        $r = bp_parse_args( $args, array(
237
+        $r = bp_parse_args($args, array(
238 238
             'status'            => 'all',
239 239
             'page_arg'          => 'bpage',
240 240
             'page'              => 1,
241 241
             'per_page'          => $per_page > 0 ? $per_page : 20,
242 242
             'max'               => false,
243 243
             'user_id'           => bp_loggedin_user_id(),
244
-        ), 'has_invoices' );
244
+        ), 'has_invoices');
245 245
 
246 246
 
247
-        if ( ! empty( $r['max'] ) && ( (int)$r['per_page'] > (int)$r['max'] ) ) {
247
+        if (!empty($r['max']) && ((int)$r['per_page'] > (int)$r['max'])) {
248 248
             $r['per_page'] = (int)$r['max'];
249 249
         }
250 250
 
251 251
         // Get the invoices.
252
-        $invoices_template = new WPInv_BP_Invoices_Template( $r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg'] );
252
+        $invoices_template = new WPInv_BP_Invoices_Template($r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg']);
253 253
 
254
-        return apply_filters( 'wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r );
254
+        return apply_filters('wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r);
255 255
     }
256 256
     
257 257
     public function setup_invoice_count() {
258
-        $query      = apply_filters( 'wpinv_user_invoices_count_query', array( 'user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false ) );
259
-        $invoices   = wpinv_get_invoices( $query );
258
+        $query      = apply_filters('wpinv_user_invoices_count_query', array('user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false));
259
+        $invoices   = wpinv_get_invoices($query);
260 260
         
261
-        $this->count = !empty( $invoices ) ? count( $invoices ) : 0;
261
+        $this->count = !empty($invoices) ? count($invoices) : 0;
262 262
     }
263 263
     
264 264
     public function pagination_count() {
265 265
         global $invoices_template;
266 266
 
267
-        $start_num = intval( ( $invoices_template->pag_page - 1 ) * $invoices_template->pag_num ) + 1;
268
-        $from_num  = bp_core_number_format( $start_num );
269
-        $to_num    = bp_core_number_format( ( $start_num + ( $invoices_template->pag_num - 1 ) > $invoices_template->total_invoice_count ) ? $invoices_template->total_invoice_count : $start_num + ( $invoices_template->pag_num - 1 ) );
270
-        $total     = bp_core_number_format( $invoices_template->total_invoice_count );
267
+        $start_num = intval(($invoices_template->pag_page - 1) * $invoices_template->pag_num) + 1;
268
+        $from_num  = bp_core_number_format($start_num);
269
+        $to_num    = bp_core_number_format(($start_num + ($invoices_template->pag_num - 1) > $invoices_template->total_invoice_count) ? $invoices_template->total_invoice_count : $start_num + ($invoices_template->pag_num - 1));
270
+        $total     = bp_core_number_format($invoices_template->total_invoice_count);
271 271
 
272
-        if ( 1 == $invoices_template->total_invoice_count ) {
273
-            $message = __( 'Viewing 1 invoice', 'invoicing' );
272
+        if (1 == $invoices_template->total_invoice_count) {
273
+            $message = __('Viewing 1 invoice', 'invoicing');
274 274
         } else {
275
-            $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing' ), $from_num, $to_num, $total );
275
+            $message = sprintf(_n('Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing'), $from_num, $to_num, $total);
276 276
         }
277 277
 
278 278
         return $message;
@@ -281,32 +281,32 @@  discard block
 block discarded – undo
281 281
     function pagination_links() {
282 282
         global $invoices_template;
283 283
 
284
-        return apply_filters( 'wpinv_bp_get_pagination_links', $invoices_template->pag_links );
284
+        return apply_filters('wpinv_bp_get_pagination_links', $invoices_template->pag_links);
285 285
     }
286 286
     
287
-    public function bp_section( $settings = array() ) {
288
-        $settings['wpinv_bp'] = __( 'BuddyPress Integration', 'invoicing' );
287
+    public function bp_section($settings = array()) {
288
+        $settings['wpinv_bp'] = __('BuddyPress Integration', 'invoicing');
289 289
         return $settings;
290 290
     }
291 291
     
292
-    public function bp_settings( $settings = array() ) {
292
+    public function bp_settings($settings = array()) {
293 293
         $settings['wpinv_bp'] = array(
294 294
             'wpinv_bp_labels' => array(
295 295
                 'id'   => 'wpinv_bp_settings',
296
-                'name' => '<h3>' . __( 'BuddyPress Integration', 'invoicing' ) . '</h3>',
296
+                'name' => '<h3>' . __('BuddyPress Integration', 'invoicing') . '</h3>',
297 297
                 'desc' => '',
298 298
                 'type' => 'header',
299 299
             ),
300 300
             'wpinv_bp_hide_menu' => array(
301 301
                 'id'   => 'wpinv_bp_hide_menu',
302
-                'name' => __( 'Hide Invoices link', 'invoicing' ),
303
-                'desc' => __( 'Hide Invoices link from BP Profile menu.', 'invoicing' ),
302
+                'name' => __('Hide Invoices link', 'invoicing'),
303
+                'desc' => __('Hide Invoices link from BP Profile menu.', 'invoicing'),
304 304
                 'type' => 'checkbox',
305 305
             ),
306 306
             'wpinv_menu_position' => array(
307 307
                 'id'   => 'wpinv_menu_position',
308
-                'name' => __( 'Menu position', 'invoicing' ),
309
-                'desc' => __( 'Menu position for the Invoices link in BP Profile menu.', 'invoicing' ),
308
+                'name' => __('Menu position', 'invoicing'),
309
+                'desc' => __('Menu position for the Invoices link in BP Profile menu.', 'invoicing'),
310 310
                 'type' => 'number',
311 311
                 'size' => 'small',
312 312
                 'min'  => '1',
@@ -316,8 +316,8 @@  discard block
 block discarded – undo
316 316
             ),
317 317
             'wpinv_bp_per_page' => array(
318 318
                 'id'   => 'wpinv_bp_per_page',
319
-                'name' => __( 'Max invoices per page', 'invoicing' ),
320
-                'desc' => __( 'Enter a number to lists the invoices for each page.', 'invoicing' ),
319
+                'name' => __('Max invoices per page', 'invoicing'),
320
+                'desc' => __('Enter a number to lists the invoices for each page.', 'invoicing'),
321 321
                 'type' => 'number',
322 322
                 'size' => 'small',
323 323
                 'min'  => '1',
@@ -342,25 +342,25 @@  discard block
 block discarded – undo
342 342
     public $pag_links = '';
343 343
     public $total_invoice_count = 0;
344 344
     
345
-    public function __construct( $status, $page, $per_page, $max, $user_id, $page_arg = 'bpage' ) {
346
-        $this->invoices = array( 'invoices' => array(), 'total' => 0 );
345
+    public function __construct($status, $page, $per_page, $max, $user_id, $page_arg = 'bpage') {
346
+        $this->invoices = array('invoices' => array(), 'total' => 0);
347 347
         
348
-        $this->pag_arg  = sanitize_key( $page_arg );
349
-        $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $page );
350
-        $this->pag_num  = bp_sanitize_pagination_arg( 'num', $per_page );
348
+        $this->pag_arg  = sanitize_key($page_arg);
349
+        $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $page);
350
+        $this->pag_num  = bp_sanitize_pagination_arg('num', $per_page);
351 351
 
352
-        $query_args     = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true );
353
-        if ( !empty( $status ) && $status != 'all' ) {
352
+        $query_args     = array('user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true);
353
+        if (!empty($status) && $status != 'all') {
354 354
            $query_args['status'] = $status;
355 355
         }
356
-        $invoices  = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) );
356
+        $invoices = wpinv_get_invoices(apply_filters('wpinv_bp_user_invoices_query', $query_args));
357 357
         
358
-        if ( !empty( $invoices ) && !empty( $invoices->found_posts ) ) {
359
-            $this->invoices['invoices'] = array_map( 'wpinv_get_invoice', $invoices->posts );
358
+        if (!empty($invoices) && !empty($invoices->found_posts)) {
359
+            $this->invoices['invoices'] = array_map('wpinv_get_invoice', $invoices->posts);
360 360
             $this->invoices['total']    = $invoices->found_posts;
361 361
         }
362 362
 
363
-        if ( empty( $max ) || ( $max >= (int)$this->invoices['total'] ) ) {
363
+        if (empty($max) || ($max >= (int)$this->invoices['total'])) {
364 364
             $this->total_invoice_count = (int)$this->invoices['total'];
365 365
         } else {
366 366
             $this->total_invoice_count = (int)$max;
@@ -368,52 +368,52 @@  discard block
 block discarded – undo
368 368
 
369 369
         $this->invoices = $this->invoices['invoices'];
370 370
 
371
-        $invoice_count = count( $this->invoices );
371
+        $invoice_count = count($this->invoices);
372 372
 
373
-        if ( empty( $max ) || ( $max >= (int)$invoice_count ) ) {
373
+        if (empty($max) || ($max >= (int)$invoice_count)) {
374 374
             $this->invoice_count = (int)$invoice_count;
375 375
         } else {
376 376
             $this->invoice_count = (int)$max;
377 377
         }
378 378
         
379
-        if ( ! empty( $this->total_invoice_count ) && ! empty( $this->pag_num ) ) {
380
-            $this->pag_links = paginate_links( array(
381
-                'base'      => add_query_arg( $this->pag_arg, '%#%' ),
379
+        if (!empty($this->total_invoice_count) && !empty($this->pag_num)) {
380
+            $this->pag_links = paginate_links(array(
381
+                'base'      => add_query_arg($this->pag_arg, '%#%'),
382 382
                 'format'    => '',
383
-                'total'     => ceil( (int)$this->total_invoice_count / (int)$this->pag_num ),
383
+                'total'     => ceil((int)$this->total_invoice_count / (int)$this->pag_num),
384 384
                 'current'   => (int)$this->pag_page,
385
-                'prev_text' => _x( '&larr;', 'Invoice pagination previous text', 'invoicing' ),
386
-                'next_text' => _x( '&rarr;', 'Invoice pagination next text',     'invoicing' ),
385
+                'prev_text' => _x('&larr;', 'Invoice pagination previous text', 'invoicing'),
386
+                'next_text' => _x('&rarr;', 'Invoice pagination next text', 'invoicing'),
387 387
                 'mid_size'  => 1,
388 388
                 'add_args'  => array(),
389
-            ) );
389
+            ));
390 390
         }
391 391
     }
392 392
 
393 393
     public function has_invoices() {
394
-        return (bool) ! empty( $this->invoice_count );
394
+        return (bool)!empty($this->invoice_count);
395 395
     }
396 396
 
397 397
     public function next_invoice() {
398 398
         $this->current_invoice++;
399
-        $this->invoice = $this->invoices[ $this->current_invoice ];
399
+        $this->invoice = $this->invoices[$this->current_invoice];
400 400
 
401 401
         return $this->invoice;
402 402
     }
403 403
 
404 404
     public function rewind_invoices() {
405 405
         $this->current_invoice = -1;
406
-        if ( $this->invoice_count > 0 ) {
406
+        if ($this->invoice_count > 0) {
407 407
             $this->invoice = $this->invoices[0];
408 408
         }
409 409
     }
410 410
 
411 411
     public function invoices() {
412
-        if ( ( $this->current_invoice + 1 ) < $this->invoice_count ) {
412
+        if (($this->current_invoice + 1) < $this->invoice_count) {
413 413
             return true;
414
-        } elseif ( ( $this->current_invoice + 1 ) === $this->invoice_count ) {
414
+        } elseif (($this->current_invoice + 1) === $this->invoice_count) {
415 415
 
416
-            do_action( 'wpinv_bp_invoice_loop_end' );
416
+            do_action('wpinv_bp_invoice_loop_end');
417 417
             
418 418
             $this->rewind_invoices();
419 419
         }
@@ -427,8 +427,8 @@  discard block
 block discarded – undo
427 427
         $this->in_the_loop = true;
428 428
         $this->invoice     = $this->next_invoice();
429 429
 
430
-        if ( 0 === $this->current_invoice ) {
431
-            do_action( 'wpinv_bp_invoice_loop_start' );
430
+        if (0 === $this->current_invoice) {
431
+            do_action('wpinv_bp_invoice_loop_start');
432 432
         }
433 433
     }
434 434
 }
@@ -438,9 +438,9 @@  discard block
 block discarded – undo
438 438
 
439 439
     $bp->invoicing = new WPInv_BP_Component();
440 440
     
441
-    add_action( 'wp_ajax_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) );
442
-    add_action( 'wp_ajax_nopriv_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) );
443
-    add_filter( 'wpinv_settings_sections_general', array( $bp->invoicing, 'bp_section' ), 10, 1 );
444
-    add_filter( 'wpinv_settings_general', array( $bp->invoicing, 'bp_settings' ), 10, 1 );
441
+    add_action('wp_ajax_invoicing_filter', array($bp->invoicing, 'invoices_content'));
442
+    add_action('wp_ajax_nopriv_invoicing_filter', array($bp->invoicing, 'invoices_content'));
443
+    add_filter('wpinv_settings_sections_general', array($bp->invoicing, 'bp_section'), 10, 1);
444
+    add_filter('wpinv_settings_general', array($bp->invoicing, 'bp_settings'), 10, 1);
445 445
 }
446
-add_action( 'bp_loaded', 'wpinv_bp_setup_component' );
447 446
\ No newline at end of file
447
+add_action('bp_loaded', 'wpinv_bp_setup_component');
448 448
\ No newline at end of file
Please login to merge, or discard this patch.
includes/wpinv-general-functions.php 3 patches
Braces   +18 added lines, -12 removed lines patch added patch discarded remove patch
@@ -67,8 +67,9 @@  discard block
 block discarded – undo
67 67
     
68 68
     if ( !empty( $args ) ) {
69 69
         // Check for backward compatibility
70
-        if ( is_string( $args ) )
71
-            $args = str_replace( '?', '', $args );
70
+        if ( is_string( $args ) ) {
71
+                    $args = str_replace( '?', '', $args );
72
+        }
72 73
 
73 74
         $args = wp_parse_args( $args );
74 75
 
@@ -87,8 +88,9 @@  discard block
 block discarded – undo
87 88
     
88 89
     if ( !empty( $args ) ) {
89 90
         // Check for backward compatibility
90
-        if ( is_string( $args ) )
91
-            $args = str_replace( '?', '', $args );
91
+        if ( is_string( $args ) ) {
92
+                    $args = str_replace( '?', '', $args );
93
+        }
92 94
 
93 95
         $args = wp_parse_args( $args );
94 96
 
@@ -108,8 +110,9 @@  discard block
 block discarded – undo
108 110
 
109 111
 	if ( !empty( $args ) ) {
110 112
 		// Check for backward compatibility
111
-		if ( is_string( $args ) )
112
-			$args = str_replace( '?', '', $args );
113
+		if ( is_string( $args ) ) {
114
+					$args = str_replace( '?', '', $args );
115
+		}
113 116
 
114 117
 		$args = wp_parse_args( $args );
115 118
 
@@ -132,8 +135,9 @@  discard block
 block discarded – undo
132 135
 
133 136
 	if ( ! empty( $args ) ) {
134 137
 		// Check for backward compatibility
135
-		if ( is_string( $args ) )
136
-			$args = str_replace( '?', '', $args );
138
+		if ( is_string( $args ) ) {
139
+					$args = str_replace( '?', '', $args );
140
+		}
137 141
 
138 142
 		$args = wp_parse_args( $args );
139 143
 
@@ -148,8 +152,9 @@  discard block
 block discarded – undo
148 152
 	$success_page = wpinv_get_option( 'success_page', 0 );
149 153
 	$success_page = get_permalink( $success_page );
150 154
 
151
-	if ( $query_string )
152
-		$success_page .= $query_string;
155
+	if ( $query_string ) {
156
+			$success_page .= $query_string;
157
+	}
153 158
 
154 159
 	return apply_filters( 'wpinv_success_page_url', $success_page );
155 160
 }
@@ -158,8 +163,9 @@  discard block
 block discarded – undo
158 163
 	$uri = wpinv_get_option( 'failure_page', '' );
159 164
 	$uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
160 165
 
161
-	if ( $extras )
162
-		$uri .= $extras;
166
+	if ( $extras ) {
167
+			$uri .= $extras;
168
+	}
163 169
 
164 170
 	return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
165 171
 }
Please login to merge, or discard this patch.
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -30,36 +30,36 @@  discard block
 block discarded – undo
30 30
 }
31 31
 
32 32
 function wpinv_can_checkout() {
33
-	$can_checkout = true; // Always true for now
33
+    $can_checkout = true; // Always true for now
34 34
 
35
-	return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout );
35
+    return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout );
36 36
 }
37 37
 
38 38
 function wpinv_get_success_page_uri() {
39
-	$page_id = wpinv_get_option( 'success_page', 0 );
40
-	$page_id = absint( $page_id );
39
+    $page_id = wpinv_get_option( 'success_page', 0 );
40
+    $page_id = absint( $page_id );
41 41
 
42
-	return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) );
42
+    return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) );
43 43
 }
44 44
 
45 45
 function wpinv_get_history_page_uri() {
46
-	$page_id = wpinv_get_option( 'invoice_history_page', 0 );
47
-	$page_id = absint( $page_id );
46
+    $page_id = wpinv_get_option( 'invoice_history_page', 0 );
47
+    $page_id = absint( $page_id );
48 48
 
49
-	return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) );
49
+    return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) );
50 50
 }
51 51
 
52 52
 function wpinv_is_success_page() {
53
-	$is_success_page = wpinv_get_option( 'success_page', false );
54
-	$is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false;
53
+    $is_success_page = wpinv_get_option( 'success_page', false );
54
+    $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false;
55 55
 
56
-	return apply_filters( 'wpinv_is_success_page', $is_success_page );
56
+    return apply_filters( 'wpinv_is_success_page', $is_success_page );
57 57
 }
58 58
 
59 59
 function wpinv_is_invoice_history_page() {
60
-	$ret = wpinv_get_option( 'invoice_history_page', false );
61
-	$ret = $ret ? is_page( $ret ) : false;
62
-	return apply_filters( 'wpinv_is_invoice_history_page', $ret );
60
+    $ret = wpinv_get_option( 'invoice_history_page', false );
61
+    $ret = $ret ? is_page( $ret ) : false;
62
+    return apply_filters( 'wpinv_is_invoice_history_page', $ret );
63 63
 }
64 64
 
65 65
 function wpinv_is_subscriptions_history_page() {
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 }
70 70
 
71 71
 function wpinv_send_to_success_page( $args = null ) {
72
-	$redirect = wpinv_get_success_page_uri();
72
+    $redirect = wpinv_get_success_page_uri();
73 73
     
74 74
     if ( !empty( $args ) ) {
75 75
         // Check for backward compatibility
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 }
90 90
 
91 91
 function wpinv_send_to_failed_page( $args = null ) {
92
-	$redirect = wpinv_get_failed_transaction_uri();
92
+    $redirect = wpinv_get_failed_transaction_uri();
93 93
     
94 94
     if ( !empty( $args ) ) {
95 95
         // Check for backward compatibility
@@ -109,72 +109,72 @@  discard block
 block discarded – undo
109 109
 }
110 110
 
111 111
 function wpinv_get_checkout_uri( $args = array() ) {
112
-	$uri = wpinv_get_option( 'checkout_page', false );
113
-	$uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
112
+    $uri = wpinv_get_option( 'checkout_page', false );
113
+    $uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
114 114
 
115
-	if ( !empty( $args ) ) {
116
-		// Check for backward compatibility
117
-		if ( is_string( $args ) )
118
-			$args = str_replace( '?', '', $args );
115
+    if ( !empty( $args ) ) {
116
+        // Check for backward compatibility
117
+        if ( is_string( $args ) )
118
+            $args = str_replace( '?', '', $args );
119 119
 
120
-		$args = wp_parse_args( $args );
120
+        $args = wp_parse_args( $args );
121 121
 
122
-		$uri = add_query_arg( $args, $uri );
123
-	}
122
+        $uri = add_query_arg( $args, $uri );
123
+    }
124 124
 
125
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
125
+    $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
126 126
 
127
-	$ajax_url = admin_url( 'admin-ajax.php', $scheme );
127
+    $ajax_url = admin_url( 'admin-ajax.php', $scheme );
128 128
 
129
-	if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
130
-		$uri = preg_replace( '/^http:/', 'https:', $uri );
131
-	}
129
+    if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
130
+        $uri = preg_replace( '/^http:/', 'https:', $uri );
131
+    }
132 132
 
133
-	return apply_filters( 'wpinv_get_checkout_uri', $uri );
133
+    return apply_filters( 'wpinv_get_checkout_uri', $uri );
134 134
 }
135 135
 
136 136
 function wpinv_send_back_to_checkout( $args = array() ) {
137
-	$redirect = wpinv_get_checkout_uri();
137
+    $redirect = wpinv_get_checkout_uri();
138 138
 
139
-	if ( ! empty( $args ) ) {
140
-		// Check for backward compatibility
141
-		if ( is_string( $args ) )
142
-			$args = str_replace( '?', '', $args );
139
+    if ( ! empty( $args ) ) {
140
+        // Check for backward compatibility
141
+        if ( is_string( $args ) )
142
+            $args = str_replace( '?', '', $args );
143 143
 
144
-		$args = wp_parse_args( $args );
144
+        $args = wp_parse_args( $args );
145 145
 
146
-		$redirect = add_query_arg( $args, $redirect );
147
-	}
146
+        $redirect = add_query_arg( $args, $redirect );
147
+    }
148 148
 
149
-	wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) );
150
-	exit;
149
+    wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) );
150
+    exit;
151 151
 }
152 152
 
153 153
 function wpinv_get_success_page_url( $query_string = null ) {
154
-	$success_page = wpinv_get_option( 'success_page', 0 );
155
-	$success_page = get_permalink( $success_page );
154
+    $success_page = wpinv_get_option( 'success_page', 0 );
155
+    $success_page = get_permalink( $success_page );
156 156
 
157
-	if ( $query_string )
158
-		$success_page .= $query_string;
157
+    if ( $query_string )
158
+        $success_page .= $query_string;
159 159
 
160
-	return apply_filters( 'wpinv_success_page_url', $success_page );
160
+    return apply_filters( 'wpinv_success_page_url', $success_page );
161 161
 }
162 162
 
163 163
 function wpinv_get_failed_transaction_uri( $extras = false ) {
164
-	$uri = wpinv_get_option( 'failure_page', '' );
165
-	$uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
164
+    $uri = wpinv_get_option( 'failure_page', '' );
165
+    $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
166 166
 
167
-	if ( $extras )
168
-		$uri .= $extras;
167
+    if ( $extras )
168
+        $uri .= $extras;
169 169
 
170
-	return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
170
+    return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
171 171
 }
172 172
 
173 173
 function wpinv_is_failed_transaction_page() {
174
-	$ret = wpinv_get_option( 'failure_page', false );
175
-	$ret = isset( $ret ) ? is_page( $ret ) : false;
174
+    $ret = wpinv_get_option( 'failure_page', false );
175
+    $ret = isset( $ret ) ? is_page( $ret ) : false;
176 176
 
177
-	return apply_filters( 'wpinv_is_failure_page', $ret );
177
+    return apply_filters( 'wpinv_is_failure_page', $ret );
178 178
 }
179 179
 
180 180
 function wpinv_transaction_query( $type = 'start' ) {
Please login to merge, or discard this patch.
Spacing   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -7,201 +7,201 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 function wpinv_is_checkout() {
15 15
     global $wp_query;
16 16
 
17
-    $is_object_set    = isset( $wp_query->queried_object );
18
-    $is_object_id_set = isset( $wp_query->queried_object_id );
19
-    $is_checkout      = is_page( wpinv_get_option( 'checkout_page' ) );
17
+    $is_object_set    = isset($wp_query->queried_object);
18
+    $is_object_id_set = isset($wp_query->queried_object_id);
19
+    $is_checkout      = is_page(wpinv_get_option('checkout_page'));
20 20
 
21
-    if ( !$is_object_set ) {
22
-        unset( $wp_query->queried_object );
21
+    if (!$is_object_set) {
22
+        unset($wp_query->queried_object);
23 23
     }
24 24
 
25
-    if ( !$is_object_id_set ) {
26
-        unset( $wp_query->queried_object_id );
25
+    if (!$is_object_id_set) {
26
+        unset($wp_query->queried_object_id);
27 27
     }
28 28
 
29
-    return apply_filters( 'wpinv_is_checkout', $is_checkout );
29
+    return apply_filters('wpinv_is_checkout', $is_checkout);
30 30
 }
31 31
 
32 32
 function wpinv_can_checkout() {
33 33
 	$can_checkout = true; // Always true for now
34 34
 
35
-	return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout );
35
+	return (bool)apply_filters('wpinv_can_checkout', $can_checkout);
36 36
 }
37 37
 
38 38
 function wpinv_get_success_page_uri() {
39
-	$page_id = wpinv_get_option( 'success_page', 0 );
40
-	$page_id = absint( $page_id );
39
+	$page_id = wpinv_get_option('success_page', 0);
40
+	$page_id = absint($page_id);
41 41
 
42
-	return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) );
42
+	return apply_filters('wpinv_get_success_page_uri', get_permalink($page_id));
43 43
 }
44 44
 
45 45
 function wpinv_get_history_page_uri() {
46
-	$page_id = wpinv_get_option( 'invoice_history_page', 0 );
47
-	$page_id = absint( $page_id );
46
+	$page_id = wpinv_get_option('invoice_history_page', 0);
47
+	$page_id = absint($page_id);
48 48
 
49
-	return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) );
49
+	return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id));
50 50
 }
51 51
 
52 52
 function wpinv_is_success_page() {
53
-	$is_success_page = wpinv_get_option( 'success_page', false );
54
-	$is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false;
53
+	$is_success_page = wpinv_get_option('success_page', false);
54
+	$is_success_page = isset($is_success_page) ? is_page($is_success_page) : false;
55 55
 
56
-	return apply_filters( 'wpinv_is_success_page', $is_success_page );
56
+	return apply_filters('wpinv_is_success_page', $is_success_page);
57 57
 }
58 58
 
59 59
 function wpinv_is_invoice_history_page() {
60
-	$ret = wpinv_get_option( 'invoice_history_page', false );
61
-	$ret = $ret ? is_page( $ret ) : false;
62
-	return apply_filters( 'wpinv_is_invoice_history_page', $ret );
60
+	$ret = wpinv_get_option('invoice_history_page', false);
61
+	$ret = $ret ? is_page($ret) : false;
62
+	return apply_filters('wpinv_is_invoice_history_page', $ret);
63 63
 }
64 64
 
65 65
 function wpinv_is_subscriptions_history_page() {
66
-    $ret = wpinv_get_option( 'invoice_subscription_page', false );
67
-    $ret = $ret ? is_page( $ret ) : false;
68
-    return apply_filters( 'wpinv_is_subscriptions_history_page', $ret );
66
+    $ret = wpinv_get_option('invoice_subscription_page', false);
67
+    $ret = $ret ? is_page($ret) : false;
68
+    return apply_filters('wpinv_is_subscriptions_history_page', $ret);
69 69
 }
70 70
 
71
-function wpinv_send_to_success_page( $args = null ) {
71
+function wpinv_send_to_success_page($args = null) {
72 72
 	$redirect = wpinv_get_success_page_uri();
73 73
     
74
-    if ( !empty( $args ) ) {
74
+    if (!empty($args)) {
75 75
         // Check for backward compatibility
76
-        if ( is_string( $args ) )
77
-            $args = str_replace( '?', '', $args );
76
+        if (is_string($args))
77
+            $args = str_replace('?', '', $args);
78 78
 
79
-        $args = wp_parse_args( $args );
79
+        $args = wp_parse_args($args);
80 80
 
81
-        $redirect = add_query_arg( $args, $redirect );
81
+        $redirect = add_query_arg($args, $redirect);
82 82
     }
83 83
 
84
-    $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : '';
84
+    $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : '';
85 85
     
86
-    $redirect = apply_filters( 'wpinv_success_page_redirect', $redirect, $gateway, $args );
87
-    wp_redirect( $redirect );
86
+    $redirect = apply_filters('wpinv_success_page_redirect', $redirect, $gateway, $args);
87
+    wp_redirect($redirect);
88 88
     exit;
89 89
 }
90 90
 
91
-function wpinv_send_to_failed_page( $args = null ) {
91
+function wpinv_send_to_failed_page($args = null) {
92 92
 	$redirect = wpinv_get_failed_transaction_uri();
93 93
     
94
-    if ( !empty( $args ) ) {
94
+    if (!empty($args)) {
95 95
         // Check for backward compatibility
96
-        if ( is_string( $args ) )
97
-            $args = str_replace( '?', '', $args );
96
+        if (is_string($args))
97
+            $args = str_replace('?', '', $args);
98 98
 
99
-        $args = wp_parse_args( $args );
99
+        $args = wp_parse_args($args);
100 100
 
101
-        $redirect = add_query_arg( $args, $redirect );
101
+        $redirect = add_query_arg($args, $redirect);
102 102
     }
103 103
 
104
-    $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : '';
104
+    $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : '';
105 105
     
106
-    $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args );
107
-    wp_redirect( $redirect );
106
+    $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args);
107
+    wp_redirect($redirect);
108 108
     exit;
109 109
 }
110 110
 
111
-function wpinv_get_checkout_uri( $args = array() ) {
112
-	$uri = wpinv_get_option( 'checkout_page', false );
113
-	$uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
111
+function wpinv_get_checkout_uri($args = array()) {
112
+	$uri = wpinv_get_option('checkout_page', false);
113
+	$uri = isset($uri) ? get_permalink($uri) : NULL;
114 114
 
115
-	if ( !empty( $args ) ) {
115
+	if (!empty($args)) {
116 116
 		// Check for backward compatibility
117
-		if ( is_string( $args ) )
118
-			$args = str_replace( '?', '', $args );
117
+		if (is_string($args))
118
+			$args = str_replace('?', '', $args);
119 119
 
120
-		$args = wp_parse_args( $args );
120
+		$args = wp_parse_args($args);
121 121
 
122
-		$uri = add_query_arg( $args, $uri );
122
+		$uri = add_query_arg($args, $uri);
123 123
 	}
124 124
 
125
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
125
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
126 126
 
127
-	$ajax_url = admin_url( 'admin-ajax.php', $scheme );
127
+	$ajax_url = admin_url('admin-ajax.php', $scheme);
128 128
 
129
-	if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
130
-		$uri = preg_replace( '/^http:/', 'https:', $uri );
129
+	if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) {
130
+		$uri = preg_replace('/^http:/', 'https:', $uri);
131 131
 	}
132 132
 
133
-	return apply_filters( 'wpinv_get_checkout_uri', $uri );
133
+	return apply_filters('wpinv_get_checkout_uri', $uri);
134 134
 }
135 135
 
136
-function wpinv_send_back_to_checkout( $args = array() ) {
136
+function wpinv_send_back_to_checkout($args = array()) {
137 137
 	$redirect = wpinv_get_checkout_uri();
138 138
 
139
-	if ( ! empty( $args ) ) {
139
+	if (!empty($args)) {
140 140
 		// Check for backward compatibility
141
-		if ( is_string( $args ) )
142
-			$args = str_replace( '?', '', $args );
141
+		if (is_string($args))
142
+			$args = str_replace('?', '', $args);
143 143
 
144
-		$args = wp_parse_args( $args );
144
+		$args = wp_parse_args($args);
145 145
 
146
-		$redirect = add_query_arg( $args, $redirect );
146
+		$redirect = add_query_arg($args, $redirect);
147 147
 	}
148 148
 
149
-	wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) );
149
+	wp_redirect(apply_filters('wpinv_send_back_to_checkout', $redirect, $args));
150 150
 	exit;
151 151
 }
152 152
 
153
-function wpinv_get_success_page_url( $query_string = null ) {
154
-	$success_page = wpinv_get_option( 'success_page', 0 );
155
-	$success_page = get_permalink( $success_page );
153
+function wpinv_get_success_page_url($query_string = null) {
154
+	$success_page = wpinv_get_option('success_page', 0);
155
+	$success_page = get_permalink($success_page);
156 156
 
157
-	if ( $query_string )
157
+	if ($query_string)
158 158
 		$success_page .= $query_string;
159 159
 
160
-	return apply_filters( 'wpinv_success_page_url', $success_page );
160
+	return apply_filters('wpinv_success_page_url', $success_page);
161 161
 }
162 162
 
163
-function wpinv_get_failed_transaction_uri( $extras = false ) {
164
-	$uri = wpinv_get_option( 'failure_page', '' );
165
-	$uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
163
+function wpinv_get_failed_transaction_uri($extras = false) {
164
+	$uri = wpinv_get_option('failure_page', '');
165
+	$uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url();
166 166
 
167
-	if ( $extras )
167
+	if ($extras)
168 168
 		$uri .= $extras;
169 169
 
170
-	return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
170
+	return apply_filters('wpinv_get_failed_transaction_uri', $uri);
171 171
 }
172 172
 
173 173
 function wpinv_is_failed_transaction_page() {
174
-	$ret = wpinv_get_option( 'failure_page', false );
175
-	$ret = isset( $ret ) ? is_page( $ret ) : false;
174
+	$ret = wpinv_get_option('failure_page', false);
175
+	$ret = isset($ret) ? is_page($ret) : false;
176 176
 
177
-	return apply_filters( 'wpinv_is_failure_page', $ret );
177
+	return apply_filters('wpinv_is_failure_page', $ret);
178 178
 }
179 179
 
180
-function wpinv_transaction_query( $type = 'start' ) {
180
+function wpinv_transaction_query($type = 'start') {
181 181
     global $wpdb;
182 182
 
183 183
     $wpdb->hide_errors();
184 184
 
185
-    if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) {
186
-        define( 'WPINV_USE_TRANSACTIONS', true );
185
+    if (!defined('WPINV_USE_TRANSACTIONS')) {
186
+        define('WPINV_USE_TRANSACTIONS', true);
187 187
     }
188 188
 
189
-    if ( WPINV_USE_TRANSACTIONS ) {
190
-        switch ( $type ) {
189
+    if (WPINV_USE_TRANSACTIONS) {
190
+        switch ($type) {
191 191
             case 'commit' :
192
-                $wpdb->query( 'COMMIT' );
192
+                $wpdb->query('COMMIT');
193 193
                 break;
194 194
             case 'rollback' :
195
-                $wpdb->query( 'ROLLBACK' );
195
+                $wpdb->query('ROLLBACK');
196 196
                 break;
197 197
             default :
198
-                $wpdb->query( 'START TRANSACTION' );
198
+                $wpdb->query('START TRANSACTION');
199 199
             break;
200 200
         }
201 201
     }
202 202
 }
203 203
 
204
-function wpinv_create_invoice( $args = array(), $data = array(), $wp_error = false ) {
204
+function wpinv_create_invoice($args = array(), $data = array(), $wp_error = false) {
205 205
     $default_args = array(
206 206
         'status'        => '',
207 207
         'user_id'       => null,
@@ -211,63 +211,63 @@  discard block
 block discarded – undo
211 211
         'parent'        => 0
212 212
     );
213 213
 
214
-    $args           = wp_parse_args( $args, $default_args );
214
+    $args           = wp_parse_args($args, $default_args);
215 215
     $invoice_data   = array();
216 216
 
217
-    if ( $args['invoice_id'] > 0 ) {
218
-        $updating           = true;
217
+    if ($args['invoice_id'] > 0) {
218
+        $updating = true;
219 219
         $invoice_data['post_type']  = 'wpi_invoice';
220 220
         $invoice_data['ID']         = $args['invoice_id'];
221 221
     } else {
222 222
         $updating                       = false;
223 223
         $invoice_data['post_type']      = 'wpi_invoice';
224
-        $invoice_data['post_status']    = apply_filters( 'wpinv_default_invoice_status', 'wpi-pending' );
224
+        $invoice_data['post_status']    = apply_filters('wpinv_default_invoice_status', 'wpi-pending');
225 225
         $invoice_data['ping_status']    = 'closed';
226
-        $invoice_data['post_author']    = !empty( $args['user_id'] ) ? $args['user_id'] : get_current_user_id();
227
-        $invoice_data['post_title']     = wpinv_format_invoice_number( '0' );
228
-        $invoice_data['post_parent']    = absint( $args['parent'] );
229
-        if ( !empty( $args['created_date'] ) ) {
226
+        $invoice_data['post_author']    = !empty($args['user_id']) ? $args['user_id'] : get_current_user_id();
227
+        $invoice_data['post_title']     = wpinv_format_invoice_number('0');
228
+        $invoice_data['post_parent']    = absint($args['parent']);
229
+        if (!empty($args['created_date'])) {
230 230
             $invoice_data['post_date']      = $args['created_date'];
231
-            $invoice_data['post_date_gmt']  = get_gmt_from_date( $args['created_date'] );
231
+            $invoice_data['post_date_gmt']  = get_gmt_from_date($args['created_date']);
232 232
         }
233 233
     }
234 234
 
235
-    if ( $args['status'] ) {
236
-        if ( ! in_array( $args['status'], array_keys( wpinv_get_invoice_statuses() ) ) ) {
237
-            return new WP_Error( 'wpinv_invalid_invoice_status', wp_sprintf( __( 'Invalid invoice status: %s', 'invoicing' ), $args['status'] ) );
235
+    if ($args['status']) {
236
+        if (!in_array($args['status'], array_keys(wpinv_get_invoice_statuses()))) {
237
+            return new WP_Error('wpinv_invalid_invoice_status', wp_sprintf(__('Invalid invoice status: %s', 'invoicing'), $args['status']));
238 238
         }
239
-        $invoice_data['post_status']    = $args['status'];
239
+        $invoice_data['post_status'] = $args['status'];
240 240
     }
241 241
 
242
-    if ( ! is_null( $args['user_note'] ) ) {
243
-        $invoice_data['post_excerpt']   = $args['user_note'];
242
+    if (!is_null($args['user_note'])) {
243
+        $invoice_data['post_excerpt'] = $args['user_note'];
244 244
     }
245 245
 
246
-    if ( $updating ) {
247
-        $invoice_id = wp_update_post( $invoice_data, true );
246
+    if ($updating) {
247
+        $invoice_id = wp_update_post($invoice_data, true);
248 248
     } else {
249
-        $invoice_id = wp_insert_post( apply_filters( 'wpinv_new_invoice_data', $invoice_data ), true );
249
+        $invoice_id = wp_insert_post(apply_filters('wpinv_new_invoice_data', $invoice_data), true);
250 250
     }
251 251
 
252
-    if ( is_wp_error( $invoice_id ) ) {
252
+    if (is_wp_error($invoice_id)) {
253 253
         return $wp_error ? $invoice_id : 0;
254 254
     }
255 255
     
256
-    $invoice = wpinv_get_invoice( $invoice_id );
257
-
258
-    if ( !$updating ) {
259
-        update_post_meta( $invoice_id, '_wpinv_key', apply_filters( 'wpinv_generate_invoice_key', uniqid( 'wpinv_' ) ) );
260
-        update_post_meta( $invoice_id, '_wpinv_currency', wpinv_get_currency() );
261
-        update_post_meta( $invoice_id, '_wpinv_include_tax', get_option( 'wpinv_prices_include_tax' ) );
262
-        update_post_meta( $invoice_id, '_wpinv_user_ip', wpinv_get_ip() );
263
-        update_post_meta( $invoice_id, '_wpinv_user_agent', wpinv_get_user_agent() );
264
-        update_post_meta( $invoice_id, '_wpinv_created_via', sanitize_text_field( $args['created_via'] ) );
256
+    $invoice = wpinv_get_invoice($invoice_id);
257
+
258
+    if (!$updating) {
259
+        update_post_meta($invoice_id, '_wpinv_key', apply_filters('wpinv_generate_invoice_key', uniqid('wpinv_')));
260
+        update_post_meta($invoice_id, '_wpinv_currency', wpinv_get_currency());
261
+        update_post_meta($invoice_id, '_wpinv_include_tax', get_option('wpinv_prices_include_tax'));
262
+        update_post_meta($invoice_id, '_wpinv_user_ip', wpinv_get_ip());
263
+        update_post_meta($invoice_id, '_wpinv_user_agent', wpinv_get_user_agent());
264
+        update_post_meta($invoice_id, '_wpinv_created_via', sanitize_text_field($args['created_via']));
265 265
         
266 266
         // Add invoice note
267
-        $invoice->add_note( wp_sprintf( __( 'Invoice is created with status %s.', 'invoicing' ), wpinv_status_nicename( $invoice->status ) ) );
267
+        $invoice->add_note(wp_sprintf(__('Invoice is created with status %s.', 'invoicing'), wpinv_status_nicename($invoice->status)));
268 268
     }
269 269
 
270
-    update_post_meta( $invoice_id, '_wpinv_version', WPINV_VERSION );
270
+    update_post_meta($invoice_id, '_wpinv_version', WPINV_VERSION);
271 271
 
272 272
     return $invoice;
273 273
 }
@@ -275,178 +275,178 @@  discard block
 block discarded – undo
275 275
 function wpinv_get_prefix() {
276 276
     $invoice_prefix = 'INV-';
277 277
     
278
-    return apply_filters( 'wpinv_get_prefix', $invoice_prefix );
278
+    return apply_filters('wpinv_get_prefix', $invoice_prefix);
279 279
 }
280 280
 
281 281
 function wpinv_get_business_logo() {
282
-    $business_logo = wpinv_get_option( 'logo' );
283
-    return apply_filters( 'wpinv_get_business_logo', $business_logo );
282
+    $business_logo = wpinv_get_option('logo');
283
+    return apply_filters('wpinv_get_business_logo', $business_logo);
284 284
 }
285 285
 
286 286
 function wpinv_get_business_name() {
287 287
     $business_name = wpinv_get_option('store_name');
288
-    return apply_filters( 'wpinv_get_business_name', $business_name );
288
+    return apply_filters('wpinv_get_business_name', $business_name);
289 289
 }
290 290
 
291 291
 function wpinv_get_blogname() {
292
-    return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
292
+    return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
293 293
 }
294 294
 
295 295
 function wpinv_get_admin_email() {
296
-    $admin_email = get_option( 'admin_email' );
297
-    return apply_filters( 'wpinv_admin_email', $admin_email );
296
+    $admin_email = get_option('admin_email');
297
+    return apply_filters('wpinv_admin_email', $admin_email);
298 298
 }
299 299
 
300 300
 function wpinv_get_business_website() {
301
-    $business_website = home_url( '/' );
302
-    return apply_filters( 'wpinv_get_business_website', $business_website );
301
+    $business_website = home_url('/');
302
+    return apply_filters('wpinv_get_business_website', $business_website);
303 303
 }
304 304
 
305
-function wpinv_get_terms_text( $invoice_id = 0 ) {
305
+function wpinv_get_terms_text($invoice_id = 0) {
306 306
     $terms_text = '';
307
-    return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id );
307
+    return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id);
308 308
 }
309 309
 
310 310
 function wpinv_get_business_footer() {
311
-    $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>';
312
-    $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link );
313
-    return apply_filters( 'wpinv_get_business_footer', $business_footer );
311
+    $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>';
312
+    $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link);
313
+    return apply_filters('wpinv_get_business_footer', $business_footer);
314 314
 }
315 315
 
316 316
 function wpinv_checkout_required_fields() {
317 317
     $required_fields = array();
318 318
     
319 319
     // Let payment gateways and other extensions determine if address fields should be required
320
-    $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() );
320
+    $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes());
321 321
     
322
-    if ( $require_billing_details ) {
322
+    if ($require_billing_details) {
323 323
         ///$required_fields['email'] = array(
324 324
                 ///'error_id' => 'invalid_email',
325 325
                 ///'error_message' => __( 'Please enter a valid email address', 'invoicing' )
326 326
             ///);
327 327
         $required_fields['first_name'] = array(
328 328
                 'error_id' => 'invalid_first_name',
329
-                'error_message' => __( 'Please enter your first name', 'invoicing' )
329
+                'error_message' => __('Please enter your first name', 'invoicing')
330 330
             );
331 331
         $required_fields['address'] = array(
332 332
                 'error_id' => 'invalid_address',
333
-                'error_message' => __( 'Please enter your address', 'invoicing' )
333
+                'error_message' => __('Please enter your address', 'invoicing')
334 334
             );
335 335
         $required_fields['city'] = array(
336 336
                 'error_id' => 'invalid_city',
337
-                'error_message' => __( 'Please enter your billing city', 'invoicing' )
337
+                'error_message' => __('Please enter your billing city', 'invoicing')
338 338
             );
339 339
         $required_fields['state'] = array(
340 340
                 'error_id' => 'invalid_state',
341
-                'error_message' => __( 'Please enter billing state / province', 'invoicing' )
341
+                'error_message' => __('Please enter billing state / province', 'invoicing')
342 342
             );
343 343
         $required_fields['country'] = array(
344 344
                 'error_id' => 'invalid_country',
345
-                'error_message' => __( 'Please select your billing country', 'invoicing' )
345
+                'error_message' => __('Please select your billing country', 'invoicing')
346 346
             );
347 347
     }
348 348
 
349
-    return apply_filters( 'wpinv_checkout_required_fields', $required_fields );
349
+    return apply_filters('wpinv_checkout_required_fields', $required_fields);
350 350
 }
351 351
 
352 352
 function wpinv_is_ssl_enforced() {
353
-    $ssl_enforced = wpinv_get_option( 'enforce_ssl', false );
354
-    return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced );
353
+    $ssl_enforced = wpinv_get_option('enforce_ssl', false);
354
+    return (bool)apply_filters('wpinv_is_ssl_enforced', $ssl_enforced);
355 355
 }
356 356
 
357
-function wpinv_user_can_view_invoice( $post ) {
357
+function wpinv_user_can_view_invoice($post) {
358 358
     $allow = false;
359 359
 
360
-    $post = get_post( $post );
360
+    $post = get_post($post);
361 361
 
362
-    if ( empty( $post->ID ) ) {
362
+    if (empty($post->ID)) {
363 363
         return $allow;
364 364
     }
365 365
 
366
-    $invoice = wpinv_get_invoice( $post->ID );
367
-    if ( empty( $invoice->ID ) ) {
366
+    $invoice = wpinv_get_invoice($post->ID);
367
+    if (empty($invoice->ID)) {
368 368
         return $allow;
369 369
     }
370 370
 
371 371
     // Don't allow trash, draft status
372
-    if ( $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) {
373
-        if ( current_user_can( 'manage_options' ) ) { // Admin user
372
+    if ($invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) {
373
+        if (current_user_can('manage_options')) { // Admin user
374 374
             $allow = true;
375 375
         } else {
376
-            if ( is_user_logged_in() ) {
377
-                if ( (int)$invoice->get_user_id() === (int)get_current_user_id() ) {
376
+            if (is_user_logged_in()) {
377
+                if ((int)$invoice->get_user_id() === (int)get_current_user_id()) {
378 378
                     $allow = true;
379
-                } else if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
379
+                } else if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
380 380
                     $allow = true;
381 381
                 }
382 382
             } else {
383
-                if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
383
+                if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
384 384
                     $allow = true;
385 385
                 }
386 386
             }
387 387
         }
388 388
     }
389 389
     
390
-    return apply_filters( 'wpinv_can_print_invoice', $allow, $post, $invoice );
390
+    return apply_filters('wpinv_can_print_invoice', $allow, $post, $invoice);
391 391
 }
392 392
 
393 393
 function wpinv_schedule_events() {
394 394
     // hourly, daily and twicedaily
395
-    if ( !wp_next_scheduled( 'wpinv_register_schedule_event_twicedaily' ) ) {
396
-        wp_schedule_event( current_time( 'timestamp' ), 'twicedaily', 'wpinv_register_schedule_event_twicedaily' );
395
+    if (!wp_next_scheduled('wpinv_register_schedule_event_twicedaily')) {
396
+        wp_schedule_event(current_time('timestamp'), 'twicedaily', 'wpinv_register_schedule_event_twicedaily');
397 397
     }
398 398
 }
399
-add_action( 'wp', 'wpinv_schedule_events' );
399
+add_action('wp', 'wpinv_schedule_events');
400 400
 
401 401
 function wpinv_schedule_event_twicedaily() {
402 402
     wpinv_email_payment_reminders();
403 403
 }
404
-add_action( 'wpinv_register_schedule_event_twicedaily', 'wpinv_schedule_event_twicedaily' );
404
+add_action('wpinv_register_schedule_event_twicedaily', 'wpinv_schedule_event_twicedaily');
405 405
 
406 406
 function wpinv_require_login_to_checkout() {
407
-    $return = wpinv_get_option( 'login_to_checkout', false );
408
-    return (bool) apply_filters( 'wpinv_require_login_to_checkout', $return );
407
+    $return = wpinv_get_option('login_to_checkout', false);
408
+    return (bool)apply_filters('wpinv_require_login_to_checkout', $return);
409 409
 }
410 410
 
411
-function wpinv_sequential_number_active( $type = '' ) {
412
-    $check = apply_filters( 'wpinv_pre_check_sequential_number_active', null, $type );
413
-    if ( null !== $check ) {
411
+function wpinv_sequential_number_active($type = '') {
412
+    $check = apply_filters('wpinv_pre_check_sequential_number_active', null, $type);
413
+    if (null !== $check) {
414 414
         return $check;
415 415
     }
416 416
     
417
-    return wpinv_get_option( 'sequential_invoice_number' );
417
+    return wpinv_get_option('sequential_invoice_number');
418 418
 }
419 419
 
420
-function wpinv_switch_to_locale( $locale = NULL ) {
420
+function wpinv_switch_to_locale($locale = NULL) {
421 421
     global $invoicing, $wpi_switch_locale;
422 422
 
423
-    if ( ! empty( $invoicing ) && function_exists( 'switch_to_locale' ) ) {
424
-        $locale = empty( $locale ) ? get_locale() : $locale;
423
+    if (!empty($invoicing) && function_exists('switch_to_locale')) {
424
+        $locale = empty($locale) ? get_locale() : $locale;
425 425
 
426
-        switch_to_locale( $locale );
426
+        switch_to_locale($locale);
427 427
 
428 428
         $wpi_switch_locale = $locale;
429 429
 
430
-        add_filter( 'plugin_locale', 'get_locale' );
430
+        add_filter('plugin_locale', 'get_locale');
431 431
 
432 432
         $invoicing->load_textdomain();
433 433
 
434
-        do_action( 'wpinv_switch_to_locale', $locale );
434
+        do_action('wpinv_switch_to_locale', $locale);
435 435
     }
436 436
 }
437 437
 
438 438
 function wpinv_restore_locale() {
439 439
     global $invoicing, $wpi_switch_locale;
440 440
     
441
-    if ( ! empty( $invoicing ) && function_exists( 'restore_previous_locale' ) && $wpi_switch_locale ) {
441
+    if (!empty($invoicing) && function_exists('restore_previous_locale') && $wpi_switch_locale) {
442 442
         restore_previous_locale();
443 443
 
444 444
         $wpi_switch_locale = NULL;
445 445
 
446
-        remove_filter( 'plugin_locale', 'get_locale' );
446
+        remove_filter('plugin_locale', 'get_locale');
447 447
 
448 448
         $invoicing->load_textdomain();
449 449
 
450
-        do_action( 'wpinv_restore_locale' );
450
+        do_action('wpinv_restore_locale');
451 451
     }
452 452
 }
453 453
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-notes.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,39 +1,39 @@
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Notes {
8
-    public static function output( $post ) {
8
+    public static function output($post) {
9 9
         global $post;
10 10
 
11
-        $notes = wpinv_get_invoice_notes( $post->ID );
11
+        $notes = wpinv_get_invoice_notes($post->ID);
12 12
 
13 13
         echo '<ul class="invoice_notes">';
14 14
 
15
-        if ( $notes ) {
16
-            foreach( $notes as $note ) {
17
-                wpinv_get_invoice_note_line_item( $note );
15
+        if ($notes) {
16
+            foreach ($notes as $note) {
17
+                wpinv_get_invoice_note_line_item($note);
18 18
             }
19 19
 
20 20
         } else {
21
-            echo '<li>' . __( 'There are no notes yet.', 'invoicing' ) . '</li>';
21
+            echo '<li>' . __('There are no notes yet.', 'invoicing') . '</li>';
22 22
         }
23 23
 
24 24
         echo '</ul>';
25 25
         ?>
26 26
         <div class="add_note">
27
-            <h4><?php _e( 'Add note', 'invoicing' ); ?></h4>
27
+            <h4><?php _e('Add note', 'invoicing'); ?></h4>
28 28
             <p>
29 29
                 <textarea type="text" name="invoice_note" id="add_invoice_note" class="input-text" cols="20" rows="5"></textarea>
30 30
             </p>
31 31
             <p>
32 32
                 <select name="invoice_note_type" id="invoice_note_type">
33
-                    <option value=""><?php _e( 'Private note', 'invoicing' ); ?></option>
34
-                    <option value="customer"><?php _e( 'Note to customer', 'invoicing' ); ?></option>
33
+                    <option value=""><?php _e('Private note', 'invoicing'); ?></option>
34
+                    <option value="customer"><?php _e('Note to customer', 'invoicing'); ?></option>
35 35
                 </select>
36
-                <a href="#" class="add_note button"><?php _e( 'Add', 'invoicing' ); ?></a> <span class="description"><?php _e( 'Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing' ); ?></span>
36
+                <a href="#" class="add_note button"><?php _e('Add', 'invoicing'); ?></a> <span class="description"><?php _e('Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing'); ?></span>
37 37
             </p>
38 38
         </div>
39 39
         <?php
Please login to merge, or discard this patch.
includes/admin/admin-pages.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -196,8 +196,9 @@
 block discarded – undo
196 196
             foreach ( $types as $name => $type ) {
197 197
                 echo '<option value="' . esc_attr( $name ) . '"';
198 198
 
199
-                if ( isset( $_GET['discount_type'] ) )
200
-                    selected( $name, $_GET['discount_type'] );
199
+                if ( isset( $_GET['discount_type'] ) ) {
200
+                                    selected( $name, $_GET['discount_type'] );
201
+                }
201 202
 
202 203
                 echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
203 204
             }
Please login to merge, or discard this patch.
Spacing   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -1,47 +1,47 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-add_filter( 'manage_wpi_discount_posts_columns', 'wpinv_discount_columns' );
8
-function wpinv_discount_columns( $existing_columns ) {
7
+add_filter('manage_wpi_discount_posts_columns', 'wpinv_discount_columns');
8
+function wpinv_discount_columns($existing_columns) {
9 9
     $columns                = array();
10 10
     $columns['cb']          = $existing_columns['cb'];
11
-    $columns['name']        = __( 'Name', 'invoicing' );
12
-    $columns['code']        = __( 'Code', 'invoicing' );
13
-    $columns['amount']      = __( 'Amount', 'invoicing' );
14
-    $columns['usage']       = __( 'Usage / Limit', 'invoicing' );
15
-    $columns['start_date']  = __( 'Start Date', 'invoicing' );
16
-    $columns['expiry_date'] = __( 'Expiry Date', 'invoicing' );
17
-    $columns['status']      = __( 'Status', 'invoicing' );
11
+    $columns['name']        = __('Name', 'invoicing');
12
+    $columns['code']        = __('Code', 'invoicing');
13
+    $columns['amount']      = __('Amount', 'invoicing');
14
+    $columns['usage']       = __('Usage / Limit', 'invoicing');
15
+    $columns['start_date']  = __('Start Date', 'invoicing');
16
+    $columns['expiry_date'] = __('Expiry Date', 'invoicing');
17
+    $columns['status']      = __('Status', 'invoicing');
18 18
 
19 19
     return $columns;
20 20
 }
21 21
 
22
-add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' );
23
-function wpinv_discount_custom_column( $column ) {
22
+add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column');
23
+function wpinv_discount_custom_column($column) {
24 24
     global $post;
25 25
     
26 26
     $discount = $post;
27 27
 
28
-    switch ( $column ) {
28
+    switch ($column) {
29 29
         case 'name' :
30
-            echo get_the_title( $discount->ID );
30
+            echo get_the_title($discount->ID);
31 31
         break;
32 32
         case 'code' :
33
-            echo wpinv_get_discount_code( $discount->ID );
33
+            echo wpinv_get_discount_code($discount->ID);
34 34
         break;
35 35
         case 'amount' :
36
-            echo wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) );
36
+            echo wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID));
37 37
         break;
38 38
         case 'usage_limit' :
39
-            echo wpinv_get_discount_uses( $discount->ID );
39
+            echo wpinv_get_discount_uses($discount->ID);
40 40
         break;
41 41
         case 'usage' :
42
-            $usage = wpinv_get_discount_uses( $discount->ID ) . ' / ';
43
-            if ( wpinv_get_discount_max_uses( $discount->ID ) ) {
44
-                $usage .= wpinv_get_discount_max_uses( $discount->ID );
42
+            $usage = wpinv_get_discount_uses($discount->ID) . ' / ';
43
+            if (wpinv_get_discount_max_uses($discount->ID)) {
44
+                $usage .= wpinv_get_discount_max_uses($discount->ID);
45 45
             } else {
46 46
                 $usage .= ' &infin;';
47 47
             }
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
             echo $usage;
50 50
         break;
51 51
         case 'start_date' :
52
-            if ( $start_date = wpinv_get_discount_start_date( $discount->ID ) ) {
53
-                $value = date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), strtotime( $start_date ) );
52
+            if ($start_date = wpinv_get_discount_start_date($discount->ID)) {
53
+                $value = date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), strtotime($start_date));
54 54
             } else {
55 55
                 $value = '-';
56 56
             }
@@ -58,163 +58,163 @@  discard block
 block discarded – undo
58 58
             echo $value;
59 59
         break;
60 60
         case 'expiry_date' :
61
-            if ( $expiration = wpinv_get_discount_expiration( $discount->ID ) ) {
62
-                $value = date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), strtotime( $expiration ) );
61
+            if ($expiration = wpinv_get_discount_expiration($discount->ID)) {
62
+                $value = date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), strtotime($expiration));
63 63
             } else {
64
-                $value = __( 'Never', 'invoicing' );
64
+                $value = __('Never', 'invoicing');
65 65
             }
66 66
                 
67 67
             echo $value;
68 68
         break;
69 69
         break;
70 70
         case 'description' :
71
-            echo wp_kses_post( $post->post_excerpt );
71
+            echo wp_kses_post($post->post_excerpt);
72 72
         break;
73 73
         case 'status' :
74
-            $status = wpinv_is_discount_expired( $discount->ID ) ? 'expired' : $discount->post_status;
74
+            $status = wpinv_is_discount_expired($discount->ID) ? 'expired' : $discount->post_status;
75 75
             
76
-            echo wpinv_discount_status( $status );
76
+            echo wpinv_discount_status($status);
77 77
         break;
78 78
     }
79 79
 }
80 80
 
81
-add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 );
82
-function wpinv_post_row_actions( $actions, $post ) {
83
-    $post_type = !empty( $post->post_type ) ? $post->post_type : '';
81
+add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2);
82
+function wpinv_post_row_actions($actions, $post) {
83
+    $post_type = !empty($post->post_type) ? $post->post_type : '';
84 84
     
85
-    if ( $post_type == 'wpi_invoice' ) {
85
+    if ($post_type == 'wpi_invoice') {
86 86
         $actions = array();
87 87
     }
88 88
     
89
-    if ( $post_type == 'wpi_discount' ) {
90
-        $actions = wpinv_discount_row_actions( $post, $actions );
89
+    if ($post_type == 'wpi_discount') {
90
+        $actions = wpinv_discount_row_actions($post, $actions);
91 91
     }
92 92
     
93 93
     return $actions;
94 94
 }
95 95
 
96
-function wpinv_discount_row_actions( $discount, $row_actions ) {
97
-    $row_actions  = array();
98
-    $edit_link = get_edit_post_link( $discount->ID );
99
-    $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>';
96
+function wpinv_discount_row_actions($discount, $row_actions) {
97
+    $row_actions = array();
98
+    $edit_link = get_edit_post_link($discount->ID);
99
+    $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>';
100 100
 
101
-    if( in_array( strtolower( $discount->post_status ),  array(  'publish' ) ) ) {
102
-        $row_actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'deactivate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Deactivate', 'invoicing' ) . '</a>';
103
-    } elseif( in_array( strtolower( $discount->post_status ),  array( 'pending', 'draft' ) ) ) {
104
-        $row_actions['activate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'activate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Activate', 'invoicing' ) . '</a>';
101
+    if (in_array(strtolower($discount->post_status), array('publish'))) {
102
+        $row_actions['deactivate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'deactivate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Deactivate', 'invoicing') . '</a>';
103
+    } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) {
104
+        $row_actions['activate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'activate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Activate', 'invoicing') . '</a>';
105 105
     }
106 106
 
107
-    if ( wpinv_get_discount_uses( $discount->ID ) > 0 ) {
108
-        if ( isset( $row_actions['delete'] ) ) {
109
-            unset( $row_actions['delete'] ); // Don't delete used discounts.
107
+    if (wpinv_get_discount_uses($discount->ID) > 0) {
108
+        if (isset($row_actions['delete'])) {
109
+            unset($row_actions['delete']); // Don't delete used discounts.
110 110
         }
111 111
     } else {
112
-        $row_actions['delete'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'delete_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Delete', 'invoicing' ) . '</a>';
112
+        $row_actions['delete'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'delete_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Delete', 'invoicing') . '</a>';
113 113
     }
114 114
     
115 115
 
116
-    $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount );
116
+    $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount);
117 117
 
118 118
     return $row_actions;
119 119
 }
120 120
 
121
-add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 );
122
-function wpinv_table_primary_column( $default, $screen_id ) {
123
-    if ( 'edit-wpi_invoice' === $screen_id ) {
121
+add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2);
122
+function wpinv_table_primary_column($default, $screen_id) {
123
+    if ('edit-wpi_invoice' === $screen_id) {
124 124
         return 'name';
125 125
     }
126 126
     
127 127
     return $default;
128 128
 }
129 129
 
130
-function wpinv_discount_bulk_actions( $actions, $display = false ) {    
131
-    if ( !$display ) {
130
+function wpinv_discount_bulk_actions($actions, $display = false) {    
131
+    if (!$display) {
132 132
         return array();
133 133
     }
134 134
     
135 135
     $actions = array(
136
-        'activate'   => __( 'Activate', 'invoicing' ),
137
-        'deactivate' => __( 'Deactivate', 'invoicing' ),
138
-        'delete'     => __( 'Delete', 'invoicing' ),
136
+        'activate'   => __('Activate', 'invoicing'),
137
+        'deactivate' => __('Deactivate', 'invoicing'),
138
+        'delete'     => __('Delete', 'invoicing'),
139 139
     );
140 140
     $two = '';
141 141
     $which = 'top';
142 142
     echo '</div><div class="alignleft actions bulkactions">';
143
-    echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
144
-    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">";
145
-    echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>";
143
+    echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>';
144
+    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">";
145
+    echo '<option value="-1">' . __('Bulk Actions') . "</option>";
146 146
 
147
-    foreach ( $actions as $name => $title ) {
147
+    foreach ($actions as $name => $title) {
148 148
         $class = 'edit' === $name ? ' class="hide-if-no-js"' : '';
149 149
 
150 150
         echo "" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>";
151 151
     }
152 152
     echo "</select>";
153 153
 
154
-    submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) );
154
+    submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two"));
155 155
     
156 156
     echo '</div><div class="alignleft actions">';
157 157
 }
158
-add_filter( 'bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10 );
158
+add_filter('bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10);
159 159
 
160
-function wpinv_disable_months_dropdown( $disable, $post_type ) {
161
-    if ( $post_type == 'wpi_discount' ) {
160
+function wpinv_disable_months_dropdown($disable, $post_type) {
161
+    if ($post_type == 'wpi_discount') {
162 162
         $disable = true;
163 163
     }
164 164
     
165 165
     return $disable;
166 166
 }
167
-add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 );
167
+add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2);
168 168
 
169 169
 function wpinv_restrict_manage_posts() {
170 170
     global $typenow;
171 171
 
172
-    if( 'wpi_discount' == $typenow ) {
172
+    if ('wpi_discount' == $typenow) {
173 173
         wpinv_discount_filters();
174 174
     }
175 175
 }
176
-add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 );
176
+add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10);
177 177
 
178 178
 function wpinv_discount_filters() {
179
-    echo wpinv_discount_bulk_actions( array(), true );
179
+    echo wpinv_discount_bulk_actions(array(), true);
180 180
     
181 181
     ?>
182 182
     <select name="discount_type" id="dropdown_wpinv_discount_type">
183
-        <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option>
183
+        <option value=""><?php _e('Show all types', 'invoicing'); ?></option>
184 184
         <?php
185 185
             $types = wpinv_get_discount_types();
186 186
 
187
-            foreach ( $types as $name => $type ) {
188
-                echo '<option value="' . esc_attr( $name ) . '"';
187
+            foreach ($types as $name => $type) {
188
+                echo '<option value="' . esc_attr($name) . '"';
189 189
 
190
-                if ( isset( $_GET['discount_type'] ) )
191
-                    selected( $name, $_GET['discount_type'] );
190
+                if (isset($_GET['discount_type']))
191
+                    selected($name, $_GET['discount_type']);
192 192
 
193
-                echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
193
+                echo '>' . esc_html__($type, 'invoicing') . '</option>';
194 194
             }
195 195
         ?>
196 196
     </select>
197 197
     <?php
198 198
 }
199 199
 
200
-function wpinv_request( $vars ) {
200
+function wpinv_request($vars) {
201 201
     global $typenow, $wp_query, $wp_post_statuses;
202 202
 
203
-    if ( 'wpi_invoice' === $typenow ) {
204
-        if ( !isset( $vars['post_status'] ) ) {
203
+    if ('wpi_invoice' === $typenow) {
204
+        if (!isset($vars['post_status'])) {
205 205
             $post_statuses = wpinv_get_invoice_statuses();
206 206
 
207
-            foreach ( $post_statuses as $status => $value ) {
208
-                if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) {
209
-                    unset( $post_statuses[ $status ] );
207
+            foreach ($post_statuses as $status => $value) {
208
+                if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) {
209
+                    unset($post_statuses[$status]);
210 210
                 }
211 211
             }
212 212
 
213
-            $vars['post_status'] = array_keys( $post_statuses );
213
+            $vars['post_status'] = array_keys($post_statuses);
214 214
         }
215 215
         
216
-        if ( isset( $vars['orderby'] ) ) {
217
-            if ( 'amount' == $vars['orderby'] ) {
216
+        if (isset($vars['orderby'])) {
217
+            if ('amount' == $vars['orderby']) {
218 218
                 $vars = array_merge(
219 219
                     $vars,
220 220
                     array(
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
                         'orderby'  => 'meta_value_num'
223 223
                     )
224 224
                 );
225
-            } else if ( 'customer' == $vars['orderby'] ) {
225
+            } else if ('customer' == $vars['orderby']) {
226 226
                 $vars = array_merge(
227 227
                     $vars,
228 228
                     array(
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
                         'orderby'  => 'meta_value'
231 231
                     )
232 232
                 );
233
-            } else if ( 'number' == $vars['orderby'] ) {
233
+            } else if ('number' == $vars['orderby']) {
234 234
                 $vars = array_merge(
235 235
                     $vars,
236 236
                     array(
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
                         'orderby'  => 'meta_value'
239 239
                     )
240 240
                 );
241
-            } else if ( 'payment_date' == $vars['orderby'] ) {
241
+            } else if ('payment_date' == $vars['orderby']) {
242 242
                 $vars = array_merge(
243 243
                     $vars,
244 244
                     array(
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
                 );
249 249
             }
250 250
         }
251
-    } else if ( 'wpi_item' == $typenow ) {
251
+    } else if ('wpi_item' == $typenow) {
252 252
         // Check if 'orderby' is set to "price"
253
-        if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) {
253
+        if (isset($vars['orderby']) && 'price' == $vars['orderby']) {
254 254
             $vars = array_merge(
255 255
                 $vars,
256 256
                 array(
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
         }
262 262
 
263 263
         // Check if "orderby" is set to "vat_rule"
264
-        if ( isset( $vars['orderby'] ) && 'vat_rule' == $vars['orderby'] ) {
264
+        if (isset($vars['orderby']) && 'vat_rule' == $vars['orderby']) {
265 265
             $vars = array_merge(
266 266
                 $vars,
267 267
                 array(
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
         }
273 273
 
274 274
         // Check if "orderby" is set to "vat_class"
275
-        if ( isset( $vars['orderby'] ) && 'vat_class' == $vars['orderby'] ) {
275
+        if (isset($vars['orderby']) && 'vat_class' == $vars['orderby']) {
276 276
             $vars = array_merge(
277 277
                 $vars,
278 278
                 array(
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
         }
284 284
         
285 285
         // Check if "orderby" is set to "type"
286
-        if ( isset( $vars['orderby'] ) && 'type' == $vars['orderby'] ) {
286
+        if (isset($vars['orderby']) && 'type' == $vars['orderby']) {
287 287
             $vars = array_merge(
288 288
                 $vars,
289 289
                 array(
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
         }
295 295
         
296 296
         // Check if "orderby" is set to "recurring"
297
-        if ( isset( $vars['orderby'] ) && 'recurring' == $vars['orderby'] ) {
297
+        if (isset($vars['orderby']) && 'recurring' == $vars['orderby']) {
298 298
             $vars = array_merge(
299 299
                 $vars,
300 300
                 array(
@@ -304,104 +304,104 @@  discard block
 block discarded – undo
304 304
             );
305 305
         }
306 306
 
307
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
307
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
308 308
         // Filter vat rule type
309
-        if ( isset( $_GET['vat_rule'] ) && $_GET['vat_rule'] !== '' ) {
309
+        if (isset($_GET['vat_rule']) && $_GET['vat_rule'] !== '') {
310 310
             $meta_query[] = array(
311 311
                     'key'   => '_wpinv_vat_rule',
312
-                    'value' => sanitize_text_field( $_GET['vat_rule'] ),
312
+                    'value' => sanitize_text_field($_GET['vat_rule']),
313 313
                     'compare' => '='
314 314
                 );
315 315
         }
316 316
         
317 317
         // Filter vat class
318
-        if ( isset( $_GET['vat_class'] ) && $_GET['vat_class'] !== '' ) {
318
+        if (isset($_GET['vat_class']) && $_GET['vat_class'] !== '') {
319 319
             $meta_query[] = array(
320 320
                     'key'   => '_wpinv_vat_class',
321
-                    'value' => sanitize_text_field( $_GET['vat_class'] ),
321
+                    'value' => sanitize_text_field($_GET['vat_class']),
322 322
                     'compare' => '='
323 323
                 );
324 324
         }
325 325
         
326 326
         // Filter item type
327
-        if ( isset( $_GET['type'] ) && $_GET['type'] !== '' ) {
327
+        if (isset($_GET['type']) && $_GET['type'] !== '') {
328 328
             $meta_query[] = array(
329 329
                     'key'   => '_wpinv_type',
330
-                    'value' => sanitize_text_field( $_GET['type'] ),
330
+                    'value' => sanitize_text_field($_GET['type']),
331 331
                     'compare' => '='
332 332
                 );
333 333
         }
334 334
         
335
-        if ( !empty( $meta_query ) ) {
335
+        if (!empty($meta_query)) {
336 336
             $vars['meta_query'] = $meta_query;
337 337
         }
338
-    } else if ( 'wpi_discount' == $typenow ) {
339
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
338
+    } else if ('wpi_discount' == $typenow) {
339
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
340 340
         // Filter vat rule type
341
-        if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) {
341
+        if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') {
342 342
             $meta_query[] = array(
343 343
                     'key'   => '_wpi_discount_type',
344
-                    'value' => sanitize_text_field( $_GET['discount_type'] ),
344
+                    'value' => sanitize_text_field($_GET['discount_type']),
345 345
                     'compare' => '='
346 346
                 );
347 347
         }
348 348
         
349
-        if ( !empty( $meta_query ) ) {
349
+        if (!empty($meta_query)) {
350 350
             $vars['meta_query'] = $meta_query;
351 351
         }
352 352
     }
353 353
 
354 354
     return $vars;
355 355
 }
356
-add_filter( 'request', 'wpinv_request' );
356
+add_filter('request', 'wpinv_request');
357 357
 
358
-function wpinv_item_type_class( $classes, $class, $post_id ) {
358
+function wpinv_item_type_class($classes, $class, $post_id) {
359 359
     global $pagenow, $typenow;
360 360
 
361
-    if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow ) {
362
-        if ( $type = get_post_meta( $post_id, '_wpinv_type', true ) ) {
363
-            $classes[] = 'wpi-type-' . sanitize_html_class( $type );
361
+    if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow) {
362
+        if ($type = get_post_meta($post_id, '_wpinv_type', true)) {
363
+            $classes[] = 'wpi-type-' . sanitize_html_class($type);
364 364
         }
365 365
         
366
-        if ( !wpinv_item_is_editable( $post_id ) ) {
366
+        if (!wpinv_item_is_editable($post_id)) {
367 367
             $classes[] = 'wpi-editable-n';
368 368
         }
369 369
     }
370 370
     return $classes;
371 371
 }
372
-add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 );
372
+add_filter('post_class', 'wpinv_item_type_class', 10, 3);
373 373
 
374 374
 function wpinv_check_quick_edit() {
375 375
     global $pagenow, $current_screen, $wpinv_item_screen;
376 376
 
377
-    if ( $pagenow == 'edit.php' && !empty( $current_screen->post_type ) ) {
378
-        if ( empty( $wpinv_item_screen ) ) {
379
-            if ( $current_screen->post_type == 'wpi_item' ) {
377
+    if ($pagenow == 'edit.php' && !empty($current_screen->post_type)) {
378
+        if (empty($wpinv_item_screen)) {
379
+            if ($current_screen->post_type == 'wpi_item') {
380 380
                 $wpinv_item_screen = 'y';
381 381
             } else {
382 382
                 $wpinv_item_screen = 'n';
383 383
             }
384 384
         }
385 385
 
386
-        if ( $wpinv_item_screen == 'y' && $pagenow == 'edit.php' ) {
387
-            add_filter( 'post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
388
-            add_filter( 'page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
386
+        if ($wpinv_item_screen == 'y' && $pagenow == 'edit.php') {
387
+            add_filter('post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
388
+            add_filter('page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
389 389
         }
390 390
     }
391 391
 }
392
-add_action( 'admin_head', 'wpinv_check_quick_edit', 10 );
392
+add_action('admin_head', 'wpinv_check_quick_edit', 10);
393 393
 
394
-function wpinv_item_disable_quick_edit( $actions = array(), $row = null ) {
395
-    if ( isset( $actions['inline hide-if-no-js'] ) ) {
396
-        unset( $actions['inline hide-if-no-js'] );
394
+function wpinv_item_disable_quick_edit($actions = array(), $row = null) {
395
+    if (isset($actions['inline hide-if-no-js'])) {
396
+        unset($actions['inline hide-if-no-js']);
397 397
     }
398 398
     
399
-    if ( !empty( $row->post_type ) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable( $row ) ) {
400
-        if ( isset( $actions['trash'] ) ) {
401
-            unset( $actions['trash'] );
399
+    if (!empty($row->post_type) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable($row)) {
400
+        if (isset($actions['trash'])) {
401
+            unset($actions['trash']);
402 402
         }
403
-        if ( isset( $actions['delete'] ) ) {
404
-            unset( $actions['delete'] );
403
+        if (isset($actions['delete'])) {
404
+            unset($actions['delete']);
405 405
         }
406 406
     }
407 407
 
@@ -418,19 +418,19 @@  discard block
 block discarded – undo
418 418
  * @param int $post_parent (default: 0) Parent for the new page
419 419
  * @return int page ID
420 420
  */
421
-function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
421
+function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) {
422 422
     global $wpdb;
423 423
 
424
-    $option_value = wpinv_get_option( $option );
424
+    $option_value = wpinv_get_option($option);
425 425
 
426
-    if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) {
427
-        if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) {
426
+    if ($option_value > 0 && ($page_object = get_post($option_value))) {
427
+        if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) {
428 428
             // Valid page is already in place
429 429
             return $page_object->ID;
430 430
         }
431 431
     }
432 432
 
433
-    if(!empty($post_parent)){
433
+    if (!empty($post_parent)) {
434 434
         $page = get_page_by_path($post_parent);
435 435
         if ($page) {
436 436
             $post_parent = $page->ID;
@@ -439,40 +439,40 @@  discard block
 block discarded – undo
439 439
         }
440 440
     }
441 441
 
442
-    if ( strlen( $page_content ) > 0 ) {
442
+    if (strlen($page_content) > 0) {
443 443
         // Search for an existing page with the specified page content (typically a shortcode)
444
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
444
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
445 445
     } else {
446 446
         // Search for an existing page with the specified page slug
447
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug ) );
447
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug));
448 448
     }
449 449
 
450
-    $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content );
450
+    $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content);
451 451
 
452
-    if ( $valid_page_found ) {
453
-        if ( $option ) {
454
-            wpinv_update_option( $option, $valid_page_found );
452
+    if ($valid_page_found) {
453
+        if ($option) {
454
+            wpinv_update_option($option, $valid_page_found);
455 455
         }
456 456
         return $valid_page_found;
457 457
     }
458 458
 
459 459
     // Search for a matching valid trashed page
460
-    if ( strlen( $page_content ) > 0 ) {
460
+    if (strlen($page_content) > 0) {
461 461
         // Search for an existing page with the specified page content (typically a shortcode)
462
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
462
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
463 463
     } else {
464 464
         // Search for an existing page with the specified page slug
465
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) );
465
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug));
466 466
     }
467 467
 
468
-    if ( $trashed_page_found ) {
468
+    if ($trashed_page_found) {
469 469
         $page_id   = $trashed_page_found;
470 470
         $page_data = array(
471 471
             'ID'             => $page_id,
472 472
             'post_status'    => 'publish',
473 473
             'post_parent'    => $post_parent,
474 474
         );
475
-        wp_update_post( $page_data );
475
+        wp_update_post($page_data);
476 476
     } else {
477 477
         $page_data = array(
478 478
             'post_status'    => 'publish',
@@ -484,11 +484,11 @@  discard block
 block discarded – undo
484 484
             'post_parent'    => $post_parent,
485 485
             'comment_status' => 'closed',
486 486
         );
487
-        $page_id = wp_insert_post( $page_data );
487
+        $page_id = wp_insert_post($page_data);
488 488
     }
489 489
 
490
-    if ( $option ) {
491
-        wpinv_update_option( $option, (int)$page_id );
490
+    if ($option) {
491
+        wpinv_update_option($option, (int)$page_id);
492 492
     }
493 493
 
494 494
     return $page_id;
Please login to merge, or discard this patch.
includes/wpinv-error-functions.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@
 block discarded – undo
13 13
         ) );
14 14
         echo '<div class="' . implode( ' ', $classes ) . '">';
15 15
             // Loop error codes and display errors
16
-           foreach ( $errors as $error_id => $error ) {
16
+            foreach ( $errors as $error_id => $error ) {
17 17
                 echo '<p class="wpinv_error" id="wpinv_error_' . $error_id . '"><strong>' . __( 'Error', 'invoicing' ) . '</strong>: ' . $error . '</p>';
18
-           }
18
+            }
19 19
         echo '</div>';
20 20
         wpinv_clear_errors();
21 21
     }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,61 +1,61 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 function wpinv_print_errors() {
8 8
     $errors = wpinv_get_errors();
9 9
 
10
-    if ( $errors ) {
11
-        $classes = apply_filters( 'wpinv_error_class', array(
10
+    if ($errors) {
11
+        $classes = apply_filters('wpinv_error_class', array(
12 12
             'wpinv_errors', 'wpinv-alert', 'wpinv-alert-error'
13
-        ) );
14
-        echo '<div class="' . implode( ' ', $classes ) . '">';
13
+        ));
14
+        echo '<div class="' . implode(' ', $classes) . '">';
15 15
             // Loop error codes and display errors
16
-           foreach ( $errors as $error_id => $error ) {
17
-                echo '<p class="wpinv_error" id="wpinv_error_' . $error_id . '"><strong>' . __( 'Error', 'invoicing' ) . '</strong>: ' . $error . '</p>';
16
+           foreach ($errors as $error_id => $error) {
17
+                echo '<p class="wpinv_error" id="wpinv_error_' . $error_id . '"><strong>' . __('Error', 'invoicing') . '</strong>: ' . $error . '</p>';
18 18
            }
19 19
         echo '</div>';
20 20
         wpinv_clear_errors();
21 21
     }
22 22
 }
23
-add_action( 'wpinv_purchase_form_before_submit', 'wpinv_print_errors' );
24
-add_action( 'wpinv_ajax_checkout_errors', 'wpinv_print_errors' );
23
+add_action('wpinv_purchase_form_before_submit', 'wpinv_print_errors');
24
+add_action('wpinv_ajax_checkout_errors', 'wpinv_print_errors');
25 25
 
26 26
 function wpinv_get_errors() {
27 27
     global $wpi_session;
28 28
     
29
-    return $wpi_session->get( 'wpinv_errors' );
29
+    return $wpi_session->get('wpinv_errors');
30 30
 }
31 31
 
32
-function wpinv_set_error( $error_id, $error_message ) {
32
+function wpinv_set_error($error_id, $error_message) {
33 33
     global $wpi_session;
34 34
     
35 35
     $errors = wpinv_get_errors();
36 36
 
37
-    if ( ! $errors ) {
37
+    if (!$errors) {
38 38
         $errors = array();
39 39
     }
40 40
 
41
-    $errors[ $error_id ] = $error_message;
42
-    $wpi_session->set( 'wpinv_errors', $errors );
41
+    $errors[$error_id] = $error_message;
42
+    $wpi_session->set('wpinv_errors', $errors);
43 43
 }
44 44
 
45 45
 function wpinv_clear_errors() {
46 46
     global $wpi_session;
47 47
     
48
-    $wpi_session->set( 'wpinv_errors', null );
48
+    $wpi_session->set('wpinv_errors', null);
49 49
 }
50 50
 
51
-function wpinv_unset_error( $error_id ) {
51
+function wpinv_unset_error($error_id) {
52 52
     global $wpi_session;
53 53
     
54 54
     $errors = wpinv_get_errors();
55 55
 
56
-    if ( $errors ) {
57
-        unset( $errors[ $error_id ] );
58
-        $wpi_session->set( 'wpinv_errors', $errors );
56
+    if ($errors) {
57
+        unset($errors[$error_id]);
58
+        $wpi_session->set('wpinv_errors', $errors);
59 59
     }
60 60
 }
61 61
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
     die();
64 64
 }
65 65
 
66
-function wpinv_die( $message = '', $title = '', $status = 400 ) {
67
-    add_filter( 'wp_die_ajax_handler', 'wpinv_die_handler', 10, 3 );
68
-    add_filter( 'wp_die_handler', 'wpinv_die_handler', 10, 3 );
69
-    wp_die( $message, $title, array( 'response' => $status ));
66
+function wpinv_die($message = '', $title = '', $status = 400) {
67
+    add_filter('wp_die_ajax_handler', 'wpinv_die_handler', 10, 3);
68
+    add_filter('wp_die_handler', 'wpinv_die_handler', 10, 3);
69
+    wp_die($message, $title, array('response' => $status));
70 70
 }
Please login to merge, or discard this patch.
includes/wpinv-gateway-functions.php 3 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -286,26 +286,26 @@  discard block
 block discarded – undo
286 286
 }
287 287
 
288 288
 function wpinv_get_chosen_gateway( $invoice_id = 0 ) {
289
-	$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
289
+    $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
290 290
 
291 291
     $chosen = false;
292 292
     if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) {
293 293
         $chosen = $invoice->get_gateway();
294 294
     }
295 295
 
296
-	$chosen   = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen;
296
+    $chosen   = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen;
297 297
 
298
-	if ( false !== $chosen ) {
299
-		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen );
300
-	}
298
+    if ( false !== $chosen ) {
299
+        $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen );
300
+    }
301 301
 
302
-	if ( ! empty ( $chosen ) ) {
303
-		$enabled_gateway = urldecode( $chosen );
304
-	} else if (  !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) {
305
-		$enabled_gateway = 'manual';
306
-	} else {
307
-		$enabled_gateway = wpinv_get_default_gateway();
308
-	}
302
+    if ( ! empty ( $chosen ) ) {
303
+        $enabled_gateway = urldecode( $chosen );
304
+    } else if (  !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) {
305
+        $enabled_gateway = 'manual';
306
+    } else {
307
+        $enabled_gateway = wpinv_get_default_gateway();
308
+    }
309 309
     
310 310
     if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) {
311 311
         if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 
317 317
     }
318 318
 
319
-	return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway );
319
+    return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway );
320 320
 }
321 321
 
322 322
 function wpinv_record_gateway_error( $title = '', $message = '', $parent = 0 ) {
@@ -324,21 +324,21 @@  discard block
 block discarded – undo
324 324
 }
325 325
 
326 326
 function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
327
-	$ret  = 0;
328
-	$args = array(
329
-		'meta_key'    => '_wpinv_gateway',
330
-		'meta_value'  => $gateway_id,
331
-		'nopaging'    => true,
332
-		'post_type'   => 'wpi_invoice',
333
-		'post_status' => $status,
334
-		'fields'      => 'ids'
335
-	);
336
-
337
-	$payments = new WP_Query( $args );
338
-
339
-	if( $payments )
340
-		$ret = $payments->post_count;
341
-	return $ret;
327
+    $ret  = 0;
328
+    $args = array(
329
+        'meta_key'    => '_wpinv_gateway',
330
+        'meta_value'  => $gateway_id,
331
+        'nopaging'    => true,
332
+        'post_type'   => 'wpi_invoice',
333
+        'post_status' => $status,
334
+        'fields'      => 'ids'
335
+    );
336
+
337
+    $payments = new WP_Query( $args );
338
+
339
+    if( $payments )
340
+        $ret = $payments->post_count;
341
+    return $ret;
342 342
 }
343 343
 
344 344
 function wpinv_settings_update_gateways( $input ) {
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
     if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) {
311 311
         if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){
312 312
             $enabled_gateway = wpinv_get_default_gateway();
313
-        }else{
313
+        } else{
314 314
             $enabled_gateway = $gateways[0];
315 315
         }
316 316
 
@@ -336,8 +336,9 @@  discard block
 block discarded – undo
336 336
 
337 337
 	$payments = new WP_Query( $args );
338 338
 
339
-	if( $payments )
340
-		$ret = $payments->post_count;
339
+	if( $payments ) {
340
+			$ret = $payments->post_count;
341
+	}
341 342
 	return $ret;
342 343
 }
343 344
 
Please login to merge, or discard this patch.
Spacing   +258 added lines, -258 removed lines patch added patch discarded remove patch
@@ -7,206 +7,206 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 function wpinv_get_payment_gateways() {
15 15
     // Default, built-in gateways
16 16
     $gateways = array(
17 17
         'paypal' => array(
18
-            'admin_label'    => __( 'PayPal Standard', 'invoicing' ),
19
-            'checkout_label' => __( 'PayPal Standard', 'invoicing' ),
18
+            'admin_label'    => __('PayPal Standard', 'invoicing'),
19
+            'checkout_label' => __('PayPal Standard', 'invoicing'),
20 20
             'ordering'       => 1,
21 21
         ),
22 22
         'authorizenet' => array(
23
-            'admin_label'    => __( 'Authorize.Net (AIM)', 'invoicing' ),
24
-            'checkout_label' => __( 'Authorize.Net - Credit Card / Debit Card', 'invoicing' ),
23
+            'admin_label'    => __('Authorize.Net (AIM)', 'invoicing'),
24
+            'checkout_label' => __('Authorize.Net - Credit Card / Debit Card', 'invoicing'),
25 25
             'ordering'       => 4,
26 26
         ),
27 27
         'worldpay' => array(
28
-            'admin_label'    => __( 'Worldpay', 'invoicing' ),
29
-            'checkout_label' => __( 'Worldpay - Credit Card / Debit Card', 'invoicing' ),
28
+            'admin_label'    => __('Worldpay', 'invoicing'),
29
+            'checkout_label' => __('Worldpay - Credit Card / Debit Card', 'invoicing'),
30 30
             'ordering'       => 5,
31 31
         ),
32 32
         'bank_transfer' => array(
33
-            'admin_label'    => __( 'Pre Bank Transfer', 'invoicing' ),
34
-            'checkout_label' => __( 'Pre Bank Transfer', 'invoicing' ),
33
+            'admin_label'    => __('Pre Bank Transfer', 'invoicing'),
34
+            'checkout_label' => __('Pre Bank Transfer', 'invoicing'),
35 35
             'ordering'       => 11,
36 36
         ),
37 37
         'manual' => array(
38
-            'admin_label'    => __( 'Test Payment', 'invoicing' ),
39
-            'checkout_label' => __( 'Test Payment', 'invoicing' ),
38
+            'admin_label'    => __('Test Payment', 'invoicing'),
39
+            'checkout_label' => __('Test Payment', 'invoicing'),
40 40
             'ordering'       => 12,
41 41
         ),
42 42
     );
43 43
 
44
-    return apply_filters( 'wpinv_payment_gateways', $gateways );
44
+    return apply_filters('wpinv_payment_gateways', $gateways);
45 45
 }
46 46
 
47
-function wpinv_payment_gateway_titles( $all_gateways ) {
47
+function wpinv_payment_gateway_titles($all_gateways) {
48 48
     global $wpinv_options;
49 49
     
50 50
     $gateways = array();
51
-    foreach ( $all_gateways as $key => $gateway ) {
52
-        if ( !empty( $wpinv_options[$key . '_title'] ) ) {
53
-            $all_gateways[$key]['checkout_label'] = __( $wpinv_options[$key . '_title'], 'invoicing' );
51
+    foreach ($all_gateways as $key => $gateway) {
52
+        if (!empty($wpinv_options[$key . '_title'])) {
53
+            $all_gateways[$key]['checkout_label'] = __($wpinv_options[$key . '_title'], 'invoicing');
54 54
         }
55 55
         
56
-        $gateways[$key] = isset( $wpinv_options[$key . '_ordering'] ) ? $wpinv_options[$key . '_ordering'] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' );
56
+        $gateways[$key] = isset($wpinv_options[$key . '_ordering']) ? $wpinv_options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : '');
57 57
     }
58 58
 
59
-    asort( $gateways );
59
+    asort($gateways);
60 60
     
61
-    foreach ( $gateways as $gateway => $key ) {
61
+    foreach ($gateways as $gateway => $key) {
62 62
         $gateways[$gateway] = $all_gateways[$gateway];
63 63
     }
64 64
     
65 65
     return $gateways;
66 66
 }
67
-add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 );
67
+add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1);
68 68
 
69
-function wpinv_get_enabled_payment_gateways( $sort = false ) {
69
+function wpinv_get_enabled_payment_gateways($sort = false) {
70 70
     $gateways = wpinv_get_payment_gateways();
71
-    $enabled  = wpinv_get_option( 'gateways', false );
71
+    $enabled  = wpinv_get_option('gateways', false);
72 72
 
73 73
     $gateway_list = array();
74 74
 
75
-    foreach ( $gateways as $key => $gateway ) {
76
-        if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) {
77
-            $gateway_list[ $key ] = $gateway;
75
+    foreach ($gateways as $key => $gateway) {
76
+        if (isset($enabled[$key]) && $enabled[$key] == 1) {
77
+            $gateway_list[$key] = $gateway;
78 78
         }
79 79
     }
80 80
 
81
-    if ( true === $sort ) {
82
-        uasort( $gateway_list, 'wpinv_sort_gateway_order' );
81
+    if (true === $sort) {
82
+        uasort($gateway_list, 'wpinv_sort_gateway_order');
83 83
         
84 84
         // Reorder our gateways so the default is first
85 85
         $default_gateway_id = wpinv_get_default_gateway();
86 86
 
87
-        if ( wpinv_is_gateway_active( $default_gateway_id ) ) {
88
-            $default_gateway    = array( $default_gateway_id => $gateway_list[ $default_gateway_id ] );
89
-            unset( $gateway_list[ $default_gateway_id ] );
87
+        if (wpinv_is_gateway_active($default_gateway_id)) {
88
+            $default_gateway = array($default_gateway_id => $gateway_list[$default_gateway_id]);
89
+            unset($gateway_list[$default_gateway_id]);
90 90
 
91
-            $gateway_list = array_merge( $default_gateway, $gateway_list );
91
+            $gateway_list = array_merge($default_gateway, $gateway_list);
92 92
         }
93 93
     }
94 94
 
95
-    return apply_filters( 'wpinv_enabled_payment_gateways', $gateway_list );
95
+    return apply_filters('wpinv_enabled_payment_gateways', $gateway_list);
96 96
 }
97 97
 
98
-function wpinv_sort_gateway_order( $a, $b ) {
98
+function wpinv_sort_gateway_order($a, $b) {
99 99
     return $a['ordering'] - $b['ordering'];
100 100
 }
101 101
 
102
-function wpinv_is_gateway_active( $gateway ) {
102
+function wpinv_is_gateway_active($gateway) {
103 103
     $gateways = wpinv_get_enabled_payment_gateways();
104 104
 
105
-    $ret = is_array($gateways) && $gateway ?  array_key_exists( $gateway, $gateways ) : false;
105
+    $ret = is_array($gateways) && $gateway ?  array_key_exists($gateway, $gateways) : false;
106 106
 
107
-    return apply_filters( 'wpinv_is_gateway_active', $ret, $gateway, $gateways );
107
+    return apply_filters('wpinv_is_gateway_active', $ret, $gateway, $gateways);
108 108
 }
109 109
 
110 110
 function wpinv_get_default_gateway() {
111
-    $default = wpinv_get_option( 'default_gateway', 'paypal' );
111
+    $default = wpinv_get_option('default_gateway', 'paypal');
112 112
 
113
-    if ( !wpinv_is_gateway_active( $default ) ) {
113
+    if (!wpinv_is_gateway_active($default)) {
114 114
         $gateways = wpinv_get_enabled_payment_gateways();
115
-        $gateways = array_keys( $gateways );
116
-        $default  = reset( $gateways );
115
+        $gateways = array_keys($gateways);
116
+        $default  = reset($gateways);
117 117
     }
118 118
 
119
-    return apply_filters( 'wpinv_default_gateway', $default );
119
+    return apply_filters('wpinv_default_gateway', $default);
120 120
 }
121 121
 
122
-function wpinv_get_gateway_admin_label( $gateway ) {
122
+function wpinv_get_gateway_admin_label($gateway) {
123 123
     $gateways = wpinv_get_payment_gateways();
124
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway;
125
-    $payment  = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false;
124
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway;
125
+    $payment  = isset($_GET['id']) ? absint($_GET['id']) : false;
126 126
 
127
-    if( $gateway == 'manual' && $payment ) {
128
-        if( !( (float)wpinv_payment_total( $payment ) > 0 ) ) {
129
-            $label = __( 'Free Purchase', 'invoicing' );
127
+    if ($gateway == 'manual' && $payment) {
128
+        if (!((float)wpinv_payment_total($payment) > 0)) {
129
+            $label = __('Free Purchase', 'invoicing');
130 130
         }
131 131
     }
132 132
 
133
-    return apply_filters( 'wpinv_gateway_admin_label', $label, $gateway );
133
+    return apply_filters('wpinv_gateway_admin_label', $label, $gateway);
134 134
 }
135 135
 
136
-function wpinv_get_gateway_description( $gateway ) {
136
+function wpinv_get_gateway_description($gateway) {
137 137
     global $wpinv_options;
138 138
 
139
-    $description = isset( $wpinv_options[$gateway . '_desc'] ) ? $wpinv_options[$gateway . '_desc'] : '';
139
+    $description = isset($wpinv_options[$gateway . '_desc']) ? $wpinv_options[$gateway . '_desc'] : '';
140 140
 
141
-    return apply_filters( 'wpinv_gateway_description', $description, $gateway );
141
+    return apply_filters('wpinv_gateway_description', $description, $gateway);
142 142
 }
143 143
 
144
-function wpinv_get_gateway_button_label( $gateway ) {
145
-    return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' );
144
+function wpinv_get_gateway_button_label($gateway) {
145
+    return apply_filters('wpinv_gateway_' . $gateway . '_button_label', '');
146 146
 }
147 147
 
148
-function wpinv_get_gateway_checkout_label( $gateway ) {
148
+function wpinv_get_gateway_checkout_label($gateway) {
149 149
     $gateways = wpinv_get_payment_gateways();
150
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway;
150
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway;
151 151
 
152
-    if( $gateway == 'manual' ) {
153
-        $label = __( 'Manual Payment', 'invoicing' );
152
+    if ($gateway == 'manual') {
153
+        $label = __('Manual Payment', 'invoicing');
154 154
     }
155 155
 
156
-    return apply_filters( 'wpinv_gateway_checkout_label', $label, $gateway );
156
+    return apply_filters('wpinv_gateway_checkout_label', $label, $gateway);
157 157
 }
158 158
 
159
-function wpinv_settings_sections_gateways( $settings ) {
159
+function wpinv_settings_sections_gateways($settings) {
160 160
     $gateways = wpinv_get_payment_gateways();
161 161
     
162 162
     if (!empty($gateways)) {
163
-        foreach  ($gateways as $key => $gateway) {
163
+        foreach ($gateways as $key => $gateway) {
164 164
             $settings[$key] = $gateway['admin_label'];
165 165
         }
166 166
     }
167 167
     
168 168
     return $settings;    
169 169
 }
170
-add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 );
170
+add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1);
171 171
 
172
-function wpinv_settings_gateways( $settings ) {
172
+function wpinv_settings_gateways($settings) {
173 173
     $gateways = wpinv_get_payment_gateways();
174 174
     
175 175
     if (!empty($gateways)) {
176
-        foreach  ($gateways as $key => $gateway) {
176
+        foreach ($gateways as $key => $gateway) {
177 177
             $setting = array();
178 178
             $setting[$key . '_header'] = array(
179 179
                     'id'   => 'gateway_header',
180
-                    'name' => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>',
180
+                    'name' => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>',
181 181
                     'custom' => $key,
182 182
                     'type' => 'gateway_header',
183 183
                 );
184 184
             $setting[$key . '_active'] = array(
185 185
                     'id'   => $key . '_active',
186
-                    'name' => __( 'Active', 'invoicing' ),
187
-                    'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ),
186
+                    'name' => __('Active', 'invoicing'),
187
+                    'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']),
188 188
                     'type' => 'checkbox',
189 189
                 );
190 190
                 
191 191
             $setting[$key . '_title'] = array(
192 192
                     'id'   => $key . '_title',
193
-                    'name' => __( 'Title', 'invoicing' ),
194
-                    'desc' => __( 'This controls the title which the user sees during checkout.', 'invoicing' ),
193
+                    'name' => __('Title', 'invoicing'),
194
+                    'desc' => __('This controls the title which the user sees during checkout.', 'invoicing'),
195 195
                     'type' => 'text',
196 196
                     'std' => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : ''
197 197
                 );
198 198
             
199 199
             $setting[$key . '_desc'] = array(
200 200
                     'id'   => $key . '_desc',
201
-                    'name' => __( 'Description', 'invoicing' ),
202
-                    'desc' => __( 'This controls the description which the user sees during checkout.', 'invoicing' ),
201
+                    'name' => __('Description', 'invoicing'),
202
+                    'desc' => __('This controls the description which the user sees during checkout.', 'invoicing'),
203 203
                     'type' => 'text',
204 204
                     'size' => 'large'
205 205
                 );
206 206
                 
207 207
             $setting[$key . '_ordering'] = array(
208 208
                     'id'   => $key . '_ordering',
209
-                    'name' => __( 'Display Order', 'invoicing' ),
209
+                    'name' => __('Display Order', 'invoicing'),
210 210
                     'type' => 'number',
211 211
                     'size' => 'small',
212 212
                     'std'  => isset($gateway['ordering']) ? $gateway['ordering'] : '10',
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
                     'step' => '1'
216 216
                 );
217 217
                 
218
-            $setting = apply_filters( 'wpinv_gateway_settings', $setting, $key );
219
-            $setting = apply_filters( 'wpinv_gateway_settings_' . $key, $setting );
218
+            $setting = apply_filters('wpinv_gateway_settings', $setting, $key);
219
+            $setting = apply_filters('wpinv_gateway_settings_' . $key, $setting);
220 220
             
221 221
             $settings[$key] = $setting;
222 222
         }
@@ -224,106 +224,106 @@  discard block
 block discarded – undo
224 224
     
225 225
     return $settings;    
226 226
 }
227
-add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 );
227
+add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1);
228 228
 
229
-function wpinv_gateway_header_callback( $args ) {
230
-    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />';
229
+function wpinv_gateway_header_callback($args) {
230
+    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />';
231 231
 }
232 232
 
233
-function wpinv_get_gateway_supports( $gateway ) {
233
+function wpinv_get_gateway_supports($gateway) {
234 234
     $gateways = wpinv_get_enabled_payment_gateways();
235
-    $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array();
236
-    return apply_filters( 'wpinv_gateway_supports', $supports, $gateway );
235
+    $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array();
236
+    return apply_filters('wpinv_gateway_supports', $supports, $gateway);
237 237
 }
238 238
 
239
-function wpinv_gateway_supports_buy_now( $gateway ) {
240
-    $supports = wpinv_get_gateway_supports( $gateway );
241
-    $ret = in_array( 'buy_now', $supports );
242
-    return apply_filters( 'wpinv_gateway_supports_buy_now', $ret, $gateway );
239
+function wpinv_gateway_supports_buy_now($gateway) {
240
+    $supports = wpinv_get_gateway_supports($gateway);
241
+    $ret = in_array('buy_now', $supports);
242
+    return apply_filters('wpinv_gateway_supports_buy_now', $ret, $gateway);
243 243
 }
244 244
 
245 245
 function wpinv_shop_supports_buy_now() {
246 246
     $gateways = wpinv_get_enabled_payment_gateways();
247 247
     $ret      = false;
248 248
 
249
-    if ( !wpinv_use_taxes()  && $gateways ) {
250
-        foreach ( $gateways as $gateway_id => $gateway ) {
251
-            if ( wpinv_gateway_supports_buy_now( $gateway_id ) ) {
249
+    if (!wpinv_use_taxes() && $gateways) {
250
+        foreach ($gateways as $gateway_id => $gateway) {
251
+            if (wpinv_gateway_supports_buy_now($gateway_id)) {
252 252
                 $ret = true;
253 253
                 break;
254 254
             }
255 255
         }
256 256
     }
257 257
 
258
-    return apply_filters( 'wpinv_shop_supports_buy_now', $ret );
258
+    return apply_filters('wpinv_shop_supports_buy_now', $ret);
259 259
 }
260 260
 
261
-function wpinv_send_to_gateway( $gateway, $payment_data ) {
262
-    $payment_data['gateway_nonce'] = wp_create_nonce( 'wpi-gateway' );
261
+function wpinv_send_to_gateway($gateway, $payment_data) {
262
+    $payment_data['gateway_nonce'] = wp_create_nonce('wpi-gateway');
263 263
 
264 264
     // $gateway must match the ID used when registering the gateway
265
-    do_action( 'wpinv_gateway_' . $gateway, $payment_data );
265
+    do_action('wpinv_gateway_' . $gateway, $payment_data);
266 266
 }
267 267
 
268 268
 function wpinv_show_gateways() {
269 269
     $gateways = wpinv_get_enabled_payment_gateways();
270 270
     $show_gateways = false;
271 271
 
272
-    $chosen_gateway = isset( $_GET['payment-mode'] ) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode'] ) : false;
272
+    $chosen_gateway = isset($_GET['payment-mode']) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode']) : false;
273 273
 
274
-    if ( count( $gateways ) > 1 && empty( $chosen_gateway ) ) {
274
+    if (count($gateways) > 1 && empty($chosen_gateway)) {
275 275
         $show_gateways = true;
276
-        if ( wpinv_get_cart_total() <= 0 ) {
276
+        if (wpinv_get_cart_total() <= 0) {
277 277
             $show_gateways = false;
278 278
         }
279 279
     }
280 280
     
281
-    if ( !$show_gateways && wpinv_cart_has_recurring_item() ) {
281
+    if (!$show_gateways && wpinv_cart_has_recurring_item()) {
282 282
         $show_gateways = true;
283 283
     }
284 284
 
285
-    return apply_filters( 'wpinv_show_gateways', $show_gateways );
285
+    return apply_filters('wpinv_show_gateways', $show_gateways);
286 286
 }
287 287
 
288
-function wpinv_get_chosen_gateway( $invoice_id = 0 ) {
289
-	$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
288
+function wpinv_get_chosen_gateway($invoice_id = 0) {
289
+	$gateways = array_keys(wpinv_get_enabled_payment_gateways());
290 290
 
291 291
     $chosen = false;
292
-    if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) {
292
+    if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) {
293 293
         $chosen = $invoice->get_gateway();
294 294
     }
295 295
 
296
-	$chosen   = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen;
296
+	$chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen;
297 297
 
298
-	if ( false !== $chosen ) {
299
-		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen );
298
+	if (false !== $chosen) {
299
+		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen);
300 300
 	}
301 301
 
302
-	if ( ! empty ( $chosen ) ) {
303
-		$enabled_gateway = urldecode( $chosen );
304
-	} else if (  !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) {
302
+	if (!empty ($chosen)) {
303
+		$enabled_gateway = urldecode($chosen);
304
+	} else if (!empty($invoice) && (float)$invoice->get_subtotal() <= 0) {
305 305
 		$enabled_gateway = 'manual';
306 306
 	} else {
307 307
 		$enabled_gateway = wpinv_get_default_gateway();
308 308
 	}
309 309
     
310
-    if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) {
311
-        if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){
310
+    if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) {
311
+        if (wpinv_is_gateway_active(wpinv_get_default_gateway())) {
312 312
             $enabled_gateway = wpinv_get_default_gateway();
313
-        }else{
313
+        } else {
314 314
             $enabled_gateway = $gateways[0];
315 315
         }
316 316
 
317 317
     }
318 318
 
319
-	return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway );
319
+	return apply_filters('wpinv_chosen_gateway', $enabled_gateway);
320 320
 }
321 321
 
322
-function wpinv_record_gateway_error( $title = '', $message = '', $parent = 0 ) {
323
-    return wpinv_error_log( $message, $title );
322
+function wpinv_record_gateway_error($title = '', $message = '', $parent = 0) {
323
+    return wpinv_error_log($message, $title);
324 324
 }
325 325
 
326
-function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
326
+function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') {
327 327
 	$ret  = 0;
328 328
 	$args = array(
329 329
 		'meta_key'    => '_wpinv_gateway',
@@ -334,48 +334,48 @@  discard block
 block discarded – undo
334 334
 		'fields'      => 'ids'
335 335
 	);
336 336
 
337
-	$payments = new WP_Query( $args );
337
+	$payments = new WP_Query($args);
338 338
 
339
-	if( $payments )
339
+	if ($payments)
340 340
 		$ret = $payments->post_count;
341 341
 	return $ret;
342 342
 }
343 343
 
344
-function wpinv_settings_update_gateways( $input ) {
344
+function wpinv_settings_update_gateways($input) {
345 345
     global $wpinv_options;
346 346
     
347
-    if ( !empty( $input['save_gateway'] ) ) {
348
-        $gateways = wpinv_get_option( 'gateways', false );
347
+    if (!empty($input['save_gateway'])) {
348
+        $gateways = wpinv_get_option('gateways', false);
349 349
         $gateways = !empty($gateways) ? $gateways : array();
350 350
         $gateway = $input['save_gateway'];
351 351
         
352
-        if ( !empty( $input[$gateway . '_active'] ) ) {
352
+        if (!empty($input[$gateway . '_active'])) {
353 353
             $gateways[$gateway] = 1;
354 354
         } else {
355
-            if ( isset( $gateways[$gateway] ) ) {
356
-                unset( $gateways[$gateway] );
355
+            if (isset($gateways[$gateway])) {
356
+                unset($gateways[$gateway]);
357 357
             }
358 358
         }
359 359
         
360 360
         $input['gateways'] = $gateways;
361 361
     }
362 362
     
363
-    if ( !empty( $input['default_gateway'] ) ) {
363
+    if (!empty($input['default_gateway'])) {
364 364
         $gateways = wpinv_get_payment_gateways();
365 365
         
366
-        foreach ( $gateways as $key => $gateway ) {
367
-            $active   = 0;
368
-            if ( !empty( $input['gateways'] ) && !empty( $input['gateways'][$key] ) ) {
366
+        foreach ($gateways as $key => $gateway) {
367
+            $active = 0;
368
+            if (!empty($input['gateways']) && !empty($input['gateways'][$key])) {
369 369
                 $active = 1;
370 370
             }
371 371
             
372 372
             $input[$key . '_active'] = $active;
373 373
             
374
-            if ( empty( $wpinv_options[$key . '_title'] ) ) {
374
+            if (empty($wpinv_options[$key . '_title'])) {
375 375
                 $input[$key . '_title'] = $gateway['checkout_label'];
376 376
             }
377 377
             
378
-            if ( !isset( $wpinv_options[$key . '_ordering'] ) && isset( $gateway['ordering'] ) ) {
378
+            if (!isset($wpinv_options[$key . '_ordering']) && isset($gateway['ordering'])) {
379 379
                 $input[$key . '_ordering'] = $gateway['ordering'];
380 380
             }
381 381
         }
@@ -383,27 +383,27 @@  discard block
 block discarded – undo
383 383
     
384 384
     return $input;
385 385
 }
386
-add_filter( 'wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1 );
386
+add_filter('wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1);
387 387
 
388 388
 // PayPal Standard settings
389
-function wpinv_gateway_settings_paypal( $setting ) {    
390
-    $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' );
391
-    $setting['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' );
389
+function wpinv_gateway_settings_paypal($setting) {    
390
+    $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');
391
+    $setting['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing');
392 392
     
393 393
     $setting['paypal_sandbox'] = array(
394 394
             'type' => 'checkbox',
395 395
             'id'   => 'paypal_sandbox',
396
-            'name' => __( 'PayPal Sandbox', 'invoicing' ),
397
-            'desc' => __( 'PayPal sandbox can be used to test payments.', 'invoicing' ),
396
+            'name' => __('PayPal Sandbox', 'invoicing'),
397
+            'desc' => __('PayPal sandbox can be used to test payments.', 'invoicing'),
398 398
             'std'  => 1
399 399
         );
400 400
         
401 401
     $setting['paypal_email'] = array(
402 402
             'type' => 'text',
403 403
             'id'   => 'paypal_email',
404
-            'name' => __( 'PayPal Email', 'invoicing' ),
405
-            'desc' => __( 'Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing' ),
406
-            'std' => __( '[email protected]', 'invoicing' ),
404
+            'name' => __('PayPal Email', 'invoicing'),
405
+            'desc' => __('Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing'),
406
+            'std' => __('[email protected]', 'invoicing'),
407 407
         );
408 408
     /*
409 409
     $setting['paypal_ipn_url'] = array(
@@ -417,137 +417,137 @@  discard block
 block discarded – undo
417 417
         
418 418
     return $setting;
419 419
 }
420
-add_filter( 'wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1 );
420
+add_filter('wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1);
421 421
 
422 422
 // Pre Bank Transfer settings
423
-function wpinv_gateway_settings_bank_transfer( $setting ) {
424
-    $setting['bank_transfer_desc']['std'] = __( 'Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing' );
423
+function wpinv_gateway_settings_bank_transfer($setting) {
424
+    $setting['bank_transfer_desc']['std'] = __('Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing');
425 425
     
426 426
     $setting['bank_transfer_ac_name'] = array(
427 427
             'type' => 'text',
428 428
             'id' => 'bank_transfer_ac_name',
429
-            'name' => __( 'Account Name', 'invoicing' ),
430
-            'desc' => __( 'Enter the bank account name to which you want to transfer payment.', 'invoicing' ),
431
-            'std'  =>  __( 'Mr. John Martin', 'invoicing' ),
429
+            'name' => __('Account Name', 'invoicing'),
430
+            'desc' => __('Enter the bank account name to which you want to transfer payment.', 'invoicing'),
431
+            'std'  =>  __('Mr. John Martin', 'invoicing'),
432 432
         );
433 433
     
434 434
     $setting['bank_transfer_ac_no'] = array(
435 435
             'type' => 'text',
436 436
             'id' => 'bank_transfer_ac_no',
437
-            'name' => __( 'Account Number', 'invoicing' ),
438
-            'desc' => __( 'Enter your bank account number.', 'invoicing' ),
439
-            'std'  =>  __( 'TEST1234567890', 'invoicing' ),
437
+            'name' => __('Account Number', 'invoicing'),
438
+            'desc' => __('Enter your bank account number.', 'invoicing'),
439
+            'std'  =>  __('TEST1234567890', 'invoicing'),
440 440
         );
441 441
     
442 442
     $setting['bank_transfer_bank_name'] = array(
443 443
             'type' => 'text',
444 444
             'id'   => 'bank_transfer_bank_name',
445
-            'name' => __( 'Bank Name', 'invoicing' ),
446
-            'desc' => __( 'Enter the bank name to which you want to transfer payment.', 'invoicing' ),
447
-            'std' => __( 'ICICI Bank', 'invoicing' ),
445
+            'name' => __('Bank Name', 'invoicing'),
446
+            'desc' => __('Enter the bank name to which you want to transfer payment.', 'invoicing'),
447
+            'std' => __('ICICI Bank', 'invoicing'),
448 448
         );
449 449
     
450 450
     $setting['bank_transfer_ifsc'] = array(
451 451
             'type' => 'text',
452 452
             'id'   => 'bank_transfer_ifsc',
453
-            'name' => __( 'IFSC Code', 'invoicing' ),
454
-            'desc' => __( 'Enter your bank IFSC code.', 'invoicing' ),
455
-            'std'  =>  __( 'ICIC0001234', 'invoicing' ),
453
+            'name' => __('IFSC Code', 'invoicing'),
454
+            'desc' => __('Enter your bank IFSC code.', 'invoicing'),
455
+            'std'  =>  __('ICIC0001234', 'invoicing'),
456 456
         );
457 457
         
458 458
     $setting['bank_transfer_iban'] = array(
459 459
             'type' => 'text',
460 460
             'id'   => 'bank_transfer_iban',
461
-            'name' => __( 'IBAN', 'invoicing' ),
462
-            'desc' => __( 'Enter your International Bank Account Number(IBAN).', 'invoicing' ),
463
-            'std'  =>  __( 'GB29NWBK60161331926819', 'invoicing' ),
461
+            'name' => __('IBAN', 'invoicing'),
462
+            'desc' => __('Enter your International Bank Account Number(IBAN).', 'invoicing'),
463
+            'std'  =>  __('GB29NWBK60161331926819', 'invoicing'),
464 464
         );
465 465
         
466 466
     $setting['bank_transfer_bic'] = array(
467 467
             'type' => 'text',
468 468
             'id'   => 'bank_transfer_bic',
469
-            'name' => __( 'BIC/Swift Code', 'invoicing' ),
470
-            'std'  =>  __( 'ICICGB2L129', 'invoicing' ),
469
+            'name' => __('BIC/Swift Code', 'invoicing'),
470
+            'std'  =>  __('ICICGB2L129', 'invoicing'),
471 471
         );
472 472
 
473 473
     $setting['bank_transfer_sort_code'] = array(
474 474
         'type' => 'text',
475 475
         'id'   => 'bank_transfer_sort_code',
476
-        'name' => __( 'Sort Code', 'invoicing' ),
477
-        'std'  =>  __( '12-34-56', 'invoicing' ),
476
+        'name' => __('Sort Code', 'invoicing'),
477
+        'std'  =>  __('12-34-56', 'invoicing'),
478 478
     );
479 479
         
480 480
     $setting['bank_transfer_info'] = array(
481 481
             'id'   => 'bank_transfer_info',
482
-            'name' => __( 'Instructions', 'invoicing' ),
483
-            'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
482
+            'name' => __('Instructions', 'invoicing'),
483
+            'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'),
484 484
             'type' => 'textarea',
485
-            'std' => __( 'Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing' ),
485
+            'std' => __('Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing'),
486 486
             'cols' => 37,
487 487
             'rows' => 5
488 488
         );
489 489
         
490 490
     return $setting;
491 491
 }
492
-add_filter( 'wpinv_gateway_settings_bank_transfer', 'wpinv_gateway_settings_bank_transfer', 10, 1 );
492
+add_filter('wpinv_gateway_settings_bank_transfer', 'wpinv_gateway_settings_bank_transfer', 10, 1);
493 493
 
494 494
 // Authorize.Net settings
495
-function wpinv_gateway_settings_authorizenet( $setting ) {
496
-    $setting['authorizenet_active']['desc'] = $setting['authorizenet_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, CAD, CHF, DKK, EUR, GBP, JPY, NOK, NZD, PLN, SEK, USD, ZAR )', 'invoicing' );
497
-    $setting['authorizenet_desc']['std'] = __( 'Pay using a Authorize.Net to process Credit card / Debit card transactions.', 'invoicing' );
495
+function wpinv_gateway_settings_authorizenet($setting) {
496
+    $setting['authorizenet_active']['desc'] = $setting['authorizenet_active']['desc'] . ' ' . __('( Supported Currencies: AUD, CAD, CHF, DKK, EUR, GBP, JPY, NOK, NZD, PLN, SEK, USD, ZAR )', 'invoicing');
497
+    $setting['authorizenet_desc']['std'] = __('Pay using a Authorize.Net to process Credit card / Debit card transactions.', 'invoicing');
498 498
     
499 499
     $setting['authorizenet_sandbox'] = array(
500 500
             'type' => 'checkbox',
501 501
             'id'   => 'authorizenet_sandbox',
502
-            'name' => __( 'Authorize.Net Test Mode', 'invoicing' ),
503
-            'desc' => __( 'Enable Authorize.Net test mode to test payments.', 'invoicing' ),
502
+            'name' => __('Authorize.Net Test Mode', 'invoicing'),
503
+            'desc' => __('Enable Authorize.Net test mode to test payments.', 'invoicing'),
504 504
             'std'  => 1
505 505
         );
506 506
         
507 507
     $setting['authorizenet_login_id'] = array(
508 508
             'type' => 'text',
509 509
             'id'   => 'authorizenet_login_id',
510
-            'name' => __( 'API Login ID', 'invoicing' ),
511
-            'desc' => __( 'API Login ID can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 2j4rBekUnD', 'invoicing' ),
510
+            'name' => __('API Login ID', 'invoicing'),
511
+            'desc' => __('API Login ID can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 2j4rBekUnD', 'invoicing'),
512 512
             'std' => '2j4rBekUnD',
513 513
         );
514 514
     
515 515
     $setting['authorizenet_transaction_key'] = array(
516 516
             'type' => 'text',
517 517
             'id'   => 'authorizenet_transaction_key',
518
-            'name' => __( 'Transaction Key', 'invoicing' ),
519
-            'desc' => __( 'Transaction Key can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 4vyBUOJgR74679xa', 'invoicing' ),
518
+            'name' => __('Transaction Key', 'invoicing'),
519
+            'desc' => __('Transaction Key can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 4vyBUOJgR74679xa', 'invoicing'),
520 520
             'std' => '4vyBUOJgR74679xa',
521 521
         );
522 522
         
523 523
     $setting['authorizenet_md5_hash'] = array(
524 524
             'type' => 'text',
525 525
             'id'   => 'authorizenet_md5_hash',
526
-            'name' => __( 'MD5-Hash', 'invoicing' ),
527
-            'desc' => __( 'The MD5 Hash security feature allows to authenticate transaction responses from the Authorize.Net for recurring payments. It can be obtained from Authorize.Net Account > Settings > Security Settings > General Settings > MD5 Hash.', 'invoicing' ),
526
+            'name' => __('MD5-Hash', 'invoicing'),
527
+            'desc' => __('The MD5 Hash security feature allows to authenticate transaction responses from the Authorize.Net for recurring payments. It can be obtained from Authorize.Net Account > Settings > Security Settings > General Settings > MD5 Hash.', 'invoicing'),
528 528
             'std' => '',
529 529
         );
530 530
 
531 531
     $setting['authorizenet_transaction_type'] = array(
532 532
         'id'          => 'authorizenet_transaction_type',
533
-        'name'        => __( 'Transaction Type', 'invoicing' ),
534
-        'desc'        => __( 'Choose transaction type.', 'invoicing' ),
533
+        'name'        => __('Transaction Type', 'invoicing'),
534
+        'desc'        => __('Choose transaction type.', 'invoicing'),
535 535
         'type'        => 'select',
536 536
         'options'     => array(
537
-            'authorize_capture' => __( 'Authorize And Capture', 'invoicing' ),
538
-            'authorize_only' => __( 'Authorize Only', 'invoicing' ),
537
+            'authorize_capture' => __('Authorize And Capture', 'invoicing'),
538
+            'authorize_only' => __('Authorize Only', 'invoicing'),
539 539
         ),
540 540
         'std'         => 'authorize_capture'
541 541
     );
542 542
 
543 543
     $setting['authorizenet_transaction_type_recurring'] = array(
544 544
         'id'          => 'authorizenet_transaction_type_recurring',
545
-        'name'        => __( 'Transaction Type for Recurring', 'invoicing' ),
546
-        'desc'        => __( 'Choose transaction type for recurring payments.', 'invoicing' ),
545
+        'name'        => __('Transaction Type for Recurring', 'invoicing'),
546
+        'desc'        => __('Choose transaction type for recurring payments.', 'invoicing'),
547 547
         'type'        => 'select',
548 548
         'options'     => array(
549
-            'authorize_capture' => __( 'Authorize And Capture', 'invoicing' ),
550
-            'authorize_only' => __( 'Authorize Only', 'invoicing' ),
549
+            'authorize_capture' => __('Authorize And Capture', 'invoicing'),
550
+            'authorize_only' => __('Authorize Only', 'invoicing'),
551 551
         ),
552 552
         'std'         => 'authorize_only'
553 553
     );
@@ -555,9 +555,9 @@  discard block
 block discarded – undo
555 555
     $setting['authorizenet_ipn_url'] = array(
556 556
             'type' => 'ipn_url',
557 557
             'id'   => 'authorizenet_ipn_url',
558
-            'name' => __( 'Silent Post URL', 'invoicing' ),
559
-            'std' => wpinv_get_ipn_url( 'authorizenet' ),
560
-            'desc' => __( 'If you are accepting recurring payments then you must set this url at Authorize.Net Account > Settings > Transaction Format Settings > Transaction Response Settings > Silent Post URL.', 'invoicing' ),
558
+            'name' => __('Silent Post URL', 'invoicing'),
559
+            'std' => wpinv_get_ipn_url('authorizenet'),
560
+            'desc' => __('If you are accepting recurring payments then you must set this url at Authorize.Net Account > Settings > Transaction Format Settings > Transaction Response Settings > Silent Post URL.', 'invoicing'),
561 561
             'size' => 'large',
562 562
             'custom' => 'authorizenet',
563 563
             'readonly' => true
@@ -565,26 +565,26 @@  discard block
 block discarded – undo
565 565
         
566 566
     return $setting;
567 567
 }
568
-add_filter( 'wpinv_gateway_settings_authorizenet', 'wpinv_gateway_settings_authorizenet', 10, 1 );
568
+add_filter('wpinv_gateway_settings_authorizenet', 'wpinv_gateway_settings_authorizenet', 10, 1);
569 569
 
570 570
 // Worldpay settings
571
-function wpinv_gateway_settings_worldpay( $setting ) {
572
-    $setting['worldpay_active']['desc'] = $setting['worldpay_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, ARS, CAD, CHF, DKK, EUR, HKD, MYR, GBP, NZD, NOK, SGD, LKR, SEK, TRY, USD, ZAR )', 'invoicing' );
573
-    $setting['worldpay_desc']['std'] = __( 'Pay using a Worldpay account to process Credit card / Debit card transactions.', 'invoicing' );
571
+function wpinv_gateway_settings_worldpay($setting) {
572
+    $setting['worldpay_active']['desc'] = $setting['worldpay_active']['desc'] . ' ' . __('( Supported Currencies: AUD, ARS, CAD, CHF, DKK, EUR, HKD, MYR, GBP, NZD, NOK, SGD, LKR, SEK, TRY, USD, ZAR )', 'invoicing');
573
+    $setting['worldpay_desc']['std'] = __('Pay using a Worldpay account to process Credit card / Debit card transactions.', 'invoicing');
574 574
     
575 575
     $setting['worldpay_sandbox'] = array(
576 576
             'type' => 'checkbox',
577 577
             'id'   => 'worldpay_sandbox',
578
-            'name' => __( 'Worldpay Test Mode', 'invoicing' ),
579
-            'desc' => __( 'This provides a special Test Environment to enable you to test your installation and integration to your website before going live.', 'invoicing' ),
578
+            'name' => __('Worldpay Test Mode', 'invoicing'),
579
+            'desc' => __('This provides a special Test Environment to enable you to test your installation and integration to your website before going live.', 'invoicing'),
580 580
             'std'  => 1
581 581
         );
582 582
         
583 583
     $setting['worldpay_instId'] = array(
584 584
             'type' => 'text',
585 585
             'id'   => 'worldpay_instId',
586
-            'name' => __( 'Installation Id', 'invoicing' ),
587
-            'desc' => __( 'Your installation id. Ex: 211616', 'invoicing' ),
586
+            'name' => __('Installation Id', 'invoicing'),
587
+            'desc' => __('Your installation id. Ex: 211616', 'invoicing'),
588 588
             'std' => '211616',
589 589
         );
590 590
     /*
@@ -600,9 +600,9 @@  discard block
 block discarded – undo
600 600
     $setting['worldpay_ipn_url'] = array(
601 601
             'type' => 'ipn_url',
602 602
             'id'   => 'worldpay_ipn_url',
603
-            'name' => __( 'Worldpay Callback Url', 'invoicing' ),
604
-            'std' => wpinv_get_ipn_url( 'worldpay' ),
605
-            'desc' => wp_sprintf( __( 'Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and type "%s" or "%s" for a dynamic payment response.', 'invoicing' ), '<font style="color:#000;font-style:normal">' . wpinv_get_ipn_url( 'worldpay' ) . '</font>', '<font style="color:#000;font-style:normal">&lt;wpdisplay item=MC_callback&gt;</font>' ),
603
+            'name' => __('Worldpay Callback Url', 'invoicing'),
604
+            'std' => wpinv_get_ipn_url('worldpay'),
605
+            'desc' => wp_sprintf(__('Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and type "%s" or "%s" for a dynamic payment response.', 'invoicing'), '<font style="color:#000;font-style:normal">' . wpinv_get_ipn_url('worldpay') . '</font>', '<font style="color:#000;font-style:normal">&lt;wpdisplay item=MC_callback&gt;</font>'),
606 606
             'size' => 'large',
607 607
             'custom' => 'worldpay',
608 608
             'readonly' => true
@@ -610,99 +610,99 @@  discard block
 block discarded – undo
610 610
         
611 611
     return $setting;
612 612
 }
613
-add_filter( 'wpinv_gateway_settings_worldpay', 'wpinv_gateway_settings_worldpay', 10, 1 );
613
+add_filter('wpinv_gateway_settings_worldpay', 'wpinv_gateway_settings_worldpay', 10, 1);
614 614
 
615
-function wpinv_ipn_url_callback( $args ) {    
616
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
615
+function wpinv_ipn_url_callback($args) {    
616
+    $sanitize_id = wpinv_sanitize_key($args['id']);
617 617
     
618 618
     $attrs = $args['readonly'] ? ' readonly' : '';
619 619
 
620
-    $html = '<input style="background-color:#fefefe" type="text" ' . $attrs . ' value="' . esc_attr( $args['std'] ) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" class="large-text">';
621
-    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">'  . $args['desc'] . '</label>';
620
+    $html = '<input style="background-color:#fefefe" type="text" ' . $attrs . ' value="' . esc_attr($args['std']) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" class="large-text">';
621
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>';
622 622
 
623 623
     echo $html;
624 624
 }
625 625
 
626
-function wpinv_is_test_mode( $gateway = '' ) {
627
-    if ( empty( $gateway ) ) {
626
+function wpinv_is_test_mode($gateway = '') {
627
+    if (empty($gateway)) {
628 628
         return false;
629 629
     }
630 630
     
631
-    $is_test_mode = wpinv_get_option( $gateway . '_sandbox', false );
631
+    $is_test_mode = wpinv_get_option($gateway . '_sandbox', false);
632 632
     
633
-    return apply_filters( 'wpinv_is_test_mode', $is_test_mode, $gateway );
633
+    return apply_filters('wpinv_is_test_mode', $is_test_mode, $gateway);
634 634
 }
635 635
 
636
-function wpinv_get_ipn_url( $gateway = '', $args = array() ) {
637
-    $data = array( 'wpi-listener' => 'IPN' );
636
+function wpinv_get_ipn_url($gateway = '', $args = array()) {
637
+    $data = array('wpi-listener' => 'IPN');
638 638
     
639
-    if ( !empty( $gateway ) ) {
640
-        $data['wpi-gateway'] = wpinv_sanitize_key( $gateway );
639
+    if (!empty($gateway)) {
640
+        $data['wpi-gateway'] = wpinv_sanitize_key($gateway);
641 641
     }
642 642
     
643
-    $args = !empty( $args ) && is_array( $args ) ? array_merge( $data, $args ) : $data;
643
+    $args = !empty($args) && is_array($args) ? array_merge($data, $args) : $data;
644 644
     
645
-    $ipn_url = add_query_arg( $args,  home_url( 'index.php' ) );
645
+    $ipn_url = add_query_arg($args, home_url('index.php'));
646 646
     
647
-    return apply_filters( 'wpinv_ipn_url', $ipn_url );
647
+    return apply_filters('wpinv_ipn_url', $ipn_url);
648 648
 }
649 649
 
650 650
 function wpinv_listen_for_payment_ipn() {
651 651
     // Regular PayPal IPN
652
-    if ( isset( $_GET['wpi-listener'] ) && $_GET['wpi-listener'] == 'IPN' ) {
653
-        do_action( 'wpinv_verify_payment_ipn' );
652
+    if (isset($_GET['wpi-listener']) && $_GET['wpi-listener'] == 'IPN') {
653
+        do_action('wpinv_verify_payment_ipn');
654 654
         
655
-        if ( !empty( $_GET['wpi-gateway'] ) ) {
656
-            wpinv_error_log( sanitize_text_field( $_GET['wpi-gateway'] ), 'WP Invoicing IPN', __FILE__, __LINE__ );
657
-            do_action( 'wpinv_verify_' . sanitize_text_field( $_GET['wpi-gateway'] ) . '_ipn' );
655
+        if (!empty($_GET['wpi-gateway'])) {
656
+            wpinv_error_log(sanitize_text_field($_GET['wpi-gateway']), 'WP Invoicing IPN', __FILE__, __LINE__);
657
+            do_action('wpinv_verify_' . sanitize_text_field($_GET['wpi-gateway']) . '_ipn');
658 658
         }
659 659
     }
660 660
 }
661
-add_action( 'init', 'wpinv_listen_for_payment_ipn' );
661
+add_action('init', 'wpinv_listen_for_payment_ipn');
662 662
 
663 663
 function wpinv_get_bank_instructions() {
664
-    $bank_instructions = wpinv_get_option( 'bank_transfer_info' );
664
+    $bank_instructions = wpinv_get_option('bank_transfer_info');
665 665
     
666
-    return apply_filters( 'wpinv_bank_instructions', $bank_instructions );
666
+    return apply_filters('wpinv_bank_instructions', $bank_instructions);
667 667
 }
668 668
 
669
-function wpinv_get_bank_info( $filtered = false ) {
669
+function wpinv_get_bank_info($filtered = false) {
670 670
     $bank_fields = array(
671
-        'bank_transfer_ac_name'     => __( 'Account Name', 'invoicing' ),
672
-        'bank_transfer_ac_no'       => __( 'Account Number', 'invoicing' ),
673
-        'bank_transfer_bank_name'   => __( 'Bank Name', 'invoicing' ),
674
-        'bank_transfer_ifsc'        => __( 'IFSC code', 'invoicing' ),
675
-        'bank_transfer_iban'        => __( 'IBAN', 'invoicing' ),
676
-        'bank_transfer_bic'         => __( 'BIC/Swift code', 'invoicing' ),
677
-        'bank_transfer_sort_code'   => __( 'Sort Code', 'invoicing' )
671
+        'bank_transfer_ac_name'     => __('Account Name', 'invoicing'),
672
+        'bank_transfer_ac_no'       => __('Account Number', 'invoicing'),
673
+        'bank_transfer_bank_name'   => __('Bank Name', 'invoicing'),
674
+        'bank_transfer_ifsc'        => __('IFSC code', 'invoicing'),
675
+        'bank_transfer_iban'        => __('IBAN', 'invoicing'),
676
+        'bank_transfer_bic'         => __('BIC/Swift code', 'invoicing'),
677
+        'bank_transfer_sort_code'   => __('Sort Code', 'invoicing')
678 678
     );
679 679
     
680 680
     $bank_info = array();
681
-    foreach ( $bank_fields as $field => $label ) {
682
-        if ( $filtered && !( $value = wpinv_get_option( $field ) ) ) {
681
+    foreach ($bank_fields as $field => $label) {
682
+        if ($filtered && !($value = wpinv_get_option($field))) {
683 683
             continue;
684 684
         }
685 685
         
686
-        $bank_info[$field] = array( 'label' => $label, 'value' => $value );
686
+        $bank_info[$field] = array('label' => $label, 'value' => $value);
687 687
     }
688 688
     
689
-    return apply_filters( 'wpinv_bank_info', $bank_info, $filtered );
689
+    return apply_filters('wpinv_bank_info', $bank_info, $filtered);
690 690
 }
691 691
 
692
-function wpinv_get_post_data( $method = 'request' ) {
692
+function wpinv_get_post_data($method = 'request') {
693 693
     $data       = array();
694 694
     $request    = $_REQUEST;
695 695
     
696
-    if ( $method == 'post' ) {
697
-        if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
696
+    if ($method == 'post') {
697
+        if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
698 698
             return $data;
699 699
         }
700 700
         
701 701
         $request = $_POST;
702 702
     }
703 703
     
704
-    if ( $method == 'get' ) {
705
-        if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'GET' ) {
704
+    if ($method == 'get') {
705
+        if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET') {
706 706
             return $data;
707 707
         }
708 708
         
@@ -713,11 +713,11 @@  discard block
 block discarded – undo
713 713
     $post_data = '';
714 714
     
715 715
     // Fallback just in case post_max_size is lower than needed
716
-    if ( ini_get( 'allow_url_fopen' ) ) {
717
-        $post_data = file_get_contents( 'php://input' );
716
+    if (ini_get('allow_url_fopen')) {
717
+        $post_data = file_get_contents('php://input');
718 718
     } else {
719 719
         // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
720
-        ini_set( 'post_max_size', '12M' );
720
+        ini_set('post_max_size', '12M');
721 721
     }
722 722
     // Start the encoded data collection with notification command
723 723
     $encoded_data = 'cmd=_notify-validate';
@@ -726,58 +726,58 @@  discard block
 block discarded – undo
726 726
     $arg_separator = wpinv_get_php_arg_separator_output();
727 727
 
728 728
     // Verify there is a post_data
729
-    if ( $post_data || strlen( $post_data ) > 0 ) {
729
+    if ($post_data || strlen($post_data) > 0) {
730 730
         // Append the data
731 731
         $encoded_data .= $arg_separator . $post_data;
732 732
     } else {
733 733
         // Check if POST is empty
734
-        if ( empty( $request ) ) {
734
+        if (empty($request)) {
735 735
             // Nothing to do
736 736
             return;
737 737
         } else {
738 738
             // Loop through each POST
739
-            foreach ( $request as $key => $value ) {
739
+            foreach ($request as $key => $value) {
740 740
                 // Encode the value and append the data
741
-                $encoded_data .= $arg_separator . "$key=" . urlencode( $value );
741
+                $encoded_data .= $arg_separator . "$key=" . urlencode($value);
742 742
             }
743 743
         }
744 744
     }
745 745
 
746 746
     // Convert collected post data to an array
747
-    parse_str( $encoded_data, $data );
747
+    parse_str($encoded_data, $data);
748 748
 
749
-    foreach ( $data as $key => $value ) {
750
-        if ( false !== strpos( $key, 'amp;' ) ) {
751
-            $new_key = str_replace( '&amp;', '&', $key );
752
-            $new_key = str_replace( 'amp;', '&' , $new_key );
749
+    foreach ($data as $key => $value) {
750
+        if (false !== strpos($key, 'amp;')) {
751
+            $new_key = str_replace('&amp;', '&', $key);
752
+            $new_key = str_replace('amp;', '&', $new_key);
753 753
 
754
-            unset( $data[ $key ] );
755
-            $data[ $new_key ] = sanitize_text_field( $value );
754
+            unset($data[$key]);
755
+            $data[$new_key] = sanitize_text_field($value);
756 756
         }
757 757
     }
758 758
     
759 759
     return $data;
760 760
 }
761 761
 
762
-function wpinv_gateway_support_subscription( $gateway ) {
762
+function wpinv_gateway_support_subscription($gateway) {
763 763
     $return = false;
764 764
     
765
-    if ( wpinv_is_gateway_active( $gateway ) ) {
766
-        $return = apply_filters( 'wpinv_' . $gateway . '_support_subscription', false );
765
+    if (wpinv_is_gateway_active($gateway)) {
766
+        $return = apply_filters('wpinv_' . $gateway . '_support_subscription', false);
767 767
     }
768 768
     
769 769
     return $return;
770 770
 }
771 771
 
772
-function wpinv_payment_gateways_on_cart( $gateways = array() ) {
773
-    if ( !empty( $gateways ) && wpinv_cart_has_recurring_item() ) {
774
-        foreach ( $gateways as $gateway => $info ) {
775
-            if ( !wpinv_gateway_support_subscription( $gateway ) ) {
776
-                unset( $gateways[$gateway] );
772
+function wpinv_payment_gateways_on_cart($gateways = array()) {
773
+    if (!empty($gateways) && wpinv_cart_has_recurring_item()) {
774
+        foreach ($gateways as $gateway => $info) {
775
+            if (!wpinv_gateway_support_subscription($gateway)) {
776
+                unset($gateways[$gateway]);
777 777
             }
778 778
         }
779 779
     }
780 780
     
781 781
     return $gateways;
782 782
 }
783
-add_filter( 'wpinv_payment_gateways_on_cart', 'wpinv_payment_gateways_on_cart', 10, 1 );
784 783
\ No newline at end of file
784
+add_filter('wpinv_payment_gateways_on_cart', 'wpinv_payment_gateways_on_cart', 10, 1);
785 785
\ No newline at end of file
Please login to merge, or discard this patch.