Passed
Pull Request — master (#205)
by
unknown
04:41
created

WPInv_BP_Component::setup_globals()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
1
<?php
2
if ( ! defined( 'ABSPATH' ) ) {
3
    exit; // Exit if accessed directly
4
}
5
6
class WPInv_BP_Component extends BP_Component {
7
    public $position;
8
    public $slug;
9
    public $count;
10
    
11
    public function __construct() {
12
        global $bp;
13
        
14
        if ( !defined( 'WPINV_BP_SLUG' ) ) {
15
            define( 'WPINV_BP_SLUG', 'invoices' );
16
        }
17
        
18
        $position       = wpinv_get_option( 'wpinv_menu_position' );
19
        $position       = $position !== '' && $position !== false ? $position : 91;
20
        $this->position = apply_filters( 'wpinv_bp_nav_position', $position );
21
        $this->slug     = WPINV_BP_SLUG;
22
        
23
        parent::start(
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (start() instead of __construct()). Are you sure this is correct? If so, you might want to change this to $this->start().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
24
            'invoicing',
25
            _x( 'Invoices', 'Invoices screen page <title>', 'invoicing' ),
26
            trailingslashit( dirname( __FILE__ ) ),
27
            array(
28
                'adminbar_myaccount_order' => $this->position
29
            )
30
        );
31
    }
32
    
33
    public function includes( $includes = array() ) {
34
        parent::includes( $includes );
35
    }
36
    
37
    public function setup_globals( $args = array() ) {
38
        global $bp;
39
40
        $args = array(
41
            'slug' => $this->slug,
42
        );
43
44
        parent::setup_globals( $args );
45
    }
46
    
47
    public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
48
        if ( !bp_is_my_profile() ) {
49
            return;
50
        }
51
        
52
        if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) {
53
            return;
54
        }
55
        
56
        $this->setup_invoice_count();
57
58
        $user_domain    = bp_loggedin_user_domain();
59
        $invoices_link  = trailingslashit( $user_domain . $this->slug );
60
        $class          = ( 0 === $this->count ) ? 'no-count' : 'count';
61
62
        $main_nav_name = sprintf(
63
            __( 'My Invoices %s', 'invoicing' ),
64
            sprintf(
65
                '<span class="%s">%s</span>',
66
                esc_attr( $class ),
67
                bp_core_number_format( $this->count )
68
            )
69
        );
70
71
        $main_nav = array(
0 ignored issues
show
Unused Code introduced by
$main_nav is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
72
            'name'                => $main_nav_name,
73
            'slug'                => $this->slug,
74
            'position'            => $this->position,
75
            'screen_function'     => array( $this, 'invoices_screen' ),
76
            'default_subnav_slug' => 'invoices',
77
            'item_css_id'         => $this->id
78
        );
79
        
80
        $sub_nav[] = array(
81
            'name'            => _x( 'My Invoices', 'Invoices screen sub nav', 'invoicing' ),
82
            'slug'            => 'invoices',
83
            'parent_url'      => $invoices_link,
84
            'parent_slug'     => $this->slug,
85
            'screen_function' => array( $this, 'invoices_screen' ),
86
            'position'        => 10,
87
            'item_css_id'     => 'invoices-my-invoices'
88
        );
89
90
        //parent::setup_nav( $main_nav, $sub_nav );
91
    }
92
93
    public function wpinv_buddypress_setup_nav() {
94
95
        global $bp;
96
97
        $user_domain    = bp_loggedin_user_domain();
98
        $invoices_link  = trailingslashit( $user_domain . $this->slug );
99
        $class          = ( 0 === $this->count ) ? 'no-count' : 'count';
100
101
        $main_nav_name = sprintf(
102
            __( 'My Invoices %s', 'invoicing' ),
103
            sprintf(
104
                '<span class="%s">%s</span>',
105
                esc_attr( $class ),
106
                bp_core_number_format( $this->count )
107
            )
108
        );
109
110
        $main_nav = array(
111
            'name'                => $main_nav_name,
112
            'slug'                => $this->slug,
113
            'position'            => $this->position,
114
            'screen_function'     => array( $this, 'invoices_screen' ),
115
            'default_subnav_slug' => 'invoices',
116
            'item_css_id'         => $this->id
117
        );
118
119
        bp_core_new_nav_item( $main_nav );
120
121
        $sub_nav[] = array(
0 ignored issues
show
Coding Style Comprehensibility introduced by
$sub_nav was never initialized. Although not strictly required by PHP, it is generally a good practice to add $sub_nav = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
122
            'name'            => _x(
123
                'My Invoices', 'Invoices screen sub nav', 'invoicing' ),
124
            'slug'            => 'invoices',
125
            'parent_url'      => $invoices_link,
126
            'parent_slug'     => $this->slug,
127
            'screen_function' => array( $this, 'invoices_screen' ),
128
            'position'        => 10,
129
            'item_css_id'     => 'invoices-my-invoices'
130
        );
131
132
133
        bp_core_new_subnav_item( $sub_nav );
134
    }
135
    
136
    public function setup_title() {
137
        // Adjust title.
138
        if ( (bool)bp_is_current_component( 'invoicing' ) ) {
139
            global $bp;
140
            
141
            $bp->bp_options_title = __( 'My Invoices', 'invoicing' );
142
        }
143
144
        parent::setup_title();
145
    }
146
    
147
    public function invoices_screen() {
148
        if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) {
149
            return;
150
        }
151
        
152
        global $bp;
153
        
154
        add_action( 'bp_template_content', array( $this, 'invoices_content' ) );
155
156
        $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' );
157
        
158
        bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) );
159
    }
160
    
161
    public function invoices_content() {
162
        if ( $this->has_invoices( bp_ajax_querystring( 'invoices' ) ) ) {
163
            global $invoices_template;
164
            
165
            do_action( 'wpinv_bp_invoices_before_content' );
166
            ?>
167
            <div class="wpi-g wpi-bp-invoices invoices invoicing" style="position:relative">
168
                <div id="pag-top" class="pagination">
169
                    <div class="pag-count" id="invoice-dir-count-top">
170
                        <?php echo $this->pagination_count(); ?>
171
                    </div>
172
                    <div class="pagination-links" id="invoice-dir-pag-top">
173
                        <?php echo $this->pagination_links(); ?>
174
                    </div>
175
                </div>
176
                <table class="table table-bordered table-hover table-responsive wpi-user-invoices" style="margin:0">
177
                    <thead>
178
                        <tr>
179 View Code Duplication
                            <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
180
                                <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>
181
                            <?php endforeach; ?>
182
                        </tr>
183
                    </thead>
184
                    <tbody>
185 View Code Duplication
                        <?php foreach ( $invoices_template->invoices as $invoice ) {
186
                            ?>
187
                            <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>">
188
                                <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
189
                                    <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'] ); ?>">
190
                                        <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?>
191
                                            <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?>
192
193
                                        <?php elseif ( 'invoice-number' === $column_id ) : ?>
194
                                            <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>">
195
                                                <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?>
196
                                            </a>
197
198
                                        <?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' ); ?>
199
                                            <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
200
201
                                        <?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 ); ?>
202
                                            <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
203
204
                                        <?php elseif ( 'invoice-status' === $column_id ) : ?>
205
                                            <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?>
206
207
                                        <?php elseif ( 'invoice-total' === $column_id ) : ?>
208
                                            <?php echo $invoice->get_total( true ); ?>
209
210
                                        <?php elseif ( 'invoice-actions' === $column_id ) : ?>
211
                                            <?php
212
                                                $actions = array(
213
                                                    'pay'    => array(
214
                                                        'url'  => $invoice->get_checkout_payment_url(),
215
                                                        'name' => __( 'Pay Now', 'invoicing' ),
216
                                                        'class' => 'btn-success'
217
                                                    ),
218
                                                    'print'   => array(
219
                                                        'url'  => $invoice->get_view_url(),
220
                                                        'name' => __( 'Print', 'invoicing' ),
221
                                                        'class' => 'btn-primary',
222
                                                        'attrs' => 'target="_blank"'
223
                                                    )
224
                                                );
225
226
                                                if ( ! $invoice->needs_payment() ) {
227
                                                    unset( $actions['pay'] );
228
                                                }
229
230
                                                if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) {
231
                                                    foreach ( $actions as $key => $action ) {
232
                                                        $class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
233
                                                        echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
234
                                                    }
235
                                                }
236
                                            ?>
237
                                        <?php endif; ?>
238
                                    </td>
239
                                <?php endforeach; ?>
240
                            </tr>
241
                        <?php } ?>
