Code Duplication    Length = 27-31 lines in 11 locations

core/domain/services/admin/AdminToolBar.php 11 locations

@@ 198-224 (lines=27) @@
195
    /**
196
     * @return void
197
     */
198
    private function addEventsAddNew()
199
    {
200
        if ($this->capabilities->current_user_can(
201
            'ee_edit_events',
202
            'ee_admin_bar_menu_espresso-toolbar-events-new'
203
        )) {
204
            $this->admin_bar->add_menu(
205
                array(
206
                    'id'     => 'espresso-toolbar-events-new',
207
                    'parent' => 'espresso-toolbar-events',
208
                    'title'  => '<span class="ee-toolbar-icon"></span>'
209
                                . esc_html__('Add New', 'event_espresso'),
210
                    'href'   => EEH_URL::add_query_args_and_nonce(
211
                        array('action' => 'create_new'),
212
                        $this->events_admin_url
213
                    ),
214
                    'meta'   => array(
215
                        'title'  => esc_html__('Add New', 'event_espresso'),
216
                        'target' => '',
217
                        'class'  => $this->menu_class,
218
                    ),
219
                )
220
            );
221
        }
222
    }
223
224
225
    /**
226
     * @return void
227
     */
@@ 314-343 (lines=30) @@
311
    /**
312
     * @return void
313
     */
314
    private function addEventsViewToday()
315
    {
316
        if ($this->capabilities->current_user_can(
317
            'ee_read_events',
318
            'ee_admin_bar_menu_espresso-toolbar-events-today'
319
        )) {
320
            $this->admin_bar->add_menu(
321
                array(
322
                    'id'     => 'espresso-toolbar-events-today',
323
                    'parent' => 'espresso-toolbar-events',
324
                    'title'  => '<span class="ee-toolbar-icon"></span>'
325
                                . esc_html__('Today', 'event_espresso'),
326
                    'href'   => EEH_URL::add_query_args_and_nonce(
327
                        array(
328
                            'action' => 'default',
329
                            'status' => 'today',
330
                        ),
331
                        $this->events_admin_url
332
                    ),
333
                    'meta'   => array(
334
                        'title'  => esc_html__('Today', 'event_espresso'),
335
                        'target' => '',
336
                        'class'  => $this->menu_class,
337
                    ),
338
                )
339
            );
340
        }
341
    }
342
343
344
    /**
345
     * @return void
346
     */
@@ 347-376 (lines=30) @@
344
    /**
345
     * @return void
346
     */
347
    private function addEventsViewThisMonth()
348
    {
349
        if ($this->capabilities->current_user_can(
350
            'ee_read_events',
351
            'ee_admin_bar_menu_espresso-toolbar-events-month'
352
        )) {
353
            $this->admin_bar->add_menu(
354
                array(
355
                    'id'     => 'espresso-toolbar-events-month',
356
                    'parent' => 'espresso-toolbar-events',
357
                    'title'  => '<span class="ee-toolbar-icon"></span>'
358
                                . esc_html__('This Month', 'event_espresso'),
359
                    'href'   => EEH_URL::add_query_args_and_nonce(
360
                        array(
361
                            'action' => 'default',
362
                            'status' => 'month',
363
                        ),
364
                        $this->events_admin_url
365
                    ),
366
                    'meta'   => array(
367
                        'title'  => esc_html__('This Month', 'event_espresso'),
368
                        'target' => '',
369
                        'class'  => $this->menu_class,
370
                    ),
371
                )
372
            );
373
        }
374
    }
375
376
377
    /**
378
     * @return void
379
     */
@@ 433-463 (lines=31) @@
430
    /**
431
     * @return void
432
     */
433
    private function addRegistrationOverviewTodayApproved()
434
    {
435
        if ($this->capabilities->current_user_can(
436
            'ee_read_registrations',
437
            'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved'
438
        )) {
439
            $this->admin_bar->add_menu(
440
                array(
441
                    'id'     => 'espresso-toolbar-registrations-today-approved',
442
                    'parent' => 'espresso-toolbar-registrations',
443
                    'title'  => '<span class="ee-toolbar-icon"></span>'
444
                                . esc_html__('Approved', 'event_espresso'),
445
                    'href'   => EEH_URL::add_query_args_and_nonce(
446
                        array(
447
                            'action'      => 'default',
448
                            'status'      => 'today',
449
                            '_reg_status' => EEM_Registration::status_id_approved,
450
                        ),
451
                        $this->reg_admin_url
452
                    ),
453
                    'meta'   => array(
454
                        'title'  => esc_html__('Approved', 'event_espresso'),
455
                        'target' => '',
456
                        'class'  => $this->menu_class . ' ee-toolbar-icon-approved',
457
                    ),
458
                )
459
            );
460
        }
461
    }
