Conditions | 27 |
Paths | > 20000 |
Total Lines | 547 |
Lines | 116 |
Ratio | 21.21 % |
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 // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
||
753 | public function add_my_sites_submenu( $wp_admin_bar ) { |
||
754 | $current_user = wp_get_current_user(); |
||
755 | |||
756 | $blog_name = get_bloginfo( 'name' ); |
||
757 | if ( empty( $blog_name ) ) { |
||
758 | $blog_name = $this->primary_site_slug; |
||
759 | } |
||
760 | |||
761 | if ( mb_strlen( $blog_name ) > 20 ) { |
||
762 | $blog_name = mb_substr( html_entity_decode( $blog_name, ENT_QUOTES ), 0, 20 ) . '…'; |
||
763 | } |
||
764 | |||
765 | $wp_admin_bar->add_menu( |
||
766 | array( |
||
767 | 'parent' => 'root-default', |
||
768 | 'id' => 'blog', |
||
769 | 'title' => _n( 'My Site', 'My Sites', $this->user_site_count, 'jetpack' ), |
||
770 | 'href' => '#', |
||
771 | 'meta' => array( |
||
772 | 'class' => 'my-sites mb-trackable', |
||
773 | ), |
||
774 | ) |
||
775 | ); |
||
776 | |||
777 | if ( $this->user_site_count > 1 ) { |
||
778 | $wp_admin_bar->add_menu( |
||
779 | array( |
||
780 | 'parent' => 'blog', |
||
781 | 'id' => 'switch-site', |
||
782 | 'title' => esc_html__( 'Switch Site', 'jetpack' ), |
||
783 | 'href' => 'https://wordpress.com/sites', |
||
784 | ) |
||
785 | ); |
||
786 | } else { |
||
787 | $wp_admin_bar->add_menu( |
||
788 | array( |
||
789 | 'parent' => 'blog', |
||
790 | 'id' => 'new-site', |
||
791 | 'title' => esc_html__( '+ Add New WordPress', 'jetpack' ), |
||
792 | 'href' => 'https://wordpress.com/start?ref=admin-bar-logged-in', |
||
793 | ) |
||
794 | ); |
||
795 | } |
||
796 | |||
797 | if ( is_user_member_of_blog( $current_user->ID ) ) { |
||
798 | $blavatar = ''; |
||
799 | $class = 'current-site'; |
||
800 | |||
801 | if ( has_site_icon() ) { |
||
802 | $src = get_site_icon_url(); |
||
803 | $blavatar = '<img class="avatar" src="' . esc_attr( $src ) . '" alt="Current site avatar">'; |
||
804 | $class = 'has-blavatar'; |
||
805 | } |
||
806 | |||
807 | $blog_info = '<div class="ab-site-icon">' . $blavatar . '</div>'; |
||
808 | $blog_info .= '<span class="ab-site-title">' . esc_html( $blog_name ) . '</span>'; |
||
809 | $blog_info .= '<span class="ab-site-description">' . esc_html( $this->primary_site_url ) . '</span>'; |
||
810 | |||
811 | $wp_admin_bar->add_menu( |
||
812 | array( |
||
813 | 'parent' => 'blog', |
||
814 | 'id' => 'blog-info', |
||
815 | 'title' => $blog_info, |
||
816 | 'href' => esc_url( trailingslashit( $this->primary_site_url ) ), |
||
817 | 'meta' => array( |
||
818 | 'class' => $class, |
||
819 | ), |
||
820 | ) |
||
821 | ); |
||
822 | } |
||
823 | |||
824 | // Site Preview. |
||
825 | if ( is_admin() ) { |
||
826 | $wp_admin_bar->add_menu( |
||
827 | array( |
||
828 | 'parent' => 'blog', |
||
829 | 'id' => 'site-view', |
||
830 | 'title' => __( 'View Site', 'jetpack' ), |
||
831 | 'href' => home_url(), |
||
832 | 'meta' => array( |
||
833 | 'class' => 'mb-icon', |
||
834 | 'target' => '_blank', |
||
835 | ), |
||
836 | ) |
||
837 | ); |
||
838 | } |
||
839 | |||
840 | // Stats. |
||
841 | View Code Duplication | if ( Jetpack::is_module_active( 'stats' ) ) { |
|
842 | $wp_admin_bar->add_menu( |
||
843 | array( |
||
844 | 'parent' => 'blog', |
||
845 | 'id' => 'blog-stats', |
||
846 | 'title' => esc_html__( 'Stats', 'jetpack' ), |
||
847 | 'href' => 'https://wordpress.com/stats/' . esc_attr( $this->primary_site_slug ), |
||
848 | 'meta' => array( |
||
849 | 'class' => 'mb-icon', |
||
850 | ), |
||
851 | ) |
||
852 | ); |
||
853 | } |
||
854 | |||
855 | View Code Duplication | if ( current_user_can( 'manage_options' ) ) { |
|
856 | $wp_admin_bar->add_menu( |
||
857 | array( |
||
858 | 'parent' => 'blog', |
||
859 | 'id' => 'activity', |
||
860 | 'title' => esc_html__( 'Activity', 'jetpack' ), |
||
861 | 'href' => 'https://wordpress.com/activity-log/' . esc_attr( $this->primary_site_slug ), |
||
862 | 'meta' => array( |
||
863 | 'class' => 'mb-icon', |
||
864 | ), |
||
865 | ) |
||
866 | ); |
||
867 | } |
||
868 | |||
869 | // Add Calypso plans link and plan type indicator. |
||
870 | if ( is_user_member_of_blog( $current_user->ID ) ) { |
||
871 | $plans_url = 'https://wordpress.com/plans/' . esc_attr( $this->primary_site_slug ); |
||
872 | $label = esc_html__( 'Plan', 'jetpack' ); |
||
873 | $plan = Jetpack_Plan::get(); |
||
874 | |||
875 | $plan_title = $this->create_menu_item_pair( |
||
876 | array( |
||
877 | 'url' => $plans_url, |
||
878 | 'id' => 'wp-admin-bar-plan', |
||
879 | 'label' => $label, |
||
880 | ), |
||
881 | array( |
||
882 | 'url' => $plans_url, |
||
883 | 'id' => 'wp-admin-bar-plan-badge', |
||
884 | 'label' => $plan['product_name_short'], |
||
885 | ) |
||
886 | ); |
||
887 | |||
888 | $wp_admin_bar->add_menu( |
||
889 | array( |
||
890 | 'parent' => 'blog', |
||
891 | 'id' => 'plan', |
||
892 | 'title' => $plan_title, |
||
893 | 'meta' => array( |
||
894 | 'class' => 'inline-action', |
||
895 | ), |
||
896 | ) |
||
897 | ); |
||
898 | } |
||
899 | |||
900 | // Publish group. |
||
901 | $wp_admin_bar->add_group( |
||
902 | array( |
||
903 | 'parent' => 'blog', |
||
904 | 'id' => 'publish', |
||
905 | ) |
||
906 | ); |
||
907 | |||
908 | // Publish header. |
||
909 | $wp_admin_bar->add_menu( |
||
910 | array( |
||
911 | 'parent' => 'publish', |
||
912 | 'id' => 'publish-header', |
||
913 | 'title' => esc_html_x( 'Manage', 'admin bar menu group label', 'jetpack' ), |
||
914 | 'meta' => array( |
||
915 | 'class' => 'ab-submenu-header', |
||
916 | ), |
||
917 | ) |
||
918 | ); |
||
919 | |||
920 | // Pages. |
||
921 | $pages_title = $this->create_menu_item_pair( |
||
922 | array( |
||
923 | 'url' => 'https://wordpress.com/pages/' . esc_attr( $this->primary_site_slug ), |
||
924 | 'id' => 'wp-admin-bar-edit-page', |
||
925 | 'label' => esc_html__( 'Site Pages', 'jetpack' ), |
||
926 | ), |
||
927 | array( |
||
928 | 'url' => 'https://wordpress.com/page/' . esc_attr( $this->primary_site_slug ), |
||
929 | 'id' => 'wp-admin-bar-new-page-badge', |
||
930 | 'label' => esc_html_x( 'Add', 'admin bar menu new item label', 'jetpack' ), |
||
931 | ) |
||
932 | ); |
||
933 | |||
934 | if ( ! current_user_can( 'edit_pages' ) ) { |
||
935 | $pages_title = $this->create_menu_item_anchor( |
||
936 | 'ab-item ab-primary mb-icon', |
||
937 | 'https://wordpress.com/pages/' . esc_attr( $this->primary_site_slug ), |
||
938 | esc_html__( 'Site Pages', 'jetpack' ), |
||
939 | 'wp-admin-bar-edit-page' |
||
940 | ); |
||
941 | } |
||
942 | |||
943 | $wp_admin_bar->add_menu( |
||
944 | array( |
||
945 | 'parent' => 'publish', |
||
946 | 'id' => 'new-page', |
||
947 | 'title' => $pages_title, |
||
948 | 'meta' => array( |
||
949 | 'class' => 'inline-action', |
||
950 | ), |
||
951 | ) |
||
952 | ); |
||
953 | |||
954 | // Blog Posts. |
||
955 | $posts_title = $this->create_menu_item_pair( |
||
956 | array( |
||
957 | 'url' => 'https://wordpress.com/posts/' . esc_attr( $this->primary_site_slug ), |
||
958 | 'id' => 'wp-admin-bar-edit-post', |
||
959 | 'label' => esc_html__( 'Blog Posts', 'jetpack' ), |
||
960 | ), |
||
961 | array( |
||
962 | 'url' => 'https://wordpress.com/post/' . esc_attr( $this->primary_site_slug ), |
||
963 | 'id' => 'wp-admin-bar-new-post-badge', |
||
964 | 'label' => esc_html_x( 'Add', 'admin bar menu new item label', 'jetpack' ), |
||
965 | ) |
||
966 | ); |
||
967 | |||
968 | if ( ! current_user_can( 'edit_posts' ) ) { |
||
969 | $posts_title = $this->create_menu_item_anchor( |
||
970 | 'ab-item ab-primary mb-icon', |
||
971 | 'https://wordpress.com/posts/' . esc_attr( $this->primary_site_slug ), |
||
972 | esc_html__( 'Blog Posts', 'jetpack' ), |
||
973 | 'wp-admin-bar-edit-post' |
||
974 | ); |
||
975 | } |
||
976 | |||
977 | $wp_admin_bar->add_menu( |
||
978 | array( |
||
979 | 'parent' => 'publish', |
||
980 | 'id' => 'new-post', |
||
981 | 'title' => $posts_title, |
||
982 | 'meta' => array( |
||
983 | 'class' => 'inline-action mb-trackable', |
||
984 | ), |
||
985 | ) |
||
986 | ); |
||
987 | |||
988 | // Comments. |
||
989 | View Code Duplication | if ( current_user_can( 'moderate_comments' ) ) { |
|
990 | $wp_admin_bar->add_menu( |
||
991 | array( |
||
992 | 'parent' => 'publish', |
||
993 | 'id' => 'comments', |
||
994 | 'title' => __( 'Comments', 'jetpack' ), |
||
995 | 'href' => 'https://wordpress.com/comments/' . esc_attr( $this->primary_site_slug ), |
||
996 | 'meta' => array( |
||
997 | 'class' => 'mb-icon', |
||
998 | ), |
||
999 | ) |
||
1000 | ); |
||
1001 | } |
||
1002 | |||
1003 | // Testimonials. |
||
1004 | View Code Duplication | if ( Jetpack::is_module_active( 'custom-content-types' ) && get_option( 'jetpack_testimonial' ) ) { |
|
1005 | $testimonials_title = $this->create_menu_item_pair( |
||
1006 | array( |
||
1007 | 'url' => 'https://wordpress.com/types/jetpack-testimonial/' . esc_attr( $this->primary_site_slug ), |
||
1008 | 'id' => 'wp-admin-bar-edit-testimonial', |
||
1009 | 'label' => esc_html__( 'Testimonials', 'jetpack' ), |
||
1010 | ), |
||
1011 | array( |
||
1012 | 'url' => 'https://wordpress.com/edit/jetpack-testimonial/' . esc_attr( $this->primary_site_slug ), |
||
1013 | 'id' => 'wp-admin-bar-new-testimonial', |
||
1014 | 'label' => esc_html_x( 'Add', 'Button label for adding a new item via the toolbar menu', 'jetpack' ), |
||
1015 | ) |
||
1016 | ); |
||
1017 | |||
1018 | if ( ! current_user_can( 'edit_pages' ) ) { |
||
1019 | $testimonials_title = $this->create_menu_item_anchor( |
||
1020 | 'ab-item ab-primary mb-icon', |
||
1021 | 'https://wordpress.com/types/jetpack-testimonial/' . esc_attr( $this->primary_site_slug ), |
||
1022 | esc_html__( 'Testimonials', 'jetpack' ), |
||
1023 | 'wp-admin-bar-edit-testimonial' |
||
1024 | ); |
||
1025 | } |
||
1026 | |||
1027 | $wp_admin_bar->add_menu( |
||
1028 | array( |
||
1029 | 'parent' => 'publish', |
||
1030 | 'id' => 'new-jetpack-testimonial', |
||
1031 | 'title' => $testimonials_title, |
||
1032 | 'meta' => array( |
||
1033 | 'class' => 'inline-action', |
||
1034 | ), |
||
1035 | ) |
||
1036 | ); |
||
1037 | } |
||
1038 | |||
1039 | // Portfolio. |
||
1040 | View Code Duplication | if ( Jetpack::is_module_active( 'custom-content-types' ) && get_option( 'jetpack_portfolio' ) ) { |
|
1041 | $portfolios_title = $this->create_menu_item_pair( |
||
1042 | array( |
||
1043 | 'url' => 'https://wordpress.com/types/jetpack-portfolio/' . esc_attr( $this->primary_site_slug ), |
||
1044 | 'id' => 'wp-admin-bar-edit-portfolio', |
||
1045 | 'label' => esc_html__( 'Portfolio', 'jetpack' ), |
||
1046 | ), |
||
1047 | array( |
||
1048 | 'url' => 'https://wordpress.com/edit/jetpack-portfolio/' . esc_attr( $this->primary_site_slug ), |
||
1049 | 'id' => 'wp-admin-bar-new-portfolio', |
||
1050 | 'label' => esc_html_x( 'Add', 'Button label for adding a new item via the toolbar menu', 'jetpack' ), |
||
1051 | ) |
||
1052 | ); |
||
1053 | |||
1054 | if ( ! current_user_can( 'edit_pages' ) ) { |
||
1055 | $portfolios_title = $this->create_menu_item_anchor( |
||
1056 | 'ab-item ab-primary mb-icon', |
||
1057 | 'https://wordpress.com/types/jetpack-portfolio/' . esc_attr( $this->primary_site_slug ), |
||
1058 | esc_html__( 'Portfolio', 'jetpack' ), |
||
1059 | 'wp-admin-bar-edit-portfolio' |
||
1060 | ); |
||
1061 | } |
||
1062 | |||
1063 | $wp_admin_bar->add_menu( |
||
1064 | array( |
||
1065 | 'parent' => 'publish', |
||
1066 | 'id' => 'new-jetpack-portfolio', |
||
1067 | 'title' => $portfolios_title, |
||
1068 | 'meta' => array( |
||
1069 | 'class' => 'inline-action', |
||
1070 | ), |
||
1071 | ) |
||
1072 | ); |
||
1073 | } |
||
1074 | |||
1075 | if ( current_user_can( 'edit_theme_options' ) ) { |
||
1076 | // Look and Feel group. |
||
1077 | $wp_admin_bar->add_group( |
||
1078 | array( |
||
1079 | 'parent' => 'blog', |
||
1080 | 'id' => 'look-and-feel', |
||
1081 | ) |
||
1082 | ); |
||
1083 | |||
1084 | // Look and Feel header. |
||
1085 | $wp_admin_bar->add_menu( |
||
1086 | array( |
||
1087 | 'parent' => 'look-and-feel', |
||
1088 | 'id' => 'look-and-feel-header', |
||
1089 | 'title' => esc_html_x( 'Personalize', 'admin bar menu group label', 'jetpack' ), |
||
1090 | 'meta' => array( |
||
1091 | 'class' => 'ab-submenu-header', |
||
1092 | ), |
||
1093 | ) |
||
1094 | ); |
||
1095 | |||
1096 | if ( is_admin() ) { |
||
1097 | // In wp-admin the `return` query arg will return to that page after closing the Customizer. |
||
1098 | $customizer_url = add_query_arg( |
||
1099 | array( |
||
1100 | 'return' => rawurlencode( site_url( $_SERVER['REQUEST_URI'] ) ), |
||
1101 | ), |
||
1102 | wp_customize_url() |
||
1103 | ); |
||
1104 | } else { |
||
1105 | /* |
||
1106 | * On the frontend the `url` query arg will load that page in the Customizer |
||
1107 | * and also return to it after closing |
||
1108 | * non-home URLs won't work unless we undo domain mapping |
||
1109 | * since the Customizer preview is unmapped to always have HTTPS. |
||
1110 | */ |
||
1111 | $current_page = '//' . $this->primary_site_slug . $_SERVER['REQUEST_URI']; |
||
1112 | $customizer_url = add_query_arg( array( 'url' => rawurlencode( $current_page ) ), wp_customize_url() ); |
||
1113 | } |
||
1114 | |||
1115 | $theme_title = $this->create_menu_item_pair( |
||
1116 | array( |
||
1117 | 'url' => $customizer_url, |
||
1118 | 'id' => 'wp-admin-bar-cmz', |
||
1119 | 'label' => esc_html_x( 'Customize', 'admin bar customize item label', 'jetpack' ), |
||
1120 | ), |
||
1121 | array( |
||
1122 | 'url' => 'https://wordpress.com/themes/' . esc_attr( $this->primary_site_slug ), |
||
1123 | 'id' => 'wp-admin-bar-themes', |
||
1124 | 'label' => esc_html__( 'Themes', 'jetpack' ), |
||
1125 | ) |
||
1126 | ); |
||
1127 | $meta = array( |
||
1128 | 'class' => 'mb-icon', |
||
1129 | 'class' => 'inline-action', |
||
1130 | ); |
||
1131 | $href = false; |
||
1132 | |||
1133 | $wp_admin_bar->add_menu( |
||
1134 | array( |
||
1135 | 'parent' => 'look-and-feel', |
||
1136 | 'id' => 'themes', |
||
1137 | 'title' => $theme_title, |
||
1138 | 'href' => $href, |
||
1139 | 'meta' => $meta, |
||
1140 | ) |
||
1141 | ); |
||
1142 | } |
||
1143 | |||
1144 | if ( current_user_can( 'manage_options' ) ) { |
||
1145 | // Configuration group. |
||
1146 | $wp_admin_bar->add_group( |
||
1147 | array( |
||
1148 | 'parent' => 'blog', |
||
1149 | 'id' => 'configuration', |
||
1150 | ) |
||
1151 | ); |
||
1152 | |||
1153 | // Configuration header. |
||
1154 | $wp_admin_bar->add_menu( |
||
1155 | array( |
||
1156 | 'parent' => 'configuration', |
||
1157 | 'id' => 'configuration-header', |
||
1158 | 'title' => esc_html_x( 'Configure', 'admin bar menu group label', 'jetpack' ), |
||
1159 | 'meta' => array( |
||
1160 | 'class' => 'ab-submenu-header', |
||
1161 | ), |
||
1162 | ) |
||
1163 | ); |
||
1164 | |||
1165 | View Code Duplication | if ( Jetpack::is_module_active( 'publicize' ) || Jetpack::is_module_active( 'sharedaddy' ) ) { |
|
1166 | $wp_admin_bar->add_menu( |
||
1167 | array( |
||
1168 | 'parent' => 'configuration', |
||
1169 | 'id' => 'sharing', |
||
1170 | 'title' => esc_html__( 'Sharing', 'jetpack' ), |
||
1171 | 'href' => 'https://wordpress.com/sharing/' . esc_attr( $this->primary_site_slug ), |
||
1172 | 'meta' => array( |
||
1173 | 'class' => 'mb-icon', |
||
1174 | ), |
||
1175 | ) |
||
1176 | ); |
||
1177 | } |
||
1178 | |||
1179 | $people_title = $this->create_menu_item_pair( |
||
1180 | array( |
||
1181 | 'url' => 'https://wordpress.com/people/team/' . esc_attr( $this->primary_site_slug ), |
||
1182 | 'id' => 'wp-admin-bar-people', |
||
1183 | 'label' => esc_html__( 'People', 'jetpack' ), |
||
1184 | ), |
||
1185 | array( |
||
1186 | 'url' => admin_url( 'user-new.php' ), |
||
1187 | 'id' => 'wp-admin-bar-people-add', |
||
1188 | 'label' => esc_html_x( 'Add', 'admin bar people item label', 'jetpack' ), |
||
1189 | ) |
||
1190 | ); |
||
1191 | |||
1192 | $wp_admin_bar->add_menu( |
||
1193 | array( |
||
1194 | 'parent' => 'configuration', |
||
1195 | 'id' => 'users-toolbar', |
||
1196 | 'title' => $people_title, |
||
1197 | 'href' => false, |
||
1198 | 'meta' => array( |
||
1199 | 'class' => 'inline-action', |
||
1200 | ), |
||
1201 | ) |
||
1202 | ); |
||
1203 | |||
1204 | $plugins_title = $this->create_menu_item_pair( |
||
1205 | array( |
||
1206 | 'url' => 'https://wordpress.com/plugins/' . esc_attr( $this->primary_site_slug ), |
||
1207 | 'id' => 'wp-admin-bar-plugins', |
||
1208 | 'label' => esc_html__( 'Plugins', 'jetpack' ), |
||
1209 | ), |
||
1210 | array( |
||
1211 | 'url' => 'https://wordpress.com/plugins/manage/' . esc_attr( $this->primary_site_slug ), |
||
1212 | 'id' => 'wp-admin-bar-plugins-add', |
||
1213 | 'label' => esc_html_x( 'Manage', 'Label for the button on the Masterbar to manage plugins', 'jetpack' ), |
||
1214 | ) |
||
1215 | ); |
||
1216 | |||
1217 | $wp_admin_bar->add_menu( |
||
1218 | array( |
||
1219 | 'parent' => 'configuration', |
||
1220 | 'id' => 'plugins', |
||
1221 | 'title' => $plugins_title, |
||
1222 | 'href' => false, |
||
1223 | 'meta' => array( |
||
1224 | 'class' => 'inline-action', |
||
1225 | ), |
||
1226 | ) |
||
1227 | ); |
||
1228 | |||
1229 | if ( jetpack_is_atomic_site() ) { |
||
1230 | $domain_title = $this->create_menu_item_pair( |
||
1231 | array( |
||
1232 | 'url' => 'https://wordpress.com/domains/' . esc_attr( $this->primary_site_slug ), |
||
1233 | 'id' => 'wp-admin-bar-domains', |
||
1234 | 'label' => esc_html__( 'Domains', 'jetpack' ), |
||
1235 | ), |
||
1236 | array( |
||
1237 | 'url' => 'https://wordpress.com/domains/add/' . esc_attr( $this->primary_site_slug ), |
||
1238 | 'id' => 'wp-admin-bar-domains-add', |
||
1239 | 'label' => esc_html_x( 'Add', 'Label for the button on the Masterbar to add a new domain', 'jetpack' ), |
||
1240 | ) |
||
1241 | ); |
||
1242 | $wp_admin_bar->add_menu( |
||
1243 | array( |
||
1244 | 'parent' => 'configuration', |
||
1245 | 'id' => 'domains', |
||
1246 | 'title' => $domain_title, |
||
1247 | 'href' => false, |
||
1248 | 'meta' => array( |
||
1249 | 'class' => 'inline-action', |
||
1250 | ), |
||
1251 | ) |
||
1252 | ); |
||
1253 | } |
||
1254 | |||
1255 | $wp_admin_bar->add_menu( |
||
1256 | array( |
||
1257 | 'parent' => 'configuration', |
||
1258 | 'id' => 'blog-settings', |
||
1259 | 'title' => esc_html__( 'Settings', 'jetpack' ), |
||
1260 | 'href' => 'https://wordpress.com/settings/general/' . esc_attr( $this->primary_site_slug ), |
||
1261 | 'meta' => array( |
||
1262 | 'class' => 'mb-icon', |
||
1263 | ), |
||
1264 | ) |
||
1265 | ); |
||
1266 | |||
1267 | if ( ! is_admin() ) { |
||
1268 | $wp_admin_bar->add_menu( |
||
1269 | array( |
||
1270 | 'parent' => 'configuration', |
||
1271 | 'id' => 'legacy-dashboard', |
||
1272 | 'title' => esc_html__( 'Dashboard', 'jetpack' ), |
||
1273 | 'href' => admin_url(), |
||
1274 | 'meta' => array( |
||
1275 | 'class' => 'mb-icon', |
||
1276 | ), |
||
1277 | ) |
||
1278 | ); |
||
1279 | } |
||
1280 | |||
1281 | // Restore dashboard menu toggle that is needed on mobile views. |
||
1282 | if ( is_admin() ) { |
||
1283 | $wp_admin_bar->add_menu( |
||
1284 | array( |
||
1285 | 'id' => 'menu-toggle', |
||
1286 | 'title' => '<span class="ab-icon"></span><span class="screen-reader-text">' . esc_html__( 'Menu', 'jetpack' ) . '</span>', |
||
1287 | 'href' => '#', |
||
1288 | ) |
||
1289 | ); |
||
1290 | } |
||
1291 | |||
1292 | /** |
||
1293 | * Fires when menu items are added to the masterbar "My Sites" menu. |
||
1294 | * |
||
1295 | * @since 5.4.0 |
||
1296 | */ |
||
1297 | do_action( 'jetpack_masterbar' ); |
||
1298 | } |
||
1299 | } |
||
1300 | } |
||
1301 |
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: