Passed
Pull Request — master (#126)
by Kiran
07:22 queued 03:36
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   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -1,67 +1,67 @@
 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 if ( empty( $sent_to_admin ) && ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) ) { ?>
49
+        <?php if (empty($sent_to_admin) && ($owner_vat_number = $wpinv_euvat->get_vat_number())) { ?>
50 50
             <tr>
51
-                <td><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></td>
51
+                <td><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></td>
52 52
                 <td><?php echo $owner_vat_number; ?></td>
53 53
             </tr>
54 54
         <?php } ?>
55
-        <?php if ( $use_taxes && ( $user_vat_number = $invoice->vat_number ) ) { ?>
55
+        <?php if ($use_taxes && ($user_vat_number = $invoice->vat_number)) { ?>
56 56
             <tr>
57
-                <td><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></td>
57
+                <td><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></td>
58 58
                 <td><?php echo $user_vat_number; ?></td>
59 59
             </tr>
60 60
         <?php } ?>
61 61
         <tr class="table-active">
62
-            <td><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></td>
63
-            <td><strong><?php echo $invoice->get_total( true ); ?></strong></td>
62
+            <td><strong><?php _e('Total Amount', 'invoicing') ?></strong></td>
63
+            <td><strong><?php echo $invoice->get_total(true); ?></strong></td>
64 64
         </tr>
65 65
     </table>
66 66
 </div>
67
-<?php do_action( 'wpinv_email_after_invoice_details', $invoice, $sent_to_admin ); ?>
68 67
\ No newline at end of file
68
+<?php do_action('wpinv_email_after_invoice_details', $invoice, $sent_to_admin); ?>
69 69
\ 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   +120 added lines, -120 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,58 +133,58 @@  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 ( 'invoice-date' === $column_id ) : $date = wpinv_get_invoice_date( $invoice->ID ); $dateYMD = wpinv_get_invoice_date( $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 ('invoice-date' === $column_id) : $date = wpinv_get_invoice_date($invoice->ID); $dateYMD = wpinv_get_invoice_date($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 ( 'invoice-status' === $column_id ) : ?>
159
-                                            <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?>
158
+                                        <?php elseif ('invoice-status' === $column_id) : ?>
159
+                                            <?php echo wpinv_invoice_status_label($invoice_status, $invoice->get_status(true)); ?>
160 160
 
161
-                                        <?php elseif ( 'invoice-total' === $column_id ) : ?>
162
-                                            <?php echo $invoice->get_total( true ); ?>
161
+                                        <?php elseif ('invoice-total' === $column_id) : ?>
162
+                                            <?php echo $invoice->get_total(true); ?>
163 163
 
164
-                                        <?php elseif ( 'invoice-actions' === $column_id ) : ?>
164
+                                        <?php elseif ('invoice-actions' === $column_id) : ?>
165 165
                                             <?php
166 166
                                                 $actions = array(
167 167
                                                     'pay'    => array(
168 168
                                                         'url'  => $invoice->get_checkout_payment_url(),
169
-                                                        'name' => __( 'Pay Now', 'invoicing' ),
169
+                                                        'name' => __('Pay Now', 'invoicing'),
170 170
                                                         'class' => 'btn-success'
171 171
                                                     ),
172 172
                                                     'print'   => array(
173 173
                                                         'url'  => $invoice->get_view_url(),
174
-                                                        'name' => __( 'Print', 'invoicing' ),
174
+                                                        'name' => __('Print', 'invoicing'),
175 175
                                                         'class' => 'btn-primary',
176 176
                                                         'attrs' => 'target="_blank"'
177 177
                                                     )
178 178
                                                 );
179 179
 
180
-                                                if ( ! $invoice->needs_payment() ) {
181
-                                                    unset( $actions['pay'] );
180
+                                                if (!$invoice->needs_payment()) {
181
+                                                    unset($actions['pay']);
182 182
                                                 }
183 183
 
184
-                                                if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) {
185
-                                                    foreach ( $actions as $key => $action ) {
184
+                                                if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) {
185
+                                                    foreach ($actions as $key => $action) {
186 186
                                                         $class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
187
-                                                        echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
187
+                                                        echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>';
188 188
                                                     }
189 189
                                                 }
190 190
                                             ?>
@@ -212,64 +212,64 @@  discard block
 block discarded – undo
212 212
             </div>
213 213
             <?php
214 214
         
215
-            do_action( 'wpinv_bp_invoices_after_content' );
215
+            do_action('wpinv_bp_invoices_after_content');
216 216
         } else {
217 217
             ?>
218 218
             <div id="message" class="info">
219
-                <p><?php _e( 'No invoice has been made yet.', 'invoicing' ); ?></p>
219
+                <p><?php _e('No invoice has been made yet.', 'invoicing'); ?></p>
220 220
             </div>
221 221
             <?php
222 222
         }
223 223
         
224
-        if ( defined( 'DOING_AJAX' ) ) {
224
+        if (defined('DOING_AJAX')) {
225 225
             exit;
226 226
         }
227 227
     }
228 228
     
229
-    public function has_invoices( $args = '' ) {
229
+    public function has_invoices($args = '') {
230 230
         global $invoices_template;
231 231
 
232
-        $per_page = absint( wpinv_get_option( 'wpinv_bp_per_page' ) );
232
+        $per_page = absint(wpinv_get_option('wpinv_bp_per_page'));
233 233
         // Parse arguments.
234
-        $r = bp_parse_args( $args, array(
234
+        $r = bp_parse_args($args, array(
235 235
             'status'            => 'all',
236 236
             'page_arg'          => 'bpage',
237 237
             'page'              => 1,
238 238
             'per_page'          => $per_page > 0 ? $per_page : 20,
239 239
             'max'               => false,
240 240
             'user_id'           => bp_loggedin_user_id(),
241
-        ), 'has_invoices' );
241
+        ), 'has_invoices');
242 242
 
243 243
 
244
-        if ( ! empty( $r['max'] ) && ( (int)$r['per_page'] > (int)$r['max'] ) ) {
244
+        if (!empty($r['max']) && ((int)$r['per_page'] > (int)$r['max'])) {
245 245
             $r['per_page'] = (int)$r['max'];
246 246
         }
247 247
 
248 248
         // Get the invoices.
249
-        $invoices_template = new WPInv_BP_Invoices_Template( $r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg'] );
249
+        $invoices_template = new WPInv_BP_Invoices_Template($r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg']);
250 250
 
251
-        return apply_filters( 'wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r );
251
+        return apply_filters('wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r);
252 252
     }
253 253
     
254 254
     public function setup_invoice_count() {
255
-        $query      = apply_filters( 'wpinv_user_invoices_count_query', array( 'user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false ) );
256
-        $invoices   = wpinv_get_invoices( $query );
255
+        $query      = apply_filters('wpinv_user_invoices_count_query', array('user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false));
256
+        $invoices   = wpinv_get_invoices($query);
257 257
         
258
-        $this->count = !empty( $invoices ) ? count( $invoices ) : 0;
258
+        $this->count = !empty($invoices) ? count($invoices) : 0;
259 259
     }
260 260
     
261 261
     public function pagination_count() {
262 262
         global $invoices_template;
263 263
 
264
-        $start_num = intval( ( $invoices_template->pag_page - 1 ) * $invoices_template->pag_num ) + 1;
265
-        $from_num  = bp_core_number_format( $start_num );
266
-        $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 ) );
267
-        $total     = bp_core_number_format( $invoices_template->total_invoice_count );
264
+        $start_num = intval(($invoices_template->pag_page - 1) * $invoices_template->pag_num) + 1;
265
+        $from_num  = bp_core_number_format($start_num);
266
+        $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));
267
+        $total     = bp_core_number_format($invoices_template->total_invoice_count);
268 268
 
269
-        if ( 1 == $invoices_template->total_invoice_count ) {
270
-            $message = __( 'Viewing 1 invoice', 'invoicing' );
269
+        if (1 == $invoices_template->total_invoice_count) {
270
+            $message = __('Viewing 1 invoice', 'invoicing');
271 271
         } else {
272
-            $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 );
272
+            $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);
273 273
         }
274 274
 
275 275
         return $message;
@@ -278,32 +278,32 @@  discard block
 block discarded – undo
278 278
     function pagination_links() {
279 279
         global $invoices_template;
280 280
 
281
-        return apply_filters( 'wpinv_bp_get_pagination_links', $invoices_template->pag_links );
281
+        return apply_filters('wpinv_bp_get_pagination_links', $invoices_template->pag_links);
282 282
     }
283 283
     
284
-    public function bp_section( $settings = array() ) {
285
-        $settings['wpinv_bp'] = __( 'BuddyPress Integration', 'invoicing' );
284
+    public function bp_section($settings = array()) {
285
+        $settings['wpinv_bp'] = __('BuddyPress Integration', 'invoicing');
286 286
         return $settings;
287 287
     }
288 288
     
289
-    public function bp_settings( $settings = array() ) {
289
+    public function bp_settings($settings = array()) {
290 290
         $settings['wpinv_bp'] = array(
291 291
             'wpinv_bp_labels' => array(
292 292
                 'id'   => 'wpinv_bp_settings',
293
-                'name' => '<h3>' . __( 'BuddyPress Integration', 'invoicing' ) . '</h3>',
293
+                'name' => '<h3>' . __('BuddyPress Integration', 'invoicing') . '</h3>',
294 294
                 'desc' => '',
295 295
                 'type' => 'header',
296 296
             ),
297 297
             'wpinv_bp_hide_menu' => array(
298 298
                 'id'   => 'wpinv_bp_hide_menu',
299
-                'name' => __( 'Hide Invoices link', 'invoicing' ),
300
-                'desc' => __( 'Hide Invoices link from BP Profile menu.', 'invoicing' ),
299
+                'name' => __('Hide Invoices link', 'invoicing'),
300
+                'desc' => __('Hide Invoices link from BP Profile menu.', 'invoicing'),
301 301
                 'type' => 'checkbox',
302 302
             ),
303 303
             'wpinv_menu_position' => array(
304 304
                 'id'   => 'wpinv_menu_position',
305
-                'name' => __( 'Menu position', 'invoicing' ),
306
-                'desc' => __( 'Menu position for the Invoices link in BP Profile menu.', 'invoicing' ),
305
+                'name' => __('Menu position', 'invoicing'),
306
+                'desc' => __('Menu position for the Invoices link in BP Profile menu.', 'invoicing'),
307 307
                 'type' => 'number',
308 308
                 'size' => 'small',
309 309
                 'min'  => '1',
@@ -313,8 +313,8 @@  discard block
 block discarded – undo
313 313
             ),
314 314
             'wpinv_bp_per_page' => array(
315 315
                 'id'   => 'wpinv_bp_per_page',
316
-                'name' => __( 'Max invoices per page', 'invoicing' ),
317
-                'desc' => __( 'Enter a number to lists the invoices for each page.', 'invoicing' ),
316
+                'name' => __('Max invoices per page', 'invoicing'),
317
+                'desc' => __('Enter a number to lists the invoices for each page.', 'invoicing'),
318 318
                 'type' => 'number',
319 319
                 'size' => 'small',
320 320
                 'min'  => '1',
@@ -339,25 +339,25 @@  discard block
 block discarded – undo
339 339
     public $pag_links = '';
340 340
     public $total_invoice_count = 0;
341 341
     
342
-    public function __construct( $status, $page, $per_page, $max, $user_id, $page_arg = 'bpage' ) {
343
-        $this->invoices = array( 'invoices' => array(), 'total' => 0 );
342
+    public function __construct($status, $page, $per_page, $max, $user_id, $page_arg = 'bpage') {
343
+        $this->invoices = array('invoices' => array(), 'total' => 0);
344 344
         
345
-        $this->pag_arg  = sanitize_key( $page_arg );
346
-        $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $page );
347
-        $this->pag_num  = bp_sanitize_pagination_arg( 'num', $per_page );
345
+        $this->pag_arg  = sanitize_key($page_arg);
346
+        $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $page);
347
+        $this->pag_num  = bp_sanitize_pagination_arg('num', $per_page);
348 348
 
349
-        $query_args     = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true );
350
-        if ( !empty( $status ) && $status != 'all' ) {
349
+        $query_args     = array('user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true);
350
+        if (!empty($status) && $status != 'all') {
351 351
            $query_args['status'] = $status;
352 352
         }
353
-        $invoices  = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) );
353
+        $invoices = wpinv_get_invoices(apply_filters('wpinv_bp_user_invoices_query', $query_args));
354 354
         
355
-        if ( !empty( $invoices ) && !empty( $invoices->found_posts ) ) {
356
-            $this->invoices['invoices'] = array_map( 'wpinv_get_invoice', $invoices->posts );
355
+        if (!empty($invoices) && !empty($invoices->found_posts)) {
356
+            $this->invoices['invoices'] = array_map('wpinv_get_invoice', $invoices->posts);
357 357
             $this->invoices['total']    = $invoices->found_posts;
358 358
         }
359 359
 
360
-        if ( empty( $max ) || ( $max >= (int)$this->invoices['total'] ) ) {
360
+        if (empty($max) || ($max >= (int)$this->invoices['total'])) {
361 361
             $this->total_invoice_count = (int)$this->invoices['total'];
362 362
         } else {
363 363
             $this->total_invoice_count = (int)$max;
@@ -365,52 +365,52 @@  discard block
 block discarded – undo
365 365
 
366 366
         $this->invoices = $this->invoices['invoices'];
367 367
 
368
-        $invoice_count = count( $this->invoices );
368
+        $invoice_count = count($this->invoices);
369 369
 
370
-        if ( empty( $max ) || ( $max >= (int)$invoice_count ) ) {
370
+        if (empty($max) || ($max >= (int)$invoice_count)) {
371 371
             $this->invoice_count = (int)$invoice_count;
372 372
         } else {
373 373
             $this->invoice_count = (int)$max;
374 374
         }
375 375
         
376
-        if ( ! empty( $this->total_invoice_count ) && ! empty( $this->pag_num ) ) {
377
-            $this->pag_links = paginate_links( array(
378
-                'base'      => add_query_arg( $this->pag_arg, '%#%' ),
376
+        if (!empty($this->total_invoice_count) && !empty($this->pag_num)) {
377
+            $this->pag_links = paginate_links(array(
378
+                'base'      => add_query_arg($this->pag_arg, '%#%'),
379 379
                 'format'    => '',
380
-                'total'     => ceil( (int)$this->total_invoice_count / (int)$this->pag_num ),
380
+                'total'     => ceil((int)$this->total_invoice_count / (int)$this->pag_num),
381 381
                 'current'   => (int)$this->pag_page,
382
-                'prev_text' => _x( '&larr;', 'Invoice pagination previous text', 'invoicing' ),
383
-                'next_text' => _x( '&rarr;', 'Invoice pagination next text',     'invoicing' ),
382
+                'prev_text' => _x('&larr;', 'Invoice pagination previous text', 'invoicing'),
383
+                'next_text' => _x('&rarr;', 'Invoice pagination next text', 'invoicing'),
384 384
                 'mid_size'  => 1,
385 385
                 'add_args'  => array(),
386
-            ) );
386
+            ));
387 387
         }
388 388
     }
389 389
 
390 390
     public function has_invoices() {
391
-        return (bool) ! empty( $this->invoice_count );
391
+        return (bool)!empty($this->invoice_count);
392 392
     }
393 393
 
394 394
     public function next_invoice() {
395 395
         $this->current_invoice++;
396
-        $this->invoice = $this->invoices[ $this->current_invoice ];
396
+        $this->invoice = $this->invoices[$this->current_invoice];
397 397
 
398 398
         return $this->invoice;
399 399
     }
400 400
 
401 401
     public function rewind_invoices() {
402 402
         $this->current_invoice = -1;
403
-        if ( $this->invoice_count > 0 ) {
403
+        if ($this->invoice_count > 0) {
404 404
             $this->invoice = $this->invoices[0];
405 405
         }
406 406
     }
407 407
 
408 408
     public function invoices() {
409
-        if ( ( $this->current_invoice + 1 ) < $this->invoice_count ) {
409
+        if (($this->current_invoice + 1) < $this->invoice_count) {
410 410
             return true;
411
-        } elseif ( ( $this->current_invoice + 1 ) === $this->invoice_count ) {
411
+        } elseif (($this->current_invoice + 1) === $this->invoice_count) {
412 412
 
413
-            do_action( 'wpinv_bp_invoice_loop_end' );
413
+            do_action('wpinv_bp_invoice_loop_end');
414 414
             
415 415
             $this->rewind_invoices();
416 416
         }
@@ -424,8 +424,8 @@  discard block
 block discarded – undo
424 424
         $this->in_the_loop = true;
425 425
         $this->invoice     = $this->next_invoice();
426 426
 
427
-        if ( 0 === $this->current_invoice ) {
428
-            do_action( 'wpinv_bp_invoice_loop_start' );
427
+        if (0 === $this->current_invoice) {
428
+            do_action('wpinv_bp_invoice_loop_start');
429 429
         }
430 430
     }
431 431
 }
@@ -435,9 +435,9 @@  discard block
 block discarded – undo
435 435
 
436 436
     $bp->invoicing = new WPInv_BP_Component();
437 437
     
438
-    add_action( 'wp_ajax_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) );
439
-    add_action( 'wp_ajax_nopriv_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) );
440
-    add_filter( 'wpinv_settings_sections_general', array( $bp->invoicing, 'bp_section' ), 10, 1 );
441
-    add_filter( 'wpinv_settings_general', array( $bp->invoicing, 'bp_settings' ), 10, 1 );
438
+    add_action('wp_ajax_invoicing_filter', array($bp->invoicing, 'invoices_content'));
439
+    add_action('wp_ajax_nopriv_invoicing_filter', array($bp->invoicing, 'invoices_content'));
440
+    add_filter('wpinv_settings_sections_general', array($bp->invoicing, 'bp_section'), 10, 1);
441
+    add_filter('wpinv_settings_general', array($bp->invoicing, 'bp_settings'), 10, 1);
442 442
 }
443
-add_action( 'bp_loaded', 'wpinv_bp_setup_component' );
444 443
\ No newline at end of file
444
+add_action('bp_loaded', 'wpinv_bp_setup_component');
445 445
\ No newline at end of file
Please login to merge, or discard this patch.
includes/wpinv-general-functions.php 3 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -30,40 +30,40 @@  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_send_to_success_page( $args = null ) {
66
-	$redirect = wpinv_get_success_page_uri();
66
+    $redirect = wpinv_get_success_page_uri();
67 67
     
68 68
     if ( !empty( $args ) ) {
69 69
         // Check for backward compatibility
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 }
84 84
 
85 85
 function wpinv_send_to_failed_page( $args = null ) {
86
-	$redirect = wpinv_get_failed_transaction_uri();
86
+    $redirect = wpinv_get_failed_transaction_uri();
87 87
     
88 88
     if ( !empty( $args ) ) {
89 89
         // Check for backward compatibility
@@ -103,72 +103,72 @@  discard block
 block discarded – undo
103 103
 }
104 104
 
105 105
 function wpinv_get_checkout_uri( $args = array() ) {
106
-	$uri = wpinv_get_option( 'checkout_page', false );
107
-	$uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
106
+    $uri = wpinv_get_option( 'checkout_page', false );
107
+    $uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
108 108
 
109
-	if ( !empty( $args ) ) {
110
-		// Check for backward compatibility
111
-		if ( is_string( $args ) )
112
-			$args = str_replace( '?', '', $args );
109
+    if ( !empty( $args ) ) {
110
+        // Check for backward compatibility
111
+        if ( is_string( $args ) )
112
+            $args = str_replace( '?', '', $args );
113 113
 
114
-		$args = wp_parse_args( $args );
114
+        $args = wp_parse_args( $args );
115 115
 
116
-		$uri = add_query_arg( $args, $uri );
117
-	}
116
+        $uri = add_query_arg( $args, $uri );
117
+    }
118 118
 
119
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
119
+    $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
120 120
 
121
-	$ajax_url = admin_url( 'admin-ajax.php', $scheme );
121
+    $ajax_url = admin_url( 'admin-ajax.php', $scheme );
122 122
 
123
-	if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
124
-		$uri = preg_replace( '/^http:/', 'https:', $uri );
125
-	}
123
+    if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
124
+        $uri = preg_replace( '/^http:/', 'https:', $uri );
125
+    }
126 126
 
127
-	return apply_filters( 'wpinv_get_checkout_uri', $uri );
127
+    return apply_filters( 'wpinv_get_checkout_uri', $uri );
128 128
 }
129 129
 
130 130
 function wpinv_send_back_to_checkout( $args = array() ) {
131
-	$redirect = wpinv_get_checkout_uri();
131
+    $redirect = wpinv_get_checkout_uri();
132 132
 
133
-	if ( ! empty( $args ) ) {
134
-		// Check for backward compatibility
135
-		if ( is_string( $args ) )
136
-			$args = str_replace( '?', '', $args );
133
+    if ( ! empty( $args ) ) {
134
+        // Check for backward compatibility
135
+        if ( is_string( $args ) )
136
+            $args = str_replace( '?', '', $args );
137 137
 
138
-		$args = wp_parse_args( $args );
138
+        $args = wp_parse_args( $args );
139 139
 
140
-		$redirect = add_query_arg( $args, $redirect );
141
-	}
140
+        $redirect = add_query_arg( $args, $redirect );
141
+    }
142 142
 
143
-	wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) );
144
-	exit;
143
+    wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) );
144
+    exit;
145 145
 }
146 146
 
147 147
 function wpinv_get_success_page_url( $query_string = null ) {
148
-	$success_page = wpinv_get_option( 'success_page', 0 );
149
-	$success_page = get_permalink( $success_page );
148
+    $success_page = wpinv_get_option( 'success_page', 0 );
149
+    $success_page = get_permalink( $success_page );
150 150
 
151
-	if ( $query_string )
152
-		$success_page .= $query_string;
151
+    if ( $query_string )
152
+        $success_page .= $query_string;
153 153
 
154
-	return apply_filters( 'wpinv_success_page_url', $success_page );
154
+    return apply_filters( 'wpinv_success_page_url', $success_page );
155 155
 }
156 156
 
157 157
 function wpinv_get_failed_transaction_uri( $extras = false ) {
158
-	$uri = wpinv_get_option( 'failure_page', '' );
159
-	$uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
158
+    $uri = wpinv_get_option( 'failure_page', '' );
159
+    $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
160 160
 
161
-	if ( $extras )
162
-		$uri .= $extras;
161
+    if ( $extras )
162
+        $uri .= $extras;
163 163
 
164
-	return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
164
+    return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
165 165
 }
166 166
 
167 167
 function wpinv_is_failed_transaction_page() {
168
-	$ret = wpinv_get_option( 'failure_page', false );
169
-	$ret = isset( $ret ) ? is_page( $ret ) : false;
168
+    $ret = wpinv_get_option( 'failure_page', false );
169
+    $ret = isset( $ret ) ? is_page( $ret ) : false;
170 170
 
171
-	return apply_filters( 'wpinv_is_failure_page', $ret );
171
+    return apply_filters( 'wpinv_is_failure_page', $ret );
172 172
 }
173 173
 
174 174
 function wpinv_transaction_query( $type = 'start' ) {
Please login to merge, or discard this patch.
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.
Spacing   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -7,195 +7,195 @@  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
-function wpinv_send_to_success_page( $args = null ) {
65
+function wpinv_send_to_success_page($args = null) {
66 66
 	$redirect = wpinv_get_success_page_uri();
67 67
     
68
-    if ( !empty( $args ) ) {
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
-        $args = wp_parse_args( $args );
73
+        $args = wp_parse_args($args);
74 74
 
75
-        $redirect = add_query_arg( $args, $redirect );
75
+        $redirect = add_query_arg($args, $redirect);
76 76
     }
77 77
 
78
-    $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : '';
78
+    $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : '';
79 79
     
80
-    $redirect = apply_filters( 'wpinv_success_page_redirect', $redirect, $gateway, $args );
81
-    wp_redirect( $redirect );
80
+    $redirect = apply_filters('wpinv_success_page_redirect', $redirect, $gateway, $args);
81
+    wp_redirect($redirect);
82 82
     exit;
83 83
 }
84 84
 
85
-function wpinv_send_to_failed_page( $args = null ) {
85
+function wpinv_send_to_failed_page($args = null) {
86 86
 	$redirect = wpinv_get_failed_transaction_uri();
87 87
     
88
-    if ( !empty( $args ) ) {
88
+    if (!empty($args)) {
89 89
         // Check for backward compatibility
90
-        if ( is_string( $args ) )
91
-            $args = str_replace( '?', '', $args );
90
+        if (is_string($args))
91
+            $args = str_replace('?', '', $args);
92 92
 
93
-        $args = wp_parse_args( $args );
93
+        $args = wp_parse_args($args);
94 94
 
95
-        $redirect = add_query_arg( $args, $redirect );
95
+        $redirect = add_query_arg($args, $redirect);
96 96
     }
97 97
 
98
-    $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : '';
98
+    $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : '';
99 99
     
100
-    $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args );
101
-    wp_redirect( $redirect );
100
+    $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args);
101
+    wp_redirect($redirect);
102 102
     exit;
103 103
 }
104 104
 
105
-function wpinv_get_checkout_uri( $args = array() ) {
106
-	$uri = wpinv_get_option( 'checkout_page', false );
107
-	$uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
105
+function wpinv_get_checkout_uri($args = array()) {
106
+	$uri = wpinv_get_option('checkout_page', false);
107
+	$uri = isset($uri) ? get_permalink($uri) : NULL;
108 108
 
109
-	if ( !empty( $args ) ) {
109
+	if (!empty($args)) {
110 110
 		// Check for backward compatibility
111
-		if ( is_string( $args ) )
112
-			$args = str_replace( '?', '', $args );
111
+		if (is_string($args))
112
+			$args = str_replace('?', '', $args);
113 113
 
114
-		$args = wp_parse_args( $args );
114
+		$args = wp_parse_args($args);
115 115
 
116
-		$uri = add_query_arg( $args, $uri );
116
+		$uri = add_query_arg($args, $uri);
117 117
 	}
118 118
 
119
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
119
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
120 120
 
121
-	$ajax_url = admin_url( 'admin-ajax.php', $scheme );
121
+	$ajax_url = admin_url('admin-ajax.php', $scheme);
122 122
 
123
-	if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
124
-		$uri = preg_replace( '/^http:/', 'https:', $uri );
123
+	if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) {
124
+		$uri = preg_replace('/^http:/', 'https:', $uri);
125 125
 	}
126 126
 
127
-	return apply_filters( 'wpinv_get_checkout_uri', $uri );
127
+	return apply_filters('wpinv_get_checkout_uri', $uri);
128 128
 }
129 129
 
130
-function wpinv_send_back_to_checkout( $args = array() ) {
130
+function wpinv_send_back_to_checkout($args = array()) {
131 131
 	$redirect = wpinv_get_checkout_uri();
132 132
 
133
-	if ( ! empty( $args ) ) {
133
+	if (!empty($args)) {
134 134
 		// Check for backward compatibility
135
-		if ( is_string( $args ) )
136
-			$args = str_replace( '?', '', $args );
135
+		if (is_string($args))
136
+			$args = str_replace('?', '', $args);
137 137
 
138
-		$args = wp_parse_args( $args );
138
+		$args = wp_parse_args($args);
139 139
 
140
-		$redirect = add_query_arg( $args, $redirect );
140
+		$redirect = add_query_arg($args, $redirect);
141 141
 	}
142 142
 
143
-	wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) );
143
+	wp_redirect(apply_filters('wpinv_send_back_to_checkout', $redirect, $args));
144 144
 	exit;
145 145
 }
146 146
 
147
-function wpinv_get_success_page_url( $query_string = null ) {
148
-	$success_page = wpinv_get_option( 'success_page', 0 );
149
-	$success_page = get_permalink( $success_page );
147
+function wpinv_get_success_page_url($query_string = null) {
148
+	$success_page = wpinv_get_option('success_page', 0);
149
+	$success_page = get_permalink($success_page);
150 150
 
151
-	if ( $query_string )
151
+	if ($query_string)
152 152
 		$success_page .= $query_string;
153 153
 
154
-	return apply_filters( 'wpinv_success_page_url', $success_page );
154
+	return apply_filters('wpinv_success_page_url', $success_page);
155 155
 }
156 156
 
157
-function wpinv_get_failed_transaction_uri( $extras = false ) {
158
-	$uri = wpinv_get_option( 'failure_page', '' );
159
-	$uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
157
+function wpinv_get_failed_transaction_uri($extras = false) {
158
+	$uri = wpinv_get_option('failure_page', '');
159
+	$uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url();
160 160
 
161
-	if ( $extras )
161
+	if ($extras)
162 162
 		$uri .= $extras;
163 163
 
164
-	return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
164
+	return apply_filters('wpinv_get_failed_transaction_uri', $uri);
165 165
 }
166 166
 
167 167
 function wpinv_is_failed_transaction_page() {
168
-	$ret = wpinv_get_option( 'failure_page', false );
169
-	$ret = isset( $ret ) ? is_page( $ret ) : false;
168
+	$ret = wpinv_get_option('failure_page', false);
169
+	$ret = isset($ret) ? is_page($ret) : false;
170 170
 
171
-	return apply_filters( 'wpinv_is_failure_page', $ret );
171
+	return apply_filters('wpinv_is_failure_page', $ret);
172 172
 }
173 173
 
174
-function wpinv_transaction_query( $type = 'start' ) {
174
+function wpinv_transaction_query($type = 'start') {
175 175
     global $wpdb;
176 176
 
177 177
     $wpdb->hide_errors();
178 178
 
179
-    if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) {
180
-        define( 'WPINV_USE_TRANSACTIONS', true );
179
+    if (!defined('WPINV_USE_TRANSACTIONS')) {
180
+        define('WPINV_USE_TRANSACTIONS', true);
181 181
     }
182 182
 
183
-    if ( WPINV_USE_TRANSACTIONS ) {
184
-        switch ( $type ) {
183
+    if (WPINV_USE_TRANSACTIONS) {
184
+        switch ($type) {
185 185
             case 'commit' :
186
-                $wpdb->query( 'COMMIT' );
186
+                $wpdb->query('COMMIT');
187 187
                 break;
188 188
             case 'rollback' :
189
-                $wpdb->query( 'ROLLBACK' );
189
+                $wpdb->query('ROLLBACK');
190 190
                 break;
191 191
             default :
192
-                $wpdb->query( 'START TRANSACTION' );
192
+                $wpdb->query('START TRANSACTION');
193 193
             break;
194 194
         }
195 195
     }
196 196
 }
197 197
 
198
-function wpinv_create_invoice( $args = array(), $data = array(), $wp_error = false ) {
198
+function wpinv_create_invoice($args = array(), $data = array(), $wp_error = false) {
199 199
     $default_args = array(
200 200
         'status'        => '',
201 201
         'user_id'       => null,
@@ -205,63 +205,63 @@  discard block
 block discarded – undo
205 205
         'parent'        => 0
206 206
     );
207 207
 
208
-    $args           = wp_parse_args( $args, $default_args );
208
+    $args           = wp_parse_args($args, $default_args);
209 209
     $invoice_data   = array();
210 210
 
211
-    if ( $args['invoice_id'] > 0 ) {
212
-        $updating           = true;
211
+    if ($args['invoice_id'] > 0) {
212
+        $updating = true;
213 213
         $invoice_data['post_type']  = 'wpi_invoice';
214 214
         $invoice_data['ID']         = $args['invoice_id'];
215 215
     } else {
216 216
         $updating                       = false;
217 217
         $invoice_data['post_type']      = 'wpi_invoice';
218
-        $invoice_data['post_status']    = apply_filters( 'wpinv_default_invoice_status', 'wpi-pending' );
218
+        $invoice_data['post_status']    = apply_filters('wpinv_default_invoice_status', 'wpi-pending');
219 219
         $invoice_data['ping_status']    = 'closed';
220
-        $invoice_data['post_author']    = !empty( $args['user_id'] ) ? $args['user_id'] : get_current_user_id();
221
-        $invoice_data['post_title']     = wpinv_format_invoice_number( '0' );
222
-        $invoice_data['post_parent']    = absint( $args['parent'] );
223
-        if ( !empty( $args['created_date'] ) ) {
220
+        $invoice_data['post_author']    = !empty($args['user_id']) ? $args['user_id'] : get_current_user_id();
221
+        $invoice_data['post_title']     = wpinv_format_invoice_number('0');
222
+        $invoice_data['post_parent']    = absint($args['parent']);
223
+        if (!empty($args['created_date'])) {
224 224
             $invoice_data['post_date']      = $args['created_date'];
225
-            $invoice_data['post_date_gmt']  = get_gmt_from_date( $args['created_date'] );
225
+            $invoice_data['post_date_gmt']  = get_gmt_from_date($args['created_date']);
226 226
         }
227 227
     }
228 228
 
229
-    if ( $args['status'] ) {
230
-        if ( ! in_array( $args['status'], array_keys( wpinv_get_invoice_statuses() ) ) ) {
231
-            return new WP_Error( 'wpinv_invalid_invoice_status', wp_sprintf( __( 'Invalid invoice status: %s', 'invoicing' ), $args['status'] ) );
229
+    if ($args['status']) {
230
+        if (!in_array($args['status'], array_keys(wpinv_get_invoice_statuses()))) {
231
+            return new WP_Error('wpinv_invalid_invoice_status', wp_sprintf(__('Invalid invoice status: %s', 'invoicing'), $args['status']));
232 232
         }
233
-        $invoice_data['post_status']    = $args['status'];
233
+        $invoice_data['post_status'] = $args['status'];
234 234
     }
235 235
 
236
-    if ( ! is_null( $args['user_note'] ) ) {
237
-        $invoice_data['post_excerpt']   = $args['user_note'];
236
+    if (!is_null($args['user_note'])) {
237
+        $invoice_data['post_excerpt'] = $args['user_note'];
238 238
     }
239 239
 
240
-    if ( $updating ) {
241
-        $invoice_id = wp_update_post( $invoice_data, true );
240
+    if ($updating) {
241
+        $invoice_id = wp_update_post($invoice_data, true);
242 242
     } else {
243
-        $invoice_id = wp_insert_post( apply_filters( 'wpinv_new_invoice_data', $invoice_data ), true );
243
+        $invoice_id = wp_insert_post(apply_filters('wpinv_new_invoice_data', $invoice_data), true);
244 244
     }
245 245
 
246
-    if ( is_wp_error( $invoice_id ) ) {
246
+    if (is_wp_error($invoice_id)) {
247 247
         return $wp_error ? $invoice_id : 0;
248 248
     }
249 249
     
250
-    $invoice = wpinv_get_invoice( $invoice_id );
251
-
252
-    if ( !$updating ) {
253
-        update_post_meta( $invoice_id, '_wpinv_key', apply_filters( 'wpinv_generate_invoice_key', uniqid( 'wpinv_' ) ) );
254
-        update_post_meta( $invoice_id, '_wpinv_currency', wpinv_get_currency() );
255
-        update_post_meta( $invoice_id, '_wpinv_include_tax', get_option( 'wpinv_prices_include_tax' ) );
256
-        update_post_meta( $invoice_id, '_wpinv_user_ip', wpinv_get_ip() );
257
-        update_post_meta( $invoice_id, '_wpinv_user_agent', wpinv_get_user_agent() );
258
-        update_post_meta( $invoice_id, '_wpinv_created_via', sanitize_text_field( $args['created_via'] ) );
250
+    $invoice = wpinv_get_invoice($invoice_id);
251
+
252
+    if (!$updating) {
253
+        update_post_meta($invoice_id, '_wpinv_key', apply_filters('wpinv_generate_invoice_key', uniqid('wpinv_')));
254
+        update_post_meta($invoice_id, '_wpinv_currency', wpinv_get_currency());
255
+        update_post_meta($invoice_id, '_wpinv_include_tax', get_option('wpinv_prices_include_tax'));
256
+        update_post_meta($invoice_id, '_wpinv_user_ip', wpinv_get_ip());
257
+        update_post_meta($invoice_id, '_wpinv_user_agent', wpinv_get_user_agent());
258
+        update_post_meta($invoice_id, '_wpinv_created_via', sanitize_text_field($args['created_via']));
259 259
         
260 260
         // Add invoice note
261
-        $invoice->add_note( wp_sprintf( __( 'Invoice is created with status %s.', 'invoicing' ), wpinv_status_nicename( $invoice->status ) ) );
261
+        $invoice->add_note(wp_sprintf(__('Invoice is created with status %s.', 'invoicing'), wpinv_status_nicename($invoice->status)));
262 262
     }
263 263
 
264
-    update_post_meta( $invoice_id, '_wpinv_version', WPINV_VERSION );
264
+    update_post_meta($invoice_id, '_wpinv_version', WPINV_VERSION);
265 265
 
266 266
     return $invoice;
267 267
 }
@@ -269,144 +269,144 @@  discard block
 block discarded – undo
269 269
 function wpinv_get_prefix() {
270 270
     $invoice_prefix = 'INV-';
271 271
     
272
-    return apply_filters( 'wpinv_get_prefix', $invoice_prefix );
272
+    return apply_filters('wpinv_get_prefix', $invoice_prefix);
273 273
 }
274 274
 
275 275
 function wpinv_get_business_logo() {
276
-    $business_logo = wpinv_get_option( 'logo' );
277
-    return apply_filters( 'wpinv_get_business_logo', $business_logo );
276
+    $business_logo = wpinv_get_option('logo');
277
+    return apply_filters('wpinv_get_business_logo', $business_logo);
278 278
 }
279 279
 
280 280
 function wpinv_get_business_name() {
281 281
     $business_name = wpinv_get_option('store_name');
282
-    return apply_filters( 'wpinv_get_business_name', $business_name );
282
+    return apply_filters('wpinv_get_business_name', $business_name);
283 283
 }
284 284
 
285 285
 function wpinv_get_blogname() {
286
-    return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
286
+    return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
287 287
 }
288 288
 
289 289
 function wpinv_get_admin_email() {
290
-    $admin_email = get_option( 'admin_email' );
291
-    return apply_filters( 'wpinv_admin_email', $admin_email );
290
+    $admin_email = get_option('admin_email');
291
+    return apply_filters('wpinv_admin_email', $admin_email);
292 292
 }
293 293
 
294 294
 function wpinv_get_business_website() {
295
-    $business_website = home_url( '/' );
296
-    return apply_filters( 'wpinv_get_business_website', $business_website );
295
+    $business_website = home_url('/');
296
+    return apply_filters('wpinv_get_business_website', $business_website);
297 297
 }
298 298
 
299
-function wpinv_get_terms_text( $invoice_id = 0 ) {
299
+function wpinv_get_terms_text($invoice_id = 0) {
300 300
     $terms_text = '';
301
-    return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id );
301
+    return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id);
302 302
 }
303 303
 
304 304
 function wpinv_get_business_footer() {
305
-    $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>';
306
-    $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link );
307
-    return apply_filters( 'wpinv_get_business_footer', $business_footer );
305
+    $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>';
306
+    $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link);
307
+    return apply_filters('wpinv_get_business_footer', $business_footer);
308 308
 }
309 309
 
310 310
 function wpinv_checkout_required_fields() {
311 311
     $required_fields = array();
312 312
     
313 313
     // Let payment gateways and other extensions determine if address fields should be required
314
-    $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() );
314
+    $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes());
315 315
     
316
-    if ( $require_billing_details ) {
316
+    if ($require_billing_details) {
317 317
         ///$required_fields['email'] = array(
318 318
                 ///'error_id' => 'invalid_email',
319 319
                 ///'error_message' => __( 'Please enter a valid email address', 'invoicing' )
320 320
             ///);
321 321
         $required_fields['first_name'] = array(
322 322
                 'error_id' => 'invalid_first_name',
323
-                'error_message' => __( 'Please enter your first name', 'invoicing' )
323
+                'error_message' => __('Please enter your first name', 'invoicing')
324 324
             );
325 325
         $required_fields['address'] = array(
326 326
                 'error_id' => 'invalid_address',
327
-                'error_message' => __( 'Please enter your address', 'invoicing' )
327
+                'error_message' => __('Please enter your address', 'invoicing')
328 328
             );
329 329
         $required_fields['city'] = array(
330 330
                 'error_id' => 'invalid_city',
331
-                'error_message' => __( 'Please enter your billing city', 'invoicing' )
331
+                'error_message' => __('Please enter your billing city', 'invoicing')
332 332
             );
333 333
         $required_fields['state'] = array(
334 334
                 'error_id' => 'invalid_state',
335
-                'error_message' => __( 'Please enter billing state / province', 'invoicing' )
335
+                'error_message' => __('Please enter billing state / province', 'invoicing')
336 336
             );
337 337
         $required_fields['country'] = array(
338 338
                 'error_id' => 'invalid_country',
339
-                'error_message' => __( 'Please select your billing country', 'invoicing' )
339
+                'error_message' => __('Please select your billing country', 'invoicing')
340 340
             );
341 341
     }
342 342
 
343
-    return apply_filters( 'wpinv_checkout_required_fields', $required_fields );
343
+    return apply_filters('wpinv_checkout_required_fields', $required_fields);
344 344
 }
345 345
 
346 346
 function wpinv_is_ssl_enforced() {
347
-    $ssl_enforced = wpinv_get_option( 'enforce_ssl', false );
348
-    return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced );
347
+    $ssl_enforced = wpinv_get_option('enforce_ssl', false);
348
+    return (bool)apply_filters('wpinv_is_ssl_enforced', $ssl_enforced);
349 349
 }
350 350
 
351
-function wpinv_user_can_view_invoice( $post ) {
351
+function wpinv_user_can_view_invoice($post) {
352 352
     $allow = false;
353 353
 
354
-    $post = get_post( $post );
354
+    $post = get_post($post);
355 355
 
356
-    if ( empty( $post->ID ) ) {
356
+    if (empty($post->ID)) {
357 357
         return $allow;
358 358
     }
359 359
 
360
-    $invoice = wpinv_get_invoice( $post->ID );
361
-    if ( empty( $invoice->ID ) ) {
360
+    $invoice = wpinv_get_invoice($post->ID);
361
+    if (empty($invoice->ID)) {
362 362
         return $allow;
363 363
     }
364 364
 
365 365
     // Don't allow trash, draft status
366
-    if ( $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) {
367
-        if ( current_user_can( 'manage_options' ) ) { // Admin user
366
+    if ($invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) {
367
+        if (current_user_can('manage_options')) { // Admin user
368 368
             $allow = true;
369 369
         } else {
370
-            if ( is_user_logged_in() ) {
371
-                if ( (int)$invoice->get_user_id() === (int)get_current_user_id() ) {
370
+            if (is_user_logged_in()) {
371
+                if ((int)$invoice->get_user_id() === (int)get_current_user_id()) {
372 372
                     $allow = true;
373
-                } else if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
373
+                } else if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
374 374
                     $allow = true;
375 375
                 }
376 376
             } else {
377
-                if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
377
+                if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
378 378
                     $allow = true;
379 379
                 }
380 380
             }
381 381
         }
382 382
     }
383 383
     
384
-    return apply_filters( 'wpinv_can_print_invoice', $allow, $post, $invoice );
384
+    return apply_filters('wpinv_can_print_invoice', $allow, $post, $invoice);
385 385
 }
386 386
 
387 387
 function wpinv_schedule_events() {
388 388
     // hourly, daily and twicedaily
389
-    if ( !wp_next_scheduled( 'wpinv_register_schedule_event_twicedaily' ) ) {
390
-        wp_schedule_event( current_time( 'timestamp' ), 'twicedaily', 'wpinv_register_schedule_event_twicedaily' );
389
+    if (!wp_next_scheduled('wpinv_register_schedule_event_twicedaily')) {
390
+        wp_schedule_event(current_time('timestamp'), 'twicedaily', 'wpinv_register_schedule_event_twicedaily');
391 391
     }
392 392
 }
393
-add_action( 'wp', 'wpinv_schedule_events' );
393
+add_action('wp', 'wpinv_schedule_events');
394 394
 
395 395
 function wpinv_schedule_event_twicedaily() {
396 396
     wpinv_email_payment_reminders();
397 397
 }
398
-add_action( 'wpinv_register_schedule_event_twicedaily', 'wpinv_schedule_event_twicedaily' );
398
+add_action('wpinv_register_schedule_event_twicedaily', 'wpinv_schedule_event_twicedaily');
399 399
 
400 400
 function wpinv_require_login_to_checkout() {
401
-    $return = wpinv_get_option( 'login_to_checkout', false );
402
-    return (bool) apply_filters( 'wpinv_require_login_to_checkout', $return );
401
+    $return = wpinv_get_option('login_to_checkout', false);
402
+    return (bool)apply_filters('wpinv_require_login_to_checkout', $return);
403 403
 }
404 404
 
405
-function wpinv_sequential_number_active( $type = '' ) {
406
-    $check = apply_filters( 'wpinv_pre_check_sequential_number_active', null, $type );
407
-    if ( null !== $check ) {
405
+function wpinv_sequential_number_active($type = '') {
406
+    $check = apply_filters('wpinv_pre_check_sequential_number_active', null, $type);
407
+    if (null !== $check) {
408 408
         return $check;
409 409
     }
410 410
     
411
-    return wpinv_get_option( 'sequential_invoice_number' );
411
+    return wpinv_get_option('sequential_invoice_number');
412 412
 }
413 413
\ 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   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -1,72 +1,72 @@  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_action( 'admin_menu', 'wpinv_add_options_link', 10 );
7
+add_action('admin_menu', 'wpinv_add_options_link', 10);
8 8
 function wpinv_add_options_link() {
9 9
     global $menu;
10 10
 
11
-    if ( !(current_user_can( 'manage_invoicing' ) || current_user_can( 'manage_options' )) ) {
11
+    if (!(current_user_can('manage_invoicing') || current_user_can('manage_options'))) {
12 12
         return;
13 13
     }
14 14
 
15
-    $capability = apply_filters( 'invoicing_capability', 'manage_invoicing' );
15
+    $capability = apply_filters('invoicing_capability', 'manage_invoicing');
16 16
 
17
-    if ( current_user_can( 'manage_options' ) ) {
18
-        $menu[] = array( '', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv' );
17
+    if (current_user_can('manage_options')) {
18
+        $menu[] = array('', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv');
19 19
     }
20 20
 
21
-    $wpi_invoice = get_post_type_object( 'wpi_invoice' );
21
+    $wpi_invoice = get_post_type_object('wpi_invoice');
22 22
 
23
-    add_menu_page( __( 'Invoicing', 'invoicing' ), __( 'Invoicing', 'invoicing' ), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460' );
23
+    add_menu_page(__('Invoicing', 'invoicing'), __('Invoicing', 'invoicing'), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460');
24 24
 
25
-    $wpi_settings_page   = add_submenu_page( 'wpinv', __( 'Invoice Settings', 'invoicing' ), __( 'Settings', 'invoicing' ), $capability, 'wpinv-settings', 'wpinv_options_page' );
25
+    $wpi_settings_page = add_submenu_page('wpinv', __('Invoice Settings', 'invoicing'), __('Settings', 'invoicing'), $capability, 'wpinv-settings', 'wpinv_options_page');
26 26
 }
27 27
 
28
-add_action( 'admin_menu', 'wpinv_remove_admin_submenus', 999 );
28
+add_action('admin_menu', 'wpinv_remove_admin_submenus', 999);
29 29
 function wpinv_remove_admin_submenus() {
30
-    remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' );
30
+    remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice');
31 31
 }
32 32
 
33
-add_filter( 'manage_wpi_discount_posts_columns', 'wpinv_discount_columns' );
34
-function wpinv_discount_columns( $existing_columns ) {
33
+add_filter('manage_wpi_discount_posts_columns', 'wpinv_discount_columns');
34
+function wpinv_discount_columns($existing_columns) {
35 35
     $columns                = array();
36 36
     $columns['cb']          = $existing_columns['cb'];
37
-    $columns['name']        = __( 'Name', 'invoicing' );
38
-    $columns['code']        = __( 'Code', 'invoicing' );
39
-    $columns['amount']      = __( 'Amount', 'invoicing' );
40
-    $columns['usage']       = __( 'Usage / Limit', 'invoicing' );
41
-    $columns['expiry_date'] = __( 'Expiry Date', 'invoicing' );
42
-    $columns['status']      = __( 'Status', 'invoicing' );
37
+    $columns['name']        = __('Name', 'invoicing');
38
+    $columns['code']        = __('Code', 'invoicing');
39
+    $columns['amount']      = __('Amount', 'invoicing');
40
+    $columns['usage']       = __('Usage / Limit', 'invoicing');
41
+    $columns['expiry_date'] = __('Expiry Date', 'invoicing');
42
+    $columns['status']      = __('Status', 'invoicing');
43 43
 
44 44
     return $columns;
45 45
 }
46 46
 
47
-add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' );
48
-function wpinv_discount_custom_column( $column ) {
47
+add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column');
48
+function wpinv_discount_custom_column($column) {
49 49
     global $post;
50 50
     
51 51
     $discount = $post;
52 52
 
53
-    switch ( $column ) {
53
+    switch ($column) {
54 54
         case 'name' :
55
-            echo get_the_title( $discount->ID );
55
+            echo get_the_title($discount->ID);
56 56
         break;
57 57
         case 'code' :
58
-            echo wpinv_get_discount_code( $discount->ID );
58
+            echo wpinv_get_discount_code($discount->ID);
59 59
         break;
60 60
         case 'amount' :
61
-            echo wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) );
61
+            echo wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID));
62 62
         break;
63 63
         case 'usage_limit' :
64
-            echo wpinv_get_discount_uses( $discount->ID );
64
+            echo wpinv_get_discount_uses($discount->ID);
65 65
         break;
66 66
         case 'usage' :
67
-            $usage = wpinv_get_discount_uses( $discount->ID ) . ' / ';
68
-            if ( wpinv_get_discount_max_uses( $discount->ID ) ) {
69
-                $usage .= wpinv_get_discount_max_uses( $discount->ID );
67
+            $usage = wpinv_get_discount_uses($discount->ID) . ' / ';
68
+            if (wpinv_get_discount_max_uses($discount->ID)) {
69
+                $usage .= wpinv_get_discount_max_uses($discount->ID);
70 70
             } else {
71 71
                 $usage .= ' &infin;';
72 72
             }
@@ -74,162 +74,162 @@  discard block
 block discarded – undo
74 74
             echo $usage;
75 75
         break;
76 76
         case 'expiry_date' :
77
-            if ( wpinv_get_discount_expiration( $discount->ID ) ) {
78
-                $expiration = date_i18n( get_option( 'date_format' ), strtotime( wpinv_get_discount_expiration( $discount->ID ) ) );
77
+            if (wpinv_get_discount_expiration($discount->ID)) {
78
+                $expiration = date_i18n(get_option('date_format'), strtotime(wpinv_get_discount_expiration($discount->ID)));
79 79
             } else {
80
-                $expiration = __( 'Never', 'invoicing' );
80
+                $expiration = __('Never', 'invoicing');
81 81
             }
82 82
                 
83 83
             echo $expiration;
84 84
         break;
85 85
         case 'description' :
86
-            echo wp_kses_post( $post->post_excerpt );
86
+            echo wp_kses_post($post->post_excerpt);
87 87
         break;
88 88
         case 'status' :
89
-            $status = wpinv_is_discount_expired( $discount->ID ) ? 'expired' : $discount->post_status;
89
+            $status = wpinv_is_discount_expired($discount->ID) ? 'expired' : $discount->post_status;
90 90
             
91
-            echo wpinv_discount_status( $status );
91
+            echo wpinv_discount_status($status);
92 92
         break;
93 93
     }
94 94
 }
95 95
 
96
-add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 );
97
-function wpinv_post_row_actions( $actions, $post ) {
98
-    $post_type = !empty( $post->post_type ) ? $post->post_type : '';
96
+add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2);
97
+function wpinv_post_row_actions($actions, $post) {
98
+    $post_type = !empty($post->post_type) ? $post->post_type : '';
99 99
     
100
-    if ( $post_type == 'wpi_invoice' ) {
100
+    if ($post_type == 'wpi_invoice') {
101 101
         $actions = array();
102 102
     }
103 103
     
104
-    if ( $post_type == 'wpi_discount' ) {
105
-        $actions = wpinv_discount_row_actions( $post, $actions );
104
+    if ($post_type == 'wpi_discount') {
105
+        $actions = wpinv_discount_row_actions($post, $actions);
106 106
     }
107 107
     
108 108
     return $actions;
109 109
 }
110 110
 
111
-function wpinv_discount_row_actions( $discount, $row_actions ) {
112
-    $row_actions  = array();
113
-    $edit_link = get_edit_post_link( $discount->ID );
114
-    $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>';
111
+function wpinv_discount_row_actions($discount, $row_actions) {
112
+    $row_actions = array();
113
+    $edit_link = get_edit_post_link($discount->ID);
114
+    $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>';
115 115
 
116
-    if( in_array( strtolower( $discount->post_status ),  array(  'publish' ) ) ) {
117
-        $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>';
118
-    } elseif( in_array( strtolower( $discount->post_status ),  array( 'pending', 'draft' ) ) ) {
119
-        $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>';
116
+    if (in_array(strtolower($discount->post_status), array('publish'))) {
117
+        $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>';
118
+    } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) {
119
+        $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>';
120 120
     }
121 121
 
122
-    if ( wpinv_get_discount_uses( $discount->ID ) > 0 ) {
123
-        if ( isset( $row_actions['delete'] ) ) {
124
-            unset( $row_actions['delete'] ); // Don't delete used discounts.
122
+    if (wpinv_get_discount_uses($discount->ID) > 0) {
123
+        if (isset($row_actions['delete'])) {
124
+            unset($row_actions['delete']); // Don't delete used discounts.
125 125
         }
126 126
     } else {
127
-        $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>';
127
+        $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>';
128 128
     }
129 129
     
130 130
 
131
-    $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount );
131
+    $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount);
132 132
 
133 133
     return $row_actions;
134 134
 }
135 135
 
136
-add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 );
137
-function wpinv_table_primary_column( $default, $screen_id ) {
138
-    if ( 'edit-wpi_invoice' === $screen_id ) {
136
+add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2);
137
+function wpinv_table_primary_column($default, $screen_id) {
138
+    if ('edit-wpi_invoice' === $screen_id) {
139 139
         return 'name';
140 140
     }
141 141
     
142 142
     return $default;
143 143
 }
144 144
 
145
-function wpinv_discount_bulk_actions( $actions, $display = false ) {    
146
-    if ( !$display ) {
145
+function wpinv_discount_bulk_actions($actions, $display = false) {    
146
+    if (!$display) {
147 147
         return array();
148 148
     }
149 149
     
150 150
     $actions = array(
151
-        'activate'   => __( 'Activate', 'invoicing' ),
152
-        'deactivate' => __( 'Deactivate', 'invoicing' ),
153
-        'delete'     => __( 'Delete', 'invoicing' ),
151
+        'activate'   => __('Activate', 'invoicing'),
152
+        'deactivate' => __('Deactivate', 'invoicing'),
153
+        'delete'     => __('Delete', 'invoicing'),
154 154
     );
155 155
     $two = '';
156 156
     $which = 'top';
157 157
     echo '</div><div class="alignleft actions bulkactions">';
158
-    echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
159
-    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">";
160
-    echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>";
158
+    echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>';
159
+    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">";
160
+    echo '<option value="-1">' . __('Bulk Actions') . "</option>";
161 161
 
162
-    foreach ( $actions as $name => $title ) {
162
+    foreach ($actions as $name => $title) {
163 163
         $class = 'edit' === $name ? ' class="hide-if-no-js"' : '';
164 164
 
165 165
         echo "" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>";
166 166
     }
167 167
     echo "</select>";
168 168
 
169
-    submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) );
169
+    submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two"));
170 170
     
171 171
     echo '</div><div class="alignleft actions">';
172 172
 }
173
-add_filter( 'bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10 );
173
+add_filter('bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10);
174 174
 
175
-function wpinv_disable_months_dropdown( $disable, $post_type ) {
176
-    if ( $post_type == 'wpi_discount' ) {
175
+function wpinv_disable_months_dropdown($disable, $post_type) {
176
+    if ($post_type == 'wpi_discount') {
177 177
         $disable = true;
178 178
     }
179 179
     
180 180
     return $disable;
181 181
 }
182
-add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 );
182
+add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2);
183 183
 
184 184
 function wpinv_restrict_manage_posts() {
185 185
     global $typenow;
186 186
 
187
-    if( 'wpi_discount' == $typenow ) {
187
+    if ('wpi_discount' == $typenow) {
188 188
         wpinv_discount_filters();
189 189
     }
190 190
 }
191
-add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 );
191
+add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10);
192 192
 
193 193
 function wpinv_discount_filters() {
194
-    echo wpinv_discount_bulk_actions( array(), true );
194
+    echo wpinv_discount_bulk_actions(array(), true);
195 195
     
196 196
     ?>
197 197
     <select name="discount_type" id="dropdown_wpinv_discount_type">
198
-        <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option>
198
+        <option value=""><?php _e('Show all types', 'invoicing'); ?></option>
199 199
         <?php
200 200
             $types = wpinv_get_discount_types();
201 201
 
202
-            foreach ( $types as $name => $type ) {
203
-                echo '<option value="' . esc_attr( $name ) . '"';
202
+            foreach ($types as $name => $type) {
203
+                echo '<option value="' . esc_attr($name) . '"';
204 204
 
205
-                if ( isset( $_GET['discount_type'] ) )
206
-                    selected( $name, $_GET['discount_type'] );
205
+                if (isset($_GET['discount_type']))
206
+                    selected($name, $_GET['discount_type']);
207 207
 
208
-                echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
208
+                echo '>' . esc_html__($type, 'invoicing') . '</option>';
209 209
             }
210 210
         ?>
211 211
     </select>
212 212
     <?php
213 213
 }
214 214
 
215
-function wpinv_request( $vars ) {
215
+function wpinv_request($vars) {
216 216
     global $typenow, $wp_query, $wp_post_statuses;
217 217
 
218
-    if ( 'wpi_invoice' === $typenow ) {
219
-        if ( !isset( $vars['post_status'] ) ) {
218
+    if ('wpi_invoice' === $typenow) {
219
+        if (!isset($vars['post_status'])) {
220 220
             $post_statuses = wpinv_get_invoice_statuses();
221 221
 
222
-            foreach ( $post_statuses as $status => $value ) {
223
-                if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) {
224
-                    unset( $post_statuses[ $status ] );
222
+            foreach ($post_statuses as $status => $value) {
223
+                if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) {
224
+                    unset($post_statuses[$status]);
225 225
                 }
226 226
             }
227 227
 
228
-            $vars['post_status'] = array_keys( $post_statuses );
228
+            $vars['post_status'] = array_keys($post_statuses);
229 229
         }
230 230
         
231
-        if ( isset( $vars['orderby'] ) ) {
232
-            if ( 'amount' == $vars['orderby'] ) {
231
+        if (isset($vars['orderby'])) {
232
+            if ('amount' == $vars['orderby']) {
233 233
                 $vars = array_merge(
234 234
                     $vars,
235 235
                     array(
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
                         'orderby'  => 'meta_value_num'
238 238
                     )
239 239
                 );
240
-            } else if ( 'customer' == $vars['orderby'] ) {
240
+            } else if ('customer' == $vars['orderby']) {
241 241
                 $vars = array_merge(
242 242
                     $vars,
243 243
                     array(
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
                         'orderby'  => 'meta_value'
246 246
                     )
247 247
                 );
248
-            } else if ( 'number' == $vars['orderby'] ) {
248
+            } else if ('number' == $vars['orderby']) {
249 249
                 $vars = array_merge(
250 250
                     $vars,
251 251
                     array(
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
                         'orderby'  => 'meta_value'
254 254
                     )
255 255
                 );
256
-            } else if ( 'payment_date' == $vars['orderby'] ) {
256
+            } else if ('payment_date' == $vars['orderby']) {
257 257
                 $vars = array_merge(
258 258
                     $vars,
259 259
                     array(
@@ -263,9 +263,9 @@  discard block
 block discarded – undo
263 263
                 );
264 264
             }
265 265
         }
266
-    } else if ( 'wpi_item' == $typenow ) {
266
+    } else if ('wpi_item' == $typenow) {
267 267
         // Check if 'orderby' is set to "price"
268
-        if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) {
268
+        if (isset($vars['orderby']) && 'price' == $vars['orderby']) {
269 269
             $vars = array_merge(
270 270
                 $vars,
271 271
                 array(
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
         }
277 277
 
278 278
         // Check if "orderby" is set to "vat_rule"
279
-        if ( isset( $vars['orderby'] ) && 'vat_rule' == $vars['orderby'] ) {
279
+        if (isset($vars['orderby']) && 'vat_rule' == $vars['orderby']) {
280 280
             $vars = array_merge(
281 281
                 $vars,
282 282
                 array(
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
         }
288 288
 
289 289
         // Check if "orderby" is set to "vat_class"
290
-        if ( isset( $vars['orderby'] ) && 'vat_class' == $vars['orderby'] ) {
290
+        if (isset($vars['orderby']) && 'vat_class' == $vars['orderby']) {
291 291
             $vars = array_merge(
292 292
                 $vars,
293 293
                 array(
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
         }
299 299
         
300 300
         // Check if "orderby" is set to "type"
301
-        if ( isset( $vars['orderby'] ) && 'type' == $vars['orderby'] ) {
301
+        if (isset($vars['orderby']) && 'type' == $vars['orderby']) {
302 302
             $vars = array_merge(
303 303
                 $vars,
304 304
                 array(
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
         }
310 310
         
311 311
         // Check if "orderby" is set to "recurring"
312
-        if ( isset( $vars['orderby'] ) && 'recurring' == $vars['orderby'] ) {
312
+        if (isset($vars['orderby']) && 'recurring' == $vars['orderby']) {
313 313
             $vars = array_merge(
314 314
                 $vars,
315 315
                 array(
@@ -319,120 +319,120 @@  discard block
 block discarded – undo
319 319
             );
320 320
         }
321 321
 
322
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
322
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
323 323
         // Filter vat rule type
324
-        if ( isset( $_GET['vat_rule'] ) && $_GET['vat_rule'] !== '' ) {
324
+        if (isset($_GET['vat_rule']) && $_GET['vat_rule'] !== '') {
325 325
             $meta_query[] = array(
326 326
                     'key'   => '_wpinv_vat_rule',
327
-                    'value' => sanitize_text_field( $_GET['vat_rule'] ),
327
+                    'value' => sanitize_text_field($_GET['vat_rule']),
328 328
                     'compare' => '='
329 329
                 );
330 330
         }
331 331
         
332 332
         // Filter vat class
333
-        if ( isset( $_GET['vat_class'] ) && $_GET['vat_class'] !== '' ) {
333
+        if (isset($_GET['vat_class']) && $_GET['vat_class'] !== '') {
334 334
             $meta_query[] = array(
335 335
                     'key'   => '_wpinv_vat_class',
336
-                    'value' => sanitize_text_field( $_GET['vat_class'] ),
336
+                    'value' => sanitize_text_field($_GET['vat_class']),
337 337
                     'compare' => '='
338 338
                 );
339 339
         }
340 340
         
341 341
         // Filter item type
342
-        if ( isset( $_GET['type'] ) && $_GET['type'] !== '' ) {
342
+        if (isset($_GET['type']) && $_GET['type'] !== '') {
343 343
             $meta_query[] = array(
344 344
                     'key'   => '_wpinv_type',
345
-                    'value' => sanitize_text_field( $_GET['type'] ),
345
+                    'value' => sanitize_text_field($_GET['type']),
346 346
                     'compare' => '='
347 347
                 );
348 348
         }
349 349
         
350
-        if ( !empty( $meta_query ) ) {
350
+        if (!empty($meta_query)) {
351 351
             $vars['meta_query'] = $meta_query;
352 352
         }
353
-    } else if ( 'wpi_discount' == $typenow ) {
354
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
353
+    } else if ('wpi_discount' == $typenow) {
354
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
355 355
         // Filter vat rule type
356
-        if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) {
356
+        if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') {
357 357
             $meta_query[] = array(
358 358
                     'key'   => '_wpi_discount_type',
359
-                    'value' => sanitize_text_field( $_GET['discount_type'] ),
359
+                    'value' => sanitize_text_field($_GET['discount_type']),
360 360
                     'compare' => '='
361 361
                 );
362 362
         }
363 363
         
364
-        if ( !empty( $meta_query ) ) {
364
+        if (!empty($meta_query)) {
365 365
             $vars['meta_query'] = $meta_query;
366 366
         }
367 367
     }
368 368
 
369 369
     return $vars;
370 370
 }
371
-add_filter( 'request', 'wpinv_request' );
371
+add_filter('request', 'wpinv_request');
372 372
 
373 373
 function wpinv_options_page() {
374
-    $page       = isset( $_GET['page'] )                ? strtolower( $_GET['page'] )               : false;
374
+    $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
375 375
     
376
-    if ( $page !== 'wpinv-settings' ) {
376
+    if ($page !== 'wpinv-settings') {
377 377
         return;
378 378
     }
379 379
     
380 380
     $settings_tabs = wpinv_get_settings_tabs();
381 381
     $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs;
382
-    $active_tab    = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
383
-    $sections      = wpinv_get_settings_tab_sections( $active_tab );
382
+    $active_tab    = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general';
383
+    $sections      = wpinv_get_settings_tab_sections($active_tab);
384 384
     $key           = 'main';
385 385
 
386
-    if ( is_array( $sections ) ) {
387
-        $key = key( $sections );
386
+    if (is_array($sections)) {
387
+        $key = key($sections);
388 388
     }
389 389
 
390
-    $registered_sections = wpinv_get_settings_tab_sections( $active_tab );
391
-    $section             = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key;
390
+    $registered_sections = wpinv_get_settings_tab_sections($active_tab);
391
+    $section             = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key;
392 392
     ob_start();
393 393
     ?>
394 394
     <div class="wrap">
395 395
         <h1 class="nav-tab-wrapper">
396 396
             <?php
397
-            foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) {
398
-                $tab_url = add_query_arg( array(
397
+            foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) {
398
+                $tab_url = add_query_arg(array(
399 399
                     'settings-updated' => false,
400 400
                     'tab' => $tab_id,
401
-                ) );
401
+                ));
402 402
 
403 403
                 // Remove the section from the tabs so we always end up at the main section
404
-                $tab_url = remove_query_arg( 'section', $tab_url );
405
-                $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
404
+                $tab_url = remove_query_arg('section', $tab_url);
405
+                $tab_url = remove_query_arg('wpi_sub', $tab_url);
406 406
 
407 407
                 $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
408 408
 
409
-                echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
410
-                    echo esc_html( $tab_name );
409
+                echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">';
410
+                    echo esc_html($tab_name);
411 411
                 echo '</a>';
412 412
             }
413 413
             ?>
414 414
         </h1>
415 415
         <?php
416
-        $number_of_sections = count( $sections );
416
+        $number_of_sections = count($sections);
417 417
         $number = 0;
418
-        if ( $number_of_sections > 1 ) {
418
+        if ($number_of_sections > 1) {
419 419
             echo '<div><ul class="subsubsub">';
420
-            foreach( $sections as $section_id => $section_name ) {
420
+            foreach ($sections as $section_id => $section_name) {
421 421
                 echo '<li>';
422 422
                 $number++;
423
-                $tab_url = add_query_arg( array(
423
+                $tab_url = add_query_arg(array(
424 424
                     'settings-updated' => false,
425 425
                     'tab' => $active_tab,
426 426
                     'section' => $section_id
427
-                ) );
428
-                $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
427
+                ));
428
+                $tab_url = remove_query_arg('wpi_sub', $tab_url);
429 429
                 $class = '';
430
-                if ( $section == $section_id ) {
430
+                if ($section == $section_id) {
431 431
                     $class = 'current';
432 432
                 }
433
-                echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>';
433
+                echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>';
434 434
 
435
-                if ( $number != $number_of_sections ) {
435
+                if ($number != $number_of_sections) {
436 436
                     echo ' | ';
437 437
                 }
438 438
                 echo '</li>';
@@ -444,19 +444,19 @@  discard block
 block discarded – undo
444 444
             <form method="post" action="options.php">
445 445
                 <table class="form-table">
446 446
                 <?php
447
-                settings_fields( 'wpinv_settings' );
447
+                settings_fields('wpinv_settings');
448 448
 
449
-                if ( 'main' === $section ) {
450
-                    do_action( 'wpinv_settings_tab_top', $active_tab );
449
+                if ('main' === $section) {
450
+                    do_action('wpinv_settings_tab_top', $active_tab);
451 451
                 }
452 452
 
453
-                do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section );
454
-                do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section );
455
-                do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section  );
453
+                do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section);
454
+                do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section);
455
+                do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section);
456 456
 
457 457
                 // For backwards compatibility
458
-                if ( 'main' === $section ) {
459
-                    do_action( 'wpinv_settings_tab_bottom', $active_tab );
458
+                if ('main' === $section) {
459
+                    do_action('wpinv_settings_tab_bottom', $active_tab);
460 460
                 }
461 461
                 ?>
462 462
                 </table>
@@ -469,53 +469,53 @@  discard block
 block discarded – undo
469 469
     echo $content;
470 470
 }
471 471
 
472
-function wpinv_item_type_class( $classes, $class, $post_id ) {
472
+function wpinv_item_type_class($classes, $class, $post_id) {
473 473
     global $pagenow, $typenow;
474 474
 
475
-    if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow ) {
476
-        if ( $type = get_post_meta( $post_id, '_wpinv_type', true ) ) {
477
-            $classes[] = 'wpi-type-' . sanitize_html_class( $type );
475
+    if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow) {
476
+        if ($type = get_post_meta($post_id, '_wpinv_type', true)) {
477
+            $classes[] = 'wpi-type-' . sanitize_html_class($type);
478 478
         }
479 479
         
480
-        if ( !wpinv_item_is_editable( $post_id ) ) {
480
+        if (!wpinv_item_is_editable($post_id)) {
481 481
             $classes[] = 'wpi-editable-n';
482 482
         }
483 483
     }
484 484
     return $classes;
485 485
 }
486
-add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 );
486
+add_filter('post_class', 'wpinv_item_type_class', 10, 3);
487 487
 
488 488
 function wpinv_check_quick_edit() {
489 489
     global $pagenow, $current_screen, $wpinv_item_screen;
490 490
 
491
-    if ( $pagenow == 'edit.php' && !empty( $current_screen->post_type ) ) {
492
-        if ( empty( $wpinv_item_screen ) ) {
493
-            if ( $current_screen->post_type == 'wpi_item' ) {
491
+    if ($pagenow == 'edit.php' && !empty($current_screen->post_type)) {
492
+        if (empty($wpinv_item_screen)) {
493
+            if ($current_screen->post_type == 'wpi_item') {
494 494
                 $wpinv_item_screen = 'y';
495 495
             } else {
496 496
                 $wpinv_item_screen = 'n';
497 497
             }
498 498
         }
499 499
 
500
-        if ( $wpinv_item_screen == 'y' && $pagenow == 'edit.php' ) {
501
-            add_filter( 'post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
502
-            add_filter( 'page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
500
+        if ($wpinv_item_screen == 'y' && $pagenow == 'edit.php') {
501
+            add_filter('post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
502
+            add_filter('page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
503 503
         }
504 504
     }
505 505
 }
506
-add_action( 'admin_head', 'wpinv_check_quick_edit', 10 );
506
+add_action('admin_head', 'wpinv_check_quick_edit', 10);
507 507
 
508
-function wpinv_item_disable_quick_edit( $actions = array(), $row = null ) {
509
-    if ( isset( $actions['inline hide-if-no-js'] ) ) {
510
-        unset( $actions['inline hide-if-no-js'] );
508
+function wpinv_item_disable_quick_edit($actions = array(), $row = null) {
509
+    if (isset($actions['inline hide-if-no-js'])) {
510
+        unset($actions['inline hide-if-no-js']);
511 511
     }
512 512
     
513
-    if ( !empty( $row->post_type ) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable( $row ) ) {
514
-        if ( isset( $actions['trash'] ) ) {
515
-            unset( $actions['trash'] );
513
+    if (!empty($row->post_type) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable($row)) {
514
+        if (isset($actions['trash'])) {
515
+            unset($actions['trash']);
516 516
         }
517
-        if ( isset( $actions['delete'] ) ) {
518
-            unset( $actions['delete'] );
517
+        if (isset($actions['delete'])) {
518
+            unset($actions['delete']);
519 519
         }
520 520
     }
521 521
 
@@ -532,19 +532,19 @@  discard block
 block discarded – undo
532 532
  * @param int $post_parent (default: 0) Parent for the new page
533 533
  * @return int page ID
534 534
  */
535
-function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
535
+function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) {
536 536
     global $wpdb;
537 537
 
538
-    $option_value = wpinv_get_option( $option );
538
+    $option_value = wpinv_get_option($option);
539 539
 
540
-    if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) {
541
-        if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) {
540
+    if ($option_value > 0 && ($page_object = get_post($option_value))) {
541
+        if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) {
542 542
             // Valid page is already in place
543 543
             return $page_object->ID;
544 544
         }
545 545
     }
546 546
 
547
-    if(!empty($post_parent)){
547
+    if (!empty($post_parent)) {
548 548
         $page = get_page_by_path($post_parent);
549 549
         if ($page) {
550 550
             $post_parent = $page->ID;
@@ -553,40 +553,40 @@  discard block
 block discarded – undo
553 553
         }
554 554
     }
555 555
 
556
-    if ( strlen( $page_content ) > 0 ) {
556
+    if (strlen($page_content) > 0) {
557 557
         // Search for an existing page with the specified page content (typically a shortcode)
558
-        $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}%" ) );
558
+        $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}%"));
559 559
     } else {
560 560
         // Search for an existing page with the specified page slug
561
-        $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 ) );
561
+        $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));
562 562
     }
563 563
 
564
-    $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content );
564
+    $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content);
565 565
 
566
-    if ( $valid_page_found ) {
567
-        if ( $option ) {
568
-            wpinv_update_option( $option, $valid_page_found );
566
+    if ($valid_page_found) {
567
+        if ($option) {
568
+            wpinv_update_option($option, $valid_page_found);
569 569
         }
570 570
         return $valid_page_found;
571 571
     }
572 572
 
573 573
     // Search for a matching valid trashed page
574
-    if ( strlen( $page_content ) > 0 ) {
574
+    if (strlen($page_content) > 0) {
575 575
         // Search for an existing page with the specified page content (typically a shortcode)
576
-        $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}%" ) );
576
+        $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}%"));
577 577
     } else {
578 578
         // Search for an existing page with the specified page slug
579
-        $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 ) );
579
+        $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));
580 580
     }
581 581
 
582
-    if ( $trashed_page_found ) {
582
+    if ($trashed_page_found) {
583 583
         $page_id   = $trashed_page_found;
584 584
         $page_data = array(
585 585
             'ID'             => $page_id,
586 586
             'post_status'    => 'publish',
587 587
             'post_parent'    => $post_parent,
588 588
         );
589
-        wp_update_post( $page_data );
589
+        wp_update_post($page_data);
590 590
     } else {
591 591
         $page_data = array(
592 592
             'post_status'    => 'publish',
@@ -598,11 +598,11 @@  discard block
 block discarded – undo
598 598
             'post_parent'    => $post_parent,
599 599
             'comment_status' => 'closed',
600 600
         );
601
-        $page_id = wp_insert_post( $page_data );
601
+        $page_id = wp_insert_post($page_data);
602 602
     }
603 603
 
604
-    if ( $option ) {
605
-        wpinv_update_option( $option, (int)$page_id );
604
+    if ($option) {
605
+        wpinv_update_option($option, (int)$page_id);
606 606
     }
607 607
 
608 608
     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   +255 added lines, -255 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,26 +383,26 @@  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_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_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing');
391 391
     
392 392
     $setting['paypal_sandbox'] = array(
393 393
             'type' => 'checkbox',
394 394
             'id'   => 'paypal_sandbox',
395
-            'name' => __( 'PayPal Sandbox', 'invoicing' ),
396
-            'desc' => __( 'PayPal sandbox can be used to test payments.', 'invoicing' ),
395
+            'name' => __('PayPal Sandbox', 'invoicing'),
396
+            'desc' => __('PayPal sandbox can be used to test payments.', 'invoicing'),
397 397
             'std'  => 1
398 398
         );
399 399
         
400 400
     $setting['paypal_email'] = array(
401 401
             'type' => 'text',
402 402
             'id'   => 'paypal_email',
403
-            'name' => __( 'PayPal Email', 'invoicing' ),
404
-            'desc' => __( 'Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing' ),
405
-            'std' => __( '[email protected]', 'invoicing' ),
403
+            'name' => __('PayPal Email', 'invoicing'),
404
+            'desc' => __('Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing'),
405
+            'std' => __('[email protected]', 'invoicing'),
406 406
         );
407 407
     /*
408 408
     $setting['paypal_ipn_url'] = array(
@@ -416,123 +416,123 @@  discard block
 block discarded – undo
416 416
         
417 417
     return $setting;
418 418
 }
419
-add_filter( 'wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1 );
419
+add_filter('wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1);
420 420
 
421 421
 // Pre Bank Transfer settings
422
-function wpinv_gateway_settings_bank_transfer( $setting ) {
423
-    $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' );
422
+function wpinv_gateway_settings_bank_transfer($setting) {
423
+    $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');
424 424
     
425 425
     $setting['bank_transfer_ac_name'] = array(
426 426
             'type' => 'text',
427 427
             'id' => 'bank_transfer_ac_name',
428
-            'name' => __( 'Account Name', 'invoicing' ),
429
-            'desc' => __( 'Enter the bank account name to which you want to transfer payment.', 'invoicing' ),
430
-            'std'  =>  __( 'Mr. John Martin', 'invoicing' ),
428
+            'name' => __('Account Name', 'invoicing'),
429
+            'desc' => __('Enter the bank account name to which you want to transfer payment.', 'invoicing'),
430
+            'std'  =>  __('Mr. John Martin', 'invoicing'),
431 431
         );
432 432
     
433 433
     $setting['bank_transfer_ac_no'] = array(
434 434
             'type' => 'text',
435 435
             'id' => 'bank_transfer_ac_no',
436
-            'name' => __( 'Account Number', 'invoicing' ),
437
-            'desc' => __( 'Enter your bank account number.', 'invoicing' ),
438
-            'std'  =>  __( 'TEST1234567890', 'invoicing' ),
436
+            'name' => __('Account Number', 'invoicing'),
437
+            'desc' => __('Enter your bank account number.', 'invoicing'),
438
+            'std'  =>  __('TEST1234567890', 'invoicing'),
439 439
         );
440 440
     
441 441
     $setting['bank_transfer_bank_name'] = array(
442 442
             'type' => 'text',
443 443
             'id'   => 'bank_transfer_bank_name',
444
-            'name' => __( 'Bank Name', 'invoicing' ),
445
-            'desc' => __( 'Enter the bank name to which you want to transfer payment.', 'invoicing' ),
446
-            'std' => __( 'ICICI Bank', 'invoicing' ),
444
+            'name' => __('Bank Name', 'invoicing'),
445
+            'desc' => __('Enter the bank name to which you want to transfer payment.', 'invoicing'),
446
+            'std' => __('ICICI Bank', 'invoicing'),
447 447
         );
448 448
     
449 449
     $setting['bank_transfer_ifsc'] = array(
450 450
             'type' => 'text',
451 451
             'id'   => 'bank_transfer_ifsc',
452
-            'name' => __( 'IFSC Code', 'invoicing' ),
453
-            'desc' => __( 'Enter your bank IFSC code.', 'invoicing' ),
454
-            'std'  =>  __( 'ICIC0001234', 'invoicing' ),
452
+            'name' => __('IFSC Code', 'invoicing'),
453
+            'desc' => __('Enter your bank IFSC code.', 'invoicing'),
454
+            'std'  =>  __('ICIC0001234', 'invoicing'),
455 455
         );
456 456
         
457 457
     $setting['bank_transfer_iban'] = array(
458 458
             'type' => 'text',
459 459
             'id'   => 'bank_transfer_iban',
460
-            'name' => __( 'IBAN', 'invoicing' ),
461
-            'desc' => __( 'Enter your International Bank Account Number(IBAN).', 'invoicing' ),
462
-            'std'  =>  __( 'GB29NWBK60161331926819', 'invoicing' ),
460
+            'name' => __('IBAN', 'invoicing'),
461
+            'desc' => __('Enter your International Bank Account Number(IBAN).', 'invoicing'),
462
+            'std'  =>  __('GB29NWBK60161331926819', 'invoicing'),
463 463
         );
464 464
         
465 465
     $setting['bank_transfer_bic'] = array(
466 466
             'type' => 'text',
467 467
             'id'   => 'bank_transfer_bic',
468
-            'name' => __( 'BIC/Swift Code', 'invoicing' ),
469
-            'std'  =>  __( 'ICICGB2L129', 'invoicing' ),
468
+            'name' => __('BIC/Swift Code', 'invoicing'),
469
+            'std'  =>  __('ICICGB2L129', 'invoicing'),
470 470
         );
471 471
 
472 472
     $setting['bank_transfer_sort_code'] = array(
473 473
         'type' => 'text',
474 474
         'id'   => 'bank_transfer_sort_code',
475
-        'name' => __( 'Sort Code', 'invoicing' ),
476
-        'std'  =>  __( '12-34-56', 'invoicing' ),
475
+        'name' => __('Sort Code', 'invoicing'),
476
+        'std'  =>  __('12-34-56', 'invoicing'),
477 477
     );
478 478
         
479 479
     $setting['bank_transfer_info'] = array(
480 480
             'id'   => 'bank_transfer_info',
481
-            'name' => __( 'Instructions', 'invoicing' ),
482
-            'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
481
+            'name' => __('Instructions', 'invoicing'),
482
+            'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'),
483 483
             'type' => 'textarea',
484
-            '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' ),
484
+            '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 485
             'cols' => 37,
486 486
             'rows' => 5
487 487
         );
488 488
         
489 489
     return $setting;
490 490
 }
491
-add_filter( 'wpinv_gateway_settings_bank_transfer', 'wpinv_gateway_settings_bank_transfer', 10, 1 );
491
+add_filter('wpinv_gateway_settings_bank_transfer', 'wpinv_gateway_settings_bank_transfer', 10, 1);
492 492
 
493 493
 // Authorize.Net settings
494
-function wpinv_gateway_settings_authorizenet( $setting ) {
495
-    $setting['authorizenet_active']['desc'] = $setting['authorizenet_active']['desc'] . ' ' . __( '( currencies supported: AUD, CAD, CHF, DKK, EUR, GBP, JPY, NOK, NZD, PLN, SEK, USD, ZAR )', 'invoicing' );
496
-    $setting['authorizenet_desc']['std'] = __( 'Pay using a Authorize.Net to process credit card / debit card transactions.', 'invoicing' );
494
+function wpinv_gateway_settings_authorizenet($setting) {
495
+    $setting['authorizenet_active']['desc'] = $setting['authorizenet_active']['desc'] . ' ' . __('( currencies supported: AUD, CAD, CHF, DKK, EUR, GBP, JPY, NOK, NZD, PLN, SEK, USD, ZAR )', 'invoicing');
496
+    $setting['authorizenet_desc']['std'] = __('Pay using a Authorize.Net to process credit card / debit card transactions.', 'invoicing');
497 497
     
498 498
     $setting['authorizenet_sandbox'] = array(
499 499
             'type' => 'checkbox',
500 500
             'id'   => 'authorizenet_sandbox',
501
-            'name' => __( 'Authorize.Net Test Mode', 'invoicing' ),
502
-            'desc' => __( 'Enable Authorize.Net test mode to test payments.', 'invoicing' ),
501
+            'name' => __('Authorize.Net Test Mode', 'invoicing'),
502
+            'desc' => __('Enable Authorize.Net test mode to test payments.', 'invoicing'),
503 503
             'std'  => 1
504 504
         );
505 505
         
506 506
     $setting['authorizenet_login_id'] = array(
507 507
             'type' => 'text',
508 508
             'id'   => 'authorizenet_login_id',
509
-            'name' => __( 'API Login ID', 'invoicing' ),
510
-            'desc' => __( 'API Login ID can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 2j4rBekUnD', 'invoicing' ),
509
+            'name' => __('API Login ID', 'invoicing'),
510
+            'desc' => __('API Login ID can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 2j4rBekUnD', 'invoicing'),
511 511
             'std' => '2j4rBekUnD',
512 512
         );
513 513
     
514 514
     $setting['authorizenet_transaction_key'] = array(
515 515
             'type' => 'text',
516 516
             'id'   => 'authorizenet_transaction_key',
517
-            'name' => __( 'Transaction Key', 'invoicing' ),
518
-            'desc' => __( 'Transaction Key can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 4vyBUOJgR74679xa', 'invoicing' ),
517
+            'name' => __('Transaction Key', 'invoicing'),
518
+            'desc' => __('Transaction Key can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 4vyBUOJgR74679xa', 'invoicing'),
519 519
             'std' => '4vyBUOJgR74679xa',
520 520
         );
521 521
         
522 522
     $setting['authorizenet_md5_hash'] = array(
523 523
             'type' => 'text',
524 524
             'id'   => 'authorizenet_md5_hash',
525
-            'name' => __( 'MD5-Hash', 'invoicing' ),
526
-            'desc' => __( 'The MD5 Hash security feature allows you to authenticate transaction responses from the Authorize.Net. If you are accepting recurring payments then md5 hash will helps to validate response from Authorize.net. It can be obtained from Authorize.Net Account > Settings > Security Settings > General Settings > MD5 Hash.', 'invoicing' ),
525
+            'name' => __('MD5-Hash', 'invoicing'),
526
+            'desc' => __('The MD5 Hash security feature allows you to authenticate transaction responses from the Authorize.Net. If you are accepting recurring payments then md5 hash will helps to validate response from Authorize.net. It can be obtained from Authorize.Net Account > Settings > Security Settings > General Settings > MD5 Hash.', 'invoicing'),
527 527
             'std' => '',
528 528
         );
529 529
         
530 530
     $setting['authorizenet_ipn_url'] = array(
531 531
             'type' => 'ipn_url',
532 532
             'id'   => 'authorizenet_ipn_url',
533
-            'name' => __( 'Silent Post URL', 'invoicing' ),
534
-            'std' => wpinv_get_ipn_url( 'authorizenet' ),
535
-            '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' ),
533
+            'name' => __('Silent Post URL', 'invoicing'),
534
+            'std' => wpinv_get_ipn_url('authorizenet'),
535
+            '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'),
536 536
             'size' => 'large',
537 537
             'custom' => 'authorizenet',
538 538
             'readonly' => true
@@ -540,25 +540,25 @@  discard block
 block discarded – undo
540 540
         
541 541
     return $setting;
542 542
 }
543
-add_filter( 'wpinv_gateway_settings_authorizenet', 'wpinv_gateway_settings_authorizenet', 10, 1 );
543
+add_filter('wpinv_gateway_settings_authorizenet', 'wpinv_gateway_settings_authorizenet', 10, 1);
544 544
 
545 545
 // Worldpay settings
546
-function wpinv_gateway_settings_worldpay( $setting ) {
547
-    $setting['worldpay_desc']['std'] = __( 'Pay using a Worldpay account to process credit card / debit card transactions.', 'invoicing' );
546
+function wpinv_gateway_settings_worldpay($setting) {
547
+    $setting['worldpay_desc']['std'] = __('Pay using a Worldpay account to process credit card / debit card transactions.', 'invoicing');
548 548
     
549 549
     $setting['worldpay_sandbox'] = array(
550 550
             'type' => 'checkbox',
551 551
             'id'   => 'worldpay_sandbox',
552
-            'name' => __( 'Worldpay Test Mode', 'invoicing' ),
553
-            'desc' => __( 'This provides a special Test Environment to enable you to test your installation and integration to your website before going live.', 'invoicing' ),
552
+            'name' => __('Worldpay Test Mode', 'invoicing'),
553
+            'desc' => __('This provides a special Test Environment to enable you to test your installation and integration to your website before going live.', 'invoicing'),
554 554
             'std'  => 1
555 555
         );
556 556
         
557 557
     $setting['worldpay_instId'] = array(
558 558
             'type' => 'text',
559 559
             'id'   => 'worldpay_instId',
560
-            'name' => __( 'Installation Id', 'invoicing' ),
561
-            'desc' => __( 'Your installation id. Ex: 211616', 'invoicing' ),
560
+            'name' => __('Installation Id', 'invoicing'),
561
+            'desc' => __('Your installation id. Ex: 211616', 'invoicing'),
562 562
             'std' => '211616',
563 563
         );
564 564
     /*
@@ -574,9 +574,9 @@  discard block
 block discarded – undo
574 574
     $setting['worldpay_ipn_url'] = array(
575 575
             'type' => 'ipn_url',
576 576
             'id'   => 'worldpay_ipn_url',
577
-            'name' => __( 'Worldpay Callback Url', 'invoicing' ),
578
-            'std' => wpinv_get_ipn_url( 'worldpay' ),
579
-            '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>' ),
577
+            'name' => __('Worldpay Callback Url', 'invoicing'),
578
+            'std' => wpinv_get_ipn_url('worldpay'),
579
+            '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>'),
580 580
             'size' => 'large',
581 581
             'custom' => 'worldpay',
582 582
             'readonly' => true
@@ -584,95 +584,95 @@  discard block
 block discarded – undo
584 584
         
585 585
     return $setting;
586 586
 }
587
-add_filter( 'wpinv_gateway_settings_worldpay', 'wpinv_gateway_settings_worldpay', 10, 1 );
587
+add_filter('wpinv_gateway_settings_worldpay', 'wpinv_gateway_settings_worldpay', 10, 1);
588 588
 
589
-function wpinv_ipn_url_callback( $args ) {    
590
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
589
+function wpinv_ipn_url_callback($args) {    
590
+    $sanitize_id = wpinv_sanitize_key($args['id']);
591 591
     
592 592
     $attrs = $args['readonly'] ? ' readonly' : '';
593 593
 
594
-    $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">';
595
-    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">'  . $args['desc'] . '</label>';
594
+    $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">';
595
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>';
596 596
 
597 597
     echo $html;
598 598
 }
599 599
 
600
-function wpinv_is_test_mode( $gateway = '' ) {
601
-    if ( empty( $gateway ) ) {
600
+function wpinv_is_test_mode($gateway = '') {
601
+    if (empty($gateway)) {
602 602
         return false;
603 603
     }
604 604
     
605
-    $is_test_mode = wpinv_get_option( $gateway . '_sandbox', false );
605
+    $is_test_mode = wpinv_get_option($gateway . '_sandbox', false);
606 606
     
607
-    return apply_filters( 'wpinv_is_test_mode', $is_test_mode, $gateway );
607
+    return apply_filters('wpinv_is_test_mode', $is_test_mode, $gateway);
608 608
 }
609 609
 
610
-function wpinv_get_ipn_url( $gateway = '', $args = array() ) {
611
-    $data = array( 'wpi-listener' => 'IPN' );
610
+function wpinv_get_ipn_url($gateway = '', $args = array()) {
611
+    $data = array('wpi-listener' => 'IPN');
612 612
     
613
-    if ( !empty( $gateway ) ) {
614
-        $data['wpi-gateway'] = wpinv_sanitize_key( $gateway );
613
+    if (!empty($gateway)) {
614
+        $data['wpi-gateway'] = wpinv_sanitize_key($gateway);
615 615
     }
616 616
     
617
-    $args = !empty( $args ) && is_array( $args ) ? array_merge( $data, $args ) : $data;
617
+    $args = !empty($args) && is_array($args) ? array_merge($data, $args) : $data;
618 618
     
619
-    $ipn_url = add_query_arg( $args,  home_url( 'index.php' ) );
619
+    $ipn_url = add_query_arg($args, home_url('index.php'));
620 620
     
621
-    return apply_filters( 'wpinv_ipn_url', $ipn_url );
621
+    return apply_filters('wpinv_ipn_url', $ipn_url);
622 622
 }
623 623
 
624 624
 function wpinv_listen_for_payment_ipn() {
625 625
     // Regular PayPal IPN
626
-    if ( isset( $_GET['wpi-listener'] ) && $_GET['wpi-listener'] == 'IPN' ) {
627
-        do_action( 'wpinv_verify_payment_ipn' );
626
+    if (isset($_GET['wpi-listener']) && $_GET['wpi-listener'] == 'IPN') {
627
+        do_action('wpinv_verify_payment_ipn');
628 628
         
629
-        if ( !empty( $_GET['wpi-gateway'] ) ) {
630
-            wpinv_error_log( sanitize_text_field( $_GET['wpi-gateway'] ), 'WP Invoicing IPN', __FILE__, __LINE__ );
631
-            do_action( 'wpinv_verify_' . sanitize_text_field( $_GET['wpi-gateway'] ) . '_ipn' );
629
+        if (!empty($_GET['wpi-gateway'])) {
630
+            wpinv_error_log(sanitize_text_field($_GET['wpi-gateway']), 'WP Invoicing IPN', __FILE__, __LINE__);
631
+            do_action('wpinv_verify_' . sanitize_text_field($_GET['wpi-gateway']) . '_ipn');
632 632
         }
633 633
     }
634 634
 }
635
-add_action( 'init', 'wpinv_listen_for_payment_ipn' );
635
+add_action('init', 'wpinv_listen_for_payment_ipn');
636 636
 
637 637
 function wpinv_get_bank_instructions() {
638
-    $bank_instructions = wpinv_get_option( 'bank_transfer_info' );
638
+    $bank_instructions = wpinv_get_option('bank_transfer_info');
639 639
     
640
-    return apply_filters( 'wpinv_bank_instructions', $bank_instructions );
640
+    return apply_filters('wpinv_bank_instructions', $bank_instructions);
641 641
 }
642 642
 
643
-function wpinv_get_bank_info( $filtered = false ) {
643
+function wpinv_get_bank_info($filtered = false) {
644 644
     $bank_fields = array(
645
-        'bank_transfer_ac_name'     => __( 'Account Name', 'invoicing' ),
646
-        'bank_transfer_ac_no'       => __( 'Account Number', 'invoicing' ),
647
-        'bank_transfer_bank_name'   => __( 'Bank Name', 'invoicing' ),
648
-        'bank_transfer_ifsc'        => __( 'IFSC code', 'invoicing' ),
649
-        'bank_transfer_iban'        => __( 'IBAN', 'invoicing' ),
650
-        'bank_transfer_bic'         => __( 'BIC/Swift code', 'invoicing' ),
651
-        'bank_transfer_sort_code'   => __( 'Sort Code', 'invoicing' )
645
+        'bank_transfer_ac_name'     => __('Account Name', 'invoicing'),
646
+        'bank_transfer_ac_no'       => __('Account Number', 'invoicing'),
647
+        'bank_transfer_bank_name'   => __('Bank Name', 'invoicing'),
648
+        'bank_transfer_ifsc'        => __('IFSC code', 'invoicing'),
649
+        'bank_transfer_iban'        => __('IBAN', 'invoicing'),
650
+        'bank_transfer_bic'         => __('BIC/Swift code', 'invoicing'),
651
+        'bank_transfer_sort_code'   => __('Sort Code', 'invoicing')
652 652
     );
653 653
     
654 654
     $bank_info = array();
655
-    foreach ( $bank_fields as $field => $label ) {
656
-        if ( $filtered && !( $value = wpinv_get_option( $field ) ) ) {
655
+    foreach ($bank_fields as $field => $label) {
656
+        if ($filtered && !($value = wpinv_get_option($field))) {
657 657
             continue;
658 658
         }
659 659
         
660
-        $bank_info[$field] = array( 'label' => $label, 'value' => $value );
660
+        $bank_info[$field] = array('label' => $label, 'value' => $value);
661 661
     }
662 662
     
663
-    return apply_filters( 'wpinv_bank_info', $bank_info, $filtered );
663
+    return apply_filters('wpinv_bank_info', $bank_info, $filtered);
664 664
 }
665 665
 
666
-function wpinv_process_before_send_to_gateway( $invoice, $invoice_data = array() ) {
667
-    if ( !empty( $invoice ) && $invoice->is_recurring() && $subscription_item = $invoice->get_recurring( true ) ) {        
666
+function wpinv_process_before_send_to_gateway($invoice, $invoice_data = array()) {
667
+    if (!empty($invoice) && $invoice->is_recurring() && $subscription_item = $invoice->get_recurring(true)) {        
668 668
         $args                          = array();
669 669
         $args['item_id']               = $subscription_item->ID;
670
-        $args['initial_amount']        = wpinv_round_amount( $invoice->get_total() );
671
-        $args['recurring_amount']      = wpinv_round_amount( $invoice->get_recurring_details( 'total' ) );
670
+        $args['initial_amount']        = wpinv_round_amount($invoice->get_total());
671
+        $args['recurring_amount']      = wpinv_round_amount($invoice->get_recurring_details('total'));
672 672
         $args['currency']              = $invoice->get_currency();
673 673
         $args['period']                = $subscription_item->get_recurring_period();
674 674
         $args['interval']              = $subscription_item->get_recurring_interval();
675
-        if ( $subscription_item->has_free_trial() ) {
675
+        if ($subscription_item->has_free_trial()) {
676 676
             $args['trial_period']      = $subscription_item->get_trial_period();
677 677
             $args['trial_interval']    = $subscription_item->get_trial_interval();
678 678
         } else {
@@ -681,25 +681,25 @@  discard block
 block discarded – undo
681 681
         }
682 682
         $args['bill_times']            = (int)$subscription_item->get_recurring_limit();
683 683
         
684
-        $invoice->update_subscription( $args );
684
+        $invoice->update_subscription($args);
685 685
     }
686 686
 }
687
-add_action( 'wpinv_checkout_before_send_to_gateway', 'wpinv_process_before_send_to_gateway', 10, 2 );
687
+add_action('wpinv_checkout_before_send_to_gateway', 'wpinv_process_before_send_to_gateway', 10, 2);
688 688
 
689
-function wpinv_get_post_data( $method = 'request' ) {
689
+function wpinv_get_post_data($method = 'request') {
690 690
     $data       = array();
691 691
     $request    = $_REQUEST;
692 692
     
693
-    if ( $method == 'post' ) {
694
-        if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
693
+    if ($method == 'post') {
694
+        if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
695 695
             return $data;
696 696
         }
697 697
         
698 698
         $request = $_POST;
699 699
     }
700 700
     
701
-    if ( $method == 'get' ) {
702
-        if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'GET' ) {
701
+    if ($method == 'get') {
702
+        if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET') {
703 703
             return $data;
704 704
         }
705 705
         
@@ -710,11 +710,11 @@  discard block
 block discarded – undo
710 710
     $post_data = '';
711 711
     
712 712
     // Fallback just in case post_max_size is lower than needed
713
-    if ( ini_get( 'allow_url_fopen' ) ) {
714
-        $post_data = file_get_contents( 'php://input' );
713
+    if (ini_get('allow_url_fopen')) {
714
+        $post_data = file_get_contents('php://input');
715 715
     } else {
716 716
         // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
717
-        ini_set( 'post_max_size', '12M' );
717
+        ini_set('post_max_size', '12M');
718 718
     }
719 719
     // Start the encoded data collection with notification command
720 720
     $encoded_data = 'cmd=_notify-validate';
@@ -723,58 +723,58 @@  discard block
 block discarded – undo
723 723
     $arg_separator = wpinv_get_php_arg_separator_output();
724 724
 
725 725
     // Verify there is a post_data
726
-    if ( $post_data || strlen( $post_data ) > 0 ) {
726
+    if ($post_data || strlen($post_data) > 0) {
727 727
         // Append the data
728 728
         $encoded_data .= $arg_separator . $post_data;
729 729
     } else {
730 730
         // Check if POST is empty
731
-        if ( empty( $request ) ) {
731
+        if (empty($request)) {
732 732
             // Nothing to do
733 733
             return;
734 734
         } else {
735 735
             // Loop through each POST
736
-            foreach ( $request as $key => $value ) {
736
+            foreach ($request as $key => $value) {
737 737
                 // Encode the value and append the data
738
-                $encoded_data .= $arg_separator . "$key=" . urlencode( $value );
738
+                $encoded_data .= $arg_separator . "$key=" . urlencode($value);
739 739
             }
740 740
         }
741 741
     }
742 742
 
743 743
     // Convert collected post data to an array
744
-    parse_str( $encoded_data, $data );
744
+    parse_str($encoded_data, $data);
745 745
 
746
-    foreach ( $data as $key => $value ) {
747
-        if ( false !== strpos( $key, 'amp;' ) ) {
748
-            $new_key = str_replace( '&amp;', '&', $key );
749
-            $new_key = str_replace( 'amp;', '&' , $new_key );
746
+    foreach ($data as $key => $value) {
747
+        if (false !== strpos($key, 'amp;')) {
748
+            $new_key = str_replace('&amp;', '&', $key);
749
+            $new_key = str_replace('amp;', '&', $new_key);
750 750
 
751
-            unset( $data[ $key ] );
752
-            $data[ $new_key ] = sanitize_text_field( $value );
751
+            unset($data[$key]);
752
+            $data[$new_key] = sanitize_text_field($value);
753 753
         }
754 754
     }
755 755
     
756 756
     return $data;
757 757
 }
758 758
 
759
-function wpinv_gateway_support_subscription( $gateway ) {
759
+function wpinv_gateway_support_subscription($gateway) {
760 760
     $return = false;
761 761
     
762
-    if ( wpinv_is_gateway_active( $gateway ) ) {
763
-        $return = apply_filters( 'wpinv_' . $gateway . '_support_subscription', false );
762
+    if (wpinv_is_gateway_active($gateway)) {
763
+        $return = apply_filters('wpinv_' . $gateway . '_support_subscription', false);
764 764
     }
765 765
     
766 766
     return $return;
767 767
 }
768 768
 
769
-function wpinv_payment_gateways_on_cart( $gateways = array() ) {
770
-    if ( !empty( $gateways ) && wpinv_cart_has_recurring_item() ) {
771
-        foreach ( $gateways as $gateway => $info ) {
772
-            if ( !wpinv_gateway_support_subscription( $gateway ) ) {
773
-                unset( $gateways[$gateway] );
769
+function wpinv_payment_gateways_on_cart($gateways = array()) {
770
+    if (!empty($gateways) && wpinv_cart_has_recurring_item()) {
771
+        foreach ($gateways as $gateway => $info) {
772
+            if (!wpinv_gateway_support_subscription($gateway)) {
773
+                unset($gateways[$gateway]);
774 774
             }
775 775
         }
776 776
     }
777 777
     
778 778
     return $gateways;
779 779
 }
780
-add_filter( 'wpinv_payment_gateways_on_cart', 'wpinv_payment_gateways_on_cart', 10, 1 );
781 780
\ No newline at end of file
781
+add_filter('wpinv_payment_gateways_on_cart', 'wpinv_payment_gateways_on_cart', 10, 1);
782 782
\ No newline at end of file
Please login to merge, or discard this patch.