462
463
464
    /**
465
     * @return void
466
     */
@@ 467-497 (lines=31) @@
464
    /**
465
     * @return void
466
     */
467
    private function addRegistrationOverviewTodayPendingPayment()
468
    {
469
        if ($this->capabilities->current_user_can(
470
            'ee_read_registrations',
471
            'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending'
472
        )) {
473
            $this->admin_bar->add_menu(
474
                array(
475
                    'id'     => 'espresso-toolbar-registrations-today-pending',
476
                    'parent' => 'espresso-toolbar-registrations',
477
                    'title'  => '<span class="ee-toolbar-icon"></span>'
478
                                . esc_html__('Pending', 'event_espresso'),
479
                    'href'   => EEH_URL::add_query_args_and_nonce(
480
                        array(
481
                            'action'      => 'default',
482
                            'status'      => 'today',
483
                            '_reg_status' => EEM_Registration::status_id_pending_payment,
484
                        ),
485
                        $this->reg_admin_url
486
                    ),
487
                    'meta'   => array(
488
                        'title'  => esc_html__('Pending Payment', 'event_espresso'),
489
                        'target' => '',
490
                        'class'  => $this->menu_class . ' ee-toolbar-icon-pending',
491
                    ),
492
                )
493
            );
494
        }
495
    }
496
497
498
    /**
499
     * @return void
500
     */
@@ 501-531 (lines=31) @@
498
    /**
499
     * @return void
500
     */
501
    private function addRegistrationOverviewTodayNotApproved()
502
    {
503
        if ($this->capabilities->current_user_can(
504
            'ee_read_registrations',
505
            'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved'
506
        )) {
507
            $this->admin_bar->add_menu(
508
                array(
509
                    'id'     => 'espresso-toolbar-registrations-today-not-approved',
510
                    'parent' => 'espresso-toolbar-registrations',
511
                    'title'  => '<span class="ee-toolbar-icon"></span>'
512
                                . esc_html__('Not Approved', 'event_espresso'),
513
                    'href'   => EEH_URL::add_query_args_and_nonce(
514
                        array(
515
                            'action'      => 'default',
516
                            'status'      => 'today',
517
                            '_reg_status' => EEM_Registration::status_id_not_approved,
518
                        ),
519
                        $this->reg_admin_url
520
                    ),
521
                    'meta'   => array(
522
                        'title'  => esc_html__('Not Approved', 'event_espresso'),
523
                        'target' => '',
524
                        'class'  => $this->menu_class . ' ee-toolbar-icon-not-approved',
525
                    ),
526
                )
527
            );
528
        }
529
    }
530
531
532
    /**
533
     * @return void
534
     */
@@ 535-565 (lines=31) @@
532
    /**
533
     * @return void
534
     */
535
    private function addRegistrationOverviewTodayCancelled()
536
    {
537
        if ($this->capabilities->current_user_can(
538
            'ee_read_registrations',
539
            'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled'
540
        )) {
541
            $this->admin_bar->add_menu(
542
                array(
543
                    'id'     => 'espresso-toolbar-registrations-today-cancelled',
544
                    'parent' => 'espresso-toolbar-registrations',
545
                    'title'  => '<span class="ee-toolbar-icon"></span>'
546
                                . esc_html__('Cancelled', 'event_espresso'),
547
                    'href'   => EEH_URL::add_query_args_and_nonce(
548
                        array(
549
                            'action'      => 'default',
550
                            'status'      => 'today',
551
                            '_reg_status' => EEM_Registration::status_id_cancelled,
552
                        ),
553
                        $this->reg_admin_url
554
                    ),
555
                    'meta'   => array(
556
                        'title'  => esc_html__('Cancelled', 'event_espresso'),
557
                        'target' => '',
558
                        'class'  => $this->menu_class . ' ee-toolbar-icon-cancelled',
559
                    ),
560
                )
561
            );
562
        }
563
    }
564
565
566
    /**
567
     * @return void
568
     */
@@ 601-631 (lines=31) @@
598
    /**
599
     * @return void
600
     */
601
    private function addRegistrationOverviewThisMonthApproved()
