Passed
Pull Request — master (#217)
by Patrik
03:45
created
templates/wpinv-invoice-print.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,41 +1,41 @@  discard block
 block discarded – undo
1 1
 <?php 
2
-if ( !defined('ABSPATH') ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit;
4 4
 }
5 5
 global $post;
6 6
 $invoice_id = $post->ID;
7
-$invoice = wpinv_get_invoice( $invoice_id );
8
-if ( empty( $invoice ) ) {
7
+$invoice = wpinv_get_invoice($invoice_id);
8
+if (empty($invoice)) {
9 9
     exit;
10 10
 }
11
-$type = $post->post_type == 'wpi_invoice' ? __( 'Invoice', 'invoicing' ): __( 'Quotation', 'invoicing' );
12
-do_action( 'wpinv_invoice_print_before_display', $invoice ); ?><!DOCTYPE html>
11
+$type = $post->post_type == 'wpi_invoice' ? __('Invoice', 'invoicing') : __('Quotation', 'invoicing');
12
+do_action('wpinv_invoice_print_before_display', $invoice); ?><!DOCTYPE html>
13 13
 <html <?php language_attributes(); ?>>
14 14
 <head>
15 15
     <meta charset="UTF-8">
16 16
     <title><?php wp_title() ?></title>
17
-    <meta charset="<?php bloginfo( 'charset' ); ?>" />
17
+    <meta charset="<?php bloginfo('charset'); ?>" />
18 18
     <meta name="viewport" content="width=device-width, initial-scale=1">
19 19
     <meta name="robots" content="noindex,nofollow">
20 20
 
21
-    <?php do_action( 'wpinv_invoice_print_head', $invoice ); ?>
21
+    <?php do_action('wpinv_invoice_print_head', $invoice); ?>
22 22
 </head>
23 23
 <body class="body wpinv wpinv-print">
24
-    <?php do_action( 'wpinv_invoice_print_body_start', $invoice ); ?>
24
+    <?php do_action('wpinv_invoice_print_body_start', $invoice); ?>
25 25
     <div class="container wpinv-wrap">
26
-        <?php if ( $watermark = wpinv_watermark( $invoice_id ) ) { ?>
27
-            <div class="watermark no-print"><p><?php echo esc_html( $watermark ) ?></p></div>
26
+        <?php if ($watermark = wpinv_watermark($invoice_id)) { ?>
27
+            <div class="watermark no-print"><p><?php echo esc_html($watermark) ?></p></div>
28 28
         <?php } ?>
29 29
         <!-- ///// Start PDF header -->
30 30
         <htmlpageheader name="wpinv-pdf-header">
31
-            <?php do_action( 'wpinv_invoice_print_before_header', $invoice ); ?>
31
+            <?php do_action('wpinv_invoice_print_before_header', $invoice); ?>
32 32
             <div class="row wpinv-header">
33 33
                 <div class="col-xs-6 wpinv-business">
34
-                    <a target="_blank" href="<?php echo esc_url( wpinv_get_business_website() ); ?>">
35
-                        <?php if ( $logo = wpinv_get_business_logo() ) { ?>
36
-                        <img class="logo" src="<?php echo esc_url( $logo ); ?>">
34
+                    <a target="_blank" href="<?php echo esc_url(wpinv_get_business_website()); ?>">
35
+                        <?php if ($logo = wpinv_get_business_logo()) { ?>
36
+                        <img class="logo" src="<?php echo esc_url($logo); ?>">
37 37
                         <?php } else { ?>
38
-                        <h1><?php echo esc_html( wpinv_get_business_name() ); ?></h1>
38
+                        <h1><?php echo esc_html(wpinv_get_business_name()); ?></h1>
39 39
                         <?php } ?>
40 40
                     </a>
41 41
                 </div>
@@ -44,56 +44,56 @@  discard block
 block discarded – undo
44 44
                     <h2><?php echo $type; ?></h2>
45 45
                 </div>
46 46
             </div>
47
-            <?php do_action( 'wpinv_invoice_print_after_header', $invoice ); ?>
47
+            <?php do_action('wpinv_invoice_print_after_header', $invoice); ?>
48 48
         </htmlpageheader>
49 49
         <!-- End PDF header ///// -->
50 50
         
51
-        <?php do_action( 'wpinv_invoice_print_before_top_content', $invoice ); ?>
51
+        <?php do_action('wpinv_invoice_print_before_top_content', $invoice); ?>
52 52
         <div class="row wpinv-top-content">
53 53
             <div class="col-xs-12 col-sm-6 wpinv-addresses">
54 54
                 <div class="col-xs-12 wpinv-address wpinv-from-address">
55 55
                     <?php wpinv_display_from_address(); ?>
56 56
                 </div>
57 57
                 <div class="col-xs-12 wpinv-address wpinv-to-address">
58
-                    <?php wpinv_display_to_address( $invoice_id ); ?>
58
+                    <?php wpinv_display_to_address($invoice_id); ?>
59 59
                 </div>
60 60
             </div>
61 61
             <div class="col-xs-12 col-sm-6 wpinv-details">
62 62
                 <div class="col-xs-12 wpinv-line-details">
63
-                    <?php do_action( 'wpinv_invoice_print_before_details', $invoice ); ?>
64
-                    <?php wpinv_display_invoice_details( $invoice ); ?>
65
-                    <?php do_action( 'wpinv_invoice_print_after_details', $invoice ); ?>
63
+                    <?php do_action('wpinv_invoice_print_before_details', $invoice); ?>
64
+                    <?php wpinv_display_invoice_details($invoice); ?>
65
+                    <?php do_action('wpinv_invoice_print_after_details', $invoice); ?>
66 66
                 </div>
67 67
             </div>
68 68
         </div>
69
-        <?php do_action( 'wpinv_invoice_print_after_top_content', $invoice ); ?>
69
+        <?php do_action('wpinv_invoice_print_after_top_content', $invoice); ?>
70 70
 
71
-        <?php do_action( 'wpinv_invoice_print_middle', $invoice ); ?>
71
+        <?php do_action('wpinv_invoice_print_middle', $invoice); ?>
72 72
         
73
-        <?php do_action( 'wpinv_invoice_print_before_line_items', $invoice ); ?>
73
+        <?php do_action('wpinv_invoice_print_before_line_items', $invoice); ?>
74 74
         <div class="row wpinv-items">
75 75
             <div class="col-sm-12 wpinv-line-items">
76
-                <?php wpinv_display_line_items( $invoice_id ); ?>
76
+                <?php wpinv_display_line_items($invoice_id); ?>
77 77
             </div>
78 78
         </div>
79
-        <?php do_action( 'wpinv_invoice_print_after_line_items', $invoice ); ?>
79
+        <?php do_action('wpinv_invoice_print_after_line_items', $invoice); ?>
80 80
         
81 81
         <!-- ///// Start PDF footer -->
82 82
         <htmlpagefooter name="wpinv-pdf-footer">
83
-            <?php do_action( 'wpinv_invoice_print_before_footer', $invoice ); ?>
83
+            <?php do_action('wpinv_invoice_print_before_footer', $invoice); ?>
84 84
             <div class="row wpinv-footer">
85 85
                 <div class="col-sm-12">
86
-                    <?php if ( $term_text = wpinv_get_terms_text() ) { ?>
87
-                    <div class="terms-text"><?php echo wpautop( $term_text ); ?></div>
86
+                    <?php if ($term_text = wpinv_get_terms_text()) { ?>
87
+                    <div class="terms-text"><?php echo wpautop($term_text); ?></div>
88 88
                     <?php } ?>
89 89
                     <div class="footer-text"><?php echo wpinv_get_business_footer(); ?></div>
90
-                    <div class="print-only"><?php _e( 'Page ', 'invoicing' ) ?> {PAGENO}/{nbpg}</div>
90
+                    <div class="print-only"><?php _e('Page ', 'invoicing') ?> {PAGENO}/{nbpg}</div>
91 91
                 </div>
92 92
             </div>
93
-            <?php do_action( 'wpinv_invoice_print_after_footer', $invoice ); ?>
93
+            <?php do_action('wpinv_invoice_print_after_footer', $invoice); ?>
94 94
         </htmlpagefooter>
95 95
         <!-- End PDF footer ///// -->
96 96
     </div><!-- END wpinv-wrap -->
97
-    <?php do_action( 'wpinv_invoice_print_body_end', $invoice ); ?>
97
+    <?php do_action('wpinv_invoice_print_body_end', $invoice); ?>
98 98
 </body>
99 99
 </html>
100 100
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv-api.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -7,51 +7,51 @@  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
 class WPInv_API {
15 15
     protected $post_type = 'wpi_invoice';
16 16
     
17
-    public function __construct( $params = array() ) {
17
+    public function __construct($params = array()) {
18 18
     }
19
-    public function insert_invoice( $data ) {
19
+    public function insert_invoice($data) {
20 20
         global $wpdb;
21 21
         //wpinv_transaction_query( 'start' );
22 22
 
23 23
         try {
24
-            if ( empty( $data['invoice'] ) ) {
25
-                throw new WPInv_API_Exception( 'wpinv_api_missing_invoice_data', sprintf( __( 'No %1$s data specified to create %1$s', 'invoicing' ), 'invoice' ), 400 );
24
+            if (empty($data['invoice'])) {
25
+                throw new WPInv_API_Exception('wpinv_api_missing_invoice_data', sprintf(__('No %1$s data specified to create %1$s', 'invoicing'), 'invoice'), 400);
26 26
             }
27 27
 
28
-            $data = apply_filters( 'wpinv_api_create_invoice_data', $data['invoice'], $this );
28
+            $data = apply_filters('wpinv_api_create_invoice_data', $data['invoice'], $this);
29 29
 
30
-            $invoice = wpinv_insert_invoice( $data, true );
31
-            if ( empty( $invoice->ID ) || is_wp_error( $invoice ) ) {
32
-                throw new WPInv_API_Exception( 'wpinv_api_cannot_create_invoice', sprintf( __( 'Cannot create invoice: %s', 'invoicing' ), implode( ', ', $invoice->get_error_messages() ) ), 400 );
30
+            $invoice = wpinv_insert_invoice($data, true);
31
+            if (empty($invoice->ID) || is_wp_error($invoice)) {
32
+                throw new WPInv_API_Exception('wpinv_api_cannot_create_invoice', sprintf(__('Cannot create invoice: %s', 'invoicing'), implode(', ', $invoice->get_error_messages())), 400);
33 33
             }
34 34
 
35 35
             // HTTP 201 Created
36
-            $this->send_status( 201 );
36
+            $this->send_status(201);
37 37
 
38
-            do_action( 'wpinv_api_create_invoice', $invoice->ID, $data, $this );
38
+            do_action('wpinv_api_create_invoice', $invoice->ID, $data, $this);
39 39
 
40 40
             //wpinv_transaction_query( 'commit' );
41 41
 
42
-            return wpinv_get_invoice( $invoice->ID );
43
-        } catch ( WPInv_API_Exception $e ) {
42
+            return wpinv_get_invoice($invoice->ID);
43
+        } catch (WPInv_API_Exception $e) {
44 44
             //wpinv_transaction_query( 'rollback' );
45 45
 
46
-            return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
46
+            return new WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode()));
47 47
         }
48 48
     }
49 49
     
50
-    public function send_status( $code ) {
51
-        status_header( $code );
50
+    public function send_status($code) {
51
+        status_header($code);
52 52
     }
53 53
     
54
-    protected function set_billing_details( $invoice, $data ) {
54
+    protected function set_billing_details($invoice, $data) {
55 55
         $address_fields = array(
56 56
             'user_id',
57 57
             'first_name',
@@ -70,66 +70,66 @@  discard block
 block discarded – undo
70 70
         $billing_details = array();
71 71
         $user_id = $invoice->get_user_id();
72 72
         
73
-        foreach ( $address_fields as $field ) {
74
-            if ( isset( $data['billing_details'][ $field ] ) ) {
75
-                $value = sanitize_text_field( $data['billing_details'][ $field ] );
73
+        foreach ($address_fields as $field) {
74
+            if (isset($data['billing_details'][$field])) {
75
+                $value = sanitize_text_field($data['billing_details'][$field]);
76 76
                 
77
-                if ( $field == 'country' && empty( $value ) ) {
78
-                    if ( !empty( $invoice->country ) ) {
77
+                if ($field == 'country' && empty($value)) {
78
+                    if (!empty($invoice->country)) {
79 79
                         $value = $invoice->country;
80 80
                     } else {
81
-                        $value = wpinv_default_billing_country( '', $user_id );
81
+                        $value = wpinv_default_billing_country('', $user_id);
82 82
                     }
83 83
                 }
84 84
                 
85
-                if ( $field == 'state' && empty( $value ) ) {
86
-                    if ( !empty( $invoice->state ) ) {
85
+                if ($field == 'state' && empty($value)) {
86
+                    if (!empty($invoice->state)) {
87 87
                         $value = $invoice->state;
88 88
                     } else {
89 89
                         $value = wpinv_get_default_state();
90 90
                     }
91 91
                 }
92 92
                 
93
-                $invoice->set( $field, $value );
93
+                $invoice->set($field, $value);
94 94
                 
95
-                update_post_meta( $invoice->ID, '_wpinv_' . $field, $value );
95
+                update_post_meta($invoice->ID, '_wpinv_' . $field, $value);
96 96
             }
97 97
         }
98 98
         
99 99
         return $invoice;
100 100
     }
101 101
     
102
-    protected function set_discount( $invoice, $data ) {
103
-        if ( isset( $data['discount'] ) ) {
104
-            $invoice->set( 'discount', wpinv_round_amount( $data['discount'] ) );
102
+    protected function set_discount($invoice, $data) {
103
+        if (isset($data['discount'])) {
104
+            $invoice->set('discount', wpinv_round_amount($data['discount']));
105 105
             
106
-            update_post_meta( $invoice->ID, '_wpinv_discount', wpinv_round_amount( $data['discount'] ) );
106
+            update_post_meta($invoice->ID, '_wpinv_discount', wpinv_round_amount($data['discount']));
107 107
             
108
-            if ( isset( $data['discount_code'] ) ) {
109
-                $invoice->set( 'discount_code', $data['discount_code'] );
108
+            if (isset($data['discount_code'])) {
109
+                $invoice->set('discount_code', $data['discount_code']);
110 110
                 
111
-                update_post_meta( $invoice->ID, '_wpinv_discount_code', $data['discount_code'] );
111
+                update_post_meta($invoice->ID, '_wpinv_discount_code', $data['discount_code']);
112 112
             }
113 113
         }
114 114
         
115 115
         return $invoice;
116 116
     }
117 117
     
118
-    protected function set_items( $invoice, $data ) {
119
-        if ( !empty( $data['items'] ) && is_array( $data['items'] ) ) {
118
+    protected function set_items($invoice, $data) {
119
+        if (!empty($data['items']) && is_array($data['items'])) {
120 120
             $items_array = array();
121 121
            
122
-            if ( !empty( $invoice->country ) ) {
122
+            if (!empty($invoice->country)) {
123 123
                 $country = $invoice->country;
124
-            } else if ( !empty( $data['billing_details']['country'] ) ) {
124
+            } else if (!empty($data['billing_details']['country'])) {
125 125
                 $country = $data['billing_details']['country'];
126 126
             } else {
127
-                $country = wpinv_default_billing_country( '', $invoice->get_user_id() );
127
+                $country = wpinv_default_billing_country('', $invoice->get_user_id());
128 128
             }
129 129
             
130
-            if ( !empty( $invoice->state ) ) {
130
+            if (!empty($invoice->state)) {
131 131
                 $state = $invoice->state;
132
-            } else if ( !empty( $data['billing_details']['state'] ) ) {
132
+            } else if (!empty($data['billing_details']['state'])) {
133 133
                 $state = $data['billing_details']['state'];
134 134
             } else {
135 135
                 $state = wpinv_get_default_state();
@@ -138,54 +138,54 @@  discard block
 block discarded – undo
138 138
             $_POST['country']   = $country;
139 139
             $_POST['state']     = $state;
140 140
             
141
-            $rate = wpinv_get_tax_rate( $country, $state, 'global' );
141
+            $rate = wpinv_get_tax_rate($country, $state, 'global');
142 142
             
143 143
             $total_tax = 0;
144
-            foreach ( $data['items'] as $item ) {
145
-                $id                 = isset( $item['id'] ) ? sanitize_text_field( $item['id'] ) : '';
146
-                $title              = isset( $item['title'] ) ? sanitize_text_field( $item['title'] ) : '';
147
-                $desc               = isset( $item['description'] ) ? sanitize_text_field( $item['description'] ) : '';
148
-                $amount             = isset( $item['amount'] ) ? wpinv_round_amount( $item['amount'] ) : 0;
144
+            foreach ($data['items'] as $item) {
145
+                $id                 = isset($item['id']) ? sanitize_text_field($item['id']) : '';
146
+                $title              = isset($item['title']) ? sanitize_text_field($item['title']) : '';
147
+                $desc               = isset($item['description']) ? sanitize_text_field($item['description']) : '';
148
+                $amount             = isset($item['amount']) ? wpinv_round_amount($item['amount']) : 0;
149 149
                 
150
-                if ( !empty( $item['vat_rates_class'] ) ) {
150
+                if (!empty($item['vat_rates_class'])) {
151 151
                     $vat_rates_class = $item['vat_rates_class'];
152 152
                 } else {
153 153
                     $vat_rates_class = '_standard';
154 154
                 }
155
-                $vat_rate = wpinv_get_tax_rate( $country, $state, $id );
155
+                $vat_rate = wpinv_get_tax_rate($country, $state, $id);
156 156
                 
157
-                $tax = $amount > 0 ? ( $amount * 0.01 * (float)$vat_rate ) : 0;
157
+                $tax = $amount > 0 ? ($amount * 0.01 * (float)$vat_rate) : 0;
158 158
                 $total_tax += $tax;
159 159
                 
160 160
                 $items_array[] = array(
161 161
                     'id'                => $id,
162
-                    'title'             => esc_html( $title ),
163
-                    'description'       => esc_html( $desc ),
164
-                    'amount'            => $amount > 0 ? wpinv_round_amount( $amount ) : 0,
165
-                    'subtotal'          => $amount > 0 ? wpinv_round_amount( $amount ) : 0,
162
+                    'title'             => esc_html($title),
163
+                    'description'       => esc_html($desc),
164
+                    'amount'            => $amount > 0 ? wpinv_round_amount($amount) : 0,
165
+                    'subtotal'          => $amount > 0 ? wpinv_round_amount($amount) : 0,
166 166
                     'vat_rates_class'   => $vat_rates_class,
167 167
                     'vat_rate'          => $vat_rate,
168
-                    'tax'               => $tax > 0 ? wpinv_round_amount( $tax ) : 0,
168
+                    'tax'               => $tax > 0 ? wpinv_round_amount($tax) : 0,
169 169
                 );
170 170
             }
171 171
 
172
-            update_post_meta( $invoice->ID, '_wpinv_tax', wpinv_round_amount( $total_tax ) );
173
-            $invoice->set( 'tax', wpinv_round_amount( $total_tax ) );
172
+            update_post_meta($invoice->ID, '_wpinv_tax', wpinv_round_amount($total_tax));
173
+            $invoice->set('tax', wpinv_round_amount($total_tax));
174 174
             
175
-            $items_array = apply_filters( 'wpinv_save_invoice_items', $items_array, $data['items'], $invoice );
175
+            $items_array = apply_filters('wpinv_save_invoice_items', $items_array, $data['items'], $invoice);
176 176
             
177
-            $invoice->set( 'items', $items_array );
178
-            update_post_meta( $invoice->ID, '_wpinv_items', $items_array );
177
+            $invoice->set('items', $items_array);
178
+            update_post_meta($invoice->ID, '_wpinv_items', $items_array);
179 179
         }
180 180
         
181 181
         return $invoice;
182 182
     }
183 183
     
184
-    protected function set_invoice_meta( $invoice_id, $invoice_meta ) {
185
-        foreach ( $invoice_meta as $meta_key => $meta_value ) {
184
+    protected function set_invoice_meta($invoice_id, $invoice_meta) {
185
+        foreach ($invoice_meta as $meta_key => $meta_value) {
186 186
 
187
-            if ( is_string( $meta_key) && ! is_protected_meta( $meta_key ) && is_scalar( $meta_value ) ) {
188
-                update_post_meta( $invoice_id, $meta_key, $meta_value );
187
+            if (is_string($meta_key) && !is_protected_meta($meta_key) && is_scalar($meta_value)) {
188
+                update_post_meta($invoice_id, $meta_key, $meta_value);
189 189
             }
190 190
         }
191 191
     }
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 class WPInv_API_Exception extends Exception {
196 196
     protected $error_code;
197 197
 
198
-    public function __construct( $error_code, $error_message, $http_status_code ) {
198
+    public function __construct($error_code, $error_message, $http_status_code) {
199 199
         $this->error_code = $error_code;
200
-        parent::__construct( $error_message, $http_status_code );
200
+        parent::__construct($error_message, $http_status_code);
201 201
     }
202 202
 
203 203
     public function getErrorCode() {
Please login to merge, or discard this patch.
templates/wpinv-invalid-access.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,56 +1,56 @@
 block discarded – undo
1 1
 <?php 
2
-if ( !defined('ABSPATH') ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit;
4 4
 }
5
-do_action( 'wpinv_invalid_invoice_before_display' ); ?><!DOCTYPE html>
5
+do_action('wpinv_invalid_invoice_before_display'); ?><!DOCTYPE html>
6 6
 <html <?php language_attributes(); ?>>
7 7
 <head>
8 8
     <meta charset="UTF-8">
9 9
     <title><?php wp_title() ?></title>
10
-    <meta charset="<?php bloginfo( 'charset' ); ?>" />
10
+    <meta charset="<?php bloginfo('charset'); ?>" />
11 11
     <meta name="viewport" content="width=device-width,initial-scale=1">
12 12
     <meta name="robots" content="noindex,nofollow">
13
-    <?php do_action( 'wpinv_invalid_invoice_head' ); ?>
13
+    <?php do_action('wpinv_invalid_invoice_head'); ?>
14 14
 </head>
15 15
 <body class="body wpinv wpinv-print wpinv-invalid-invoice">
16
-    <?php do_action( 'wpinv_invalid_invoice_body_start' ); ?>
16
+    <?php do_action('wpinv_invalid_invoice_body_start'); ?>
17 17
     <div class="container wpinv-wrap">
18 18
         <!-- ///// Start Header -->
19 19
         <htmlpageheader name="wpinv-pdf-header">
20
-            <?php do_action( 'wpinv_invalid_invoice_before_header' ); ?>
20
+            <?php do_action('wpinv_invalid_invoice_before_header'); ?>
21 21
             <div class="row wpinv-header">
22 22
                 <div class="col-xs-12 wpinv-business">
23
-                    <a target="_blank" href="<?php echo esc_url( wpinv_get_business_website() ); ?>">
24
-                        <?php if ( $logo = wpinv_get_business_logo() ) { ?>
25
-                        <img class="logo" src="<?php echo esc_url( $logo ); ?>">
23
+                    <a target="_blank" href="<?php echo esc_url(wpinv_get_business_website()); ?>">
24
+                        <?php if ($logo = wpinv_get_business_logo()) { ?>
25
+                        <img class="logo" src="<?php echo esc_url($logo); ?>">
26 26
                         <?php } else { ?>
27
-                        <h1><?php echo esc_html( wpinv_get_business_name() ); ?></h1>
27
+                        <h1><?php echo esc_html(wpinv_get_business_name()); ?></h1>
28 28
                         <?php } ?>
29 29
                     </a>
30 30
                 </div>
31 31
             </div>
32
-            <?php do_action( 'wpinv_invalid_invoice_after_header' ); ?>
32
+            <?php do_action('wpinv_invalid_invoice_after_header'); ?>
33 33
         </htmlpageheader>
34 34
         <!-- End Header ///// -->
35 35
         
36
-        <?php do_action( 'wpinv_invalid_invoice_before_content' ); ?>
36
+        <?php do_action('wpinv_invalid_invoice_before_content'); ?>
37 37
 
38
-        <?php do_action( 'wpinv_invalid_invoice_content' ); ?>
38
+        <?php do_action('wpinv_invalid_invoice_content'); ?>
39 39
         
40
-        <?php do_action( 'wpinv_invalid_invoice_after_content' ); ?>
40
+        <?php do_action('wpinv_invalid_invoice_after_content'); ?>
41 41
         
42 42
         <!-- ///// Start Footer -->
43 43
         <htmlpagefooter name="wpinv-pdf-footer">
44
-            <?php do_action( 'wpinv_invalid_invoice_before_footer' ); ?>
44
+            <?php do_action('wpinv_invalid_invoice_before_footer'); ?>
45 45
             <div class="row wpinv-footer">
46 46
                 <div class="col-sm-12">
47 47
                     <div class="footer-text"><?php echo wpinv_get_business_footer(); ?></div>
48 48
                 </div>
49 49
             </div>
50
-            <?php do_action( 'wpinv_invalid_invoice_after_footer' ); ?>
50
+            <?php do_action('wpinv_invalid_invoice_after_footer'); ?>
51 51
         </htmlpagefooter>
52 52
         <!-- End Footer ///// -->
53 53
     </div>
54
-    <?php do_action( 'wpinv_invalid_invoice_body_end' ); ?>
54
+    <?php do_action('wpinv_invalid_invoice_body_end'); ?>
55 55
 </body>
56 56
 </html>
57 57
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv-db.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Exit if accessed directly
4
-if ( ! defined( 'ABSPATH' ) ) exit;
4
+if (!defined('ABSPATH')) exit;
5 5
 
6 6
 abstract class Wpinv_DB {
7 7
 
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 	 * @since   1.0.0
67 67
 	 * @return  object
68 68
 	 */
69
-	public function get( $row_id ) {
69
+	public function get($row_id) {
70 70
 		global $wpdb;
71
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
71
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
72 72
 	}
73 73
 
74 74
 	/**
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
 	 * @since   1.0.0
79 79
 	 * @return  object
80 80
 	 */
81
-	public function get_by( $column, $row_id ) {
81
+	public function get_by($column, $row_id) {
82 82
 		global $wpdb;
83
-		$column = esc_sql( $column );
84
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) );
83
+		$column = esc_sql($column);
84
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id));
85 85
 	}
86 86
 
87 87
 	/**
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
 	 * @since   1.0.0
92 92
 	 * @return  string
93 93
 	 */
94
-	public function get_column( $column, $row_id ) {
94
+	public function get_column($column, $row_id) {
95 95
 		global $wpdb;
96
-		$column = esc_sql( $column );
97
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
96
+		$column = esc_sql($column);
97
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
98 98
 	}
99 99
 
100 100
 	/**
@@ -104,11 +104,11 @@  discard block
 block discarded – undo
104 104
 	 * @since   1.0.0
105 105
 	 * @return  string
106 106
 	 */
107
-	public function get_column_by( $column, $column_where, $column_value ) {
107
+	public function get_column_by($column, $column_where, $column_value) {
108 108
 		global $wpdb;
109
-		$column_where = esc_sql( $column_where );
110
-		$column       = esc_sql( $column );
111
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) );
109
+		$column_where = esc_sql($column_where);
110
+		$column       = esc_sql($column);
111
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value));
112 112
 	}
113 113
 
114 114
 	/**
@@ -118,31 +118,31 @@  discard block
 block discarded – undo
118 118
 	 * @since   1.0.0
119 119
 	 * @return  int
120 120
 	 */
121
-	public function insert( $data, $type = '' ) {
121
+	public function insert($data, $type = '') {
122 122
 		global $wpdb;
123 123
 
124 124
 		// Set default values
125
-		$data = wp_parse_args( $data, $this->get_column_defaults() );
125
+		$data = wp_parse_args($data, $this->get_column_defaults());
126 126
 
127
-		do_action( 'wpinv_pre_insert_' . $type, $data );
127
+		do_action('wpinv_pre_insert_' . $type, $data);
128 128
 
129 129
 		// Initialise column format array
130 130
 		$column_formats = $this->get_columns();
131 131
 
132 132
 		// Force fields to lower case
133
-		$data = array_change_key_case( $data );
133
+		$data = array_change_key_case($data);
134 134
 
135 135
 		// White list columns
136
-		$data = array_intersect_key( $data, $column_formats );
136
+		$data = array_intersect_key($data, $column_formats);
137 137
 
138 138
 		// Reorder $column_formats to match the order of columns given in $data
139
-		$data_keys = array_keys( $data );
140
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
139
+		$data_keys = array_keys($data);
140
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
141 141
 
142
-		$wpdb->insert( $this->table_name, $data, $column_formats );
142
+		$wpdb->insert($this->table_name, $data, $column_formats);
143 143
 		$wpdb_insert_id = $wpdb->insert_id;
144 144
 
145
-		do_action( 'wpinv_post_insert_' . $type, $wpdb_insert_id, $data );
145
+		do_action('wpinv_post_insert_' . $type, $wpdb_insert_id, $data);
146 146
 
147 147
 		return $wpdb_insert_id;
148 148
 	}
@@ -154,18 +154,18 @@  discard block
 block discarded – undo
154 154
 	 * @since   1.0.0
155 155
 	 * @return  bool
156 156
 	 */
157
-	public function update( $row_id, $data = array(), $where = '' ) {
157
+	public function update($row_id, $data = array(), $where = '') {
158 158
 
159 159
 		global $wpdb;
160 160
 
161 161
 		// Row ID must be positive integer
162
-		$row_id = absint( $row_id );
162
+		$row_id = absint($row_id);
163 163
 
164
-		if( empty( $row_id ) ) {
164
+		if (empty($row_id)) {
165 165
 			return false;
166 166
 		}
167 167
 
168
-		if( empty( $where ) ) {
168
+		if (empty($where)) {
169 169
 			$where = $this->primary_key;
170 170
 		}
171 171
 
@@ -173,16 +173,16 @@  discard block
 block discarded – undo
173 173
 		$column_formats = $this->get_columns();
174 174
 
175 175
 		// Force fields to lower case
176
-		$data = array_change_key_case( $data );
176
+		$data = array_change_key_case($data);
177 177
 
178 178
 		// White list columns
179
-		$data = array_intersect_key( $data, $column_formats );
179
+		$data = array_intersect_key($data, $column_formats);
180 180
 
181 181
 		// Reorder $column_formats to match the order of columns given in $data
182
-		$data_keys = array_keys( $data );
183
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
182
+		$data_keys = array_keys($data);
183
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
184 184
 
185
-		if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) {
185
+		if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) {
186 186
 			return false;
187 187
 		}
188 188
 
@@ -196,18 +196,18 @@  discard block
 block discarded – undo
196 196
 	 * @since   1.0.0
197 197
 	 * @return  bool
198 198
 	 */
199
-	public function delete( $row_id = 0 ) {
199
+	public function delete($row_id = 0) {
200 200
 
201 201
 		global $wpdb;
202 202
 
203 203
 		// Row ID must be positive integer
204
-		$row_id = absint( $row_id );
204
+		$row_id = absint($row_id);
205 205
 
206
-		if( empty( $row_id ) ) {
206
+		if (empty($row_id)) {
207 207
 			return false;
208 208
 		}
209 209
 
210
-		if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) {
210
+		if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) {
211 211
 			return false;
212 212
 		}
213 213
 
@@ -221,11 +221,11 @@  discard block
 block discarded – undo
221 221
 	 * @param  string $table The table name
222 222
 	 * @return bool          If the table name exists
223 223
 	 */
224
-	public function table_exists( $table ) {
224
+	public function table_exists($table) {
225 225
 		global $wpdb;
226
-		$table = sanitize_text_field( $table );
226
+		$table = sanitize_text_field($table);
227 227
 
228
-		return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table;
228
+		return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table;
229 229
 	}
230 230
 
231 231
 	/**
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	 * @return bool Returns if the customers table was installed and upgrade routine run
236 236
 	 */
237 237
 	public function installed() {
238
-		return $this->table_exists( $this->table_name );
238
+		return $this->table_exists($this->table_name);
239 239
 	}
240 240
 
241 241
 }
Please login to merge, or discard this patch.
templates/emails/wpinv-email-styles.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -1,25 +1,25 @@  discard block
 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
 // Load colours
7
-$bg              = wpinv_get_option( 'email_background_color', '#f5f5f5' );
8
-$body            = wpinv_get_option( 'email_body_background_color', '#fdfdfd' );
9
-$base            = wpinv_get_option( 'email_base_color', '#557da2' );
10
-$base_text       = wpinv_light_or_dark( $base, '#202020', '#ffffff' );
11
-$text            = wpinv_get_option( 'email_text_color', '#505050' );
7
+$bg              = wpinv_get_option('email_background_color', '#f5f5f5');
8
+$body            = wpinv_get_option('email_body_background_color', '#fdfdfd');
9
+$base            = wpinv_get_option('email_base_color', '#557da2');
10
+$base_text       = wpinv_light_or_dark($base, '#202020', '#ffffff');
11
+$text            = wpinv_get_option('email_text_color', '#505050');
12 12
 
13
-$bg_darker_10    = wpinv_hex_darker( $bg, 10 );
14
-$body_darker_10  = wpinv_hex_darker( $body, 10 );
15
-$base_lighter_20 = wpinv_hex_lighter( $base, 20 );
16
-$base_lighter_40 = wpinv_hex_lighter( $base, 40 );
17
-$text_lighter_20 = wpinv_hex_lighter( $text, 20 );
13
+$bg_darker_10    = wpinv_hex_darker($bg, 10);
14
+$body_darker_10  = wpinv_hex_darker($body, 10);
15
+$base_lighter_20 = wpinv_hex_lighter($base, 20);
16
+$base_lighter_40 = wpinv_hex_lighter($base, 40);
17
+$text_lighter_20 = wpinv_hex_lighter($text, 20);
18 18
 
19 19
 // !important; is a gmail hack to prevent styles being stripped if it doesn't like something.
20 20
 ?>
21 21
 #wrapper {
22
-    background-color: <?php echo esc_attr( $bg ); ?>;
22
+    background-color: <?php echo esc_attr($bg); ?>;
23 23
     margin: 0;
24 24
     -webkit-text-size-adjust: none !important;
25 25
     padding: 3%;
@@ -40,15 +40,15 @@  discard block
 block discarded – undo
40 40
 
41 41
 #template_container {
42 42
     box-shadow: 0 1px 4px rgba(0,0,0,0.1) !important;
43
-    background-color: <?php echo esc_attr( $body ); ?>;
44
-    border: 1px solid <?php echo esc_attr( $bg_darker_10 ); ?>;
43
+    background-color: <?php echo esc_attr($body); ?>;
44
+    border: 1px solid <?php echo esc_attr($bg_darker_10); ?>;
45 45
     border-radius: 3px !important;
46 46
 }
47 47
 
48 48
 #template_header {
49
-    background-color: <?php echo esc_attr( $base ); ?>;
49
+    background-color: <?php echo esc_attr($base); ?>;
50 50
     border-radius: 3px 3px 0 0 !important;
51
-    color: <?php echo esc_attr( $base_text ); ?>;
51
+    color: <?php echo esc_attr($base_text); ?>;
52 52
     border-bottom: 0;
53 53
     font-weight: bold;
54 54
     line-height: 100%;
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 }
62 62
 
63 63
 #template_header h1 {
64
-    color: <?php echo esc_attr( $base_text ); ?>;
64
+    color: <?php echo esc_attr($base_text); ?>;
65 65
 }
66 66
 
67 67
 #template_footer td {
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
 #template_footer #credit {
74 74
     border:0;
75
-    color: <?php echo esc_attr( $base_lighter_40 ); ?>;
75
+    color: <?php echo esc_attr($base_lighter_40); ?>;
76 76
     font-family: Arial;
77 77
     font-size:12px;
78 78
     line-height:125%;
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 }
82 82
 
83 83
 #body_content {
84
-    background-color: <?php echo esc_attr( $body ); ?>;
84
+    background-color: <?php echo esc_attr($body); ?>;
85 85
 }
86 86
 
87 87
 #body_content table td {
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 }
102 102
 
103 103
 #body_content_inner {
104
-    color: <?php echo esc_attr( $text_lighter_20 ); ?>;
104
+    color: <?php echo esc_attr($text_lighter_20); ?>;
105 105
     font-family: Arial,Helvetica,sans-serif;
106 106
     font-size: 14px;
107 107
     line-height: 150%;
@@ -109,17 +109,17 @@  discard block
 block discarded – undo
109 109
 }
110 110
 
111 111
 .td {
112
-    color: <?php echo esc_attr( $text_lighter_20 ); ?>;
113
-    border: 1px solid <?php echo esc_attr( $body_darker_10 ); ?>;
112
+    color: <?php echo esc_attr($text_lighter_20); ?>;
113
+    border: 1px solid <?php echo esc_attr($body_darker_10); ?>;
114 114
 }
115 115
 
116 116
 .text {
117
-    color: <?php echo esc_attr( $text ); ?>;
117
+    color: <?php echo esc_attr($text); ?>;
118 118
     font-family: Arial,Helvetica,sans-serif;
119 119
 }
120 120
 
121 121
 .link {
122
-    color: <?php echo esc_attr( $base ); ?>;
122
+    color: <?php echo esc_attr($base); ?>;
123 123
 }
124 124
 
125 125
 #header_wrapper {
@@ -128,19 +128,19 @@  discard block
 block discarded – undo
128 128
 }
129 129
 
130 130
 h1 {
131
-    color: <?php echo esc_attr( $base ); ?>;
131
+    color: <?php echo esc_attr($base); ?>;
132 132
     font-family: Arial,Helvetica,sans-serif;
133 133
     font-size: 30px;
134 134
     font-weight: 300;
135 135
     line-height: 150%;
136 136
     margin: 0;
137 137
     text-align: <?php echo is_rtl() ? 'right' : 'left'; ?>;
138
-    text-shadow: 0 1px 0 <?php echo esc_attr( $base_lighter_20 ); ?>;
138
+    text-shadow: 0 1px 0 <?php echo esc_attr($base_lighter_20); ?>;
139 139
     -webkit-font-smoothing: antialiased;
140 140
 }
141 141
 
142 142
 h2 {
143
-    color: <?php echo esc_attr( $base ); ?>;
143
+    color: <?php echo esc_attr($base); ?>;
144 144
     display: block;
145 145
     font-family: Arial,Helvetica,sans-serif;
146 146
     font-size: 18px;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 }
152 152
 
153 153
 h3 {
154
-    color: <?php echo esc_attr( $base ); ?>;
154
+    color: <?php echo esc_attr($base); ?>;
155 155
     display: block;
156 156
     font-family: Arial,Helvetica,sans-serif;
157 157
     font-size: 16px;
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 }
163 163
 
164 164
 a {
165
-    color: <?php echo esc_attr( $base ); ?>;
165
+    color: <?php echo esc_attr($base); ?>;
166 166
     font-weight: normal;
167 167
     text-decoration: underline;
168 168
 }
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 }
181 181
 
182 182
 .table-bordered {
183
-    border: 1px solid <?php echo esc_attr( $body_darker_10 ); ?>;
183
+    border: 1px solid <?php echo esc_attr($body_darker_10); ?>;
184 184
     border-collapse: collapse;
185 185
     border-spacing: 0;
186 186
     width: 100%;
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 
189 189
 .table-bordered th,
190 190
 .table-bordered td {
191
-    border: 1px solid <?php echo esc_attr( $body_darker_10 ); ?>;
192
-    color: <?php echo esc_attr( $text_lighter_20 ); ?>;
191
+    border: 1px solid <?php echo esc_attr($body_darker_10); ?>;
192
+    color: <?php echo esc_attr($text_lighter_20); ?>;
193 193
     font-size: 14px;
194 194
 }
195 195
 .small {
@@ -288,9 +288,9 @@  discard block
 block discarded – undo
288 288
   text-decoration: none;
289 289
 }
290 290
 .btn-default {
291
-    color: <?php echo esc_attr( $base_text ); ?>;
292
-    background-color: <?php echo esc_attr( $base ); ?>;
293
-    border-color: <?php echo esc_attr( $base ); ?>;
291
+    color: <?php echo esc_attr($base_text); ?>;
292
+    background-color: <?php echo esc_attr($base); ?>;
293
+    border-color: <?php echo esc_attr($base); ?>;
294 294
 }
295 295
 .btn-primary {
296 296
   color: #fff;
Please login to merge, or discard this patch.
templates/emails/wpinv-email-invoice-items.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 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, $ajax_cart_details;
@@ -11,152 +11,152 @@  discard block
 block discarded – undo
11 11
 $quantities_enabled = wpinv_item_quantities_enabled();
12 12
 $use_taxes          = wpinv_use_taxes();
13 13
 $zero_tax           = !(float)$invoice->get_tax() > 0 ? true : false;
14
-$tax_label          = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' );
15
-$tax_title          = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : '';
14
+$tax_label          = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing');
15
+$tax_title          = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : '';
16 16
 
17
-do_action( 'wpinv_before_email_items', $invoice ); ?>
17
+do_action('wpinv_before_email_items', $invoice); ?>
18 18
 <div id="wpinv-email-items">
19
-    <h3 class="wpinv-items-t"><?php echo apply_filters( 'wpinv_email_items_title', __( 'Items', 'invoicing' ) ); ?></h3>
19
+    <h3 class="wpinv-items-t"><?php echo apply_filters('wpinv_email_items_title', __('Items', 'invoicing')); ?></h3>
20 20
     <table id="wpinv_checkout_cart" class="table table-bordered table-hover">
21 21
         <thead>
22 22
             <tr class="wpinv_cart_header_row">
23
-                <?php do_action( 'wpinv_email_items_table_header_first' ); ?>
24
-                <th class="wpinv_cart_item_name text-left"><?php _e( 'Item Name', 'invoicing' ); ?></th>
25
-                <th class="wpinv_cart_item_price text-right"><?php _e( 'Item Price', 'invoicing' ); ?></th>
26
-                <?php if ( $quantities_enabled ) { ?>
27
-                <th class="wpinv_cart_item_qty text-right"><?php _e( 'Qty', 'invoicing' ); ?></th>
23
+                <?php do_action('wpinv_email_items_table_header_first'); ?>
24
+                <th class="wpinv_cart_item_name text-left"><?php _e('Item Name', 'invoicing'); ?></th>
25
+                <th class="wpinv_cart_item_price text-right"><?php _e('Item Price', 'invoicing'); ?></th>
26
+                <?php if ($quantities_enabled) { ?>
27
+                <th class="wpinv_cart_item_qty text-right"><?php _e('Qty', 'invoicing'); ?></th>
28 28
                 <?php } ?>
29
-                <?php if ( !$zero_tax && $use_taxes ) { ?>
29
+                <?php if (!$zero_tax && $use_taxes) { ?>
30 30
                 <th class="wpinv_cart_item_tax text-right"><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></th>
31 31
                 <?php } ?>
32
-                <th class="wpinv_cart_item_subtotal text-right"><?php echo __( 'Item Total', 'invoicing' ) . ' <span class="normal small">' . $tax_title . '<span>'; ?></th>
33
-                <?php do_action( 'wpinv_email_items_table_header_last' ); ?>
32
+                <th class="wpinv_cart_item_subtotal text-right"><?php echo __('Item Total', 'invoicing') . ' <span class="normal small">' . $tax_title . '<span>'; ?></th>
33
+                <?php do_action('wpinv_email_items_table_header_last'); ?>
34 34
             </tr>
35 35
         </thead>
36 36
         <tbody>
37 37
             <?php
38
-                do_action( 'wpinv_email_items_before' );
39
-                if ( $cart_items ) {
40
-                    foreach ( $cart_items as $key => $item ) {
41
-                        $wpi_item = $item['id'] ? new WPInv_Item( $item['id'] ) : NULL;
38
+                do_action('wpinv_email_items_before');
39
+                if ($cart_items) {
40
+                    foreach ($cart_items as $key => $item) {
41
+                        $wpi_item = $item['id'] ? new WPInv_Item($item['id']) : NULL;
42 42
                     ?>
43
-                    <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr( $key ) . '_' . esc_attr( $item['id'] ); ?>" data-item-id="<?php echo esc_attr( $item['id'] ); ?>">
44
-                        <?php do_action( 'wpinv_email_items_table_body_first', $item ); ?>
43
+                    <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr($key) . '_' . esc_attr($item['id']); ?>" data-item-id="<?php echo esc_attr($item['id']); ?>">
44
+                        <?php do_action('wpinv_email_items_table_body_first', $item); ?>
45 45
                         <td class="wpinv_cart_item_name text-left">
46 46
                             <?php
47
-                                if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $item['id'] ) ) {
47
+                                if (current_theme_supports('post-thumbnails') && has_post_thumbnail($item['id'])) {
48 48
                                     echo '<div class="wpinv_cart_item_image">';
49
-                                        echo get_the_post_thumbnail( $item['id'], apply_filters( 'wpinv_checkout_image_size', array( 25,25 ) ) );
49
+                                        echo get_the_post_thumbnail($item['id'], apply_filters('wpinv_checkout_image_size', array(25, 25)));
50 50
                                     echo '</div>';
51 51
                                 }
52
-                                $item_title = esc_html( wpinv_get_cart_item_name( $item ) ) . wpinv_get_item_suffix( $wpi_item );
52
+                                $item_title = esc_html(wpinv_get_cart_item_name($item)) . wpinv_get_item_suffix($wpi_item);
53 53
                                 echo '<span class="wpinv_email_cart_item_title">' . $item_title . '</span>';
54 54
                                 
55
-                                $summary = apply_filters( 'wpinv_email_invoice_line_item_summary', '', $item, $wpi_item, $invoice );
56
-                                if ( !empty( $summary ) ) {
55
+                                $summary = apply_filters('wpinv_email_invoice_line_item_summary', '', $item, $wpi_item, $invoice);
56
+                                if (!empty($summary)) {
57 57
                                     echo '<p class="small">' . $summary . '</p>';
58 58
                                 }
59 59
     
60
-                                do_action( 'wpinv_email_cart_item_title_after', $item, $key );
60
+                                do_action('wpinv_email_cart_item_title_after', $item, $key);
61 61
                             ?>
62 62
                         </td>
63 63
                         <td class="wpinv_cart_item_price text-right">
64 64
                             <?php 
65
-                            echo wpinv_cart_item_price( $item );
66
-                            do_action( 'wpinv_email_cart_item_price_after', $item, $key );
65
+                            echo wpinv_cart_item_price($item);
66
+                            do_action('wpinv_email_cart_item_price_after', $item, $key);
67 67
                             ?>
68 68
                         </td>
69
-                        <?php if ( $quantities_enabled ) { ?>
69
+                        <?php if ($quantities_enabled) { ?>
70 70
                         <td class="wpinv_cart_item_qty text-right">
71 71
                             <?php
72
-                            echo wpinv_get_cart_item_quantity( $item );
73
-                            do_action( 'wpinv_email_item_quantitiy', $item, $key );
72
+                            echo wpinv_get_cart_item_quantity($item);
73
+                            do_action('wpinv_email_item_quantitiy', $item, $key);
74 74
                             ?>
75 75
                         </td>
76 76
                         <?php } ?>
77
-                        <?php if ( !$zero_tax && $use_taxes ) { ?>
77
+                        <?php if (!$zero_tax && $use_taxes) { ?>
78 78
                         <td class="wpinv_cart_item_tax text-right">
79 79
                             <?php
80
-                            echo wpinv_cart_item_tax( $item );
81
-                            do_action( 'wpinv_email_item_tax', $item, $key );
80
+                            echo wpinv_cart_item_tax($item);
81
+                            do_action('wpinv_email_item_tax', $item, $key);
82 82
                             ?>
83 83
                         </td>
84 84
                         <?php } ?>
85 85
                         <td class="wpinv_cart_item_subtotal text-right">
86 86
                             <?php
87
-                            echo wpinv_cart_item_subtotal( $item );
88
-                            do_action( 'wpinv_email_item_subtotal', $item, $key );
87
+                            echo wpinv_cart_item_subtotal($item);
88
+                            do_action('wpinv_email_item_subtotal', $item, $key);
89 89
                             ?>
90 90
                         </td>
91
-                        <?php do_action( 'wpinv_email_items_table_body_last', $item, $key ); ?>
91
+                        <?php do_action('wpinv_email_items_table_body_last', $item, $key); ?>
92 92
                     </tr>
93 93
                 <?php } ?>
94 94
             <?php } ?>
95
-            <?php do_action( 'wpinv_email_items_middle' ); ?>
96
-            <?php do_action( 'wpinv_email_items_after' ); ?>
95
+            <?php do_action('wpinv_email_items_middle'); ?>
96
+            <?php do_action('wpinv_email_items_after'); ?>
97 97
         </tbody>
98 98
         <tfoot>
99
-            <?php $cart_columns = wpinv_checkout_cart_columns(); if ( $zero_tax && $use_taxes ) { $cart_columns--; } ?>
100
-            <?php if ( has_action( 'wpinv_email_footer_buttons' ) ) { ?>
99
+            <?php $cart_columns = wpinv_checkout_cart_columns(); if ($zero_tax && $use_taxes) { $cart_columns--; } ?>
100
+            <?php if (has_action('wpinv_email_footer_buttons')) { ?>
101 101
                 <tr class="wpinv_cart_footer_row">
102
-                    <?php do_action( 'wpinv_email_items_table_buttons_first', $cart_items ); ?>
103
-                    <td colspan="<?php echo ( $cart_columns ); ?>">
104
-                        <?php do_action( 'wpinv_email_footer_buttons' ); ?>
102
+                    <?php do_action('wpinv_email_items_table_buttons_first', $cart_items); ?>
103
+                    <td colspan="<?php echo ($cart_columns); ?>">
104
+                        <?php do_action('wpinv_email_footer_buttons'); ?>
105 105
                     </td>
106
-                    <?php do_action( 'wpinv_email_items_table_buttons_first', $cart_items ); ?>
106
+                    <?php do_action('wpinv_email_items_table_buttons_first', $cart_items); ?>
107 107
                 </tr>
108 108
             <?php } ?>
109 109
 
110
-            <?php if ( !$zero_tax && $use_taxes && !wpinv_prices_include_tax() && wpinv_is_cart_taxed() ) { ?>
110
+            <?php if (!$zero_tax && $use_taxes && !wpinv_prices_include_tax() && wpinv_is_cart_taxed()) { ?>
111 111
                 <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row">
112
-                    <?php do_action( 'wpinv_email_items_table_subtotal_first', $cart_items ); ?>
113
-                    <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_subtotal_label text-right">
114
-                        <strong><?php _e( 'Sub-Total', 'invoicing' ); ?>:</strong>
112
+                    <?php do_action('wpinv_email_items_table_subtotal_first', $cart_items); ?>
113
+                    <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_subtotal_label text-right">
114
+                        <strong><?php _e('Sub-Total', 'invoicing'); ?>:</strong>
115 115
                     </td>
116 116
                     <td class="wpinv_cart_subtotal text-right">
117
-                        <span class="wpinv_cart_subtotal_amount bold"><?php echo $invoice->get_subtotal( true ); ?></span>
117
+                        <span class="wpinv_cart_subtotal_amount bold"><?php echo $invoice->get_subtotal(true); ?></span>
118 118
                     </td>
119
-                    <?php do_action( 'wpinv_email_items_table_subtotal_last', $cart_items, $invoice ); ?>
119
+                    <?php do_action('wpinv_email_items_table_subtotal_last', $cart_items, $invoice); ?>
120 120
                 </tr>
121 121
             <?php } ?>
122 122
             
123
-            <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?>
123
+            <?php if (wpinv_discount($invoice_id, false) > 0) { ?>
124 124
                 <tr class="wpinv_cart_footer_row wpinv_cart_discount_row">
125
-                    <?php do_action( 'wpinv_receipt_items_table_discount_first', $cart_items, $invoice ); ?>
126
-                    <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_discount_label text-right">
127
-                        <strong><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</strong>
125
+                    <?php do_action('wpinv_receipt_items_table_discount_first', $cart_items, $invoice); ?>
126
+                    <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_discount_label text-right">
127
+                        <strong><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</strong>
128 128
                     </td>
129 129
                     <td class="wpinv_cart_discount text-right">
130
-                        <span class="wpinv_cart_discount_amount"><?php echo wpinv_discount( $invoice_id, true, true ); ?></span>
130
+                        <span class="wpinv_cart_discount_amount"><?php echo wpinv_discount($invoice_id, true, true); ?></span>
131 131
                     </td>
132
-                    <?php do_action( 'wpinv_receipt_items_table_discount_last', $cart_items, $invoice ); ?>
132
+                    <?php do_action('wpinv_receipt_items_table_discount_last', $cart_items, $invoice); ?>
133 133
                 </tr>
134 134
             <?php } ?>
135 135
 
136
-            <?php if ( !$zero_tax && $use_taxes && wpinv_is_cart_taxed() ) { ?>
136
+            <?php if (!$zero_tax && $use_taxes && wpinv_is_cart_taxed()) { ?>
137 137
                 <tr class="wpinv_cart_footer_row wpinv_cart_tax_row">
138
-                    <?php do_action( 'wpinv_email_items_table_tax_first', $cart_items, $invoice ); ?>
139
-                    <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_tax_label text-right">
138
+                    <?php do_action('wpinv_email_items_table_tax_first', $cart_items, $invoice); ?>
139
+                    <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_tax_label text-right">
140 140
                         <strong><?php echo $tax_label; ?>:</strong>
141 141
                     </td>
142 142
                     <td class="wpinv_cart_tax text-right">
143
-                        <span class="wpinv_cart_tax_amount"><?php echo $invoice->get_tax( true ); ?></span>
143
+                        <span class="wpinv_cart_tax_amount"><?php echo $invoice->get_tax(true); ?></span>
144 144
                     </td>
145
-                    <?php do_action( 'wpinv_email_items_table_tax_last', $cart_items, $invoice ); ?>
145
+                    <?php do_action('wpinv_email_items_table_tax_last', $cart_items, $invoice); ?>
146 146
                 </tr>
147 147
             <?php } ?>
148 148
 
149 149
             <tr class="wpinv_cart_footer_row">
150
-                <?php do_action( 'wpinv_email_items_table_footer_first', $cart_items, $invoice ); ?>
151
-                <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_total_label text-right">
152
-                    <?php echo apply_filters( 'wpinv_email_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?>
150
+                <?php do_action('wpinv_email_items_table_footer_first', $cart_items, $invoice); ?>
151
+                <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_total_label text-right">
152
+                    <?php echo apply_filters('wpinv_email_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?>
153 153
                 </td>
154 154
                 <td class="wpinv_cart_total text-right">
155
-                    <span class="wpinv_cart_amount bold"><?php echo $invoice->get_total( true ); ?></span>
155
+                    <span class="wpinv_cart_amount bold"><?php echo $invoice->get_total(true); ?></span>
156 156
                 </td>
157
-                <?php do_action( 'wpinv_email_items_table_footer_last', $cart_items, $invoice ); ?>
157
+                <?php do_action('wpinv_email_items_table_footer_last', $cart_items, $invoice); ?>
158 158
             </tr>
159 159
         </tfoot>
160 160
     </table>
161 161
 </div>
162
-<?php do_action( 'wpinv_after_email_items', $invoice ); ?>
163 162
\ No newline at end of file
163
+<?php do_action('wpinv_after_email_items', $invoice); ?>
164 164
\ No newline at end of file
Please login to merge, or discard this patch.
uninstall.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -9,58 +9,58 @@
 block discarded – undo
9 9
  */
10 10
 
11 11
 // If uninstall not called from WordPress, then exit.
12
-if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
12
+if (!defined('WP_UNINSTALL_PLUGIN')) {
13 13
     exit;
14 14
 }
15 15
 
16 16
 global $wpdb, $wp_version;
17 17
 
18
-$remove_data = get_option( 'wpinv_remove_data_on_invoice_unistall' );
18
+$remove_data = get_option('wpinv_remove_data_on_invoice_unistall');
19 19
 
20 20
 /*
21 21
  * Only remove ALL product and page data if WPINV_REMOVE_ALL_DATA constant is set to true in user's
22 22
  * wp-config.php. This is to prevent data loss when deleting the plugin from the backend
23 23
  * and to ensure only the site owner can perform this action.
24 24
  */
25
-if ( defined( 'WPINV_REMOVE_ALL_DATA' ) ) {
25
+if (defined('WPINV_REMOVE_ALL_DATA')) {
26 26
     $remove_data = true === WPINV_REMOVE_ALL_DATA ? true : false;
27 27
 }
28 28
 
29
-if ( $remove_data ) {
29
+if ($remove_data) {
30 30
     // Load Invoicing file.
31
-    include_once( 'invoicing.php' );
31
+    include_once('invoicing.php');
32 32
 
33 33
     // Roles + caps.
34
-    include_once( dirname( __FILE__ ) . '/includes/admin/install.php' );
34
+    include_once(dirname(__FILE__) . '/includes/admin/install.php');
35 35
     wpinv_remove_admin_caps();
36 36
     
37
-    $settings = get_option( 'wpinv_settings' );
37
+    $settings = get_option('wpinv_settings');
38 38
     
39 39
     // Delete pages.
40
-    $wpi_pages = array( 'checkout_page', 'success_page', 'failure_page', 'invoice_history_page', 'quote_history_page', 'invoice_subscription_page' );
41
-    foreach ( $wpi_pages as $page ) {
42
-        if ( !empty( $page ) && !empty( $settings[ $page ] ) ) {
43
-            wp_delete_post( $settings[ $page ], true );
40
+    $wpi_pages = array('checkout_page', 'success_page', 'failure_page', 'invoice_history_page', 'quote_history_page', 'invoice_subscription_page');
41
+    foreach ($wpi_pages as $page) {
42
+        if (!empty($page) && !empty($settings[$page])) {
43
+            wp_delete_post($settings[$page], true);
44 44
         }
45 45
     }
46 46
     
47 47
     // Delete posts + data.
48
-    $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'wpi_invoice', 'wpi_item', 'wpi_discount', 'wpi_quote' );" );
49
-    $wpdb->query( "DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;" );
48
+    $wpdb->query("DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'wpi_invoice', 'wpi_item', 'wpi_discount', 'wpi_quote' );");
49
+    $wpdb->query("DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;");
50 50
     
51 51
     // Delete comments.
52
-    $wpdb->query( "DELETE FROM {$wpdb->comments} WHERE comment_type LIKE 'wpinv_note';" );
53
-    $wpdb->query( "DELETE meta FROM {$wpdb->commentmeta} meta LEFT JOIN {$wpdb->comments} comments ON comments.comment_ID = meta.comment_id WHERE comments.comment_ID IS NULL;" );
52
+    $wpdb->query("DELETE FROM {$wpdb->comments} WHERE comment_type LIKE 'wpinv_note';");
53
+    $wpdb->query("DELETE meta FROM {$wpdb->commentmeta} meta LEFT JOIN {$wpdb->comments} comments ON comments.comment_ID = meta.comment_id WHERE comments.comment_ID IS NULL;");
54 54
     
55 55
     // Delete user meta.
56
-    $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%_wpinv_%' OR meta_key LIKE '%_wpi_invoice%' OR meta_key LIKE '%_wpi_item%' OR meta_key LIKE '%_wpi_discount%' OR meta_key LIKE '_wpi_stripe%' OR meta_key LIKE '%_wpi_quote%';" );
56
+    $wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%_wpinv_%' OR meta_key LIKE '%_wpi_invoice%' OR meta_key LIKE '%_wpi_item%' OR meta_key LIKE '%_wpi_discount%' OR meta_key LIKE '_wpi_stripe%' OR meta_key LIKE '%_wpi_quote%';");
57 57
     
58 58
     // Cleanup Cron Schedule
59
-    wp_clear_scheduled_hook( 'wp_session_garbage_collection' );
60
-    wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' );
59
+    wp_clear_scheduled_hook('wp_session_garbage_collection');
60
+    wp_clear_scheduled_hook('wpinv_register_schedule_event_twicedaily');
61 61
     
62 62
     // Delete options.
63
-    $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wpinv_%' OR option_name LIKE '_wpinv_%' OR option_name LIKE '\_transient\_wpinv\_%';" );
63
+    $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wpinv_%' OR option_name LIKE '_wpinv_%' OR option_name LIKE '\_transient\_wpinv\_%';");
64 64
     
65 65
     // Clear any cached data that has been removed
66 66
     wp_cache_flush();
Please login to merge, or discard this patch.
templates/emails/wpinv-email-invoice-details.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,68 +1,68 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6 6
 global $wpinv_euvat;
7 7
 
8
-$sent_to_admin  = !empty( $sent_to_admin ) ? true : false;
9
-$invoice_url = $invoice->get_view_url( true );
8
+$sent_to_admin = !empty($sent_to_admin) ? true : false;
9
+$invoice_url = $invoice->get_view_url(true);
10 10
 $use_taxes = wpinv_use_taxes();
11 11
 $vat_name = $wpinv_euvat->get_vat_name();
12 12
 
13
-do_action( 'wpinv_email_before_invoice_details', $invoice, $sent_to_admin ); ?>
13
+do_action('wpinv_email_before_invoice_details', $invoice, $sent_to_admin); ?>
14 14
 <div id="wpinv-email-details">
15
-    <h3 class="wpinv-details-t"><?php echo apply_filters( 'wpinv_email_details_title', __( 'Invoice Details', 'invoicing' ), $invoice ); ?></h3>
15
+    <h3 class="wpinv-details-t"><?php echo apply_filters('wpinv_email_details_title', __('Invoice Details', 'invoicing'), $invoice); ?></h3>
16 16
     <table class="table table-bordered table-sm">
17
-        <?php if ( $invoice_number = $invoice->get_number() ) { ?>
17
+        <?php if ($invoice_number = $invoice->get_number()) { ?>
18 18
             <tr>
19
-                <td><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></td>
20
-                <td><a href="<?php echo esc_url( $invoice_url ) ;?>"><?php echo $invoice_number; ?></a></td>
19
+                <td><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></td>
20
+                <td><a href="<?php echo esc_url($invoice_url); ?>"><?php echo $invoice_number; ?></a></td>
21 21
             </tr>
22 22
         <?php } ?>
23 23
         <tr>
24
-            <td><?php echo apply_filters( 'wpinv_invoice_status_label', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></td>
25
-            <td><?php echo $invoice->get_status( true ); ?></td>
24
+            <td><?php echo apply_filters('wpinv_invoice_status_label', __('Invoice Status', 'invoicing'), $invoice); ?></td>
25
+            <td><?php echo $invoice->get_status(true); ?></td>
26 26
         </tr>
27
-        <?php if ( $invoice->is_renewal() ) { ?>
27
+        <?php if ($invoice->is_renewal()) { ?>
28 28
         <tr>
29
-            <td><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></td>
30
-            <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td>
29
+            <td><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></td>
30
+            <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td>
31 31
         </tr>
32 32
         <?php } ?>
33
-        <?php if ( ( $gateway_title = $invoice->get_gateway_title() ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?>
34
-            <td><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></td>
33
+        <?php if (($gateway_title = $invoice->get_gateway_title()) && ($invoice->is_paid() || $invoice->is_refunded())) { ?>
34
+            <td><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></td>
35 35
             <td><?php echo $gateway_title; ?></td>
36 36
         <?php } ?>
37
-        <?php if ( $invoice_date = $invoice->get_invoice_date( false ) ) { ?>
37
+        <?php if ($invoice_date = $invoice->get_invoice_date(false)) { ?>
38 38
             <tr>
39
-                <td><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></td>
40
-                <td><?php echo wp_sprintf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $invoice_date ) ), $invoice->get_invoice_date() ); ?></td>
39
+                <td><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></td>
40
+                <td><?php echo wp_sprintf('<time datetime="%s">%s</time>', date_i18n('c', strtotime($invoice_date)), $invoice->get_invoice_date()); ?></td>
41 41
             </tr>
42 42
         <?php } ?>
43
-        <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date() ) ) { ?>
43
+        <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date())) { ?>
44 44
             <tr>
45
-                <td><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></td>
46
-                <td><?php echo wp_sprintf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $due_date ) ), $invoice->get_due_date( true ) ); ?></td>
45
+                <td><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></td>
46
+                <td><?php echo wp_sprintf('<time datetime="%s">%s</time>', date_i18n('c', strtotime($due_date)), $invoice->get_due_date(true)); ?></td>
47 47
             </tr>
48 48
         <?php } ?>
49
-        <?php do_action( 'wpinv_email_invoice_details_after_due_date', $invoice->ID ); ?>
50
-        <?php if ( empty( $sent_to_admin ) && ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) ) { ?>
49
+        <?php do_action('wpinv_email_invoice_details_after_due_date', $invoice->ID); ?>
50
+        <?php if (empty($sent_to_admin) && ($owner_vat_number = $wpinv_euvat->get_vat_number())) { ?>
51 51
             <tr>
52
-                <td><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></td>
52
+                <td><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></td>
53 53
                 <td><?php echo $owner_vat_number; ?></td>
54 54
             </tr>
55 55
         <?php } ?>
56
-        <?php if ( $use_taxes && ( $user_vat_number = $invoice->vat_number ) ) { ?>
56
+        <?php if ($use_taxes && ($user_vat_number = $invoice->vat_number)) { ?>
57 57
             <tr>
58
-                <td><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></td>
58
+                <td><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></td>
59 59
                 <td><?php echo $user_vat_number; ?></td>
60 60
             </tr>
61 61
         <?php } ?>
62 62
         <tr class="table-active">
63
-            <td><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></td>
64
-            <td><strong><?php echo $invoice->get_total( true ); ?></strong></td>
63
+            <td><strong><?php _e('Total Amount', 'invoicing') ?></strong></td>
64
+            <td><strong><?php echo $invoice->get_total(true); ?></strong></td>
65 65
         </tr>
66 66
     </table>
67 67
 </div>
68
-<?php do_action( 'wpinv_email_after_invoice_details', $invoice, $sent_to_admin ); ?>
69 68
\ No newline at end of file
69
+<?php do_action('wpinv_email_after_invoice_details', $invoice, $sent_to_admin); ?>
70 70
\ No newline at end of file
Please login to merge, or discard this patch.
includes/wpinv-payment-functions.php 1 patch
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -1,156 +1,156 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-function wpinv_is_subscription_payment( $invoice = '' ) {
4
-    if ( empty( $invoice ) ) {
3
+function wpinv_is_subscription_payment($invoice = '') {
4
+    if (empty($invoice)) {
5 5
         return false;
6 6
     }
7 7
     
8
-    if ( !is_object( $invoice ) && is_scalar( $invoice ) ) {
9
-        $invoice = wpinv_get_invoice( $invoice );
8
+    if (!is_object($invoice) && is_scalar($invoice)) {
9
+        $invoice = wpinv_get_invoice($invoice);
10 10
     }
11 11
     
12
-    if ( empty( $invoice ) ) {
12
+    if (empty($invoice)) {
13 13
         return false;
14 14
     }
15 15
         
16
-    if ( $invoice->is_renewal() ) {
16
+    if ($invoice->is_renewal()) {
17 17
         return true;
18 18
     }
19 19
 
20 20
     return false;
21 21
 }
22 22
 
23
-function wpinv_payment_link_transaction_id( $invoice = '' ) {
24
-    if ( empty( $invoice ) ) {
23
+function wpinv_payment_link_transaction_id($invoice = '') {
24
+    if (empty($invoice)) {
25 25
         return false;
26 26
     }
27 27
     
28
-    if ( !is_object( $invoice ) && is_scalar( $invoice ) ) {
29
-        $invoice = wpinv_get_invoice( $invoice );
28
+    if (!is_object($invoice) && is_scalar($invoice)) {
29
+        $invoice = wpinv_get_invoice($invoice);
30 30
     }
31 31
     
32
-    if ( empty( $invoice ) ) {
32
+    if (empty($invoice)) {
33 33
         return false;
34 34
     }
35 35
 
36
-    return apply_filters( 'wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice );
36
+    return apply_filters('wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice);
37 37
 }
38 38
 
39
-function wpinv_subscription_initial_payment_desc( $amount, $period, $interval, $trial_period = '', $trial_interval = 0 ) {
39
+function wpinv_subscription_initial_payment_desc($amount, $period, $interval, $trial_period = '', $trial_interval = 0) {
40 40
     $interval   = (int)$interval > 0 ? (int)$interval : 1;
41 41
     
42
-    if ( $trial_interval > 0 && !empty( $trial_period ) ) {
43
-        $amount = __( 'Free', 'invoicing' );
42
+    if ($trial_interval > 0 && !empty($trial_period)) {
43
+        $amount = __('Free', 'invoicing');
44 44
         $interval = $trial_interval;
45 45
         $period = $trial_period;
46 46
     }
47 47
     
48 48
     $description = '';
49
-    switch ( $period ) {
49
+    switch ($period) {
50 50
         case 'D' :
51 51
         case 'day' :
52
-            $description = wp_sprintf( _n( '%s for the first day.', '%s for the first %d days.', $interval, 'invoicing' ), $amount, $interval );
52
+            $description = wp_sprintf(_n('%s for the first day.', '%s for the first %d days.', $interval, 'invoicing'), $amount, $interval);
53 53
             break;
54 54
         case 'W' :
55 55
         case 'week' :
56
-            $description = wp_sprintf( _n( '%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing' ), $amount, $interval );
56
+            $description = wp_sprintf(_n('%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing'), $amount, $interval);
57 57
             break;
58 58
         case 'M' :
59 59
         case 'month' :
60
-            $description = wp_sprintf( _n( '%s for the first month.', '%s for the first %d months.', $interval, 'invoicing' ), $amount, $interval );
60
+            $description = wp_sprintf(_n('%s for the first month.', '%s for the first %d months.', $interval, 'invoicing'), $amount, $interval);
61 61
             break;
62 62
         case 'Y' :
63 63
         case 'year' :
64
-            $description = wp_sprintf( _n( '%s for the first year.', '%s for the first %d years.', $interval, 'invoicing' ), $amount, $interval );
64
+            $description = wp_sprintf(_n('%s for the first year.', '%s for the first %d years.', $interval, 'invoicing'), $amount, $interval);
65 65
             break;
66 66
     }
67 67
 
68
-    return apply_filters( 'wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval  );
68
+    return apply_filters('wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval);
69 69
 }
70 70
 
71
-function wpinv_subscription_recurring_payment_desc( $amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0 ) {
71
+function wpinv_subscription_recurring_payment_desc($amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0) {
72 72
     $interval   = (int)$interval > 0 ? (int)$interval : 1;
73 73
     $bill_times = (int)$bill_times > 0 ? (int)$bill_times : 0;
74 74
     
75 75
     $description = '';
76
-    switch ( $period ) {
76
+    switch ($period) {
77 77
         case 'D' :
78 78
         case 'day' :            
79
-            if ( (int)$bill_times > 0 ) {
80
-                if ( $interval > 1 ) {
81
-                    if ( $bill_times > 1 ) {
82
-                        $description = wp_sprintf( __( '%s for each %d days, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times );
79
+            if ((int)$bill_times > 0) {
80
+                if ($interval > 1) {
81
+                    if ($bill_times > 1) {
82
+                        $description = wp_sprintf(__('%s for each %d days, for %d installments.', 'invoicing'), $amount, $interval, $bill_times);
83 83
                     } else {
84
-                        $description = wp_sprintf( __( '%s for %d days.', 'invoicing' ), $amount, $interval );
84
+                        $description = wp_sprintf(__('%s for %d days.', 'invoicing'), $amount, $interval);
85 85
                     }
86 86
                 } else {
87
-                    $description = wp_sprintf( _n( '%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
87
+                    $description = wp_sprintf(_n('%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times);
88 88
                 }
89 89
             } else {
90
-                $description = wp_sprintf( _n( '%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval );
90
+                $description = wp_sprintf(_n('%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval);
91 91
             }
92 92
             break;
93 93
         case 'W' :
94 94
         case 'week' :            
95
-            if ( (int)$bill_times > 0 ) {
96
-                if ( $interval > 1 ) {
97
-                    if ( $bill_times > 1 ) {
98
-                        $description = wp_sprintf( __( '%s for each %d weeks, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times );
95
+            if ((int)$bill_times > 0) {
96
+                if ($interval > 1) {
97
+                    if ($bill_times > 1) {
98
+                        $description = wp_sprintf(__('%s for each %d weeks, for %d installments.', 'invoicing'), $amount, $interval, $bill_times);
99 99
                     } else {
100
-                        $description = wp_sprintf( __( '%s for %d weeks.', 'invoicing' ), $amount, $interval );
100
+                        $description = wp_sprintf(__('%s for %d weeks.', 'invoicing'), $amount, $interval);
101 101
                     }
102 102
                 } else {
103
-                    $description = wp_sprintf( _n( '%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
103
+                    $description = wp_sprintf(_n('%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times);
104 104
                 }
105 105
             } else {
106
-                $description = wp_sprintf( _n( '%s for each week.', '%s for each %d weeks.', $interval, 'invoicing' ), $amount, $interval );
106
+                $description = wp_sprintf(_n('%s for each week.', '%s for each %d weeks.', $interval, 'invoicing'), $amount, $interval);
107 107
             }
108 108
             break;
109 109
         case 'M' :
110 110
         case 'month' :            
111
-            if ( (int)$bill_times > 0 ) {
112
-                if ( $interval > 1 ) {
113
-                    if ( $bill_times > 1 ) {
114
-                        $description = wp_sprintf( __( '%s for each %d months, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times );
111
+            if ((int)$bill_times > 0) {
112
+                if ($interval > 1) {
113
+                    if ($bill_times > 1) {
114
+                        $description = wp_sprintf(__('%s for each %d months, for %d installments.', 'invoicing'), $amount, $interval, $bill_times);
115 115
                     } else {
116
-                        $description = wp_sprintf( __( '%s for %d months.', 'invoicing' ), $amount, $interval );
116
+                        $description = wp_sprintf(__('%s for %d months.', 'invoicing'), $amount, $interval);
117 117
                     }
118 118
                 } else {
119
-                    $description = wp_sprintf( _n( '%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
119
+                    $description = wp_sprintf(_n('%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times);
120 120
                 }
121 121
             } else {
122
-                $description = wp_sprintf( _n( '%s for each month.', '%s for each %d months.', $interval, 'invoicing' ), $amount, $interval );
122
+                $description = wp_sprintf(_n('%s for each month.', '%s for each %d months.', $interval, 'invoicing'), $amount, $interval);
123 123
             }
124 124
             break;
125 125
         case 'Y' :
126 126
         case 'year' :            
127
-            if ( (int)$bill_times > 0 ) {
128
-                if ( $interval > 1 ) {
129
-                    if ( $bill_times > 1 ) {
130
-                        $description = wp_sprintf( __( '%s for each %d years, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times );
127
+            if ((int)$bill_times > 0) {
128
+                if ($interval > 1) {
129
+                    if ($bill_times > 1) {
130
+                        $description = wp_sprintf(__('%s for each %d years, for %d installments.', 'invoicing'), $amount, $interval, $bill_times);
131 131
                     } else {
132
-                        $description = wp_sprintf( __( '%s for %d years.', 'invoicing'), $amount, $interval );
132
+                        $description = wp_sprintf(__('%s for %d years.', 'invoicing'), $amount, $interval);
133 133
                     }
134 134
                 } else {
135
-                    $description = wp_sprintf( _n( '%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
135
+                    $description = wp_sprintf(_n('%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times);
136 136
                 }
137 137
             } else {
138
-                $description = wp_sprintf( _n( '%s for each year.', '%s for each %d years.', $interval, 'invoicing' ), $amount, $interval );
138
+                $description = wp_sprintf(_n('%s for each year.', '%s for each %d years.', $interval, 'invoicing'), $amount, $interval);
139 139
             }
140 140
             break;
141 141
     }
142 142
 
143
-    return apply_filters( 'wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval );
143
+    return apply_filters('wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval);
144 144
 }
145 145
 
146
-function wpinv_subscription_payment_desc( $invoice ) {
147
-    if ( empty( $invoice ) ) {
146
+function wpinv_subscription_payment_desc($invoice) {
147
+    if (empty($invoice)) {
148 148
         return NULL;
149 149
     }
150 150
     
151 151
     $description = '';
152
-    if ( $invoice->is_parent() && $item = $invoice->get_recurring( true ) ) {
153
-        if ( $item->has_free_trial() ) {
152
+    if ($invoice->is_parent() && $item = $invoice->get_recurring(true)) {
153
+        if ($item->has_free_trial()) {
154 154
             $trial_period = $item->get_trial_period();
155 155
             $trial_interval = $item->get_trial_interval();
156 156
         } else {
@@ -158,45 +158,45 @@  discard block
 block discarded – undo
158 158
             $trial_interval = 0;
159 159
         }
160 160
         
161
-        $description = wpinv_get_billing_cycle( $invoice->get_total(), $invoice->get_recurring_details( 'total' ), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency() );
161
+        $description = wpinv_get_billing_cycle($invoice->get_total(), $invoice->get_recurring_details('total'), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency());
162 162
     }
163 163
     
164
-    return apply_filters( 'wpinv_subscription_payment_desc', $description, $invoice );
164
+    return apply_filters('wpinv_subscription_payment_desc', $description, $invoice);
165 165
 }
166 166
 
167
-function wpinv_get_billing_cycle( $initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '' ) {
168
-    $initial_total      = wpinv_round_amount( $initial );
169
-    $recurring_total    = wpinv_round_amount( $recurring );
167
+function wpinv_get_billing_cycle($initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '') {
168
+    $initial_total      = wpinv_round_amount($initial);
169
+    $recurring_total    = wpinv_round_amount($recurring);
170 170
     
171
-    if ( $trial_interval > 0 && !empty( $trial_period ) ) {
171
+    if ($trial_interval > 0 && !empty($trial_period)) {
172 172
         // Free trial
173 173
     } else {
174
-        if ( $bill_times == 1 ) {
174
+        if ($bill_times == 1) {
175 175
             $recurring_total = $initial_total;
176
-        } else if ( $bill_times > 1 && $initial_total != $recurring_total ) {
176
+        } else if ($bill_times > 1 && $initial_total != $recurring_total) {
177 177
             $bill_times--;
178 178
         }
179 179
     }
180 180
     
181
-    $initial_amount     = wpinv_price( wpinv_format_amount( $initial_total ), $currency );
182
-    $recurring_amount   = wpinv_price( wpinv_format_amount( $recurring_total ), $currency );
181
+    $initial_amount     = wpinv_price(wpinv_format_amount($initial_total), $currency);
182
+    $recurring_amount   = wpinv_price(wpinv_format_amount($recurring_total), $currency);
183 183
     
184
-    $recurring          = wpinv_subscription_recurring_payment_desc( $recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval );
184
+    $recurring          = wpinv_subscription_recurring_payment_desc($recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval);
185 185
         
186
-    if ( $initial_total != $recurring_total ) {
187
-        $initial        = wpinv_subscription_initial_payment_desc( $initial_amount, $period, $interval, $trial_period, $trial_interval );
186
+    if ($initial_total != $recurring_total) {
187
+        $initial        = wpinv_subscription_initial_payment_desc($initial_amount, $period, $interval, $trial_period, $trial_interval);
188 188
         
189
-        $description    = wp_sprintf( __( '%s Then %s', 'invoicing' ), $initial, $recurring );
189
+        $description    = wp_sprintf(__('%s Then %s', 'invoicing'), $initial, $recurring);
190 190
     } else {
191 191
         $description    = $recurring;
192 192
     }
193 193
     
194
-    return apply_filters( 'wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency );
194
+    return apply_filters('wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency);
195 195
 }
196 196
 
197
-function wpinv_recurring_send_payment_failed( $invoice ) {
198
-    if ( !empty( $invoice->ID ) ) {
199
-        wpinv_failed_invoice_notification( $invoice->ID );
197
+function wpinv_recurring_send_payment_failed($invoice) {
198
+    if (!empty($invoice->ID)) {
199
+        wpinv_failed_invoice_notification($invoice->ID);
200 200
     }
201 201
 }
202
-add_action( 'wpinv_recurring_payment_failed', 'wpinv_recurring_send_payment_failed', 10, 1 );
203 202
\ No newline at end of file
203
+add_action('wpinv_recurring_payment_failed', 'wpinv_recurring_send_payment_failed', 10, 1);
204 204
\ No newline at end of file
Please login to merge, or discard this patch.