Last active
May 6, 2016 15:37
-
-
Save DrewAPicture/5063196b87f9040e453e4410941a718b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Adds 'Affiliates' Toolbar links in the My Sites drop-down. | |
* | |
* @param WP_Admin_Bar $wp_admin_bar Toolbar instance. | |
*/ | |
function affiliate_toolbar_links( $wp_admin_bar ) { | |
foreach ( $wp_admin_bar->user->blogs as $blog ) { | |
$blog_id = $blog->userblog_id; | |
// Add 'Affiliates' link. | |
$wp_admin_bar->add_menu( array( | |
'parent' => "blog-{$blog->userblog_id}", | |
'id' => "affiliates-blog-{$blog_id}", | |
'title' => __( 'Affiliates', 'affiliate-wp' ), | |
'href' => add_query_arg( 'page', 'affiliate-wp', get_admin_url( $blog_id, 'admin.php' ) ) | |
) ); | |
// Remove 'New Post'. | |
$wp_admin_bar->remove_menu( "blog-{$blog_id}-n" ); | |
// Remove 'View Comments'. | |
$wp_admin_bar->remove_menu( "blog-{$blog_id}-c" ); | |
// Remove 'Visit Site'. | |
$wp_admin_bar->remove_menu( "blog-{$blog_id}-v" ); | |
} | |
} | |
add_action( 'admin_bar_menu', 'affiliate_toolbar_links', 100 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment