mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-22 15:31:42 +01:00
Add secondary section to 'Add New' admin bar menu. see #18197.
git-svn-id: http://svn.automattic.com/wordpress/trunk@18787 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c00a49dd7a
commit
0c79429d8b
@ -429,36 +429,66 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) {
|
|||||||
* @since 3.1.0
|
* @since 3.1.0
|
||||||
*/
|
*/
|
||||||
function wp_admin_bar_new_content_menu( $wp_admin_bar ) {
|
function wp_admin_bar_new_content_menu( $wp_admin_bar ) {
|
||||||
$actions = array();
|
$primary = array();
|
||||||
|
$secondary = array();
|
||||||
|
|
||||||
foreach ( (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' ) as $ptype_obj ) {
|
foreach ( (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' ) as $ptype_obj ) {
|
||||||
if ( ! current_user_can( $ptype_obj->cap->edit_posts ) )
|
if ( ! current_user_can( $ptype_obj->cap->edit_posts ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$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 );
|
$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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( current_user_can( 'upload_files' ) )
|
if ( current_user_can( 'upload_files' ) )
|
||||||
$actions[ 'media-new.php' ] = array( _x( 'Media', 'add new from admin bar' ), 'upload_files', 'new-media' );
|
$primary[ 'media-new.php' ] = array( _x( 'Media', 'add new from admin bar' ), 'upload_files', 'new-media' );
|
||||||
|
|
||||||
if ( current_user_can( 'manage_links' ) )
|
if ( current_user_can( 'manage_links' ) )
|
||||||
$actions[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'manage_links', 'new-link' );
|
$primary[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'manage_links', 'new-link' );
|
||||||
|
|
||||||
if ( current_user_can( 'create_users' ) || current_user_can( 'promote_users' ) )
|
if ( current_user_can( 'create_users' ) || current_user_can( 'promote_users' ) )
|
||||||
$actions[ 'user-new.php' ] = array( _x( 'User', 'add new from admin bar' ), 'create_users', 'new-user' );
|
$secondary[ 'user-new.php' ] = array( _x( 'User', 'add new from admin bar' ), 'create_users', 'new-user' );
|
||||||
|
|
||||||
if ( ! is_multisite() && current_user_can( 'install_themes' ) )
|
if ( ! is_multisite() && current_user_can( 'install_themes' ) )
|
||||||
$actions[ 'theme-install.php' ] = array( _x( 'Theme', 'add new from admin bar' ), 'install_themes', 'new-theme' );
|
$secondary[ 'theme-install.php' ] = array( _x( 'Theme', 'add new from admin bar' ), 'install_themes', 'new-theme' );
|
||||||
|
|
||||||
if ( ! is_multisite() && current_user_can( 'install_plugins' ) )
|
if ( ! is_multisite() && current_user_can( 'install_plugins' ) )
|
||||||
$actions[ 'plugin-install.php' ] = array( _x( 'Plugin', 'add new from admin bar' ), 'install_plugins', 'new-plugin' );
|
$secondary[ 'plugin-install.php' ] = array( _x( 'Plugin', 'add new from admin bar' ), 'install_plugins', 'new-plugin' );
|
||||||
|
|
||||||
if ( empty( $actions ) )
|
if ( empty( $primary ) && empty( $secondary ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$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 ) ) ) ) );
|
$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( $primary ) ) ),
|
||||||
|
) );
|
||||||
|
|
||||||
foreach ( $actions as $link => $action ) {
|
$items = array(
|
||||||
$wp_admin_bar->add_menu( array( 'parent' => 'new-content', 'id' => $action[2], 'title' => $action[0], 'href' => admin_url($link) ) );
|
'new-content' => $primary,
|
||||||
|
'new-content-secondary' => $secondary,
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ( $items as $parent => $actions ) {
|
||||||
|
|
||||||
|
if ( ! empty( $actions ) && $parent == 'new-content-secondary' ) {
|
||||||
|
$wp_admin_bar->add_menu( array(
|
||||||
|
'parent' => 'new-content',
|
||||||
|
'id' => 'new-content-secondary',
|
||||||
|
'title' => ' ',
|
||||||
|
'meta' => array(
|
||||||
|
'class' => 'secondary',
|
||||||
|
),
|
||||||
|
) );
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ( $actions as $link => $action ) {
|
||||||
|
$wp_admin_bar->add_menu( array(
|
||||||
|
'parent' => $parent,
|
||||||
|
'id' => $action[2],
|
||||||
|
'title' => $action[0],
|
||||||
|
'href' => admin_url( $link )
|
||||||
|
) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user