45
45
$menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' );
47
$menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'open-if-no-js menu-top menu-icon-post', 'menu-posts', 'dashicons-admin-post' );
48
$submenu['edit.php'][5] = array( __('All Posts'), 'edit_posts', 'edit.php' );
49
/* translators: add new post */
50
$submenu['edit.php'][10] = array( _x('Add New', 'post'), get_post_type_object( 'post' )->cap->create_posts, 'post-new.php' );
53
foreach ( get_taxonomies( array(), 'objects' ) as $tax ) {
54
if ( ! $tax->show_ui || ! $tax->show_in_menu || ! in_array('post', (array) $tax->object_type, true) )
57
$submenu['edit.php'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name );
61
49
$menu[10] = array( __('Media'), 'upload_files', 'upload.php', '', 'menu-top menu-icon-media', 'menu-media', 'dashicons-admin-media' );
62
50
$submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php');
63
51
/* translators: add new file */
64
52
$submenu['upload.php'][10] = array( _x('Add New', 'file'), 'upload_files', 'media-new.php');
65
54
foreach ( get_taxonomies_for_attachments( 'objects' ) as $tax ) {
66
55
if ( ! $tax->show_ui || ! $tax->show_in_menu )
69
58
$submenu['upload.php'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name . '&post_type=attachment' );
73
62
$menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-top menu-icon-links', 'menu-links', 'dashicons-admin-links' );
74
63
$submenu['link-manager.php'][5] = array( _x('All Links', 'admin menu'), 'manage_links', 'link-manager.php' );
76
65
$submenu['link-manager.php'][10] = array( _x('Add New', 'link'), 'manage_links', 'link-add.php' );
77
66
$submenu['link-manager.php'][15] = array( __('Link Categories'), 'manage_categories', 'edit-tags.php?taxonomy=link_category' );
79
$menu[20] = array( __('Pages'), 'edit_pages', 'edit.php?post_type=page', '', 'menu-top menu-icon-page', 'menu-pages', 'dashicons-admin-page' );
80
$submenu['edit.php?post_type=page'][5] = array( __('All Pages'), 'edit_pages', 'edit.php?post_type=page' );
81
/* translators: add new page */
82
$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' );
84
foreach ( get_taxonomies( array(), 'objects' ) as $tax ) {
85
if ( ! $tax->show_ui || ! $tax->show_in_menu || ! in_array('page', (array) $tax->object_type, true) )
88
$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' );
92
$awaiting_mod = wp_count_comments();
93
$awaiting_mod = $awaiting_mod->moderated;
94
$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' );
70
// Avoid the comment count query for users who cannot edit_posts.
71
if ( current_user_can( 'edit_posts' ) ) {
72
$awaiting_mod = wp_count_comments();
73
$awaiting_mod = $awaiting_mod->moderated;
75
sprintf( __( 'Comments %s' ), '<span class="awaiting-mod count-' . absint( $awaiting_mod ) . '"><span class="pending-count">' . number_format_i18n( $awaiting_mod ) . '</span></span>' ),
79
'menu-top menu-icon-comments',
81
'dashicons-admin-comments',
83
unset( $awaiting_mod );
97
86
$submenu[ 'edit-comments.php' ][0] = array( __('All Comments'), 'edit_posts', 'edit-comments.php' );
99
88
$_wp_last_object_menu = 25; // The index of the last top-level menu in the object menu group
101
foreach ( (array) get_post_types( array('show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) ) as $ptype ) {
90
$types = (array) get_post_types( array('show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) );
91
$builtin = array( 'post', 'page' );
92
foreach ( array_merge( $builtin, $types ) as $ptype ) {
102
93
$ptype_obj = get_post_type_object( $ptype );
103
94
// Check if it should be a submenu.
104
95
if ( $ptype_obj->show_in_menu !== true )
106
97
$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.
107
98
$ptype_for_id = sanitize_html_class( $ptype );
100
$menu_icon = 'dashicons-admin-post';
109
101
if ( is_string( $ptype_obj->menu_icon ) ) {
110
102
// Special handling for data:image/svg+xml and Dashicons.
111
103
if ( 0 === strpos( $ptype_obj->menu_icon, 'data:image/svg+xml;base64,' ) || 0 === strpos( $ptype_obj->menu_icon, 'dashicons-' ) ) {
114
106
$menu_icon = esc_url( $ptype_obj->menu_icon );
116
$ptype_class = $ptype_for_id;
118
$menu_icon = 'dashicons-admin-post';
119
$ptype_class = 'post';
108
} elseif ( in_array( $ptype, $builtin ) ) {
109
$menu_icon = 'dashicons-admin-' . $ptype;
112
$menu_class = 'menu-top menu-icon-' . $ptype_for_id;
113
// 'post' special case
114
if ( 'post' === $ptype ) {
115
$menu_class .= ' open-if-no-js';
116
$ptype_file = "edit.php";
117
$post_new_file = "post-new.php";
118
$edit_tags_file = "edit-tags.php?taxonomy=%s";
120
$ptype_file = "edit.php?post_type=$ptype";
121
$post_new_file = "post-new.php?post_type=$ptype";
122
$edit_tags_file = "edit-tags.php?taxonomy=%s&post_type=$ptype";
125
if ( in_array( $ptype, $builtin ) ) {
126
$ptype_menu_id = 'menu-' . $ptype_for_id . 's';
128
$ptype_menu_id = 'menu-posts-' . $ptype_for_id;
123
131
* If $ptype_menu_position is already populated or will be populated
124
132
* by a hard-coded value below, increment the position.
127
135
while ( isset($menu[$ptype_menu_position]) || in_array($ptype_menu_position, $core_menu_positions) )
128
136
$ptype_menu_position++;
130
$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 );
131
$submenu["edit.php?post_type=$ptype"][5] = array( $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype");
132
$submenu["edit.php?post_type=$ptype"][10] = array( $ptype_obj->labels->add_new, $ptype_obj->cap->create_posts, "post-new.php?post_type=$ptype" );
138
$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 );
139
$submenu[ $ptype_file ][5] = array( $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, $ptype_file );
140
$submenu[ $ptype_file ][10] = array( $ptype_obj->labels->add_new, $ptype_obj->cap->create_posts, $post_new_file );
135
143
foreach ( get_taxonomies( array(), 'objects' ) as $tax ) {
136
144
if ( ! $tax->show_ui || ! $tax->show_in_menu || ! in_array($ptype, (array) $tax->object_type, true) )
139
$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" );
147
$submenu[ $ptype_file ][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, sprintf( $edit_tags_file, $tax->name ) );
142
unset($ptype, $ptype_obj, $ptype_class, $ptype_for_id, $ptype_menu_position, $menu_icon, $i, $tax);
150
unset( $ptype, $ptype_obj, $ptype_for_id, $ptype_menu_position, $menu_icon, $i, $tax, $post_new_file );
144
152
$menu[59] = array( '', 'read', 'separator2', '', 'wp-menu-separator' );