Code Duplication    Length = 27-31 lines in 11 locations

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

@@ 211-237 (lines=27) @@
208
    /**
209
     * @return void
210
     */
211
    private function addEventsAddNew()
212
    {
213
        if (
214
            $this->capabilities->current_user_can(
215
                'ee_edit_events',
216
                'ee_admin_bar_menu_espresso-toolbar-events-new'
217
            )
218
        ) {
219
            $this->admin_bar->add_menu(
220
                array(
221
                    'id'     => 'espresso-toolbar-events-new',
222
                    'parent' => 'espresso-toolbar-events',
223
                    'title'  => '<span class="ee-toolbar-icon"></span>'
224
                                . esc_html__('Add New', 'event_espresso'),
225
                    'href'   => EEH_URL::add_query_args_and_nonce(
226
                        array('action' => 'create_new'),
227
                        $this->events_admin_url
228
                    ),
229
                    'meta'   => array(
230
                        'title'  => esc_html__('Add New', 'event_espresso'),
231
                        'target' => '',
232
                        'class'  => $this->menu_class,
233
                    ),
234
                )
235
            );
236
        }
237
    }
238
239
240
@@ 338-367 (lines=30) @@
335
    /**
336
     * @return void
337
     */
338
    private function addEventsViewToday()
339
    {
340
        if (
341
            $this->capabilities->current_user_can(
342
                'ee_read_events',
343
                'ee_admin_bar_menu_espresso-toolbar-events-today'
344
            )
345
        ) {
346
            $this->admin_bar->add_menu(
347
                array(
348
                    'id'     => 'espresso-toolbar-events-today',
349
                    'parent' => 'espresso-toolbar-events',
350
                    'title'  => '<span class="ee-toolbar-icon"></span>'
351
                                . esc_html__('Today', 'event_espresso'),
352
                    'href'   => EEH_URL::add_query_args_and_nonce(
353
                        array(
354
                            'action' => 'default',
355
                            'status' => 'today'
356
                        ),
357
                        $this->events_admin_url
358
                    ),
359
                    'meta'   => array(
360
                        'title'  => esc_html__('Today', 'event_espresso'),
361
                        'target' => '',
362
                        'class'  => $this->menu_class,
363
                    ),
364
                )
365
            );
366
        }
367
    }
368
369
370
@@ 374-403 (lines=30) @@
371
    /**
372
     * @return void
373
     */
374
    private function addEventsViewThisMonth()
375
    {
376
        if (
377
            $this->capabilities->current_user_can(
378
                'ee_read_events',
379
                'ee_admin_bar_menu_espresso-toolbar-events-month'
380
            )
381
        ) {
382
            $this->admin_bar->add_menu(
383
                array(
384
                    'id'     => 'espresso-toolbar-events-month',
385
                    'parent' => 'espresso-toolbar-events',
386
                    'title'  => '<span class="ee-toolbar-icon"></span>'
387
                                . esc_html__('This Month', 'event_espresso'),
388
                    'href'   => EEH_URL::add_query_args_and_nonce(
389
                        array(
390
                            'action' => 'default',
391
                            'status' => 'month'
392
                        ),
393
                        $this->events_admin_url
394
                    ),
395
                    'meta'   => array(
396
                        'title'  => esc_html__('This Month', 'event_espresso'),
397
                        'target' => '',
398
                        'class'  => $this->menu_class,
399
                    ),
400
                )
401
            );
402
        }
403
    }
404
405
406
@@ 469-499 (lines=31) @@
466
    /**
467
     * @return void
468
     */
469
    private function addRegistrationOverviewTodayApproved()
470
    {
471
        if (
472
            $this->capabilities->current_user_can(
473
                'ee_read_registrations',
474
                'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved'
475
            )
476
        ) {
477
            $this->admin_bar->add_menu(
478
                array(
479
                    'id'     => 'espresso-toolbar-registrations-today-approved',
480
                    'parent' => 'espresso-toolbar-registrations',
481
                    'title'  => '<span class="ee-toolbar-icon"></span>'
482
                                . esc_html__('Approved', 'event_espresso'),
483
                    'href'   => EEH_URL::add_query_args_and_nonce(
484
                        array(
485
                            'action'      => 'default',
486
                            'status'      => 'today',
487
                            '_reg_status' => EEM_Registration::status_id_approved,
488
                        ),
489
                        $this->reg_admin_url
490
                    ),
491
                    'meta'   => array(
492
                        'title'  => esc_html__('Approved', 'event_espresso'),
493
                        'target' => '',
494
                        'class'  => $this->menu_class . ' ee-toolbar-icon-approved',
495
                    ),
496
                )
497
            );
498
        }
499
    }