602
    {
603
        if ($this->capabilities->current_user_can(
604
            'ee_read_registrations',
605
            'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved'
606
        )) {
607
            $this->admin_bar->add_menu(
608
                array(
609
                    'id'     => 'espresso-toolbar-registrations-month-approved',
610
                    'parent' => 'espresso-toolbar-registrations',
611
                    'title'  => '<span class="ee-toolbar-icon"></span>'
612
                                . esc_html__('Approved', 'event_espresso'),
613
                    'href'   => EEH_URL::add_query_args_and_nonce(
614
                        array(
615
                            'action'      => 'default',
616
                            'status'      => 'month',
617
                            '_reg_status' => EEM_Registration::status_id_approved,
618
                        ),
619
                        $this->reg_admin_url
620
                    ),
621
                    'meta'   => array(
622
                        'title'  => esc_html__('Approved', 'event_espresso'),
623
                        'target' => '',
624
                        'class'  => $this->menu_class . ' ee-toolbar-icon-approved',
625
                    ),
626
                )
627
            );
628
        }
629
    }
630
631
632
    /**
633
     * @return void
634
     */
@@ 635-665 (lines=31) @@
632
    /**
633
     * @return void
634
     */
635
    private function addRegistrationOverviewThisMonthPending()
636
    {
637
        if ($this->capabilities->current_user_can(
638
            'ee_read_registrations',
639
            'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending'
640
        )) {
641
            $this->admin_bar->add_menu(
642
                array(
643
                    'id'     => 'espresso-toolbar-registrations-month-pending',
644
                    'parent' => 'espresso-toolbar-registrations',
645
                    'title'  => '<span class="ee-toolbar-icon"></span>'
646
                                . esc_html__('Pending', 'event_espresso'),
647
                    'href'   => EEH_URL::add_query_args_and_nonce(
648
                        array(
649
                            'action'      => 'default',
650
                            'status'      => 'month',
651
                            '_reg_status' => EEM_Registration::status_id_pending_payment,
652
                        ),
653
                        $this->reg_admin_url
654
                    ),
655
                    'meta'   => array(
656
                        'title'  => esc_html__('Pending', 'event_espresso'),
657
                        'target' => '',
658
                        'class'  => $this->menu_class . ' ee-toolbar-icon-pending',
659
                    ),
660
                )
661
            );
662
        }
663
    }
664
665
666
    /**
667
     * @return void
668
     */
@@ 669-699 (lines=31) @@
666
    /**
667
     * @return void
668
     */
669
    private function addRegistrationOverviewThisMonthNotApproved()
670
    {
671
        if ($this->capabilities->current_user_can(
672
            'ee_read_registrations',
673
            'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved'
674
        )) {
675
            $this->admin_bar->add_menu(
676
                array(
677
                    'id'     => 'espresso-toolbar-registrations-month-not-approved',
678
                    'parent' => 'espresso-toolbar-registrations',
679
                    'title'  => '<span class="ee-toolbar-icon"></span>'
680
                                . esc_html__('Not Approved', 'event_espresso'),
681
                    'href'   => EEH_URL::add_query_args_and_nonce(
682
                        array(
683
                            'action'      => 'default',
684
                            'status'      => 'month',
685
                            '_reg_status' => EEM_Registration::status_id_not_approved,
686
                        ),
687
                        $this->reg_admin_url
688
                    ),
689
                    'meta'   => array(
690
                        'title'  => esc_html__('Not Approved', 'event_espresso'),
691
                        'target' => '',
692
                        'class'  => $this->menu_class . ' ee-toolbar-icon-not-approved',
693
                    ),
694
                )
695
            );
696
        }
697
    }
698
699
700
    /**
701
     * @return void
702
     */
@@ 703-733 (lines=31) @@
700
    /**
701
     * @return void
702
     */
703
    private function addRegistrationOverviewThisMonthCancelled()
704
    {
705
        if ($this->capabilities->current_user_can(
706
            'ee_read_registrations',
707
            'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled'
708
        )) {
709
            $this->admin_bar->add_menu(
710
                array(
711
                    'id'     => 'espresso-toolbar-registrations-month-cancelled',
712
                    'parent' => 'espresso-toolbar-registrations',
713
                    'title'  => '<span class="ee-toolbar-icon"></span>'
714
                                . esc_html__('Cancelled', 'event_espresso'),
715
                    'href'   => EEH_URL::add_query_args_and_nonce(
716
                        array(
717
                            'action'      => 'default',
718
                            'status'      => 'month',
719
                            '_reg_status' => EEM_Registration::status_id_cancelled,
720
                        ),
721
                        $this->reg_admin_url
722
                    ),
723
                    'meta'   => array(
724
                        'title'  => esc_html__('Cancelled', 'event_espresso'),
725
                        'target' => '',
726
                        'class'  => $this->menu_class . ' ee-toolbar-icon-cancelled',
727
                    ),
728
                )
729
            );
730
        }
731
    }
732
733
734
    /**
735
     * @return void
736
     */