242
                    </tbody>
243
                </table>
244
                <div id="pag-bottom" class="pagination">
245
                    <div class="pag-count" id="invoice-dir-count-bottom">
246
                        <?php echo $this->pagination_count(); ?>
247
                    </div>
248
                    <div class="pagination-links" id="invoice-dir-pag-bottom">
249
                        <?php echo $this->pagination_links(); ?>
250
                    </div>
251
                </div>
252
                <script type="text/javascript">
253
                jQuery('.wpi-bp-invoices .pagination-links').click(function(e) {
254
                    jQuery('table.wpi-user-invoices').css({'opacity': '0.67'});
255
                    jQuery('.wpi-bp-invoices').append('<span style="position:absolute;top:49.5%;left:49.5%;"><i class="fa fa-spin fa-refresh"></i></span>');
256
                });
257
                </script>
258
            </div>
259
            <?php
260
        
261
            do_action( 'wpinv_bp_invoices_after_content' );
262
        } else {
263
            ?>
264
            <div id="message" class="info">
265
                <p><?php _e( 'No invoice has been made yet.', 'invoicing' ); ?></p>
266
            </div>
267
            <?php
268
        }
269
        
270
        if ( defined( 'DOING_AJAX' ) ) {
271
            exit;
272
        }
273
    }
274
    
275
    public function has_invoices( $args = '' ) {
276
        global $invoices_template;
277
278
        $per_page = absint( wpinv_get_option( 'wpinv_bp_per_page' ) );
279
        // Parse arguments.
280
        $r = bp_parse_args( $args, array(
281
            'status'            => 'all',
282
            'page_arg'          => 'bpage',
283
            'page'              => 1,
284
            'per_page'          => $per_page > 0 ? $per_page : 20,
285
            'max'               => false,
286
            'user_id'           => bp_loggedin_user_id(),
287
        ), 'has_invoices' );
288
289
290
        if ( ! empty( $r['max'] ) && ( (int)$r['per_page'] > (int)$r['max'] ) ) {
291
            $r['per_page'] = (int)$r['max'];
292
        }
293
294
        // Get the invoices.
295
        $invoices_template = new WPInv_BP_Invoices_Template( $r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg'] );
296
297
        return apply_filters( 'wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r );
298
    }
299
    
300
    public function setup_invoice_count() {
301
        $query      = apply_filters( 'wpinv_user_invoices_count_query', array( 'user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false ) );
302
        $invoices   = wpinv_get_invoices( $query );
303
        
304
        $this->count = !empty( $invoices ) ? count( $invoices ) : 0;
305
    }
306
    
307
    public function pagination_count() {
308
        global $invoices_template;
309
310
        $start_num = intval( ( $invoices_template->pag_page - 1 ) * $invoices_template->pag_num ) + 1;
311
        $from_num  = bp_core_number_format( $start_num );
312
        $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 ) );
313
        $total     = bp_core_number_format( $invoices_template->total_invoice_count );
314
315
        if ( 1 == $invoices_template->total_invoice_count ) {
316
            $message = __( 'Viewing 1 invoice', 'invoicing' );
317
        } else {
318
            $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 );
319
        }
320
321
        return $message;
322
    }
323
    
324
    function pagination_links() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
325
        global $invoices_template;
326
327
        return apply_filters( 'wpinv_bp_get_pagination_links', $invoices_template->pag_links );
328
    }
329
    
330
    public function bp_section( $settings = array() ) {
331
        $settings['wpinv_bp'] = __( 'BuddyPress Integration', 'invoicing' );
332
        return $settings;
333
    }
334
    
335
    public function bp_settings( $settings = array() ) {
336
        $settings['wpinv_bp'] = array(
337
            'wpinv_bp_labels' => array(
338
                'id'   => 'wpinv_bp_settings',
339
                'name' => '<h3>' . __( 'BuddyPress Integration', 'invoicing' ) . '</h3>',
340
                'desc' => '',
341
                'type' => 'header',
342
            ),
343
            'wpinv_bp_hide_menu' => array(
344
                'id'   => 'wpinv_bp_hide_menu',
345
                'name' => __( 'Hide Invoices link', 'invoicing' ),
346
                'desc' => __( 'Hide Invoices link from BP Profile menu.', 'invoicing' ),
347
                'type' => 'checkbox',
348
            ),
349
            'wpinv_menu_position' => array(
350
                'id'   => 'wpinv_menu_position',
351
                'name' => __( 'Menu position', 'invoicing' ),
352
                'desc' => __( 'Menu position for the Invoices link in BP Profile menu.', 'invoicing' ),
353
                'type' => 'number',
354
                'size' => 'small',
355
                'min'  => '1',
356
                'max'  => '100000',
357
                'step' => '1',
358
                'std'  => '91'
359
            ),
360
            'wpinv_bp_per_page' => array(
361
                'id'   => 'wpinv_bp_per_page',
362
                'name' => __( 'Max invoices per page', 'invoicing' ),
363
                'desc' => __( 'Enter a number to lists the invoices for each page.', 'invoicing' ),
364
                'type' => 'number',
365
                'size' => 'small',
366
                'min'  => '1',
367
                'max'  => '1000',
368
                'step' => '1',
369
                'std'  => '20'
370
            ),
371
        );
372
        
373
        return $settings;
374
    }
375
376
    public function wp_nav_menu_objects($items, $args){
377
        if(!is_user_logged_in()){
378
            return $items;
379
        }
380
381
        if(!apply_filters('wpinv_bp_invoice_history_redirect', true, $items, $args)){
382
            return $items;
383
        }
384
385
        $user_id = get_current_user_id();
386
        $link = bp_core_get_user_domain( $user_id ).WPINV_BP_SLUG;
387
        $history_link = wpinv_get_history_page_uri();
388
        foreach ( $items as $item ) {
389
            $item->url = str_replace( $history_link, $link, $item->url );
390
        }
391
392
        return $items;
393
    }
394
}
395
396
class WPInv_BP_Invoices_Template {
397
    public $current_invoice = -1;
398
    public $invoice_count = 0;
399
    public $invoices = array();
400
    public $invoice;
401
    public $in_the_loop = false;
402
    public $pag_page = 1;
403
    public $pag_num = 20;
404
    public $pag_links = '';
405
    public $total_invoice_count = 0;
406
    
407
    public function __construct( $status, $page, $per_page, $max, $user_id, $page_arg = 'bpage' ) {
408
        $this->invoices = array( 'invoices' => array(), 'total' => 0 );
409
        
410
        $this->pag_arg  = sanitize_key( $page_arg );
0 ignored issues
show
Bug introduced by
The property pag_arg does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
411
        $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $page );
412
        $this->pag_num  = bp_sanitize_pagination_arg( 'num', $per_page );
413
414
        $query_args     = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true );
