Passed
Push — master ( 6a5c27...530be4 )
by Stiofan
41s queued 14s
created
includes/class-wpinv-bp-core.php 1 patch
Spacing   +119 added lines, -119 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
 
@@ -9,42 +9,42 @@  discard block
 block discarded – undo
9 9
     
10 10
     public function __construct() {
11 11
 
12
-        if ( !defined( 'WPINV_BP_SLUG' ) ) {
13
-            define( 'WPINV_BP_SLUG', 'invoices' );
12
+        if (!defined('WPINV_BP_SLUG')) {
13
+            define('WPINV_BP_SLUG', 'invoices');
14 14
         }
15 15
 
16
-        add_action( 'wp_ajax_invoicing_filter', array( $this, 'invoices_content' ) );
17
-        add_action( 'wp_ajax_nopriv_invoicing_filter', array( $this, 'invoices_content' ) );
18
-        add_filter( 'wpinv_settings_sections_general', array( $this, 'bp_section' ), 10, 1 );
19
-        add_filter( 'wpinv_settings_general', array( $this, 'bp_settings' ), 10, 1 );
20
-        add_filter( 'wp_nav_menu_objects', array( $this, 'wp_nav_menu_objects' ), 10, 2 );
16
+        add_action('wp_ajax_invoicing_filter', array($this, 'invoices_content'));
17
+        add_action('wp_ajax_nopriv_invoicing_filter', array($this, 'invoices_content'));
18
+        add_filter('wpinv_settings_sections_general', array($this, 'bp_section'), 10, 1);
19
+        add_filter('wpinv_settings_general', array($this, 'bp_settings'), 10, 1);
20
+        add_filter('wp_nav_menu_objects', array($this, 'wp_nav_menu_objects'), 10, 2);
21 21
         add_action('bp_setup_nav', array($this, 'setup_nav'), 15);
22 22
         
23
-        $position       = wpinv_get_option( 'wpinv_menu_position' );
23
+        $position       = wpinv_get_option('wpinv_menu_position');
24 24
         $position       = $position !== '' && $position !== false ? $position : 91;
25
-        $this->position = apply_filters( 'wpinv_bp_nav_position', $position );
26
-        $this->id     = WPINV_BP_SLUG;
25
+        $this->position = apply_filters('wpinv_bp_nav_position', $position);
26
+        $this->id = WPINV_BP_SLUG;
27 27
     }
28 28
 
29 29
     public function setup_nav() {
30 30
 
31
-        if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) || !is_user_logged_in()) {
31
+        if (wpinv_get_option('wpinv_bp_hide_menu') || !is_user_logged_in()) {
32 32
             return;
33 33
         }
34 34
 
35
-        if(bp_displayed_user_id() != bp_loggedin_user_id() && !current_user_can('administrator')){
35
+        if (bp_displayed_user_id() != bp_loggedin_user_id() && !current_user_can('administrator')) {
36 36
             return;
37 37
         }
38 38
 
39 39
         $count = $this->get_invoice_count();
40
-        $class = ( 0 === $count ) ? 'no-count' : 'count';
40
+        $class = (0 === $count) ? 'no-count' : 'count';
41 41
 
42 42
         $main_nav_name = sprintf(
43
-            __( 'My Invoices %s', 'invoicing' ),
43
+            __('My Invoices %s', 'invoicing'),
44 44
             sprintf(
45 45
                 '<span class="%s">%s</span>',
46
-                esc_attr( $class ),
47
-                bp_core_number_format( $count )
46
+                esc_attr($class),
47
+                bp_core_number_format($count)
48 48
             )
49 49
         );
50 50
 
@@ -52,31 +52,31 @@  discard block
 block discarded – undo
52 52
             'name'                => $main_nav_name,
53 53
             'slug'                => WPINV_BP_SLUG,
54 54
             'position'            => $this->position,
55
-            'screen_function'     => array( $this, 'invoices_screen' ),
55
+            'screen_function'     => array($this, 'invoices_screen'),
56 56
             'default_subnav_slug' => 'invoices',
57 57
             'item_css_id'         => $this->id
58 58
         );
59 59
 
60
-        bp_core_new_nav_item( $main_nav );
60
+        bp_core_new_nav_item($main_nav);
61 61
     }
62 62
     
