WordPress.org

Make WordPress Core

Ticket #19541: admin_bar_create_content.patch

File admin_bar_create_content.patch, 1.8 KB (added by davistobias, 2 years ago)
  • wp-includes/admin-bar.php

     
    473473 */ 
    474474function wp_admin_bar_new_content_menu( $wp_admin_bar ) { 
    475475        $actions = array(); 
     476        $position = array(); 
    476477 
    477478        $cpts = (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' ); 
    478479 
    479480        if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->edit_posts ) ) { 
    480481                $actions[ 'post-new.php' ] = array( $cpts['post']->labels->name_admin_bar, 'new-post' ); 
     482                $position[] = 5; 
    481483                unset( $cpts['post'] ); 
    482484        } 
    483485 
    484         if ( current_user_can( 'upload_files' ) ) 
     486        if ( current_user_can( 'upload_files' ) ) { 
    485487                $actions[ 'media-new.php' ] = array( _x( 'Media', 'add new from admin bar' ), 'new-media' ); 
     488                $position[] = 10; 
     489        } 
    486490 
    487         if ( current_user_can( 'manage_links' ) ) 
     491        if ( current_user_can( 'manage_links' ) ) { 
    488492                $actions[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'new-link' ); 
     493                $position[] = 15; 
     494        } 
    489495 
    490496        if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->edit_posts ) ) { 
    491497                $actions[ 'post-new.php?post_type=page' ] = array( $cpts['page']->labels->name_admin_bar, 'new-page' ); 
     498                $position[] = 20; 
    492499                unset( $cpts['page'] ); 
    493500        } 
    494501 
     
    499506 
    500507                $key = 'post-new.php?post_type=' . $cpt->name; 
    501508                $actions[ $key ] = array( $cpt->labels->name_admin_bar, 'new-' . $cpt->name ); 
     509                $position[] = ( $cpt->menu_position ? $cpt->menu_position + 1 : max( $position ) + 1 ); 
    502510        } 
    503511 
     512        // Menu position order 
     513        array_multisort( $position, $actions ); 
     514 
    504515        if ( current_user_can( 'create_users' ) || current_user_can( 'promote_users' ) ) 
    505516                $actions[ 'user-new.php' ] = array( _x( 'User', 'add new from admin bar' ), 'new-user' ); 
    506517