16 * 3: Class |
16 * 3: Class |
17 * 4: ID |
17 * 4: ID |
18 * 5: Icon for top level menu |
18 * 5: Icon for top level menu |
19 * |
19 * |
20 * @global array $menu |
20 * @global array $menu |
21 * @name $menu |
|
22 * @var array |
|
23 */ |
21 */ |
24 |
22 |
25 $menu[2] = array( __('Dashboard'), 'read', 'index.php', '', 'menu-top menu-top-first menu-icon-dashboard', 'menu-dashboard', 'dashicons-dashboard' ); |
23 $menu[2] = array( __('Dashboard'), 'read', 'index.php', '', 'menu-top menu-top-first menu-icon-dashboard', 'menu-dashboard', 'dashicons-dashboard' ); |
26 |
24 |
27 $submenu[ 'index.php' ][0] = array( __('Home'), 'read', 'index.php' ); |
25 $submenu[ 'index.php' ][0] = array( __('Home'), 'read', 'index.php' ); |
28 |
26 |
29 if ( is_multisite() ) { |
27 if ( is_multisite() ) { |
30 $submenu[ 'index.php' ][5] = array( __('My Sites'), 'read', 'my-sites.php' ); |
28 $submenu[ 'index.php' ][5] = array( __('My Sites'), 'read', 'my-sites.php' ); |
31 } |
29 } |
32 |
30 |
33 if ( ! is_multisite() || is_super_admin() ) |
31 if ( ! is_multisite() || current_user_can( 'update_core' ) ) { |
34 $update_data = wp_get_update_data(); |
32 $update_data = wp_get_update_data(); |
|
33 } |
35 |
34 |
36 if ( ! is_multisite() ) { |
35 if ( ! is_multisite() ) { |
37 if ( current_user_can( 'update_core' ) ) |
36 if ( current_user_can( 'update_core' ) ) { |
38 $cap = 'update_core'; |
37 $cap = 'update_core'; |
39 elseif ( current_user_can( 'update_plugins' ) ) |
38 } elseif ( current_user_can( 'update_plugins' ) ) { |
40 $cap = 'update_plugins'; |
39 $cap = 'update_plugins'; |
41 else |
40 } elseif ( current_user_can( 'update_themes' ) ) { |
42 $cap = 'update_themes'; |
41 $cap = 'update_themes'; |
43 $submenu[ 'index.php' ][10] = array( sprintf( __('Updates %s'), "<span class='update-plugins count-{$update_data['counts']['total']}' title='{$update_data['title']}'><span class='update-count'>" . number_format_i18n($update_data['counts']['total']) . "</span></span>" ), $cap, 'update-core.php'); |
42 } else { |
|
43 $cap = 'update_languages'; |
|
44 } |
|
45 $submenu[ 'index.php' ][10] = array( sprintf( __('Updates %s'), "<span class='update-plugins count-{$update_data['counts']['total']}'><span class='update-count'>" . number_format_i18n($update_data['counts']['total']) . "</span></span>" ), $cap, 'update-core.php'); |
44 unset( $cap ); |
46 unset( $cap ); |
45 } |
47 } |
46 |
48 |
47 $menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' ); |
49 $menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' ); |
48 |
50 |
49 $menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'open-if-no-js menu-top menu-icon-post', 'menu-posts', 'dashicons-admin-post' ); |
51 // $menu[5] = Posts |
50 $submenu['edit.php'][5] = array( __('All Posts'), 'edit_posts', 'edit.php' ); |
|
51 /* translators: add new post */ |
|
52 $submenu['edit.php'][10] = array( _x('Add New', 'post'), get_post_type_object( 'post' )->cap->create_posts, 'post-new.php' ); |
|
53 |
|
54 $i = 15; |
|
55 foreach ( get_taxonomies( array(), 'objects' ) as $tax ) { |
|
56 if ( ! $tax->show_ui || ! $tax->show_in_menu || ! in_array('post', (array) $tax->object_type, true) ) |
|
57 continue; |
|
58 |
|
59 $submenu['edit.php'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name ); |
|
60 } |
|
61 unset($tax); |
|
62 |
52 |
63 $menu[10] = array( __('Media'), 'upload_files', 'upload.php', '', 'menu-top menu-icon-media', 'menu-media', 'dashicons-admin-media' ); |
53 $menu[10] = array( __('Media'), 'upload_files', 'upload.php', '', 'menu-top menu-icon-media', 'menu-media', 'dashicons-admin-media' ); |
64 $submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php'); |
54 $submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php'); |
65 /* translators: add new file */ |
55 /* translators: add new file */ |
66 $submenu['upload.php'][10] = array( _x('Add New', 'file'), 'upload_files', 'media-new.php'); |
56 $submenu['upload.php'][10] = array( _x('Add New', 'file'), 'upload_files', 'media-new.php'); |
|
57 $i = 15; |
67 foreach ( get_taxonomies_for_attachments( 'objects' ) as $tax ) { |
58 foreach ( get_taxonomies_for_attachments( 'objects' ) as $tax ) { |
68 if ( ! $tax->show_ui || ! $tax->show_in_menu ) |
59 if ( ! $tax->show_ui || ! $tax->show_in_menu ) |
69 continue; |
60 continue; |
70 |
61 |
71 $submenu['upload.php'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name . '&post_type=attachment' ); |
62 $submenu['upload.php'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name . '&post_type=attachment' ); |
72 } |
63 } |
73 unset($tax); |
64 unset( $tax, $i ); |
74 |
65 |
75 $menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-top menu-icon-links', 'menu-links', 'dashicons-admin-links' ); |
66 $menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-top menu-icon-links', 'menu-links', 'dashicons-admin-links' ); |
76 $submenu['link-manager.php'][5] = array( _x('All Links', 'admin menu'), 'manage_links', 'link-manager.php' ); |
67 $submenu['link-manager.php'][5] = array( _x('All Links', 'admin menu'), 'manage_links', 'link-manager.php' ); |
77 /* translators: add new links */ |
68 /* translators: add new links */ |
78 $submenu['link-manager.php'][10] = array( _x('Add New', 'link'), 'manage_links', 'link-add.php' ); |
69 $submenu['link-manager.php'][10] = array( _x('Add New', 'link'), 'manage_links', 'link-add.php' ); |
79 $submenu['link-manager.php'][15] = array( __('Link Categories'), 'manage_categories', 'edit-tags.php?taxonomy=link_category' ); |
70 $submenu['link-manager.php'][15] = array( __('Link Categories'), 'manage_categories', 'edit-tags.php?taxonomy=link_category' ); |
80 |
71 |
81 $menu[20] = array( __('Pages'), 'edit_pages', 'edit.php?post_type=page', '', 'menu-top menu-icon-page', 'menu-pages', 'dashicons-admin-page' ); |
72 // $menu[20] = Pages |
82 $submenu['edit.php?post_type=page'][5] = array( __('All Pages'), 'edit_pages', 'edit.php?post_type=page' ); |
73 |
83 /* translators: add new page */ |
74 // Avoid the comment count query for users who cannot edit_posts. |
84 $submenu['edit.php?post_type=page'][10] = array( _x('Add New', 'page'), get_post_type_object( 'page' )->cap->create_posts, 'post-new.php?post_type=page' ); |
75 if ( current_user_can( 'edit_posts' ) ) { |
85 $i = 15; |
76 $awaiting_mod = wp_count_comments(); |
86 foreach ( get_taxonomies( array(), 'objects' ) as $tax ) { |
77 $awaiting_mod = $awaiting_mod->moderated; |
87 if ( ! $tax->show_ui || ! $tax->show_in_menu || ! in_array('page', (array) $tax->object_type, true) ) |
78 $menu[25] = array( |
88 continue; |
79 sprintf( __( 'Comments %s' ), '<span class="awaiting-mod count-' . absint( $awaiting_mod ) . '"><span class="pending-count">' . number_format_i18n( $awaiting_mod ) . '</span></span>' ), |
89 |
80 'edit_posts', |
90 $submenu['edit.php?post_type=page'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name . '&post_type=page' ); |
81 'edit-comments.php', |
91 } |
82 '', |
92 unset($tax); |
83 'menu-top menu-icon-comments', |
93 |
84 'menu-comments', |
94 $awaiting_mod = wp_count_comments(); |
85 'dashicons-admin-comments', |
95 $awaiting_mod = $awaiting_mod->moderated; |
86 ); |
96 $menu[25] = array( sprintf( __('Comments %s'), "<span class='awaiting-mod count-$awaiting_mod'><span class='pending-count'>" . number_format_i18n($awaiting_mod) . "</span></span>" ), 'edit_posts', 'edit-comments.php', '', 'menu-top menu-icon-comments', 'menu-comments', 'dashicons-admin-comments' ); |
87 unset( $awaiting_mod ); |
97 unset($awaiting_mod); |
88 } |
98 |
89 |
99 $submenu[ 'edit-comments.php' ][0] = array( __('All Comments'), 'edit_posts', 'edit-comments.php' ); |
90 $submenu[ 'edit-comments.php' ][0] = array( __('All Comments'), 'edit_posts', 'edit-comments.php' ); |
100 |
91 |
101 $_wp_last_object_menu = 25; // The index of the last top-level menu in the object menu group |
92 $_wp_last_object_menu = 25; // The index of the last top-level menu in the object menu group |
102 |
93 |
103 foreach ( (array) get_post_types( array('show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) ) as $ptype ) { |
94 $types = (array) get_post_types( array('show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) ); |
|
95 $builtin = array( 'post', 'page' ); |
|
96 foreach ( array_merge( $builtin, $types ) as $ptype ) { |
104 $ptype_obj = get_post_type_object( $ptype ); |
97 $ptype_obj = get_post_type_object( $ptype ); |
105 // Check if it should be a submenu. |
98 // Check if it should be a submenu. |
106 if ( $ptype_obj->show_in_menu !== true ) |
99 if ( $ptype_obj->show_in_menu !== true ) |
107 continue; |
100 continue; |
108 $ptype_menu_position = is_int( $ptype_obj->menu_position ) ? $ptype_obj->menu_position : ++$_wp_last_object_menu; // If we're to use $_wp_last_object_menu, increment it first. |
101 $ptype_menu_position = is_int( $ptype_obj->menu_position ) ? $ptype_obj->menu_position : ++$_wp_last_object_menu; // If we're to use $_wp_last_object_menu, increment it first. |
109 $ptype_for_id = sanitize_html_class( $ptype ); |
102 $ptype_for_id = sanitize_html_class( $ptype ); |
110 |
103 |
|
104 $menu_icon = 'dashicons-admin-post'; |
111 if ( is_string( $ptype_obj->menu_icon ) ) { |
105 if ( is_string( $ptype_obj->menu_icon ) ) { |
112 // Special handling for data:image/svg+xml and Dashicons. |
106 // Special handling for data:image/svg+xml and Dashicons. |
113 if ( 0 === strpos( $ptype_obj->menu_icon, 'data:image/svg+xml;base64,' ) || 0 === strpos( $ptype_obj->menu_icon, 'dashicons-' ) ) { |
107 if ( 0 === strpos( $ptype_obj->menu_icon, 'data:image/svg+xml;base64,' ) || 0 === strpos( $ptype_obj->menu_icon, 'dashicons-' ) ) { |
114 $menu_icon = $ptype_obj->menu_icon; |
108 $menu_icon = $ptype_obj->menu_icon; |
115 } else { |
109 } else { |
116 $menu_icon = esc_url( $ptype_obj->menu_icon ); |
110 $menu_icon = esc_url( $ptype_obj->menu_icon ); |
117 } |
111 } |
118 $ptype_class = $ptype_for_id; |
112 } elseif ( in_array( $ptype, $builtin ) ) { |
|
113 $menu_icon = 'dashicons-admin-' . $ptype; |
|
114 } |
|
115 |
|
116 $menu_class = 'menu-top menu-icon-' . $ptype_for_id; |
|
117 // 'post' special case |
|
118 if ( 'post' === $ptype ) { |
|
119 $menu_class .= ' open-if-no-js'; |
|
120 $ptype_file = "edit.php"; |
|
121 $post_new_file = "post-new.php"; |
|
122 $edit_tags_file = "edit-tags.php?taxonomy=%s"; |
119 } else { |
123 } else { |
120 $menu_icon = 'dashicons-admin-post'; |
124 $ptype_file = "edit.php?post_type=$ptype"; |
121 $ptype_class = 'post'; |
125 $post_new_file = "post-new.php?post_type=$ptype"; |
122 } |
126 $edit_tags_file = "edit-tags.php?taxonomy=%s&post_type=$ptype"; |
123 |
127 } |
|
128 |
|
129 if ( in_array( $ptype, $builtin ) ) { |
|
130 $ptype_menu_id = 'menu-' . $ptype_for_id . 's'; |
|
131 } else { |
|
132 $ptype_menu_id = 'menu-posts-' . $ptype_for_id; |
|
133 } |
124 /* |
134 /* |
125 * If $ptype_menu_position is already populated or will be populated |
135 * If $ptype_menu_position is already populated or will be populated |
126 * by a hard-coded value below, increment the position. |
136 * by a hard-coded value below, increment the position. |
127 */ |
137 */ |
128 $core_menu_positions = array(59, 60, 65, 70, 75, 80, 85, 99); |
138 $core_menu_positions = array(59, 60, 65, 70, 75, 80, 85, 99); |
129 while ( isset($menu[$ptype_menu_position]) || in_array($ptype_menu_position, $core_menu_positions) ) |
139 while ( isset($menu[$ptype_menu_position]) || in_array($ptype_menu_position, $core_menu_positions) ) |
130 $ptype_menu_position++; |
140 $ptype_menu_position++; |
131 |
141 |
132 $menu[$ptype_menu_position] = array( esc_attr( $ptype_obj->labels->menu_name ), $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype", '', 'menu-top menu-icon-' . $ptype_class, 'menu-posts-' . $ptype_for_id, $menu_icon ); |
142 $menu[$ptype_menu_position] = array( esc_attr( $ptype_obj->labels->menu_name ), $ptype_obj->cap->edit_posts, $ptype_file, '', $menu_class, $ptype_menu_id, $menu_icon ); |
133 $submenu["edit.php?post_type=$ptype"][5] = array( $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype"); |
143 $submenu[ $ptype_file ][5] = array( $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, $ptype_file ); |
134 $submenu["edit.php?post_type=$ptype"][10] = array( $ptype_obj->labels->add_new, $ptype_obj->cap->create_posts, "post-new.php?post_type=$ptype" ); |
144 $submenu[ $ptype_file ][10] = array( $ptype_obj->labels->add_new, $ptype_obj->cap->create_posts, $post_new_file ); |
135 |
145 |
136 $i = 15; |
146 $i = 15; |
137 foreach ( get_taxonomies( array(), 'objects' ) as $tax ) { |
147 foreach ( get_taxonomies( array(), 'objects' ) as $tax ) { |
138 if ( ! $tax->show_ui || ! $tax->show_in_menu || ! in_array($ptype, (array) $tax->object_type, true) ) |
148 if ( ! $tax->show_ui || ! $tax->show_in_menu || ! in_array($ptype, (array) $tax->object_type, true) ) |
139 continue; |
149 continue; |
140 |
150 |
141 $submenu["edit.php?post_type=$ptype"][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, "edit-tags.php?taxonomy=$tax->name&post_type=$ptype" ); |
151 $submenu[ $ptype_file ][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, sprintf( $edit_tags_file, $tax->name ) ); |
142 } |
152 } |
143 } |
153 } |
144 unset($ptype, $ptype_obj, $ptype_class, $ptype_for_id, $ptype_menu_position, $menu_icon, $i, $tax); |
154 unset( $ptype, $ptype_obj, $ptype_for_id, $ptype_menu_position, $menu_icon, $i, $tax, $post_new_file ); |
145 |
155 |
146 $menu[59] = array( '', 'read', 'separator2', '', 'wp-menu-separator' ); |
156 $menu[59] = array( '', 'read', 'separator2', '', 'wp-menu-separator' ); |
147 |
157 |
148 $appearance_cap = current_user_can( 'switch_themes') ? 'switch_themes' : 'edit_theme_options'; |
158 $appearance_cap = current_user_can( 'switch_themes') ? 'switch_themes' : 'edit_theme_options'; |
149 |
159 |
150 $menu[60] = array( __( 'Appearance' ), $appearance_cap, 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'dashicons-admin-appearance' ); |
160 $menu[60] = array( __( 'Appearance' ), $appearance_cap, 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'dashicons-admin-appearance' ); |
151 $submenu['themes.php'][5] = array( __( 'Themes' ), $appearance_cap, 'themes.php' ); |
161 $submenu['themes.php'][5] = array( __( 'Themes' ), $appearance_cap, 'themes.php' ); |
152 |
162 |
153 $customize_url = add_query_arg( 'return', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 'customize.php' ); |
163 $customize_url = add_query_arg( 'return', urlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), 'customize.php' ); |
154 $submenu['themes.php'][6] = array( __( 'Customize' ), 'customize', esc_url( $customize_url ), '', 'hide-if-no-customize' ); |
164 $submenu['themes.php'][6] = array( __( 'Customize' ), 'customize', esc_url( $customize_url ), '', 'hide-if-no-customize' ); |
155 |
165 |
156 if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) { |
166 if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) { |
157 $submenu['themes.php'][10] = array( __( 'Menus' ), 'edit_theme_options', 'nav-menus.php' ); |
167 $submenu['themes.php'][10] = array( __( 'Menus' ), 'edit_theme_options', 'nav-menus.php' ); |
158 } |
168 } |
228 $submenu['tools.php'][10] = array( __('Import'), 'import', 'import.php' ); |
245 $submenu['tools.php'][10] = array( __('Import'), 'import', 'import.php' ); |
229 $submenu['tools.php'][15] = array( __('Export'), 'export', 'export.php' ); |
246 $submenu['tools.php'][15] = array( __('Export'), 'export', 'export.php' ); |
230 if ( is_multisite() && !is_main_site() ) |
247 if ( is_multisite() && !is_main_site() ) |
231 $submenu['tools.php'][25] = array( __('Delete Site'), 'delete_site', 'ms-delete-site.php' ); |
248 $submenu['tools.php'][25] = array( __('Delete Site'), 'delete_site', 'ms-delete-site.php' ); |
232 if ( ! is_multisite() && defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE ) |
249 if ( ! is_multisite() && defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE ) |
233 $submenu['tools.php'][50] = array(__('Network Setup'), 'manage_options', 'network.php'); |
250 $submenu['tools.php'][50] = array(__('Network Setup'), 'setup_network', 'network.php'); |
234 |
251 |
235 $menu[80] = array( __('Settings'), 'manage_options', 'options-general.php', '', 'menu-top menu-icon-settings', 'menu-settings', 'dashicons-admin-settings' ); |
252 $change_notice = ''; |
236 $submenu['options-general.php'][10] = array(_x('General', 'settings screen'), 'manage_options', 'options-general.php'); |
253 if ( current_user_can( 'manage_privacy_options' ) && WP_Privacy_Policy_Content::text_change_check() ) { |
237 $submenu['options-general.php'][15] = array(__('Writing'), 'manage_options', 'options-writing.php'); |
254 $change_notice = ' <span class="update-plugins 1"><span class="plugin-count">' . number_format_i18n( 1 ) . '</span></span>'; |
238 $submenu['options-general.php'][20] = array(__('Reading'), 'manage_options', 'options-reading.php'); |
255 } |
239 $submenu['options-general.php'][25] = array(__('Discussion'), 'manage_options', 'options-discussion.php'); |
256 |
240 $submenu['options-general.php'][30] = array(__('Media'), 'manage_options', 'options-media.php'); |
257 // translators: %s is the update notification bubble, if updates are available. |
241 $submenu['options-general.php'][40] = array(__('Permalinks'), 'manage_options', 'options-permalink.php'); |
258 $menu[80] = array( sprintf( __( 'Settings %s' ), $change_notice ), 'manage_options', 'options-general.php', '', 'menu-top menu-icon-settings', 'menu-settings', 'dashicons-admin-settings' ); |
|
259 $submenu['options-general.php'][10] = array( _x( 'General', 'settings screen' ), 'manage_options', 'options-general.php' ); |
|
260 $submenu['options-general.php'][15] = array( __( 'Writing' ), 'manage_options', 'options-writing.php' ); |
|
261 $submenu['options-general.php'][20] = array( __( 'Reading' ), 'manage_options', 'options-reading.php' ); |
|
262 $submenu['options-general.php'][25] = array( __( 'Discussion' ), 'manage_options', 'options-discussion.php' ); |
|
263 $submenu['options-general.php'][30] = array( __( 'Media' ), 'manage_options', 'options-media.php' ); |
|
264 $submenu['options-general.php'][40] = array( __( 'Permalinks' ), 'manage_options', 'options-permalink.php' ); |
|
265 // translators: %s is the update notification bubble, if updates are available. |
|
266 $submenu['options-general.php'][45] = array( sprintf( __( 'Privacy %s' ), $change_notice ), 'manage_privacy_options', 'privacy.php' ); |
242 |
267 |
243 $_wp_last_utility_menu = 80; // The index of the last top-level menu in the utility menu group |
268 $_wp_last_utility_menu = 80; // The index of the last top-level menu in the utility menu group |
244 |
269 |
245 $menu[99] = array( '', 'read', 'separator-last', '', 'wp-menu-separator' ); |
270 $menu[99] = array( '', 'read', 'separator-last', '', 'wp-menu-separator' ); |
246 |
271 |