WordPress.org

Make WordPress Core

Changeset 18261


Ignore:
Timestamp:
06/11/11 02:20:18 (3 years ago)
Author:
nacin
Message:

Introduce name_admin_bar label and the show_in_admin_bar (Add New menu) argument for post types. Allows for proper translations of these strings and provides for consolidated logic. fixes #16406.

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/admin-bar.php

    r18254 r18261  
    239239function wp_admin_bar_new_content_menu( $wp_admin_bar ) { 
    240240    $actions = array(); 
    241     foreach ( (array) get_post_types( array( 'show_ui' => true ), 'objects' ) as $ptype_obj ) { 
    242         if ( true !== $ptype_obj->show_in_menu || ! current_user_can( $ptype_obj->cap->edit_posts ) ) 
     241    foreach ( (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' ) as $ptype_obj ) { 
     242        if ( ! current_user_can( $ptype_obj->cap->edit_posts ) ) 
    243243            continue; 
    244244 
    245         $actions[ 'post-new.php?post_type=' . $ptype_obj->name ] = array( $ptype_obj->labels->singular_name, $ptype_obj->cap->edit_posts, 'new-' . $ptype_obj->name ); 
     245        $actions[ 'post-new.php?post_type=' . $ptype_obj->name ] = array( $ptype_obj->labels->name_admin_bar, $ptype_obj->cap->edit_posts, 'new-' . $ptype_obj->name ); 
    246246    } 
    247247 
  • trunk/wp-includes/post.php

    r18234 r18261  
    1919function create_initial_post_types() { 
    2020    register_post_type( 'post', array( 
     21        'labels' => array( 
     22            'name_admin_bar' => _x( 'Post', 'add new on admin bar' ), 
     23        ), 
    2124        'public'  => true, 
    2225        '_builtin' => true, /* internal use only. don't use this when registering your own post type. */ 
     
    3134 
    3235    register_post_type( 'page', array( 
     36        'labels' => array( 
     37            'name_admin_bar' => _x( 'Page', 'add new on admin bar' ), 
     38        ), 
    3339        'public' => true, 
    3440        'publicly_queryable' => false, 
     
    916922        'supports' => array(), 'register_meta_box_cb' => null, 
    917923        'taxonomies' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null, 
    918         'permalink_epmask' => EP_PERMALINK, 'can_export' => true, 'show_in_nav_menus' => null, 'show_in_menu' => null, 
     924        'permalink_epmask' => EP_PERMALINK, 'can_export' => true, 
     925        'show_in_nav_menus' => null, 'show_in_menu' => null, 'show_in_admin_bar' => null, 
    919926    ); 
    920927    $args = wp_parse_args($args, $defaults); 
     
    938945    if ( null === $args->show_in_menu || ! $args->show_ui ) 
    939946        $args->show_in_menu = $args->show_ui; 
     947 
     948    // If not set, default to the whether the full UI is shown. 
     949    if ( null === $args->show_in_admin_bar ) 
     950        $args->show_in_admin_bar = true === $args->show_in_menu; 
    940951 
    941952    // Whether to show this type in nav-menus.php.  Defaults to the setting for public. 
     
    11941205    if ( !isset( $object->labels['singular_name'] ) && isset( $object->labels['name'] ) ) 
    11951206        $object->labels['singular_name'] = $object->labels['name']; 
     1207 
     1208    if ( ! isset( $object->labels['name_admin_bar'] ) ) 
     1209        $object->labels['name_admin_bar'] = isset( $object->labels['singular_name'] ) ? $object->labels['singular_name'] : $object->name; 
    11961210 
    11971211    if ( !isset( $object->labels['menu_name'] ) && isset( $object->labels['name'] ) ) 
Note: See TracChangeset for help on using the changeset viewer.