32 |
32 |
33 if ( ! is_multisite() || is_super_admin() ) |
33 if ( ! is_multisite() || is_super_admin() ) |
34 $update_data = wp_get_update_data(); |
34 $update_data = wp_get_update_data(); |
35 |
35 |
36 if ( ! is_multisite() ) { |
36 if ( ! is_multisite() ) { |
37 $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>" ), 'update_core', 'update-core.php'); |
37 if ( current_user_can( 'update_core' ) ) |
|
38 $cap = 'update_core'; |
|
39 elseif ( current_user_can( 'update_plugins' ) ) |
|
40 $cap = 'update_plugins'; |
|
41 else |
|
42 $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'); |
|
44 unset( $cap ); |
38 } |
45 } |
39 |
46 |
40 $menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' ); |
47 $menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' ); |
41 |
48 |
42 $menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'open-if-no-js menu-top menu-icon-post', 'menu-posts', 'div' ); |
49 $menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'open-if-no-js menu-top menu-icon-post', 'menu-posts', 'none' ); |
43 $submenu['edit.php'][5] = array( __('All Posts'), 'edit_posts', 'edit.php' ); |
50 $submenu['edit.php'][5] = array( __('All Posts'), 'edit_posts', 'edit.php' ); |
44 /* translators: add new post */ |
51 /* translators: add new post */ |
45 $submenu['edit.php'][10] = array( _x('Add New', 'post'), 'edit_posts', 'post-new.php' ); |
52 $submenu['edit.php'][10] = array( _x('Add New', 'post'), get_post_type_object( 'post' )->cap->create_posts, 'post-new.php' ); |
46 |
53 |
47 $i = 15; |
54 $i = 15; |
48 foreach ( get_taxonomies( array(), 'objects' ) as $tax ) { |
55 foreach ( get_taxonomies( array(), 'objects' ) as $tax ) { |
49 if ( ! $tax->show_ui || ! in_array('post', (array) $tax->object_type, true) ) |
56 if ( ! $tax->show_ui || ! in_array('post', (array) $tax->object_type, true) ) |
50 continue; |
57 continue; |
51 |
58 |
52 $submenu['edit.php'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name ); |
59 $submenu['edit.php'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name ); |
53 } |
60 } |
54 unset($tax); |
61 unset($tax); |
55 |
62 |
56 $menu[10] = array( __('Media'), 'upload_files', 'upload.php', '', 'menu-top menu-icon-media', 'menu-media', 'div' ); |
63 $menu[10] = array( __('Media'), 'upload_files', 'upload.php', '', 'menu-top menu-icon-media', 'menu-media', 'none' ); |
57 $submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php'); |
64 $submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php'); |
58 /* translators: add new file */ |
65 /* translators: add new file */ |
59 $submenu['upload.php'][10] = array( _x('Add New', 'file'), 'upload_files', 'media-new.php'); |
66 $submenu['upload.php'][10] = array( _x('Add New', 'file'), 'upload_files', 'media-new.php'); |
60 |
67 foreach ( get_taxonomies_for_attachments( 'objects' ) as $tax ) { |
61 $menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-top menu-icon-links', 'menu-links', 'div' ); |
68 if ( ! $tax->show_ui ) |
|
69 continue; |
|
70 |
|
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' ); |
|
72 } |
|
73 unset($tax); |
|
74 |
|
75 $menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-top menu-icon-links', 'menu-links', 'none' ); |
62 $submenu['link-manager.php'][5] = array( _x('All Links', 'admin menu'), 'manage_links', 'link-manager.php' ); |
76 $submenu['link-manager.php'][5] = array( _x('All Links', 'admin menu'), 'manage_links', 'link-manager.php' ); |
63 /* translators: add new links */ |
77 /* translators: add new links */ |
64 $submenu['link-manager.php'][10] = array( _x('Add New', 'link'), 'manage_links', 'link-add.php' ); |
78 $submenu['link-manager.php'][10] = array( _x('Add New', 'link'), 'manage_links', 'link-add.php' ); |
65 $submenu['link-manager.php'][15] = array( __('Link Categories'), 'manage_categories', 'edit-tags.php?taxonomy=link_category' ); |
79 $submenu['link-manager.php'][15] = array( __('Link Categories'), 'manage_categories', 'edit-tags.php?taxonomy=link_category' ); |
66 |
80 |
67 $menu[20] = array( __('Pages'), 'edit_pages', 'edit.php?post_type=page', '', 'menu-top menu-icon-page', 'menu-pages', 'div' ); |
81 $menu[20] = array( __('Pages'), 'edit_pages', 'edit.php?post_type=page', '', 'menu-top menu-icon-page', 'menu-pages', 'none' ); |
68 $submenu['edit.php?post_type=page'][5] = array( __('All Pages'), 'edit_pages', 'edit.php?post_type=page' ); |
82 $submenu['edit.php?post_type=page'][5] = array( __('All Pages'), 'edit_pages', 'edit.php?post_type=page' ); |
69 /* translators: add new page */ |
83 /* translators: add new page */ |
70 $submenu['edit.php?post_type=page'][10] = array( _x('Add New', 'page'), 'edit_pages', 'post-new.php?post_type=page' ); |
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' ); |
71 $i = 15; |
85 $i = 15; |
72 foreach ( get_taxonomies( array(), 'objects' ) as $tax ) { |
86 foreach ( get_taxonomies( array(), 'objects' ) as $tax ) { |
73 if ( ! $tax->show_ui || ! in_array('page', (array) $tax->object_type, true) ) |
87 if ( ! $tax->show_ui || ! in_array('page', (array) $tax->object_type, true) ) |
74 continue; |
88 continue; |
75 |
89 |
95 $ptype_for_id = sanitize_html_class( $ptype ); |
109 $ptype_for_id = sanitize_html_class( $ptype ); |
96 if ( is_string( $ptype_obj->menu_icon ) ) { |
110 if ( is_string( $ptype_obj->menu_icon ) ) { |
97 $menu_icon = esc_url( $ptype_obj->menu_icon ); |
111 $menu_icon = esc_url( $ptype_obj->menu_icon ); |
98 $ptype_class = $ptype_for_id; |
112 $ptype_class = $ptype_for_id; |
99 } else { |
113 } else { |
100 $menu_icon = 'div'; |
114 $menu_icon = 'none'; |
101 $ptype_class = 'post'; |
115 $ptype_class = 'post'; |
102 } |
116 } |
103 |
117 |
104 // if $ptype_menu_position is already populated or will be populated by a hard-coded value below, increment the position. |
118 // if $ptype_menu_position is already populated or will be populated by a hard-coded value below, increment the position. |
105 $core_menu_positions = array(59, 60, 65, 70, 75, 80, 85, 99); |
119 $core_menu_positions = array(59, 60, 65, 70, 75, 80, 85, 99); |
106 while ( isset($menu[$ptype_menu_position]) || in_array($ptype_menu_position, $core_menu_positions) ) |
120 while ( isset($menu[$ptype_menu_position]) || in_array($ptype_menu_position, $core_menu_positions) ) |
107 $ptype_menu_position++; |
121 $ptype_menu_position++; |
108 |
122 |
109 $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 ); |
123 $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 ); |
110 $submenu["edit.php?post_type=$ptype"][5] = array( $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype"); |
124 $submenu["edit.php?post_type=$ptype"][5] = array( $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype"); |
111 $submenu["edit.php?post_type=$ptype"][10] = array( $ptype_obj->labels->add_new, $ptype_obj->cap->edit_posts, "post-new.php?post_type=$ptype" ); |
125 $submenu["edit.php?post_type=$ptype"][10] = array( $ptype_obj->labels->add_new, $ptype_obj->cap->create_posts, "post-new.php?post_type=$ptype" ); |
112 |
126 |
113 $i = 15; |
127 $i = 15; |
114 foreach ( get_taxonomies( array(), 'objects' ) as $tax ) { |
128 foreach ( get_taxonomies( array(), 'objects' ) as $tax ) { |
115 if ( ! $tax->show_ui || ! in_array($ptype, (array) $tax->object_type, true) ) |
129 if ( ! $tax->show_ui || ! in_array($ptype, (array) $tax->object_type, true) ) |
116 continue; |
130 continue; |
121 unset($ptype, $ptype_obj, $ptype_class, $ptype_for_id, $ptype_menu_position, $menu_icon, $i, $tax); |
135 unset($ptype, $ptype_obj, $ptype_class, $ptype_for_id, $ptype_menu_position, $menu_icon, $i, $tax); |
122 |
136 |
123 $menu[59] = array( '', 'read', 'separator2', '', 'wp-menu-separator' ); |
137 $menu[59] = array( '', 'read', 'separator2', '', 'wp-menu-separator' ); |
124 |
138 |
125 if ( current_user_can( 'switch_themes') ) { |
139 if ( current_user_can( 'switch_themes') ) { |
126 $menu[60] = array( __('Appearance'), 'switch_themes', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'div' ); |
140 $menu[60] = array( __('Appearance'), 'switch_themes', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'none' ); |
127 $submenu['themes.php'][5] = array(__('Themes'), 'switch_themes', 'themes.php'); |
141 $submenu['themes.php'][5] = array(__('Themes'), 'switch_themes', 'themes.php'); |
128 if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) |
142 if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) |
129 $submenu['themes.php'][10] = array(__('Menus'), 'edit_theme_options', 'nav-menus.php'); |
143 $submenu['themes.php'][10] = array(__('Menus'), 'edit_theme_options', 'nav-menus.php'); |
130 } else { |
144 } else { |
131 $menu[60] = array( __('Appearance'), 'edit_theme_options', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'div' ); |
145 $menu[60] = array( __('Appearance'), 'edit_theme_options', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'none' ); |
132 $submenu['themes.php'][5] = array(__('Themes'), 'edit_theme_options', 'themes.php'); |
146 $submenu['themes.php'][5] = array(__('Themes'), 'edit_theme_options', 'themes.php'); |
133 if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) |
147 if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) |
134 $submenu['themes.php'][10] = array(__('Menus'), 'edit_theme_options', 'nav-menus.php' ); |
148 $submenu['themes.php'][10] = array(__('Menus'), 'edit_theme_options', 'nav-menus.php' ); |
135 } |
149 } |
136 |
150 |
140 function _add_themes_utility_last() { |
154 function _add_themes_utility_last() { |
141 // Must use API on the admin_menu hook, direct modification is only possible on/before the _admin_menu hook |
155 // Must use API on the admin_menu hook, direct modification is only possible on/before the _admin_menu hook |
142 add_submenu_page('themes.php', _x('Editor', 'theme editor'), _x('Editor', 'theme editor'), 'edit_themes', 'theme-editor.php'); |
156 add_submenu_page('themes.php', _x('Editor', 'theme editor'), _x('Editor', 'theme editor'), 'edit_themes', 'theme-editor.php'); |
143 } |
157 } |
144 |
158 |
145 $menu_perms = get_site_option( 'menu_items', array() ); |
159 $count = ''; |
146 if ( ! is_multisite() || is_super_admin() || ! empty( $menu_perms['plugins'] ) ) { |
160 if ( ! is_multisite() && current_user_can( 'update_plugins' ) ) { |
147 if ( ! isset( $update_data ) ) |
161 if ( ! isset( $update_data ) ) |
148 $update_data = wp_get_update_data(); |
162 $update_data = wp_get_update_data(); |
149 |
163 $count = "<span class='update-plugins count-{$update_data['counts']['plugins']}'><span class='plugin-count'>" . number_format_i18n($update_data['counts']['plugins']) . "</span></span>"; |
150 $count = ''; |
164 } |
151 if ( ! is_multisite() && current_user_can( 'update_plugins' ) ) |
165 |
152 $count = "<span class='update-plugins count-{$update_data['counts']['plugins']}'><span class='plugin-count'>" . number_format_i18n($update_data['counts']['plugins']) . "</span></span>"; |
166 $menu[65] = array( sprintf( __('Plugins %s'), $count ), 'activate_plugins', 'plugins.php', '', 'menu-top menu-icon-plugins', 'menu-plugins', 'none' ); |
153 |
167 |
154 $menu[65] = array( sprintf( __('Plugins %s'), $count ), 'activate_plugins', 'plugins.php', '', 'menu-top menu-icon-plugins', 'menu-plugins', 'div' ); |
168 $submenu['plugins.php'][5] = array( __('Installed Plugins'), 'activate_plugins', 'plugins.php' ); |
155 |
169 |
156 $submenu['plugins.php'][5] = array( __('Installed Plugins'), 'activate_plugins', 'plugins.php' ); |
170 if ( ! is_multisite() ) { |
157 |
171 /* translators: add new plugin */ |
158 if ( ! is_multisite() ) { |
172 $submenu['plugins.php'][10] = array( _x('Add New', 'plugin'), 'install_plugins', 'plugin-install.php' ); |
159 /* translators: add new plugin */ |
173 $submenu['plugins.php'][15] = array( _x('Editor', 'plugin editor'), 'edit_plugins', 'plugin-editor.php' ); |
160 $submenu['plugins.php'][10] = array( _x('Add New', 'plugin'), 'install_plugins', 'plugin-install.php' ); |
174 } |
161 $submenu['plugins.php'][15] = array( _x('Editor', 'plugin editor'), 'edit_plugins', 'plugin-editor.php' ); |
175 |
162 } |
176 unset( $update_data ); |
163 } |
|
164 unset($menu_perms, $update_data); |
|
165 |
177 |
166 if ( current_user_can('list_users') ) |
178 if ( current_user_can('list_users') ) |
167 $menu[70] = array( __('Users'), 'list_users', 'users.php', '', 'menu-top menu-icon-users', 'menu-users', 'div' ); |
179 $menu[70] = array( __('Users'), 'list_users', 'users.php', '', 'menu-top menu-icon-users', 'menu-users', 'none' ); |
168 else |
180 else |
169 $menu[70] = array( __('Profile'), 'read', 'profile.php', '', 'menu-top menu-icon-users', 'menu-users', 'div' ); |
181 $menu[70] = array( __('Profile'), 'read', 'profile.php', '', 'menu-top menu-icon-users', 'menu-users', 'none' ); |
170 |
182 |
171 if ( current_user_can('list_users') ) { |
183 if ( current_user_can('list_users') ) { |
172 $_wp_real_parent_file['profile.php'] = 'users.php'; // Back-compat for plugins adding submenus to profile.php. |
184 $_wp_real_parent_file['profile.php'] = 'users.php'; // Back-compat for plugins adding submenus to profile.php. |
173 $submenu['users.php'][5] = array(__('All Users'), 'list_users', 'users.php'); |
185 $submenu['users.php'][5] = array(__('All Users'), 'list_users', 'users.php'); |
174 if ( current_user_can('create_users') ) |
186 if ( current_user_can('create_users') ) |
184 $submenu['profile.php'][10] = array(__('Add New User'), 'create_users', 'user-new.php'); |
196 $submenu['profile.php'][10] = array(__('Add New User'), 'create_users', 'user-new.php'); |
185 else |
197 else |
186 $submenu['profile.php'][10] = array(__('Add New User'), 'promote_users', 'user-new.php'); |
198 $submenu['profile.php'][10] = array(__('Add New User'), 'promote_users', 'user-new.php'); |
187 } |
199 } |
188 |
200 |
189 $menu[75] = array( __('Tools'), 'edit_posts', 'tools.php', '', 'menu-top menu-icon-tools', 'menu-tools', 'div' ); |
201 $menu[75] = array( __('Tools'), 'edit_posts', 'tools.php', '', 'menu-top menu-icon-tools', 'menu-tools', 'none' ); |
190 $submenu['tools.php'][5] = array( __('Available Tools'), 'edit_posts', 'tools.php' ); |
202 $submenu['tools.php'][5] = array( __('Available Tools'), 'edit_posts', 'tools.php' ); |
191 $submenu['tools.php'][10] = array( __('Import'), 'import', 'import.php' ); |
203 $submenu['tools.php'][10] = array( __('Import'), 'import', 'import.php' ); |
192 $submenu['tools.php'][15] = array( __('Export'), 'export', 'export.php' ); |
204 $submenu['tools.php'][15] = array( __('Export'), 'export', 'export.php' ); |
193 if ( is_multisite() && !is_main_site() ) |
205 if ( is_multisite() && !is_main_site() ) |
194 $submenu['tools.php'][25] = array( __('Delete Site'), 'manage_options', 'ms-delete-site.php' ); |
206 $submenu['tools.php'][25] = array( __('Delete Site'), 'manage_options', 'ms-delete-site.php' ); |
195 if ( ! is_multisite() && defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE ) |
207 if ( ! is_multisite() && defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE ) |
196 $submenu['tools.php'][50] = array(__('Network Setup'), 'manage_options', 'network.php'); |
208 $submenu['tools.php'][50] = array(__('Network Setup'), 'manage_options', 'network.php'); |
197 |
209 |
198 $menu[80] = array( __('Settings'), 'manage_options', 'options-general.php', '', 'menu-top menu-icon-settings', 'menu-settings', 'div' ); |
210 $menu[80] = array( __('Settings'), 'manage_options', 'options-general.php', '', 'menu-top menu-icon-settings', 'menu-settings', 'none' ); |
199 $submenu['options-general.php'][10] = array(_x('General', 'settings screen'), 'manage_options', 'options-general.php'); |
211 $submenu['options-general.php'][10] = array(_x('General', 'settings screen'), 'manage_options', 'options-general.php'); |
200 $submenu['options-general.php'][15] = array(__('Writing'), 'manage_options', 'options-writing.php'); |
212 $submenu['options-general.php'][15] = array(__('Writing'), 'manage_options', 'options-writing.php'); |
201 $submenu['options-general.php'][20] = array(__('Reading'), 'manage_options', 'options-reading.php'); |
213 $submenu['options-general.php'][20] = array(__('Reading'), 'manage_options', 'options-reading.php'); |
202 $submenu['options-general.php'][25] = array(__('Discussion'), 'manage_options', 'options-discussion.php'); |
214 $submenu['options-general.php'][25] = array(__('Discussion'), 'manage_options', 'options-discussion.php'); |
203 $submenu['options-general.php'][30] = array(__('Media'), 'manage_options', 'options-media.php'); |
215 $submenu['options-general.php'][30] = array(__('Media'), 'manage_options', 'options-media.php'); |
204 $submenu['options-general.php'][35] = array(__('Privacy'), 'manage_options', 'options-privacy.php'); |
|
205 $submenu['options-general.php'][40] = array(__('Permalinks'), 'manage_options', 'options-permalink.php'); |
216 $submenu['options-general.php'][40] = array(__('Permalinks'), 'manage_options', 'options-permalink.php'); |
206 |
217 |
207 $_wp_last_utility_menu = 80; // The index of the last top-level menu in the utility menu group |
218 $_wp_last_utility_menu = 80; // The index of the last top-level menu in the utility menu group |
208 |
219 |
209 $menu[99] = array( '', 'read', 'separator-last', '', 'wp-menu-separator' ); |
220 $menu[99] = array( '', 'read', 'separator-last', '', 'wp-menu-separator' ); |