415
        if ( !empty( $status ) && $status != 'all' ) {
416
           $query_args['status'] = $status;
417
        }
418
        $invoices  = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) );
419
        
420
        if ( !empty( $invoices ) && !empty( $invoices->found_posts ) ) {
421
            $this->invoices['invoices'] = array_map( 'wpinv_get_invoice', $invoices->posts );
422
            $this->invoices['total']    = $invoices->found_posts;
423
        }
424
425
        if ( empty( $max ) || ( $max >= (int)$this->invoices['total'] ) ) {
426
            $this->total_invoice_count = (int)$this->invoices['total'];
427
        } else {
428
            $this->total_invoice_count = (int)$max;
429
        }
430
431
        $this->invoices = $this->invoices['invoices'];
432
433
        $invoice_count = count( $this->invoices );
434
435
        if ( empty( $max ) || ( $max >= (int)$invoice_count ) ) {
436
            $this->invoice_count = (int)$invoice_count;
437
        } else {
438
            $this->invoice_count = (int)$max;
439
        }
440
        
441
        if ( ! empty( $this->total_invoice_count ) && ! empty( $this->pag_num ) ) {
442
            $this->pag_links = paginate_links( array(
443
                'base'      => add_query_arg( $this->pag_arg, '%#%' ),
444
                'format'    => '',
445
                'total'     => ceil( (int)$this->total_invoice_count / (int)$this->pag_num ),
446
                'current'   => (int)$this->pag_page,
447
                'prev_text' => _x( '&larr;', 'Invoice pagination previous text', 'invoicing' ),
448
                'next_text' => _x( '&rarr;', 'Invoice pagination next text',     'invoicing' ),
449
                'mid_size'  => 1,
450
                'add_args'  => array(),
451
            ) );
452
        }
453
    }
454
455
    public function has_invoices() {
456
        return (bool) ! empty( $this->invoice_count );
457
    }
458
459
    public function next_invoice() {
460
        $this->current_invoice++;
461
        $this->invoice = $this->invoices[ $this->current_invoice ];
462
463
        return $this->invoice;
464
    }
465
466
    public function rewind_invoices() {
467
        $this->current_invoice = -1;
468
        if ( $this->invoice_count > 0 ) {
469
            $this->invoice = $this->invoices[0];
470
        }
471
    }
472
473
    public function invoices() {
474
        if ( ( $this->current_invoice + 1 ) < $this->invoice_count ) {
475
            return true;
476
        } elseif ( ( $this->current_invoice + 1 ) === $this->invoice_count ) {
477
478
            do_action( 'wpinv_bp_invoice_loop_end' );
479
            
480
            $this->rewind_invoices();
481
        }
482
483
        $this->in_the_loop = false;
484
        return false;
485
    }
486
487
    public function the_invoice() {
488
489
        $this->in_the_loop = true;
490
        $this->invoice     = $this->next_invoice();
491
492
        if ( 0 === $this->current_invoice ) {
493
            do_action( 'wpinv_bp_invoice_loop_start' );
494
        }
495
    }
496
}
497
498
function wpinv_bp_setup_component() {
499
    global $bp;
500
501
    $bp->invoicing = new WPInv_BP_Component();
502
    
503
    add_action( 'wp_ajax_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) );
504
    add_action( 'wp_ajax_nopriv_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) );
505
    add_filter( 'wpinv_settings_sections_general', array( $bp->invoicing, 'bp_section' ), 10, 1 );
506
    add_filter( 'wpinv_settings_general', array( $bp->invoicing, 'bp_settings' ), 10, 1 );
507
    add_filter( 'wp_nav_menu_objects', array( $bp->invoicing, 'wp_nav_menu_objects' ), 10, 2 );
508
    add_action('bp_setup_nav', array($bp->invoicing, 'wpinv_buddypress_setup_nav'), 15);
509
}
510
add_action( 'bp_loaded', 'wpinv_bp_setup_component' );