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