| Conditions | 26 | 
| Paths | > 20000 | 
| Total Lines | 469 | 
| Code Lines | 302 | 
| Lines | 86 | 
| Ratio | 18.34 % | 
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php  | 
            ||
| 557 | 	public function add_my_sites_submenu( $wp_admin_bar ) { | 
            ||
| 558 | $current_user = wp_get_current_user();  | 
            ||
| 559 | |||
| 560 | $blog_name = get_bloginfo( 'name' );  | 
            ||
| 561 | 		if ( empty( $blog_name ) ) { | 
            ||
| 562 | $blog_name = $this->primary_site_slug;  | 
            ||
| 563 | }  | 
            ||
| 564 | |||
| 565 | 		if ( mb_strlen( $blog_name ) > 20 ) { | 
            ||
| 566 | $blog_name = mb_substr( html_entity_decode( $blog_name, ENT_QUOTES ), 0, 20 ) . '…';  | 
            ||
| 567 | }  | 
            ||
| 568 | |||
| 569 | $wp_admin_bar->add_menu( array(  | 
            ||
| 570 | 'parent' => 'root-default',  | 
            ||
| 571 | 'id' => 'blog',  | 
            ||
| 572 | 'title' => _n( 'My Site', 'My Sites', $this->user_site_count, 'jetpack' ),  | 
            ||
| 573 | 'href' => '#',  | 
            ||
| 574 | 'meta' => array(  | 
            ||
| 575 | 'class' => 'my-sites mb-trackable',  | 
            ||
| 576 | ),  | 
            ||
| 577 | ) );  | 
            ||
| 578 | |||
| 579 | 		if ( $this->user_site_count > 1 ) { | 
            ||
| 580 | $wp_admin_bar->add_menu( array(  | 
            ||
| 581 | 'parent' => 'blog',  | 
            ||
| 582 | 'id' => 'switch-site',  | 
            ||
| 583 | 'title' => esc_html__( 'Switch Site', 'jetpack' ),  | 
            ||
| 584 | 'href' => 'https://wordpress.com/sites',  | 
            ||
| 585 | ) );  | 
            ||
| 586 | 		} else { | 
            ||
| 587 | $wp_admin_bar->add_menu( array(  | 
            ||
| 588 | 'parent' => 'blog',  | 
            ||
| 589 | 'id' => 'new-site',  | 
            ||
| 590 | 'title' => esc_html__( '+ Add New WordPress', 'jetpack' ),  | 
            ||
| 591 | 'href' => 'https://wordpress.com/start?ref=admin-bar-logged-in',  | 
            ||
| 592 | ) );  | 
            ||
| 593 | }  | 
            ||
| 594 | |||
| 595 | 		if ( is_user_member_of_blog( $current_user->ID ) ) { | 
            ||
| 596 | $blavatar = '';  | 
            ||
| 597 | $class = 'current-site';  | 
            ||
| 598 | |||
| 599 | 			if ( has_site_icon() ) { | 
            ||
| 600 | $src = get_site_icon_url();  | 
            ||
| 601 | $blavatar = '<img class="avatar" src="'. esc_attr( $src ) . '" alt="Current site avatar">';  | 
            ||
| 602 | $class = 'has-blavatar';  | 
            ||
| 603 | }  | 
            ||
| 604 | |||
| 605 | $blog_info = '<div class="ab-site-icon">' . $blavatar . '</div>';  | 
            ||
| 606 | $blog_info .= '<span class="ab-site-title">' . esc_html( $blog_name ) . '</span>';  | 
            ||
| 607 | $blog_info .= '<span class="ab-site-description">' . esc_html( $this->primary_site_url ) . '</span>';  | 
            ||
| 608 | |||
| 609 | $wp_admin_bar->add_menu( array(  | 
            ||
| 610 | 'parent' => 'blog',  | 
            ||
| 611 | 'id' => 'blog-info',  | 
            ||
| 612 | 'title' => $blog_info,  | 
            ||
| 613 | 'href' => esc_url( trailingslashit( $this->primary_site_url ) ),  | 
            ||
| 614 | 'meta' => array(  | 
            ||
| 615 | 'class' => $class,  | 
            ||
| 616 | ),  | 
            ||
| 617 | ) );  | 
            ||
| 618 | }  | 
            ||
| 619 | |||
| 620 | // Site Preview  | 
            ||
| 621 | 		if ( is_admin() ) { | 
            ||
| 622 | $wp_admin_bar->add_menu( array(  | 
            ||
| 623 | 'parent' => 'blog',  | 
            ||
| 624 | 'id' => 'site-view',  | 
            ||
| 625 | 'title' => __( 'View Site', 'jetpack' ),  | 
            ||
| 626 | 'href' => home_url(),  | 
            ||
| 627 | 'meta' => array(  | 
            ||
| 628 | 'class' => 'mb-icon',  | 
            ||
| 629 | 'target' => '_blank',  | 
            ||
| 630 | ),  | 
            ||
| 631 | ) );  | 
            ||
| 632 | }  | 
            ||
| 633 | |||
| 634 | // Stats  | 
            ||
| 635 | View Code Duplication | 		if ( Jetpack::is_module_active( 'stats' ) ) { | 
            |
| 636 | $wp_admin_bar->add_menu( array(  | 
            ||
| 637 | 'parent' => 'blog',  | 
            ||
| 638 | 'id' => 'blog-stats',  | 
            ||
| 639 | 'title' => esc_html__( 'Stats', 'jetpack' ),  | 
            ||
| 640 | 'href' => 'https://wordpress.com/stats/' . esc_attr( $this->primary_site_slug ),  | 
            ||
| 641 | 'meta' => array(  | 
            ||
| 642 | 'class' => 'mb-icon',  | 
            ||
| 643 | ),  | 
            ||
| 644 | ) );  | 
            ||
| 645 | }  | 
            ||
| 646 | |||
| 647 | // Add Calypso plans link and plan type indicator  | 
            ||
| 648 | 		if ( is_user_member_of_blog( $current_user->ID ) ) { | 
            ||
| 649 | $plans_url = 'https://wordpress.com/plans/' . esc_attr( $this->primary_site_slug );  | 
            ||
| 650 | $label = esc_html__( 'Plan', 'jetpack' );  | 
            ||
| 651 | $plan = Jetpack::get_active_plan();  | 
            ||
| 652 | |||
| 653 | $plan_title = $this->create_menu_item_pair(  | 
            ||
| 654 | array(  | 
            ||
| 655 | 'url' => $plans_url,  | 
            ||
| 656 | 'id' => 'wp-admin-bar-plan',  | 
            ||
| 657 | 'label' => $label,  | 
            ||
| 658 | ),  | 
            ||
| 659 | array(  | 
            ||
| 660 | 'url' => $plans_url,  | 
            ||
| 661 | 'id' => 'wp-admin-bar-plan-badge',  | 
            ||
| 662 | 'label' => $plan['product_name_short']  | 
            ||
| 663 | )  | 
            ||
| 664 | );  | 
            ||
| 665 | |||
| 666 | $wp_admin_bar->add_menu( array(  | 
            ||
| 667 | 'parent' => 'blog',  | 
            ||
| 668 | 'id' => 'plan',  | 
            ||
| 669 | 'title' => $plan_title,  | 
            ||
| 670 | 'meta' => array(  | 
            ||
| 671 | 'class' => 'inline-action',  | 
            ||
| 672 | ),  | 
            ||
| 673 | ) );  | 
            ||
| 674 | }  | 
            ||
| 675 | |||
| 676 | // Publish group  | 
            ||
| 677 | $wp_admin_bar->add_group( array(  | 
            ||
| 678 | 'parent' => 'blog',  | 
            ||
| 679 | 'id' => 'publish',  | 
            ||
| 680 | ) );  | 
            ||
| 681 | |||
| 682 | // Publish header  | 
            ||
| 683 | $wp_admin_bar->add_menu( array(  | 
            ||
| 684 | 'parent' => 'publish',  | 
            ||
| 685 | 'id' => 'publish-header',  | 
            ||
| 686 | 'title' => esc_html_x( 'Manage', 'admin bar menu group label', 'jetpack' ),  | 
            ||
| 687 | 'meta' => array(  | 
            ||
| 688 | 'class' => 'ab-submenu-header',  | 
            ||
| 689 | ),  | 
            ||
| 690 | ) );  | 
            ||
| 691 | |||
| 692 | // Pages  | 
            ||
| 693 | $pages_title = $this->create_menu_item_pair(  | 
            ||
| 694 | array(  | 
            ||
| 695 | 'url' => 'https://wordpress.com/pages/' . esc_attr( $this->primary_site_slug ),  | 
            ||
| 696 | 'id' => 'wp-admin-bar-edit-page',  | 
            ||
| 697 | 'label' => esc_html__( 'Site Pages', 'jetpack' ),  | 
            ||
| 698 | ),  | 
            ||
| 699 | array(  | 
            ||
| 700 | 'url' => 'https://wordpress.com/page/' . esc_attr( $this->primary_site_slug ),  | 
            ||
| 701 | 'id' => 'wp-admin-bar-new-page-badge',  | 
            ||
| 702 | 'label' => esc_html_x( 'Add', 'admin bar menu new item label', 'jetpack' ),  | 
            ||
| 703 | )  | 
            ||
| 704 | );  | 
            ||
| 705 | |||
| 706 | 		if ( ! current_user_can( 'edit_pages' ) ) { | 
            ||
| 707 | $pages_title = $this->create_menu_item_anchor(  | 
            ||
| 708 | 'ab-item ab-primary mb-icon',  | 
            ||
| 709 | 'https://wordpress.com/pages/' . esc_attr( $this->primary_site_slug ),  | 
            ||
| 710 | esc_html__( 'Site Pages', 'jetpack' ),  | 
            ||
| 711 | 'wp-admin-bar-edit-page'  | 
            ||
| 712 | );  | 
            ||
| 713 | }  | 
            ||
| 714 | |||
| 715 | $wp_admin_bar->add_menu( array(  | 
            ||
| 716 | 'parent' => 'publish',  | 
            ||
| 717 | 'id' => 'new-page',  | 
            ||
| 718 | 'title' => $pages_title,  | 
            ||
| 719 | 'meta' => array(  | 
            ||
| 720 | 'class' => 'inline-action',  | 
            ||
| 721 | ),  | 
            ||
| 722 | ) );  | 
            ||
| 723 | |||
| 724 | // Blog Posts  | 
            ||
| 725 | $posts_title = $this->create_menu_item_pair(  | 
            ||
| 726 | array(  | 
            ||
| 727 | 'url' => 'https://wordpress.com/posts/' . esc_attr( $this->primary_site_slug ),  | 
            ||
| 728 | 'id' => 'wp-admin-bar-edit-post',  | 
            ||
| 729 | 'label' => esc_html__( 'Blog Posts', 'jetpack' ),  | 
            ||
| 730 | ),  | 
            ||
| 731 | array(  | 
            ||
| 732 | 'url' => 'https://wordpress.com/post/' . esc_attr( $this->primary_site_slug ),  | 
            ||
| 733 | 'id' => 'wp-admin-bar-new-post-badge',  | 
            ||
| 734 | 'label' => esc_html_x( 'Add', 'admin bar menu new item label', 'jetpack' ),  | 
            ||
| 735 | )  | 
            ||
| 736 | );  | 
            ||
| 737 | |||
| 738 | 		if ( ! current_user_can( 'edit_posts' ) ) { | 
            ||
| 739 | $posts_title = $this->create_menu_item_anchor(  | 
            ||
| 740 | 'ab-item ab-primary mb-icon',  | 
            ||
| 741 | 'https://wordpress.com/posts/' . esc_attr( $this->primary_site_slug ),  | 
            ||
| 742 | esc_html__( 'Blog Posts', 'jetpack' ),  | 
            ||
| 743 | 'wp-admin-bar-edit-post'  | 
            ||
| 744 | );  | 
            ||
| 745 | }  | 
            ||
| 746 | |||
| 747 | $wp_admin_bar->add_menu( array(  | 
            ||
| 748 | 'parent' => 'publish',  | 
            ||
| 749 | 'id' => 'new-post',  | 
            ||
| 750 | 'title' => $posts_title,  | 
            ||
| 751 | 'meta' => array(  | 
            ||
| 752 | 'class' => 'inline-action mb-trackable',  | 
            ||
| 753 | ),  | 
            ||
| 754 | ) );  | 
            ||
| 755 | |||
| 756 | // Comments  | 
            ||
| 757 | 		if ( current_user_can( 'moderate_comments' ) ) { | 
            ||
| 758 | $wp_admin_bar->add_menu( array(  | 
            ||
| 759 | 'parent' => 'publish',  | 
            ||
| 760 | 'id' => 'comments',  | 
            ||
| 761 | 'title' => __( 'Comments' ),  | 
            ||
| 762 | 'href' => 'https://wordpress.com/comments/' . esc_attr( $this->primary_site_slug ),  | 
            ||
| 763 | 'meta' => array(  | 
            ||
| 764 | 'class' => 'mb-icon',  | 
            ||
| 765 | ),  | 
            ||
| 766 | ) );  | 
            ||
| 767 | }  | 
            ||
| 768 | |||
| 769 | // Testimonials  | 
            ||
| 770 | View Code Duplication | 		if ( Jetpack::is_module_active( 'custom-content-types' ) && get_option( 'jetpack_testimonial' ) ) { | 
            |
| 771 | $testimonials_title = $this->create_menu_item_pair(  | 
            ||
| 772 | array(  | 
            ||
| 773 | 'url' => 'https://wordpress.com/types/jetpack-testimonial/' . esc_attr( $this->primary_site_slug ),  | 
            ||
| 774 | 'id' => 'wp-admin-bar-edit-testimonial',  | 
            ||
| 775 | 'label' => esc_html__( 'Testimonials', 'jetpack' ),  | 
            ||
| 776 | ),  | 
            ||
| 777 | array(  | 
            ||
| 778 | 'url' => 'https://wordpress.com/edit/jetpack-testimonial/' . esc_attr( $this->primary_site_slug ),  | 
            ||
| 779 | 'id' => 'wp-admin-bar-new-testimonial',  | 
            ||
| 780 | 'label' => esc_html_x( 'Add', 'Button label for adding a new item via the toolbar menu', 'jetpack' ),  | 
            ||
| 781 | )  | 
            ||
| 782 | );  | 
            ||
| 783 | |||
| 784 | 			if ( ! current_user_can( 'edit_pages' ) ) { | 
            ||
| 785 | $testimonials_title = $this->create_menu_item_anchor(  | 
            ||
| 786 | 'ab-item ab-primary mb-icon',  | 
            ||
| 787 | 'https://wordpress.com/types/jetpack-testimonial/' . esc_attr( $this->primary_site_slug ),  | 
            ||
| 788 | esc_html__( 'Testimonials', 'jetpack' ),  | 
            ||
| 789 | 'wp-admin-bar-edit-testimonial'  | 
            ||
| 790 | );  | 
            ||
| 791 | }  | 
            ||
| 792 | |||
| 793 | $wp_admin_bar->add_menu( array(  | 
            ||
| 794 | 'parent' => 'publish',  | 
            ||
| 795 | 'id' => 'new-jetpack-testimonial',  | 
            ||
| 796 | 'title' => $testimonials_title,  | 
            ||
| 797 | 'meta' => array(  | 
            ||
| 798 | 'class' => 'inline-action',  | 
            ||
| 799 | ),  | 
            ||
| 800 | ) );  | 
            ||
| 801 | }  | 
            ||
| 802 | |||
| 803 | // Portfolio  | 
            ||
| 804 | View Code Duplication | 		if ( Jetpack::is_module_active( 'custom-content-types' ) && get_option( 'jetpack_portfolio' ) ) { | 
            |
| 805 | $portfolios_title = $this->create_menu_item_pair(  | 
            ||
| 806 | array(  | 
            ||
| 807 | 'url' => 'https://wordpress.com/types/jetpack-portfolio/' . esc_attr( $this->primary_site_slug ),  | 
            ||
| 808 | 'id' => 'wp-admin-bar-edit-portfolio',  | 
            ||
| 809 | 'label' => esc_html__( 'Portfolio', 'jetpack' ),  | 
            ||
| 810 | ),  | 
            ||
| 811 | array(  | 
            ||
| 812 | 'url' => 'https://wordpress.com/edit/jetpack-portfolio/' . esc_attr( $this->primary_site_slug ),  | 
            ||
| 813 | 'id' => 'wp-admin-bar-new-portfolio',  | 
            ||
| 814 | 'label' => esc_html_x( 'Add', 'Button label for adding a new item via the toolbar menu', 'jetpack' ),  | 
            ||
| 815 | )  | 
            ||
| 816 | );  | 
            ||
| 817 | |||
| 818 | 			if ( ! current_user_can( 'edit_pages' ) ) { | 
            ||
| 819 | $portfolios_title = $this->create_menu_item_anchor(  | 
            ||
| 820 | 'ab-item ab-primary mb-icon',  | 
            ||
| 821 | 'https://wordpress.com/types/jetpack-portfolio/' . esc_attr( $this->primary_site_slug ),  | 
            ||
| 822 | esc_html__( 'Portfolio', 'jetpack' ),  | 
            ||
| 823 | 'wp-admin-bar-edit-portfolio'  | 
            ||
| 824 | );  | 
            ||
| 825 | }  | 
            ||
| 826 | |||
| 827 | $wp_admin_bar->add_menu( array(  | 
            ||
| 828 | 'parent' => 'publish',  | 
            ||
| 829 | 'id' => 'new-jetpack-portfolio',  | 
            ||
| 830 | 'title' => $portfolios_title,  | 
            ||
| 831 | 'meta' => array(  | 
            ||
| 832 | 'class' => 'inline-action',  | 
            ||
| 833 | ),  | 
            ||
| 834 | ) );  | 
            ||
| 835 | }  | 
            ||
| 836 | |||
| 837 | 		if ( current_user_can( 'edit_theme_options' ) ) { | 
            ||
| 838 | // Look and Feel group  | 
            ||
| 839 | $wp_admin_bar->add_group( array(  | 
            ||
| 840 | 'parent' => 'blog',  | 
            ||
| 841 | 'id' => 'look-and-feel',  | 
            ||
| 842 | ) );  | 
            ||
| 843 | |||
| 844 | // Look and Feel header  | 
            ||
| 845 | $wp_admin_bar->add_menu( array(  | 
            ||
| 846 | 'parent' => 'look-and-feel',  | 
            ||
| 847 | 'id' => 'look-and-feel-header',  | 
            ||
| 848 | 'title' => esc_html_x( 'Personalize', 'admin bar menu group label', 'jetpack' ),  | 
            ||
| 849 | 'meta' => array(  | 
            ||
| 850 | 'class' => 'ab-submenu-header',  | 
            ||
| 851 | ),  | 
            ||
| 852 | ) );  | 
            ||
| 853 | |||
| 854 | 			if ( is_admin() ) { | 
            ||
| 855 | // In wp-admin the `return` query arg will return to that page after closing the Customizer  | 
            ||
| 856 | $customizer_url = add_query_arg( array( 'return' => urlencode( site_url( $_SERVER['REQUEST_URI'] ) ) ), wp_customize_url() );  | 
            ||
| 857 | 			} else { | 
            ||
| 858 | // On the frontend the `url` query arg will load that page in the Customizer and also return to it after closing  | 
            ||
| 859 | // non-home URLs won't work unless we undo domain mapping since the Customizer preview is unmapped to always have HTTPS  | 
            ||
| 860 | $current_page = '//' . $this->primary_site_slug . $_SERVER['REQUEST_URI'];  | 
            ||
| 861 | $customizer_url = add_query_arg( array( 'url' => urlencode( $current_page ) ), wp_customize_url() );  | 
            ||
| 862 | }  | 
            ||
| 863 | |||
| 864 | $theme_title = $this->create_menu_item_pair(  | 
            ||
| 865 | array(  | 
            ||
| 866 | 'url' => 'https://wordpress.com/themes/' . esc_attr( $this->primary_site_slug ),  | 
            ||
| 867 | 'id' => 'wp-admin-bar-themes',  | 
            ||
| 868 | 'label' => esc_html__( 'Themes', 'jetpack' ),  | 
            ||
| 869 | ),  | 
            ||
| 870 | array(  | 
            ||
| 871 | 'url' => $customizer_url,  | 
            ||
| 872 | 'id' => 'wp-admin-bar-cmz',  | 
            ||
| 873 | 'label' => esc_html_x( 'Customize', 'admin bar customize item label', 'jetpack' ),  | 
            ||
| 874 | )  | 
            ||
| 875 | );  | 
            ||
| 876 | $meta = array( 'class' => 'mb-icon', 'class' => 'inline-action' );  | 
            ||
| 877 | $href = false;  | 
            ||
| 878 | |||
| 879 | $wp_admin_bar->add_menu( array(  | 
            ||
| 880 | 'parent' => 'look-and-feel',  | 
            ||
| 881 | 'id' => 'themes',  | 
            ||
| 882 | 'title' => $theme_title,  | 
            ||
| 883 | 'href' => $href,  | 
            ||
| 884 | 'meta' => $meta  | 
            ||
| 885 | ) );  | 
            ||
| 886 | }  | 
            ||
| 887 | |||
| 888 | 		if ( current_user_can( 'manage_options' ) ) { | 
            ||
| 889 | // Configuration group  | 
            ||
| 890 | $wp_admin_bar->add_group( array(  | 
            ||
| 891 | 'parent' => 'blog',  | 
            ||
| 892 | 'id' => 'configuration',  | 
            ||
| 893 | ) );  | 
            ||
| 894 | |||
| 895 | // Configuration header  | 
            ||
| 896 | $wp_admin_bar->add_menu( array(  | 
            ||
| 897 | 'parent' => 'configuration',  | 
            ||
| 898 | 'id' => 'configuration-header',  | 
            ||
| 899 | 'title' => esc_html__( 'Configure', 'admin bar menu group label', 'jetpack' ),  | 
            ||
| 900 | 'meta' => array(  | 
            ||
| 901 | 'class' => 'ab-submenu-header',  | 
            ||
| 902 | ),  | 
            ||
| 903 | ) );  | 
            ||
| 904 | |||
| 905 | View Code Duplication | 			if ( Jetpack::is_module_active( 'publicize' ) || Jetpack::is_module_active( 'sharedaddy' ) ) { | 
            |
| 906 | $wp_admin_bar->add_menu( array(  | 
            ||
| 907 | 'parent' => 'configuration',  | 
            ||
| 908 | 'id' => 'sharing',  | 
            ||
| 909 | 'title' => esc_html__( 'Sharing', 'jetpack' ),  | 
            ||
| 910 | 'href' => 'https://wordpress.com/sharing/' . esc_attr( $this->primary_site_slug ),  | 
            ||
| 911 | 'meta' => array(  | 
            ||
| 912 | 'class' => 'mb-icon',  | 
            ||
| 913 | ),  | 
            ||
| 914 | ) );  | 
            ||
| 915 | }  | 
            ||
| 916 | |||
| 917 | $people_title = $this->create_menu_item_pair(  | 
            ||
| 918 | array(  | 
            ||
| 919 | 'url' => 'https://wordpress.com/people/team/' . esc_attr( $this->primary_site_slug ),  | 
            ||
| 920 | 'id' => 'wp-admin-bar-people',  | 
            ||
| 921 | 'label' => esc_html__( 'People', 'jetpack' ),  | 
            ||
| 922 | ),  | 
            ||
| 923 | array(  | 
            ||
| 924 | 'url' => admin_url( 'user-new.php' ),  | 
            ||
| 925 | 'id' => 'wp-admin-bar-people-add',  | 
            ||
| 926 | 'label' => esc_html_x( 'Add', 'admin bar people item label', 'jetpack' ),  | 
            ||
| 927 | )  | 
            ||
| 928 | );  | 
            ||
| 929 | |||
| 930 | $wp_admin_bar->add_menu( array(  | 
            ||
| 931 | 'parent' => 'configuration',  | 
            ||
| 932 | 'id' => 'users-toolbar',  | 
            ||
| 933 | 'title' => $people_title,  | 
            ||
| 934 | 'href' => false,  | 
            ||
| 935 | 'meta' => array(  | 
            ||
| 936 | 'class' => 'inline-action',  | 
            ||
| 937 | ),  | 
            ||
| 938 | ) );  | 
            ||
| 939 | |||
| 940 | $plugins_title = $this->create_menu_item_pair(  | 
            ||
| 941 | array(  | 
            ||
| 942 | 'url' => 'https://wordpress.com/plugins/' . esc_attr( $this->primary_site_slug ),  | 
            ||
| 943 | 'id' => 'wp-admin-bar-plugins',  | 
            ||
| 944 | 'label' => esc_html__( 'Plugins', 'jetpack' ),  | 
            ||
| 945 | ),  | 
            ||
| 946 | array(  | 
            ||
| 947 | 'url' => 'https://wordpress.com/plugins/manage/' . esc_attr( $this->primary_site_slug ),  | 
            ||
| 948 | 'id' => 'wp-admin-bar-plugins-add',  | 
            ||
| 949 | 'label' => esc_html_x( 'Manage', 'Label for the button on the Masterbar to manage plugins', 'jetpack' ),  | 
            ||
| 950 | )  | 
            ||
| 951 | );  | 
            ||
| 952 | |||
| 953 | $wp_admin_bar->add_menu( array(  | 
            ||
| 954 | 'parent' => 'configuration',  | 
            ||
| 955 | 'id' => 'plugins',  | 
            ||
| 956 | 'title' => $plugins_title,  | 
            ||
| 957 | 'href' => false,  | 
            ||
| 958 | 'meta' => array(  | 
            ||
| 959 | 'class' => 'inline-action',  | 
            ||
| 960 | ),  | 
            ||
| 961 | ) );  | 
            ||
| 962 | |||
| 963 | 			if ( jetpack_is_atomic_site() ) { | 
            ||
| 964 | $domain_title = $this->create_menu_item_pair(  | 
            ||
| 965 | array(  | 
            ||
| 966 | 'url' => 'https://wordpress.com/domains/' . esc_attr( $this->primary_site_slug ),  | 
            ||
| 967 | 'id' => 'wp-admin-bar-domains',  | 
            ||
| 968 | 'label' => esc_html__( 'Domains', 'jetpack' ),  | 
            ||
| 969 | ),  | 
            ||
| 970 | array(  | 
            ||
| 971 | 'url' => 'https://wordpress.com/domains/add/' . esc_attr( $this->primary_site_slug ),  | 
            ||
| 972 | 'id' => 'wp-admin-bar-domains-add',  | 
            ||
| 973 | 'label' => esc_html_x( 'Add', 'Label for the button on the Masterbar to add a new domain', 'jetpack' ),  | 
            ||
| 974 | )  | 
            ||
| 975 | );  | 
            ||
| 976 | $wp_admin_bar->add_menu( array(  | 
            ||
| 977 | 'parent' => 'configuration',  | 
            ||
| 978 | 'id' => 'domains',  | 
            ||
| 979 | 'title' => $domain_title,  | 
            ||
| 980 | 'href' => false,  | 
            ||
| 981 | 'meta' => array(  | 
            ||
| 982 | 'class' => 'inline-action',  | 
            ||
| 983 | ),  | 
            ||
| 984 | ) );  | 
            ||
| 985 | }  | 
            ||
| 986 | |||
| 987 | $wp_admin_bar->add_menu( array(  | 
            ||
| 988 | 'parent' => 'configuration',  | 
            ||
| 989 | 'id' => 'blog-settings',  | 
            ||
| 990 | 'title' => esc_html__( 'Settings', 'jetpack' ),  | 
            ||
| 991 | 'href' => 'https://wordpress.com/settings/general/' . esc_attr( $this->primary_site_slug ),  | 
            ||
| 992 | 'meta' => array(  | 
            ||
| 993 | 'class' => 'mb-icon',  | 
            ||
| 994 | ),  | 
            ||
| 995 | ) );  | 
            ||
| 996 | |||
| 997 | 			if ( ! is_admin() ) { | 
            ||
| 998 | $wp_admin_bar->add_menu( array(  | 
            ||
| 999 | 'parent' => 'configuration',  | 
            ||
| 1000 | 'id' => 'legacy-dashboard',  | 
            ||
| 1001 | 'title' => esc_html__( 'Dashboard', 'jetpack' ),  | 
            ||
| 1002 | 'href' => admin_url(),  | 
            ||
| 1003 | 'meta' => array(  | 
            ||
| 1004 | 'class' => 'mb-icon',  | 
            ||
| 1005 | ),  | 
            ||
| 1006 | ) );  | 
            ||
| 1007 | }  | 
            ||
| 1008 | |||
| 1009 | // Restore dashboard menu toggle that is needed on mobile views.  | 
            ||
| 1010 | 			if ( is_admin() ) { | 
            ||
| 1011 | $wp_admin_bar->add_menu( array(  | 
            ||
| 1012 | 'id' => 'menu-toggle',  | 
            ||
| 1013 | 'title' => '<span class="ab-icon"></span><span class="screen-reader-text">' . esc_html__( 'Menu', 'jetpack' ) . '</span>',  | 
            ||
| 1014 | 'href' => '#',  | 
            ||
| 1015 | ) );  | 
            ||
| 1016 | }  | 
            ||
| 1017 | |||
| 1018 | /**  | 
            ||
| 1019 | * Fires when menu items are added to the masterbar "My Sites" menu.  | 
            ||
| 1020 | *  | 
            ||
| 1021 | * @since 5.4  | 
            ||
| 1022 | */  | 
            ||
| 1023 | do_action( 'jetpack_masterbar' );  | 
            ||
| 1024 | }  | 
            ||
| 1025 | }  | 
            ||
| 1026 | }  | 
            ||
| 1027 | 
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: