WordPress.org

Make WordPress Core

Ticket #16865: 16865.2.diff

File 16865.2.diff, 6.2 KB (added by scribu, 4 years ago)

enclosing function

  • wp-includes/post.php

     
    1919function create_initial_post_types() { 
    2020        register_post_type( 'post', array( 
    2121                'public'  => true, 
    22                 '_builtin' => true, /* internal use only. don't use this when registering your own post type. */ 
     22                'menu_position' => 5, 
    2323                '_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */ 
    2424                'capability_type' => 'post', 
    2525                'map_meta_cap' => true, 
  • wp-admin/menu.php

     
    2121 * @name $menu 
    2222 * @var array 
    2323 */ 
     24function _wp_build_admin_menu() { 
     25        global $menu, $submenu, $_wp_last_object_menu, $_wp_last_utility_menu, $_wp_real_parent_file; 
    2426 
    2527$menu[2] = array( __('Dashboard'), 'read', 'index.php', '', 'menu-top menu-top-first menu-icon-dashboard', 'menu-dashboard', 'div' ); 
    2628 
     
    5860        $submenu[ 'index.php' ][10] = array( sprintf( __('Updates %s'), "<span class='update-plugins count-$total_update_count' title='$update_title'><span class='update-count'>" . number_format_i18n($total_update_count) . "</span></span>" ), 'update_core',  'update-core.php'); 
    5961} 
    6062 
    61 unset($plugin_update_count, $theme_update_count, $wordpress_update_count, $update_themes, $update_plugins, $update_wordpress); 
    62  
    6363$menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' ); 
    6464 
    65 $menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'open-if-no-js menu-top menu-icon-post', 'menu-posts', 'div' ); 
    66         $submenu['edit.php'][5]  = array( __('Posts'), 'edit_posts', 'edit.php' ); 
    67         /* translators: add new post */ 
    68         $submenu['edit.php'][10]  = array( _x('Add New', 'post'), 'edit_posts', 'post-new.php' ); 
    69  
    70         $i = 15; 
    71         foreach ( get_taxonomies( array(), 'objects' ) as $tax ) { 
    72                 if ( ! $tax->show_ui || ! in_array('post', (array) $tax->object_type, true) ) 
    73                         continue; 
    74  
    75                 $submenu['edit.php'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name ); 
    76         } 
    77         unset($tax); 
    78  
    7965$menu[10] = array( __('Media'), 'upload_files', 'upload.php', '', 'menu-top menu-icon-media', 'menu-media', 'div' ); 
    8066        $submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php'); 
    8167        /* translators: add new file */ 
     
    10389$awaiting_mod = wp_count_comments(); 
    10490$awaiting_mod = $awaiting_mod->moderated; 
    10591$menu[25] = array( sprintf( __('Comments %s'), "<span id='awaiting-mod' class='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' ); 
    106 unset($awaiting_mod); 
    10792 
    10893$_wp_last_object_menu = 25; // The index of the last top-level menu in the object menu group 
    10994 
     
    11499                continue; 
    115100        $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. 
    116101        $ptype_for_id = sanitize_html_class( $ptype ); 
     102 
    117103        if ( is_string( $ptype_obj->menu_icon ) ) { 
    118104                $menu_icon   = esc_url( $ptype_obj->menu_icon ); 
    119105                $ptype_class = $ptype_for_id; 
     
    122108                $ptype_class = 'post'; 
    123109        } 
    124110 
     111        $menu_class = 'menu-top menu-icon-' . $ptype_class; 
     112        // 'post' special case 
     113        if ( 'post' == $ptype ) 
     114                $menu_class .= ' open-if-no-js'; 
     115 
    125116        // if $ptype_menu_position is already populated or will be populated by a hard-coded value below, increment the position. 
    126117        $core_menu_positions = array(59, 60, 65, 70, 75, 80, 85, 99); 
    127118        while ( isset($menu[$ptype_menu_position]) || in_array($ptype_menu_position, $core_menu_positions) ) 
    128119                $ptype_menu_position++; 
    129120 
    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 ); 
     121        $menu[$ptype_menu_position] = array( esc_attr( $ptype_obj->labels->menu_name ), $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype", '', $menu_class, 'menu-posts-' . $ptype_for_id, $menu_icon ); 
     122 
    131123        $submenu["edit.php?post_type=$ptype"][5]  = array( $ptype_obj->labels->menu_name, $ptype_obj->cap->edit_posts,  "edit.php?post_type=$ptype"); 
    132124        $submenu["edit.php?post_type=$ptype"][10]  = array( $ptype_obj->labels->add_new, $ptype_obj->cap->edit_posts, "post-new.php?post_type=$ptype" ); 
    133125 
     
    139131                $submenu["edit.php?post_type=$ptype"][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, "edit-tags.php?taxonomy=$tax->name&amp;post_type=$ptype" ); 
    140132        } 
    141133} 
    142 unset($ptype, $ptype_obj, $ptype_class, $ptype_for_id, $ptype_menu_position, $menu_icon, $i, $tax); 
    143134 
    144135$menu[59] = array( '', 'read', 'separator2', '', 'wp-menu-separator' ); 
    145136 
     
    181172                        $submenu['plugins.php'][15] = array( _x('Editor', 'plugin editor'), 'edit_plugins', 'plugin-editor.php' ); 
    182173                } 
    183174} 
    184 unset($menu_perms, $update_plugins, $update_count); 
    185175 
    186176if ( current_user_can('list_users') ) 
    187177        $menu[70] = array( __('Users'), 'list_users', 'users.php', '', 'menu-top menu-icon-users', 'menu-users', 'div' ); 
     
    235225$_wp_real_parent_file['page-new.php'] = 'edit.php?post_type=page'; 
    236226$_wp_real_parent_file['wpmu-admin.php'] = 'tools.php'; 
    237227$_wp_real_parent_file['ms-admin.php'] = 'tools.php'; 
     228} 
     229_wp_build_admin_menu(); 
    238230 
    239231// ensure we're backwards compatible 
    240232$compat = array( 
  • wp-admin/edit.php

     
    3535} 
    3636unset( $_redirect ); 
    3737 
    38 if ( 'post' != $post_type ) { 
    39         $parent_file = "edit.php?post_type=$post_type"; 
    40         $submenu_file = "edit.php?post_type=$post_type"; 
    41         $post_new_file = "post-new.php?post_type=$post_type"; 
    42 } else { 
    43         $parent_file = 'edit.php'; 
    44         $submenu_file = 'edit.php'; 
    45         $post_new_file = 'post-new.php'; 
    46 } 
     38$parent_file = "edit.php?post_type=$post_type"; 
     39$submenu_file = "edit.php?post_type=$post_type"; 
     40$post_new_file = "post-new.php?post_type=$post_type"; 
    4741 
    4842$doaction = $wp_list_table->current_action(); 
    4943