Make WordPress Core


Ignore:
Timestamp:
10/10/2011 06:40:00 PM (15 years ago)
Author:
koopersmith
Message:

Improve admin bar item order for W menu, add new menu, and edit content item. see #18197.

File:
1 edited

Legend:

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

    r18919 r18927  
    118118        ) );
    119119
     120        // Add WordPress.org link
     121        $wp_admin_bar->add_menu( array(
     122                'parent' => 'wp-logo-secondary',
     123                'id'     => 'wporg',
     124                'title'  => __('WordPress.org'),
     125                'href'   => 'http://wordpress.org',
     126        ) );
     127
    120128        // Add codex link
    121129        $wp_admin_bar->add_menu( array(
    … …  
    126134        ) );
    127135
     136        // Add forums link
     137        $wp_admin_bar->add_menu( array(
     138                'parent' => 'wp-logo-secondary',
     139                'id'     => 'support-forums',
     140                'title'  => __('Support Forums'),
     141                'href'   => 'http://wordpress.org/support/',
     142        ) );
     143
    128144        // Add feedback link
    129145        $wp_admin_bar->add_menu( array(
    … …  
    132148                'title'  => __('Feedback'),
    133149                'href'   => 'http://wordpress.org/support/forum/requests-and-feedback',
    134         ) );
    135 
    136         // Add forums link
    137         $wp_admin_bar->add_menu( array(
    138                 'parent' => 'wp-logo-secondary',
    139                 'id'     => 'support-forums',
    140                 'title'  => __('Support Forums'),
    141                 'href'   => 'http://wordpress.org/support/',
    142         ) );
    143 
    144         // Add WordPress.org link
    145         $wp_admin_bar->add_menu( array(
    146                 'parent' => 'wp-logo-secondary',
    147                 'id'     => 'wporg',
    148                 'title'  => __('WordPress.org'),
    149                 'href'   => 'http://wordpress.org',
    150150        ) );
    151151}
    … …  
    466466        $primary = $secondary = array();
    467467
    468         foreach ( (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' ) as $ptype_obj ) {
    469                 if ( ! current_user_can( $ptype_obj->cap->edit_posts ) )
    470                         continue;
    471 
    472                 $key = 'post' == $ptype_obj->name ? 'post-new.php' : 'post-new.php?post_type=' . $ptype_obj->name;
    473                 $primary[ $key ] = array( $ptype_obj->labels->name_admin_bar, 'new-' . $ptype_obj->name );
     468        $cpts = (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' );
     469
     470        if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->edit_posts ) ) {
     471                $primary[ 'post-new.php' ] = array( $cpts['post']->labels->name_admin_bar, 'new-post' );
     472                unset( $cpts['post'] );
    474473        }
    475474
    … …  
    480479                $primary[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'new-link' );
    481480
     481        if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->edit_posts ) ) {
     482                $primary[ 'post-new.php?post_type=page' ] = array( $cpts['page']->labels->name_admin_bar, 'new-page' );
     483                unset( $cpts['page'] );
     484        }
     485
     486        // Add any additional custom post types.
     487        foreach ( $cpts as $cpt ) {
     488                if ( ! current_user_can( $cpt->cap->edit_posts ) )
     489                        continue;
     490
     491                $key = 'post-new.php?post_type=' . $cpt->name;
     492                $primary[ $key ] = array( $cpt->labels->name_admin_bar, 'new-' . $cpt->name );
     493        }
     494
    482495        if ( current_user_can( 'create_users' ) || current_user_can( 'promote_users' ) )
    483496                $secondary[ 'user-new.php' ] = array( _x( 'User', 'add new from admin bar' ), 'new-user' );
    484 
    485         if ( ! is_multisite() && current_user_can( 'install_themes' ) )
    486                 $secondary[ 'theme-install.php' ] = array( _x( 'Theme', 'add new from admin bar' ), 'new-theme' );
    487 
    488         if ( ! is_multisite() && current_user_can( 'install_plugins' ) )
    489                 $secondary[ 'plugin-install.php' ] = array( _x( 'Plugin', 'add new from admin bar' ), 'new-plugin' );
    490497
    491498        if ( ! $primary && ! $secondary )
Note: See TracChangeset for help on using the changeset viewer.