Changeset 19230 for trunk/wp-includes/admin-bar.php
- Timestamp:
- 11/09/2011 07:12:48 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/admin-bar.php
r19214 r19230 92 92 } 93 93 94 // Add secondary menu.95 $wp_admin_bar->add_menu( array(96 'parent' => 'wp-logo',97 'id' => 'wp-logo-secondary',98 'title' => ' ',99 'meta' => array(100 'class' => 'secondary',101 ),102 ) );103 104 94 // Add WordPress.org link 105 95 $wp_admin_bar->add_menu( array( 106 'parent' => 'wp-logo-secondary', 107 'id' => 'wporg', 108 'title' => __('WordPress.org'), 109 'href' => __('http://wordpress.org'), 96 'parent' => 'wp-logo', 97 'secondary' => true, 98 'id' => 'wporg', 99 'title' => __('WordPress.org'), 100 'href' => __('http://wordpress.org'), 110 101 ) ); 111 102 112 103 // Add codex link 113 104 $wp_admin_bar->add_menu( array( 114 'parent' => 'wp-logo-secondary', 115 'id' => 'documentation', 116 'title' => __('Documentation'), 117 'href' => __('http://codex.wordpress.org'), 105 'parent' => 'wp-logo', 106 'secondary' => true, 107 'id' => 'documentation', 108 'title' => __('Documentation'), 109 'href' => __('http://codex.wordpress.org'), 118 110 ) ); 119 111 120 112 // Add forums link 121 113 $wp_admin_bar->add_menu( array( 122 'parent' => 'wp-logo-secondary', 123 'id' => 'support-forums', 124 'title' => __('Support Forums'), 125 'href' => __('http://wordpress.org/support/'), 114 'parent' => 'wp-logo', 115 'secondary' => true, 116 'id' => 'support-forums', 117 'title' => __('Support Forums'), 118 'href' => __('http://wordpress.org/support/'), 126 119 ) ); 127 120 128 121 // Add feedback link 129 122 $wp_admin_bar->add_menu( array( 130 'parent' => 'wp-logo-secondary', 131 'id' => 'feedback', 132 'title' => __('Feedback'), 133 'href' => __('http://wordpress.org/support/forum/requests-and-feedback'), 123 'parent' => 'wp-logo', 124 'secondary' => true, 125 'id' => 'feedback', 126 'title' => __('Feedback'), 127 'href' => __('http://wordpress.org/support/forum/requests-and-feedback'), 134 128 ) ); 135 129 } … … 151 145 $avatar = get_avatar( $user_id, 28 ); 152 146 $howdy = sprintf( __('Howdy, %1$s'), $user_identity ); 153 $class = 'opposite'; 154 155 if ( ! empty( $avatar ) ) 156 $class .= ' with-avatar'; 157 158 $wp_admin_bar->add_menu( array( 159 'id' => 'my-account', 160 'title' => $howdy . $avatar, 161 'href' => $profile_url, 162 'meta' => array( 163 'class' => $class, 147 $class = empty( $avatar ) ? '' : 'with-avatar'; 148 149 $wp_admin_bar->add_menu( array( 150 'id' => 'my-account', 151 'secondary' => true, 152 'title' => $howdy . $avatar, 153 'href' => $profile_url, 154 'meta' => array( 155 'class' => $class, 164 156 ), 165 157 ) ); … … 323 315 } 324 316 325 if ( $wp_admin_bar->user->blogs ) {326 $wp_admin_bar->add_menu( array(327 'parent' => 'my-sites',328 'id' => 'my-sites-secondary',329 'title' => ' ',330 'meta' => array(331 'class' => 'secondary',332 ),333 ) );334 }335 336 317 // Add blog links 337 318 $blue_wp_logo_url = includes_url('images/wpmini-blue.png'); … … 346 327 347 328 $wp_admin_bar->add_menu( array( 348 'parent' => 'my-sites-secondary', 349 'id' => $menu_id, 350 'title' => $blavatar . $blogname, 351 'href' => get_admin_url( $blog->userblog_id ), 329 'parent' => 'my-sites', 330 'secondary' => true, 331 'id' => $menu_id, 332 'title' => $blavatar . $blogname, 333 'href' => get_admin_url( $blog->userblog_id ), 352 334 ) ); 353 335 … … 474 456 */ 475 457 function wp_admin_bar_new_content_menu( $wp_admin_bar ) { 476 $ primary = $secondary= array();458 $actions = array(); 477 459 478 460 $cpts = (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' ); 479 461 480 462 if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->edit_posts ) ) { 481 $ primary[ 'post-new.php' ] = array( $cpts['post']->labels->name_admin_bar, 'new-post' );463 $actions[ 'post-new.php' ] = array( $cpts['post']->labels->name_admin_bar, 'new-post' ); 482 464 unset( $cpts['post'] ); 483 465 } 484 466 485 467 if ( current_user_can( 'upload_files' ) ) 486 $ primary[ 'media-new.php' ] = array( _x( 'Media', 'add new from admin bar' ), 'new-media' );468 $actions[ 'media-new.php' ] = array( _x( 'Media', 'add new from admin bar' ), 'new-media' ); 487 469 488 470 if ( current_user_can( 'manage_links' ) ) 489 $ primary[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'new-link' );471 $actions[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'new-link' ); 490 472 491 473 if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->edit_posts ) ) { 492 $ primary[ 'post-new.php?post_type=page' ] = array( $cpts['page']->labels->name_admin_bar, 'new-page' );474 $actions[ 'post-new.php?post_type=page' ] = array( $cpts['page']->labels->name_admin_bar, 'new-page' ); 493 475 unset( $cpts['page'] ); 494 476 } … … 500 482 501 483 $key = 'post-new.php?post_type=' . $cpt->name; 502 $ primary[ $key ] = array( $cpt->labels->name_admin_bar, 'new-' . $cpt->name );484 $actions[ $key ] = array( $cpt->labels->name_admin_bar, 'new-' . $cpt->name ); 503 485 } 504 486 505 487 if ( current_user_can( 'create_users' ) || current_user_can( 'promote_users' ) ) 506 $ secondary[ 'user-new.php' ] = array( _x( 'User', 'add new from admin bar' ), 'new-user');507 508 if ( ! $ primary && ! $secondary)488 $actions[ 'user-new.php' ] = array( _x( 'User', 'add new from admin bar' ), 'new-user', true ); 489 490 if ( ! $actions ) 509 491 return; 510 492 … … 512 494 'id' => 'new-content', 513 495 'title' => _x( 'Add New', 'admin bar menu group label' ), 514 'href' => admin_url( current( array_keys( $primary ) ) ), 515 ) ); 516 517 $items = array( 518 'new-content' => $primary, 519 'new-content-secondary' => $secondary, 520 ); 521 522 foreach ( $items as $parent => $actions ) { 523 524 if ( ! empty( $actions ) && $parent == 'new-content-secondary' ) { 525 $wp_admin_bar->add_menu( array( 526 'parent' => 'new-content', 527 'id' => 'new-content-secondary', 528 'title' => ' ', 529 'meta' => array( 530 'class' => 'secondary', 531 ), 532 ) ); 533 } 534 535 foreach ( $actions as $link => $action ) { 536 $wp_admin_bar->add_menu( array( 537 'parent' => $parent, 538 'id' => $action[1], 539 'title' => $action[0], 540 'href' => admin_url( $link ) 541 ) ); 542 } 496 'href' => admin_url( current( array_keys( $actions ) ) ), 497 ) ); 498 499 foreach ( $actions as $link => $action ) { 500 list( $title, $id ) = $action; 501 $secondary = ! empty( $action[2] ); 502 503 $wp_admin_bar->add_menu( array( 504 'parent' => 'new-content', 505 'secondary' => $secondary, 506 'id' => $id, 507 'title' => $title, 508 'href' => admin_url( $link ) 509 ) ); 543 510 } 544 511 }
Note: See TracChangeset
for help on using the changeset viewer.