Ticket #19541: 19541.diff
| File 19541.diff, 3.4 KB (added by nacin, 8 months ago) |
|---|
-
wp-includes/admin-bar.php
488 488 $cpts = (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' ); 489 489 490 490 if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->edit_posts ) ) { 491 $actions[ 'post-new.php' ] = array($cpts['post']->labels->name_admin_bar, 'new-post' );491 $actions[5] = array( 'post-new.php', $cpts['post']->labels->name_admin_bar, 'new-post' ); 492 492 unset( $cpts['post'] ); 493 493 } 494 494 495 495 if ( current_user_can( 'upload_files' ) ) 496 $actions[ 'media-new.php' ] = array(_x( 'Media', 'add new from admin bar' ), 'new-media' );496 $actions[10] = array( 'media-new.php', _x( 'Media', 'add new from admin bar' ), 'new-media' ); 497 497 498 498 if ( current_user_can( 'manage_links' ) ) 499 $actions[ 'link-add.php' ] = array(_x( 'Link', 'add new from admin bar' ), 'new-link' );499 $actions[15] = array( 'link-add.php', _x( 'Link', 'add new from admin bar' ), 'new-link' ); 500 500 501 501 if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->edit_posts ) ) { 502 $actions[ 'post-new.php?post_type=page' ] = array($cpts['page']->labels->name_admin_bar, 'new-page' );502 $actions[20] = array( 'post-new.php?post_type=page', $cpts['page']->labels->name_admin_bar, 'new-page' ); 503 503 unset( $cpts['page'] ); 504 504 } 505 505 506 if ( current_user_can( 'promote_users' ) || current_user_can( 'create_users' ) ) 507 $actions[70] = array( 'user-new.php', _x( 'User', 'add new from admin bar' ), 'new-user' ); 508 506 509 // Add any additional custom post types. 507 510 foreach ( $cpts as $cpt ) { 508 511 if ( ! current_user_can( $cpt->cap->edit_posts ) ) 509 512 continue; 510 513 511 $key = 'post-new.php?post_type=' . $cpt->name; 512 $actions[ $key ] = array( $cpt->labels->name_admin_bar, 'new-' . $cpt->name ); 514 $link = 'post-new.php?post_type=' . $cpt->name; 515 // Avoid clash with parent node and a 'content' post type. 516 $id = 'content' === $cpt->name ? 'add-new-content' : 'new-' . $cpt->name; 517 518 if ( $position = $cpt->menu_position ) { 519 while ( isset( $actions[ $position ] ) ) 520 $position++; 521 $actions[ $position ] = array( $link, $cpt->labels->name_admin_bar, $id ); 522 } else { 523 $actions[] = array( $link, $cpt->labels->name_admin_bar, $id ); 524 } 513 525 } 514 // Avoid clash with parent node and a 'content' post type.515 if ( isset( $actions['post-new.php?post_type=content'] ) )516 $actions['post-new.php?post_type=content'][1] = 'add-new-content';517 526 518 if ( current_user_can( 'create_users' ) || current_user_can( 'promote_users' ) )519 $actions[ 'user-new.php' ] = array( _x( 'User', 'add new from admin bar' ), 'new-user' );520 521 527 if ( ! $actions ) 522 528 return; 523 529 530 ksort( $actions ); 531 524 532 $title = '<span class="ab-icon"></span><span class="ab-label">' . _x( 'New', 'admin bar menu group label' ) . '</span>'; 525 533 534 $first = current( $actions ); 535 526 536 $wp_admin_bar->add_menu( array( 527 537 'id' => 'new-content', 528 538 'title' => $title, 529 'href' => admin_url( current( array_keys( $actions ) )),539 'href' => admin_url( $first[0] ), 530 540 'meta' => array( 531 541 'title' => _x( 'Add New', 'admin bar menu group label' ), 532 542 ), 533 543 ) ); 534 544 535 foreach ( $actions as $ link => $action ) {536 list( $ title, $id ) = $action;545 foreach ( $actions as $action ) { 546 list( $link, $title, $id ) = $action; 537 547 538 548 $wp_admin_bar->add_menu( array( 539 549 'parent' => 'new-content',
