Changeset 18787
- Timestamp:
- 09/27/2011 03:53:43 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/admin-bar.php
r18777 r18787 430 430 */ 431 431 function wp_admin_bar_new_content_menu( $wp_admin_bar ) { 432 $actions = array(); 432 $primary = array(); 433 $secondary = array(); 434 433 435 foreach ( (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' ) as $ptype_obj ) { 434 436 if ( ! current_user_can( $ptype_obj->cap->edit_posts ) ) 435 437 continue; 436 438 437 $ 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 );439 $primary[ 'post-new.php?post_type=' . $ptype_obj->name ] = array( $ptype_obj->labels->name_admin_bar, $ptype_obj->cap->edit_posts, 'new-' . $ptype_obj->name ); 438 440 } 439 441 440 442 if ( current_user_can( 'upload_files' ) ) 441 $ actions[ 'media-new.php' ] = array( _x( 'Media', 'add new from admin bar' ), 'upload_files', 'new-media' );443 $primary[ 'media-new.php' ] = array( _x( 'Media', 'add new from admin bar' ), 'upload_files', 'new-media' ); 442 444 443 445 if ( current_user_can( 'manage_links' ) ) 444 $ actions[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'manage_links', 'new-link' );446 $primary[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'manage_links', 'new-link' ); 445 447 446 448 if ( current_user_can( 'create_users' ) || current_user_can( 'promote_users' ) ) 447 $ actions[ 'user-new.php' ] = array( _x( 'User', 'add new from admin bar' ), 'create_users', 'new-user' );449 $secondary[ 'user-new.php' ] = array( _x( 'User', 'add new from admin bar' ), 'create_users', 'new-user' ); 448 450 449 451 if ( ! is_multisite() && current_user_can( 'install_themes' ) ) 450 $ actions[ 'theme-install.php' ] = array( _x( 'Theme', 'add new from admin bar' ), 'install_themes', 'new-theme' );452 $secondary[ 'theme-install.php' ] = array( _x( 'Theme', 'add new from admin bar' ), 'install_themes', 'new-theme' ); 451 453 452 454 if ( ! is_multisite() && current_user_can( 'install_plugins' ) ) 453 $ actions[ 'plugin-install.php' ] = array( _x( 'Plugin', 'add new from admin bar' ), 'install_plugins', 'new-plugin' );454 455 if ( empty( $ actions) )455 $secondary[ 'plugin-install.php' ] = array( _x( 'Plugin', 'add new from admin bar' ), 'install_plugins', 'new-plugin' ); 456 457 if ( empty( $primary ) && empty( $secondary ) ) 456 458 return; 457 459 458 $wp_admin_bar->add_menu( array( 'id' => 'new-content', 'title' => _x( 'Add New', 'admin bar menu group label' ), 'href' => admin_url( array_shift( array_keys( $actions ) ) ) ) ); 459 460 foreach ( $actions as $link => $action ) { 461 $wp_admin_bar->add_menu( array( 'parent' => 'new-content', 'id' => $action[2], 'title' => $action[0], 'href' => admin_url($link) ) ); 460 $wp_admin_bar->add_menu( array( 461 'id' => 'new-content', 462 'title' => _x( 'Add New', 'admin bar menu group label' ), 463 'href' => admin_url( array_shift( array_keys( $primary ) ) ), 464 ) ); 465 466 $items = array( 467 'new-content' => $primary, 468 'new-content-secondary' => $secondary, 469 ); 470 471 foreach ( $items as $parent => $actions ) { 472 473 if ( ! empty( $actions ) && $parent == 'new-content-secondary' ) { 474 $wp_admin_bar->add_menu( array( 475 'parent' => 'new-content', 476 'id' => 'new-content-secondary', 477 'title' => ' ', 478 'meta' => array( 479 'class' => 'secondary', 480 ), 481 ) ); 482 } 483 484 foreach ( $actions as $link => $action ) { 485 $wp_admin_bar->add_menu( array( 486 'parent' => $parent, 487 'id' => $action[2], 488 'title' => $action[0], 489 'href' => admin_url( $link ) 490 ) ); 491 } 462 492 } 463 493 }
Note: See TracChangeset
for help on using the changeset viewer.