339 'meta' => array( |
339 'meta' => array( |
340 'class' => is_super_admin() ? 'ab-sub-secondary' : '', |
340 'class' => is_super_admin() ? 'ab-sub-secondary' : '', |
341 ), |
341 ), |
342 ) ); |
342 ) ); |
343 |
343 |
344 $blue_wp_logo_url = includes_url('images/wpmini-blue.png'); |
|
345 |
|
346 foreach ( (array) $wp_admin_bar->user->blogs as $blog ) { |
344 foreach ( (array) $wp_admin_bar->user->blogs as $blog ) { |
347 // @todo Replace with some favicon lookup. |
345 switch_to_blog( $blog->userblog_id ); |
348 //$blavatar = '<img src="' . esc_url( blavatar_url( blavatar_domain( $blog->siteurl ), 'img', 16, $blue_wp_logo_url ) ) . '" alt="Blavatar" width="16" height="16" />'; |
346 |
349 $blavatar = '<img src="' . esc_url($blue_wp_logo_url) . '" alt="' . esc_attr__( 'Blavatar' ) . '" width="16" height="16" class="blavatar"/>'; |
347 $blavatar = '<div class="blavatar"></div>'; |
350 |
348 |
351 $blogname = empty( $blog->blogname ) ? $blog->domain : $blog->blogname; |
349 $blogname = empty( $blog->blogname ) ? $blog->domain : $blog->blogname; |
352 $menu_id = 'blog-' . $blog->userblog_id; |
350 $menu_id = 'blog-' . $blog->userblog_id; |
353 |
351 |
354 $wp_admin_bar->add_menu( array( |
352 $wp_admin_bar->add_menu( array( |
355 'parent' => 'my-sites-list', |
353 'parent' => 'my-sites-list', |
356 'id' => $menu_id, |
354 'id' => $menu_id, |
357 'title' => $blavatar . $blogname, |
355 'title' => $blavatar . $blogname, |
358 'href' => get_admin_url( $blog->userblog_id ), |
356 'href' => admin_url(), |
359 ) ); |
357 ) ); |
360 |
358 |
361 $wp_admin_bar->add_menu( array( |
359 $wp_admin_bar->add_menu( array( |
362 'parent' => $menu_id, |
360 'parent' => $menu_id, |
363 'id' => $menu_id . '-d', |
361 'id' => $menu_id . '-d', |
364 'title' => __( 'Dashboard' ), |
362 'title' => __( 'Dashboard' ), |
365 'href' => get_admin_url( $blog->userblog_id ), |
363 'href' => admin_url(), |
366 ) ); |
364 ) ); |
367 |
365 |
368 if ( current_user_can_for_blog( $blog->userblog_id, 'edit_posts' ) ) { |
366 if ( current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) { |
369 $wp_admin_bar->add_menu( array( |
367 $wp_admin_bar->add_menu( array( |
370 'parent' => $menu_id, |
368 'parent' => $menu_id, |
371 'id' => $menu_id . '-n', |
369 'id' => $menu_id . '-n', |
372 'title' => __( 'New Post' ), |
370 'title' => __( 'New Post' ), |
373 'href' => get_admin_url( $blog->userblog_id, 'post-new.php' ), |
371 'href' => admin_url( 'post-new.php' ), |
374 ) ); |
372 ) ); |
|
373 } |
|
374 |
|
375 if ( current_user_can( 'edit_posts' ) ) { |
375 $wp_admin_bar->add_menu( array( |
376 $wp_admin_bar->add_menu( array( |
376 'parent' => $menu_id, |
377 'parent' => $menu_id, |
377 'id' => $menu_id . '-c', |
378 'id' => $menu_id . '-c', |
378 'title' => __( 'Manage Comments' ), |
379 'title' => __( 'Manage Comments' ), |
379 'href' => get_admin_url( $blog->userblog_id, 'edit-comments.php' ), |
380 'href' => admin_url( 'edit-comments.php' ), |
380 ) ); |
381 ) ); |
381 } |
382 } |
382 |
383 |
383 $wp_admin_bar->add_menu( array( |
384 $wp_admin_bar->add_menu( array( |
384 'parent' => $menu_id, |
385 'parent' => $menu_id, |
385 'id' => $menu_id . '-v', |
386 'id' => $menu_id . '-v', |
386 'title' => __( 'Visit Site' ), |
387 'title' => __( 'Visit Site' ), |
387 'href' => get_home_url( $blog->userblog_id, '/' ), |
388 'href' => home_url( '/' ), |
388 ) ); |
389 ) ); |
|
390 |
|
391 restore_current_blog(); |
389 } |
392 } |
390 } |
393 } |
391 |
394 |
392 /** |
395 /** |
393 * Provide a shortlink. |
396 * Provide a shortlink. |
415 * Provide an edit link for posts and terms. |
418 * Provide an edit link for posts and terms. |
416 * |
419 * |
417 * @since 3.1.0 |
420 * @since 3.1.0 |
418 */ |
421 */ |
419 function wp_admin_bar_edit_menu( $wp_admin_bar ) { |
422 function wp_admin_bar_edit_menu( $wp_admin_bar ) { |
420 global $post, $tag, $wp_the_query; |
423 global $tag, $wp_the_query; |
421 |
424 |
422 if ( is_admin() ) { |
425 if ( is_admin() ) { |
423 $current_screen = get_current_screen(); |
426 $current_screen = get_current_screen(); |
|
427 $post = get_post(); |
424 |
428 |
425 if ( 'post' == $current_screen->base |
429 if ( 'post' == $current_screen->base |
426 && 'add' != $current_screen->action |
430 && 'add' != $current_screen->action |
427 && ( $post_type_object = get_post_type_object( $post->post_type ) ) |
431 && ( $post_type_object = get_post_type_object( $post->post_type ) ) |
428 && current_user_can( $post_type_object->cap->read_post, $post->ID ) |
432 && current_user_can( $post_type_object->cap->read_post, $post->ID ) |
429 && ( $post_type_object->public ) ) |
433 && ( $post_type_object->public ) |
|
434 && ( $post_type_object->show_in_admin_bar ) ) |
430 { |
435 { |
431 $wp_admin_bar->add_menu( array( |
436 $wp_admin_bar->add_menu( array( |
432 'id' => 'view', |
437 'id' => 'view', |
433 'title' => $post_type_object->labels->view_item, |
438 'title' => $post_type_object->labels->view_item, |
434 'href' => get_permalink( $post->ID ) |
439 'href' => get_permalink( $post->ID ) |
482 function wp_admin_bar_new_content_menu( $wp_admin_bar ) { |
487 function wp_admin_bar_new_content_menu( $wp_admin_bar ) { |
483 $actions = array(); |
488 $actions = array(); |
484 |
489 |
485 $cpts = (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' ); |
490 $cpts = (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' ); |
486 |
491 |
487 if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->edit_posts ) ) { |
492 if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->create_posts ) ) |
488 $actions[ 'post-new.php' ] = array( $cpts['post']->labels->name_admin_bar, 'new-post' ); |
493 $actions[ 'post-new.php' ] = array( $cpts['post']->labels->name_admin_bar, 'new-post' ); |
489 unset( $cpts['post'] ); |
494 |
490 } |
495 if ( isset( $cpts['attachment'] ) && current_user_can( 'upload_files' ) ) |
491 |
496 $actions[ 'media-new.php' ] = array( $cpts['attachment']->labels->name_admin_bar, 'new-media' ); |
492 if ( current_user_can( 'upload_files' ) ) |
|
493 $actions[ 'media-new.php' ] = array( _x( 'Media', 'add new from admin bar' ), 'new-media' ); |
|
494 |
497 |
495 if ( current_user_can( 'manage_links' ) ) |
498 if ( current_user_can( 'manage_links' ) ) |
496 $actions[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'new-link' ); |
499 $actions[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'new-link' ); |
497 |
500 |
498 if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->edit_posts ) ) { |
501 if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->create_posts ) ) |
499 $actions[ 'post-new.php?post_type=page' ] = array( $cpts['page']->labels->name_admin_bar, 'new-page' ); |
502 $actions[ 'post-new.php?post_type=page' ] = array( $cpts['page']->labels->name_admin_bar, 'new-page' ); |
500 unset( $cpts['page'] ); |
503 |
501 } |
504 unset( $cpts['post'], $cpts['page'], $cpts['attachment'] ); |
502 |
505 |
503 // Add any additional custom post types. |
506 // Add any additional custom post types. |
504 foreach ( $cpts as $cpt ) { |
507 foreach ( $cpts as $cpt ) { |
505 if ( ! current_user_can( $cpt->cap->edit_posts ) ) |
508 if ( ! current_user_can( $cpt->cap->create_posts ) ) |
506 continue; |
509 continue; |
507 |
510 |
508 $key = 'post-new.php?post_type=' . $cpt->name; |
511 $key = 'post-new.php?post_type=' . $cpt->name; |
509 $actions[ $key ] = array( $cpt->labels->name_admin_bar, 'new-' . $cpt->name ); |
512 $actions[ $key ] = array( $cpt->labels->name_admin_bar, 'new-' . $cpt->name ); |
510 } |
513 } |
|
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'; |
511 |
517 |
512 if ( current_user_can( 'create_users' ) || current_user_can( 'promote_users' ) ) |
518 if ( current_user_can( 'create_users' ) || current_user_can( 'promote_users' ) ) |
513 $actions[ 'user-new.php' ] = array( _x( 'User', 'add new from admin bar' ), 'new-user' ); |
519 $actions[ 'user-new.php' ] = array( _x( 'User', 'add new from admin bar' ), 'new-user' ); |
514 |
520 |
515 if ( ! $actions ) |
521 if ( ! $actions ) |