Make WordPress Core


Ignore:
Timestamp:
06/11/2011 02:20:18 AM (14 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.