63 63
     public function invoices_screen() {
64
-        if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) {
64
+        if (wpinv_get_option('wpinv_bp_hide_menu')) {
65 65
             return;
66 66
         }
67 67
         
68
-        add_action( 'bp_template_content', array( $this, 'invoices_content' ) );
68
+        add_action('bp_template_content', array($this, 'invoices_content'));
69 69
 
70
-        $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' );
70
+        $template = apply_filters('bp_core_template_plugin', 'members/single/plugins');
71 71
         
72
-        bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) );
72
+        bp_core_load_template(apply_filters('wpinv_bp_core_template_plugin', $template));
73 73
     }
74 74
     
75 75
     public function invoices_content() {
76
-        if ( $this->has_invoices( bp_ajax_querystring( 'invoices' ) ) ) {
76
+        if ($this->has_invoices(bp_ajax_querystring('invoices'))) {
77 77
             global $invoices_template;
78 78
             
79
-            do_action( 'wpinv_bp_invoices_before_content' );
79
+            do_action('wpinv_bp_invoices_before_content');
80 80
             ?>
81 81
             <div class="wpi-g wpi-bp-invoices invoices invoicing" style="position:relative">
82 82
                 <div id="pag-top" class="pagination">
@@ -90,61 +90,61 @@  discard block
 block discarded – undo
90 90
                 <table class="table table-bordered table-hover table-responsive wpi-user-invoices" style="margin:0">
91 91
                     <thead>
92 92
                         <tr>
93
-                            <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
94
-                                <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>
93
+                            <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?>
94
+                                <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>
95 95
                             <?php endforeach; ?>
96 96
                         </tr>
97 97
                     </thead>
98 98
                     <tbody>
99
-                        <?php foreach ( $invoices_template->invoices as $invoice ) {
99
+                        <?php foreach ($invoices_template->invoices as $invoice) {
100 100
                             ?>
101 101
                             <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>">
102
-                                <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
103
-                                    <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'] ); ?>">
104
-                                        <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?>
105
-                                            <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?>
106
-
107
-                                        <?php elseif ( 'invoice-number' === $column_id ) : ?>
108
-                                            <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>">
109
-                                                <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?>
102
+                                <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?>
103
+                                    <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']); ?>">
104
+                                        <?php if (has_action('wpinv_user_invoices_column_' . $column_id)) : ?>
105
+                                            <?php do_action('wpinv_user_invoices_column_' . $column_id, $invoice); ?>
106
+
107
+                                        <?php elseif ('invoice-number' === $column_id) : ?>
108
+                                            <a href="<?php echo esc_url($invoice->get_view_url()); ?>">
109
+                                                <?php echo _x('#', 'hash before invoice number', 'invoicing') . $invoice->get_number(); ?>
110 110
                                             </a>
111 111
 
112
-                                        <?php elseif ( 'created-date' === $column_id ) : $date = wpinv_get_date_created( $invoice->ID ); $dateYMD = wpinv_get_date_created( $invoice->ID, 'Y-m-d H:i:s' ); ?>
113
-                                            <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
112
+                                        <?php elseif ('created-date' === $column_id) : $date = wpinv_get_date_created($invoice->ID); $dateYMD = wpinv_get_date_created($invoice->ID, 'Y-m-d H:i:s'); ?>
113
+                                            <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
114 114
 
115
-                                        <?php elseif ( 'payment-date' === $column_id ) : $date = wpinv_get_invoice_date( $invoice->ID, '', false ); $dateYMD = wpinv_get_invoice_date( $invoice->ID, 'Y-m-d H:i:s', false ); ?>
116
-                                            <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
115
+                                        <?php elseif ('payment-date' === $column_id) : $date = wpinv_get_invoice_date($invoice->ID, '', false); $dateYMD = wpinv_get_invoice_date($invoice->ID, 'Y-m-d H:i:s', false); ?>
116
+                                            <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
117 117
 
118
-                                        <?php elseif ( 'invoice-status' === $column_id ) : ?>
119
-                                            <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?>
118
+                                        <?php elseif ('invoice-status' === $column_id) : ?>
119
+                                            <?php echo wpinv_invoice_status_label($invoice_status, $invoice->get_status(true)); ?>
120 120
 
121
-                                        <?php elseif ( 'invoice-total' === $column_id ) : ?>
122
-                                            <?php echo $invoice->get_total( true ); ?>
121
+                                        <?php elseif ('invoice-total' === $column_id) : ?>
122
+                                            <?php echo $invoice->get_total(true); ?>
123 123
 
124
-                                        <?php elseif ( 'invoice-actions' === $column_id ) : ?>
124
+                                        <?php elseif ('invoice-actions' === $column_id) : ?>
125 125
                                             <?php
126 126
                                                 $actions = array(
127 127
                                                     'pay'    => array(
128 128
                                                         'url'  => $invoice->get_checkout_payment_url(),
129
-                                                        'name' => __( 'Pay Now', 'invoicing' ),
129
+                                                        'name' => __('Pay Now', 'invoicing'),
130 130
                                                         'class' => 'btn-success'
131 131
                                                     ),
132 132
                                                     'print'   => array(
133 133
                                                         'url'  => $invoice->get_view_url(),
134
-                                                        'name' => __( 'Print', 'invoicing' ),
134
+                                                        'name' => __('Print', 'invoicing'),
135 135
                                                         'class' => 'btn-primary',
136 136
                                                         'attrs' => 'target="_blank"'
137 137
                                                     )
138 138
                                                 );
139 139
 
140
-                                                if ( ! $invoice->needs_payment() ) {
141
-                                                    unset( $actions['pay'] );
140
+                                                if (!$invoice->needs_payment()) {
141
+                                                    unset($actions['pay']);
142 142
                                                 }
143 143
 
144
-                                                if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) {
145
-                                                    foreach ( $actions as $key => $action ) {
144
+                                                if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) {
145
+                                                    foreach ($actions as $key => $action) {
146 146
                                                         $class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
147
-                                                        echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
147
+                                                        echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>';
148 148
                                                     }
149 149
                                                 }
150 150
                                             ?>
@@ -172,64 +172,64 @@  discard block
 block discarded – undo
172 172
             </div>
173 173
             <?php
174 174
         
175
-            do_action( 'wpinv_bp_invoices_after_content' );
175
+            do_action('wpinv_bp_invoices_after_content');
176 176
         } else {
177 177
             ?>
178 178
             <div id="message" class="info">
179
-                <p><?php _e( 'No invoice has been made yet.', 'invoicing' ); ?></p>
179
+                <p><?php _e('No invoice has been made yet.', 'invoicing'); ?></p>
180 180
             </div>
181 181
             <?php
182 182
         }
183 183
         
184
-        if ( defined( 'DOING_AJAX' ) ) {
184
+        if (defined('DOING_AJAX')) {
185 185
             exit;
186 186
         }
187 187
     }
188 188
     
189
-    public function has_invoices( $args = '' ) {
189
+    public function has_invoices($args = '') {
190 190
         global $invoices_template;
191 191
 
192
-        $per_page = absint( wpinv_get_option( 'wpinv_bp_per_page' ) );
192
+        $per_page = absint(wpinv_get_option('wpinv_bp_per_page'));
193 193
         // Parse arguments.
194
-        $r = bp_parse_args( $args, array(
194
+        $r = bp_parse_args($args, array(
195 195
             'status'            => 'all',
196 196
             'page_arg'          => 'bpage',
197 197
             'page'              => 1,
198 198
             'per_page'          => $per_page > 0 ? $per_page : 20,
199 199
             'max'               => false,
200 200
             'user_id'           => bp_displayed_user_id(),
201
-        ), 'has_invoices' );
201
+        ), 'has_invoices');
202 202
 
203 203
 
204
-        if ( ! empty( $r['max'] ) && ( (int)$r['per_page'] > (int)$r['max'] ) ) {
204
+        if (!empty($r['max']) && ((int)$r['per_page'] > (int)$r['max'])) {
205 205
             $r['per_page'] = (int)$r['max'];
206 206
         }
207 207
 
208 208
         // Get the invoices.
209
-        $invoices_template = new WPInv_BP_Invoices_Template( $r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg'] );
209
+        $invoices_template = new WPInv_BP_Invoices_Template($r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg']);
210 210
 
211
-        return apply_filters( 'wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r );
211
+        return apply_filters('wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r);
212 212
     }
213 213
     
214 214
     public function get_invoice_count() {
215
-        $query      = apply_filters( 'wpinv_user_invoices_count_query', array( 'status' => 'all','user' => bp_displayed_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false ) );
216
-        $invoices   = wpinv_get_invoices( $query );
215
+        $query      = apply_filters('wpinv_user_invoices_count_query', array('status' => 'all', 'user' => bp_displayed_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false));
216
+        $invoices   = wpinv_get_invoices($query);
217 217
         
218
-        return !empty( $invoices ) ? count( $invoices ) : 0;
218
+        return !empty($invoices) ? count($invoices) : 0;
219 219
     }
220 220
     
221 221
     public function pagination_count() {
222 222
         global $invoices_template;
223 223
 
224
-        $start_num = intval( ( $invoices_template->pag_page - 1 ) * $invoices_template->pag_num ) + 1;
225
-        $from_num  = bp_core_number_format( $start_num );
226
-        $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 ) );
227
-        $total     = bp_core_number_format( $invoices_template->total_invoice_count );
224
+        $start_num = intval(($invoices_template->pag_page - 1) * $invoices_template->pag_num) + 1;
225
+        $from_num  = bp_core_number_format($start_num);
226
+        $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));
227
+        $total     = bp_core_number_format($invoices_template->total_invoice_count);
228 228
 
229
-        if ( 1 == $invoices_template->total_invoice_count ) {
230
-            $message = __( 'Viewing 1 invoice', 'invoicing' );
229
+        if (1 == $invoices_template->total_invoice_count) {
230
+            $message = __('Viewing 1 invoice', 'invoicing');
231 231
         } else {
232
-            $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 );
232
+            $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);
233 233
         }
234 234
 
235 235
         return $message;
@@ -238,32 +238,32 @@  discard block
 block discarded – undo
238 238
     function pagination_links() {
239 239
         global $invoices_template;
240 240
 
241
-        return apply_filters( 'wpinv_bp_get_pagination_links', $invoices_template->pag_links );
241
+        return apply_filters('wpinv_bp_get_pagination_links', $invoices_template->pag_links);
242 242
     }
243 243
     
244
-    public function bp_section( $settings = array() ) {
245
-        $settings['wpinv_bp'] = __( 'BuddyPress Integration', 'invoicing' );
244
+    public function bp_section($settings = array()) {
245
+        $settings['wpinv_bp'] = __('BuddyPress Integration', 'invoicing');
246 246
         return $settings;
247 247
     }
248 248
     
249
-    public function bp_settings( $settings = array() ) {
249
+    public function bp_settings($settings = array()) {
250 250
         $settings['wpinv_bp'] = array(
251 251
             'wpinv_bp_labels' => array(
252 252
                 'id'   => 'wpinv_bp_settings',
253
-                'name' => '<h3>' . __( 'BuddyPress Integration', 'invoicing' ) . '</h3>',
253
+                'name' => '<h3>' . __('BuddyPress Integration', 'invoicing') . '</h3>',
254 254
                 'desc' => '',
255 255
                 'type' => 'header',
256 256
             ),
257 257
             'wpinv_bp_hide_menu' => array(
258 258
                 'id'   => 'wpinv_bp_hide_menu',
259
-                'name' => __( 'Hide Invoices link', 'invoicing' ),
260
-                'desc' => __( 'Hide Invoices link from BP Profile menu.', 'invoicing' ),
259
+                'name' => __('Hide Invoices link', 'invoicing'),
260
+                'desc' => __('Hide Invoices link from BP Profile menu.', 'invoicing'),
261 261
                 'type' => 'checkbox',
262 262
             ),
263 263
             'wpinv_menu_position' => array(
264 264
                 'id'   => 'wpinv_menu_position',
265
-                'name' => __( 'Menu position', 'invoicing' ),
266
-                'desc' => __( 'Menu position for the Invoices link in BP Profile menu.', 'invoicing' ),
265
+                'name' => __('Menu position', 'invoicing'),
266
+                'desc' => __('Menu position for the Invoices link in BP Profile menu.', 'invoicing'),
267 267
                 'type' => 'number',
268 268
                 'size' => 'small',
269 269
                 'min'  => '1',
@@ -273,8 +273,8 @@  discard block
 block discarded – undo
273 273
             ),
274 274
             'wpinv_bp_per_page' => array(
275 275
                 'id'   => 'wpinv_bp_per_page',
276
-                'name' => __( 'Max invoices per page', 'invoicing' ),
277
-                'desc' => __( 'Enter a number to lists the invoices for each page.', 'invoicing' ),
276
+                'name' => __('Max invoices per page', 'invoicing'),
277
+                'desc' => __('Enter a number to lists the invoices for each page.', 'invoicing'),
278 278
                 'type' => 'number',
279 279
                 'size' => 'small',
280 280
                 'min'  => '1',
@@ -287,20 +287,20 @@  discard block
 block discarded – undo
287 287
         return $settings;
288 288
     }
289 289
 
290
-    public function wp_nav_menu_objects($items, $args){
291
-        if(!is_user_logged_in()){
290
+    public function wp_nav_menu_objects($items, $args) {
291
+        if (!is_user_logged_in()) {
292 292
             return $items;
293 293
         }
294 294
 
295
-        if(!apply_filters('wpinv_bp_invoice_history_redirect', true, $items, $args)){
295
+        if (!apply_filters('wpinv_bp_invoice_history_redirect', true, $items, $args)) {
296 296
             return $items;
297 297
         }
298 298
 
299 299
         $user_id = get_current_user_id();
300
-        $link = bp_core_get_user_domain( $user_id ).WPINV_BP_SLUG;
300
+        $link = bp_core_get_user_domain($user_id) . WPINV_BP_SLUG;
301 301
         $history_link = wpinv_get_history_page_uri();
302
-        foreach ( $items as $item ) {
303
-            $item->url = str_replace( $history_link, $link, $item->url );
302
+        foreach ($items as $item) {
303
+            $item->url = str_replace($history_link, $link, $item->url);
304 304
         }
305 305
 
306 306
         return $items;
@@ -318,25 +318,25 @@  discard block
 block discarded – undo
318 318
     public $pag_links = '';
319 319
     public $total_invoice_count = 0;
320 320
     
321
-    public function __construct( $status, $page, $per_page, $max, $user_id, $page_arg = 'bpage' ) {
322
-        $this->invoices = array( 'invoices' => array(), 'total' => 0 );
321
+    public function __construct($status, $page, $per_page, $max, $user_id, $page_arg = 'bpage') {
322
+        $this->invoices = array('invoices' => array(), 'total' => 0);
323 323
         
324
-        $this->pag_arg  = sanitize_key( $page_arg );
325
-        $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $page );
326
-        $this->pag_num  = bp_sanitize_pagination_arg( 'num', $per_page );
324
+        $this->pag_arg  = sanitize_key($page_arg);
325
+        $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $page);
326
+        $this->pag_num  = bp_sanitize_pagination_arg('num', $per_page);
327 327
 
328
-        $query_args     = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true );
329
-        if ( !empty( $status ) && $status != 'all' ) {
328
+        $query_args     = array('user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true);
329
+        if (!empty($status) && $status != 'all') {
330 330
            $query_args['status'] = $status;
331 331
         }
332
-        $invoices  = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) );
332
+        $invoices = wpinv_get_invoices(apply_filters('wpinv_bp_user_invoices_query', $query_args));
333 333
         
334
-        if ( !empty( $invoices ) && !empty( $invoices->found_posts ) ) {
335
-            $this->invoices['invoices'] = array_map( 'wpinv_get_invoice', $invoices->posts );
334
+        if (!empty($invoices) && !empty($invoices->found_posts)) {
335
+            $this->invoices['invoices'] = array_map('wpinv_get_invoice', $invoices->posts);
336 336
             $this->invoices['total']    = $invoices->found_posts;
337 337
         }
338 338
 
339
-        if ( empty( $max ) || ( $max >= (int)$this->invoices['total'] ) ) {
339
+        if (empty($max) || ($max >= (int)$this->invoices['total'])) {
340 340
             $this->total_invoice_count = (int)$this->invoices['total'];
341 341
         } else {
342 342
             $this->total_invoice_count = (int)$max;
@@ -344,52 +344,52 @@  discard block
 block discarded – undo
344 344
 
345 345
         $this->invoices = $this->invoices['invoices'];
346 346
 
347
-        $invoice_count = count( $this->invoices );
347
+        $invoice_count = count($this->invoices);
348 348
 
349
-        if ( empty( $max ) || ( $max >= (int)$invoice_count ) ) {
349
+        if (empty($max) || ($max >= (int)$invoice_count)) {
350 350
             $this->invoice_count = (int)$invoice_count;
351 351
         } else {
352 352
             $this->invoice_count = (int)$max;
353 353
         }
354 354
         
355
-        if ( ! empty( $this->total_invoice_count ) && ! empty( $this->pag_num ) ) {
356
-            $this->pag_links = paginate_links( array(
357
-                'base'      => add_query_arg( $this->pag_arg, '%#%' ),
355
+        if (!empty($this->total_invoice_count) && !empty($this->pag_num)) {
356
+            $this->pag_links = paginate_links(array(
357
+                'base'      => add_query_arg($this->pag_arg, '%#%'),
358 358
                 'format'    => '',
359
-                'total'     => ceil( (int)$this->total_invoice_count / (int)$this->pag_num ),
359
+                'total'     => ceil((int)$this->total_invoice_count / (int)$this->pag_num),
360 360
                 'current'   => (int)$this->pag_page,
361
-                'prev_text' => _x( '&larr;', 'Invoice pagination previous text', 'invoicing' ),
362
-                'next_text' => _x( '&rarr;', 'Invoice pagination next text',     'invoicing' ),
361
+                'prev_text' => _x('&larr;', 'Invoice pagination previous text', 'invoicing'),
362
+                'next_text' => _x('&rarr;', 'Invoice pagination next text', 'invoicing'),
363 363
                 'mid_size'  => 1,
364 364
                 'add_args'  => array(),
365
-            ) );
365
+            ));
366 366
         }
367 367
     }
368 368
 
369 369
     public function has_invoices() {
370
-        return (bool) ! empty( $this->invoice_count );
370
+        return (bool)!empty($this->invoice_count);
371 371
     }
372 372
 
373 373
     public function next_invoice() {
374 374
         $this->current_invoice++;
375
-        $this->invoice = $this->invoices[ $this->current_invoice ];
375
+        $this->invoice = $this->invoices[$this->current_invoice];
376 376
 
377 377
         return $this->invoice;
378 378
     }
379 379
 
380 380
     public function rewind_invoices() {
381 381
         $this->current_invoice = -1;
382
-        if ( $this->invoice_count > 0 ) {
382
+        if ($this->invoice_count > 0) {
383 383
             $this->invoice = $this->invoices[0];
384 384
         }
385 385
     }
386 386
 
387 387
     public function invoices() {
388
-        if ( ( $this->current_invoice + 1 ) < $this->invoice_count ) {
388
+        if (($this->current_invoice + 1) < $this->invoice_count) {
389 389
             return true;
390
-        } elseif ( ( $this->current_invoice + 1 ) === $this->invoice_count ) {
390
+        } elseif (($this->current_invoice + 1) === $this->invoice_count) {
391 391
 
392
-            do_action( 'wpinv_bp_invoice_loop_end' );
392
+            do_action('wpinv_bp_invoice_loop_end');
393 393
             
394 394
             $this->rewind_invoices();
395 395
         }
@@ -403,19 +403,19 @@  discard block
 block discarded – undo
403 403
         $this->in_the_loop = true;
404 404
         $this->invoice     = $this->next_invoice();
405 405
 
406
-        if ( 0 === $this->current_invoice ) {
407
-            do_action( 'wpinv_bp_invoice_loop_start' );
406
+        if (0 === $this->current_invoice) {
407
+            do_action('wpinv_bp_invoice_loop_start');
408 408
         }
409 409
     }
410 410
 }
411 411
 
412 412
 function wpinv_bp_setup_component() {
413 413
 
414
-    if(!class_exists( 'BuddyPress' )){
414
+    if (!class_exists('BuddyPress')) {
415 415
         return;
416 416
     }
417 417
 
418 418
     new WPInv_BP_Component();
419 419
 
420 420
 }
421
-add_action( 'bp_loaded', 'wpinv_bp_setup_component' );
422 421
\ No newline at end of file
422
+add_action('bp_loaded', 'wpinv_bp_setup_component');
423 423
\ No newline at end of file
Please login to merge, or discard this patch.