500
501
502
@@ 506-536 (lines=31) @@
503
    /**
504
     * @return void
505
     */
506
    private function addRegistrationOverviewTodayPendingPayment()
507
    {
508
        if (
509
            $this->capabilities->current_user_can(
510
                'ee_read_registrations',
511
                'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending'
512
            )
513
        ) {
514
            $this->admin_bar->add_menu(
515
                array(
516
                    'id'     => 'espresso-toolbar-registrations-today-pending',
517
                    'parent' => 'espresso-toolbar-registrations',
518
                    'title'  => '<span class="ee-toolbar-icon"></span>'
519
                                . esc_html__('Pending', 'event_espresso'),
520
                    'href'   => EEH_URL::add_query_args_and_nonce(
521
                        array(
522
                            'action'     => 'default',
523
                            'status'     => 'today',
524
                            '_reg_status' => EEM_Registration::status_id_pending_payment,
525
                        ),
526
                        $this->reg_admin_url
527
                    ),
528
                    'meta'   => array(
529
                        'title'  => esc_html__('Pending Payment', 'event_espresso'),
530
                        'target' => '',
531
                        'class'  => $this->menu_class . ' ee-toolbar-icon-pending',
532
                    ),
533
                )
534
            );
535
        }
536
    }
537
538
539
@@ 543-573 (lines=31) @@
540
    /**
541
     * @return void
542
     */
543
    private function addRegistrationOverviewTodayNotApproved()
544
    {
545
        if (
546
            $this->capabilities->current_user_can(
547
                'ee_read_registrations',
548
                'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved'
549
            )
550
        ) {
551
            $this->admin_bar->add_menu(
552
                array(
553
                    'id'     => 'espresso-toolbar-registrations-today-not-approved',
554
                    'parent' => 'espresso-toolbar-registrations',
555
                    'title'  => '<span class="ee-toolbar-icon"></span>'
556
                                . esc_html__('Not Approved', 'event_espresso'),
557
                    'href'   => EEH_URL::add_query_args_and_nonce(
558
                        array(
559
                            'action'      => 'default',
560
                            'status'      => 'today',
561
                            '_reg_status' => EEM_Registration::status_id_not_approved,
562
                        ),
563
                        $this->reg_admin_url
564
                    ),
565
                    'meta'   => array(
566
                        'title'  => esc_html__('Not Approved', 'event_espresso'),
567
                        'target' => '',
568
                        'class'  => $this->menu_class . ' ee-toolbar-icon-not-approved',
569
                    ),
570
                )
571
            );
572
        }
573
    }
574
575
576
@@ 580-610 (lines=31) @@
577
    /**
578
     * @return void
579
     */
580
    private function addRegistrationOverviewTodayCancelled()
581
    {
582
        if (
583
            $this->capabilities->current_user_can(
584
                'ee_read_registrations',
585
                'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled'
586
            )
587
        ) {
588
            $this->admin_bar->add_menu(
589
                array(
590
                    'id'     => 'espresso-toolbar-registrations-today-cancelled',
591
                    'parent' => 'espresso-toolbar-registrations',
592
                    'title'  => '<span class="ee-toolbar-icon"></span>'
593
                                . esc_html__('Cancelled', 'event_espresso'),
594
                    'href'   => EEH_URL::add_query_args_and_nonce(
595
                        array(
596
                            'action'      => 'default',
597
                            'status'      => 'today',
598
                            '_reg_status' => EEM_Registration::status_id_cancelled,
599
                        ),
600
                        $this->reg_admin_url
601
                    ),
602
                    'meta'   => array(
603
                        'title'  => esc_html__('Cancelled', 'event_espresso'),
604
                        'target' => '',
605
                        'class'  => $this->menu_class . ' ee-toolbar-icon-cancelled',
606
                    ),
607
                )
608
            );
609
        }
610
    }
611
612
613
@@ 652-682 (lines=31) @@
649
    /**
650
     * @return void
651
     */
652
    private function addRegistrationOverviewThisMonthApproved()
653
    {
654
        if (
655
            $this->capabilities->current_user_can(
656
                'ee_read_registrations',
657
                'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved'
658
            )
659
        ) {
660
            $this->admin_bar->add_menu(
661
                array(
662
                    'id'     => 'espresso-toolbar-registrations-month-approved',
663
                    'parent' => 'espresso-toolbar-registrations',
664
                    'title'  => '<span class="ee-toolbar-icon"></span>'
665
                                . esc_html__('Approved', 'event_espresso'),
666
                    'href'   => EEH_URL::add_query_args_and_nonce(
667
                        array(
668
                            'action'      => 'default',
669
                            'status'      => 'month',
670
                            '_reg_status' => EEM_Registration::status_id_approved,
671
                        ),
672
                        $this->reg_admin_url
673
                    ),
674
                    'meta'   => array(
675
                        'title'  => esc_html__('Approved', 'event_espresso'),
676
                        'target' => '',
677
                        'class'  => $this->menu_class . ' ee-toolbar-icon-approved',
678
                    ),
679
                )
680
            );
681
        }
682
    }
683
684
685
@@ 689-719 (lines=31) @@
686
    /**
687
     * @return void
688
     */
689
    private function addRegistrationOverviewThisMonthPending()
690
    {
691
        if (
692
            $this->capabilities->current_user_can(
693
                'ee_read_registrations',
694
                'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending'
695
            )
696
        ) {
697
            $this->admin_bar->add_menu(
698
                array(
699
                    'id'     => 'espresso-toolbar-registrations-month-pending',
700
                    'parent' => 'espresso-toolbar-registrations',
701
                    'title'  => '<span class="ee-toolbar-icon"></span>'
702
                                . esc_html__('Pending', 'event_espresso'),
703
                    'href'   => EEH_URL::add_query_args_and_nonce(
704
                        array(
705
                            'action'      => 'default',
706
                            'status'      => 'month',
707
                            '_reg_status' => EEM_Registration::status_id_pending_payment,
708
                        ),
709
                        $this->reg_admin_url
710
                    ),
711
                    'meta'   => array(
712
                        'title'  => esc_html__('Pending', 'event_espresso'),
713
                        'target' => '',
714
                        'class'  => $this->menu_class . ' ee-toolbar-icon-pending',
715
                    ),
716
                )
717
            );
718
        }
719
    }
720
721
722
@@ 726-756 (lines=31) @@
723
    /**
724
     * @return void
725
     */
726
    private function addRegistrationOverviewThisMonthNotApproved()
727
    {
728
        if (
729
            $this->capabilities->current_user_can(
730
                'ee_read_registrations',
731
                'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved'
732
            )
733
        ) {
734
            $this->admin_bar->add_menu(
735
                array(
736
                    'id'     => 'espresso-toolbar-registrations-month-not-approved',
737
                    'parent' => 'espresso-toolbar-registrations',
738
                    'title'  => '<span class="ee-toolbar-icon"></span>'
739
                                . esc_html__('Not Approved', 'event_espresso'),
740
                    'href'   => EEH_URL::add_query_args_and_nonce(
741
                        array(
742
                            'action'      => 'default',
743
                            'status'      => 'month',
744
                            '_reg_status' => EEM_Registration::status_id_not_approved,
745
                        ),
746
                        $this->reg_admin_url
747
                    ),
748
                    'meta'   => array(
749
                        'title'  => esc_html__('Not Approved', 'event_espresso'),
750
                        'target' => '',
751
                        'class'  => $this->menu_class . ' ee-toolbar-icon-not-approved',
752
                    ),
753
                )
754
            );
755
        }
756
    }
757
758
759
@@ 763-793 (lines=31) @@
760
    /**
761
     * @return void
762
     */
763
    private function addRegistrationOverviewThisMonthCancelled()
764
    {
765
        if (
766
            $this->capabilities->current_user_can(
767
                'ee_read_registrations',
768
                'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled'
769
            )
770
        ) {
771
            $this->admin_bar->add_menu(
772
                array(
773
                    'id'     => 'espresso-toolbar-registrations-month-cancelled',
774
                    'parent' => 'espresso-toolbar-registrations',
775
                    'title'  => '<span class="ee-toolbar-icon"></span>'
776
                                . esc_html__('Cancelled', 'event_espresso'),
777
                    'href'   => EEH_URL::add_query_args_and_nonce(
778
                        array(
779
                            'action'      => 'default',
780
                            'status'      => 'month',
781
                            '_reg_status' => EEM_Registration::status_id_cancelled,
782
                        ),
783
                        $this->reg_admin_url
784
                    ),
785
                    'meta'   => array(
786
                        'title'  => esc_html__('Cancelled', 'event_espresso'),
787
                        'target' => '',
788
                        'class'  => $this->menu_class . ' ee-toolbar-icon-cancelled',
789
                    ),
790
                )
791
            );
792
        }
793
    }
794
795
796