Make WordPress Core

Ticket #19069: 19069.diff

File 19069.diff, 5.2 KB (added by kawauso, 14 years ago)

First pass

  • wp-admin/menu.php

     
    3939
    4040$menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' );
    4141
    42 $menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'open-if-no-js menu-top menu-icon-post', 'menu-posts', 'div' );
    43         $submenu['edit.php'][5]  = array( __('All Posts'), 'edit_posts', 'edit.php' );
    44         /* translators: add new post */
    45         $submenu['edit.php'][10]  = array( _x('Add New', 'post'), 'edit_posts', 'post-new.php' );
     42if ( in_array( 'post', get_post_types( array('show_ui' => true ) ) ) ) {
     43        $menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'open-if-no-js menu-top menu-icon-post', 'menu-posts', 'div' );
     44                $submenu['edit.php'][5]  = array( __('All Posts'), 'edit_posts', 'edit.php' );
     45                /* translators: add new post */
     46                $submenu['edit.php'][10]  = array( _x('Add New', 'post'), 'edit_posts', 'post-new.php' );
    4647
    47         $i = 15;
    48         foreach ( get_taxonomies( array(), 'objects' ) as $tax ) {
    49                 if ( ! $tax->show_ui || ! in_array('post', (array) $tax->object_type, true) )
    50                         continue;
     48                $i = 15;
     49                foreach ( get_taxonomies( array(), 'objects' ) as $tax ) {
     50                        if ( ! $tax->show_ui || ! in_array('post', (array) $tax->object_type, true) )
     51                                continue;
    5152
    52                 $submenu['edit.php'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name );
    53         }
    54         unset($tax);
     53                        $submenu['edit.php'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name );
     54                }
     55                unset($tax);
     56}
    5557
    5658$menu[10] = array( __('Media'), 'upload_files', 'upload.php', '', 'menu-top menu-icon-media', 'menu-media', 'div' );
    5759        $submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php');
     
    6466        $submenu['link-manager.php'][10] = array( _x('Add New', 'link'), 'manage_links', 'link-add.php' );
    6567        $submenu['link-manager.php'][15] = array( __('Link Categories'), 'manage_categories', 'edit-tags.php?taxonomy=link_category' );
    6668
    67 $menu[20] = array( __('Pages'), 'edit_pages', 'edit.php?post_type=page', '', 'menu-top menu-icon-page', 'menu-pages', 'div' );
    68         $submenu['edit.php?post_type=page'][5] = array( __('All Pages'), 'edit_pages', 'edit.php?post_type=page' );
    69         /* 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' );
    71         $i = 15;
    72         foreach ( get_taxonomies( array(), 'objects' ) as $tax ) {
    73                 if ( ! $tax->show_ui || ! in_array('page', (array) $tax->object_type, true) )
    74                         continue;
     69if ( in_array( 'page', get_post_types( array('show_ui' => true ) ) ) ) {
     70        $menu[20] = array( __('Pages'), 'edit_pages', 'edit.php?post_type=page', '', 'menu-top menu-icon-page', 'menu-pages', 'div' );
     71                $submenu['edit.php?post_type=page'][5] = array( __('All Pages'), 'edit_pages', 'edit.php?post_type=page' );
     72                /* translators: add new page */
     73                $submenu['edit.php?post_type=page'][10] = array( _x('Add New', 'page'), 'edit_pages', 'post-new.php?post_type=page' );
     74                $i = 15;
     75                foreach ( get_taxonomies( array(), 'objects' ) as $tax ) {
     76                        if ( ! $tax->show_ui || ! in_array('page', (array) $tax->object_type, true) )
     77                                continue;
    7578
    76                 $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' );
     79                        $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' );
     80                }
     81                unset($tax);
     82}
     83
     84$show_comments_menu = false;
     85foreach ( (array) get_post_types( array( 'show_ui' => true ) ) as $ptype ) {
     86        if ( post_type_supports( $ptype, 'comments' ) ) {
     87                $show_comments_menu = true;
     88                break;
    7789        }
    78         unset($tax);
     90}
    7991
    80 $awaiting_mod = wp_count_comments();
    81 $awaiting_mod = $awaiting_mod->moderated;
    82 $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', 'div' );
    83 unset($awaiting_mod);
     92if ( $show_comments_menu ) {
     93        $awaiting_mod = wp_count_comments();
     94        $awaiting_mod = $awaiting_mod->moderated;
     95        $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', 'div' );
     96        unset($awaiting_mod);
    8497
    85 $submenu[ 'edit-comments.php' ][0] = array( __('All Comments'), 'edit_posts', 'edit-comments.php' );
     98        $submenu[ 'edit-comments.php' ][0] = array( __('All Comments'), 'edit_posts', 'edit-comments.php' );
     99}
    86100
    87 $_wp_last_object_menu = 25; // The index of the last top-level menu in the object menu group
     101end( $menu );
     102$_wp_last_object_menu = key( $menu ); // The index of the last top-level menu in the object menu group
    88103
    89104foreach ( (array) get_post_types( array('show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) ) as $ptype ) {
    90105        $ptype_obj = get_post_type_object( $ptype );