Skip to content

Instantly share code, notes, and snippets.

@stephanieleary
Created January 23, 2017 18:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephanieleary/c5f80584bdf104fa05fcf1e6d424883e to your computer and use it in GitHub Desktop.
Save stephanieleary/c5f80584bdf104fa05fcf1e6d424883e to your computer and use it in GitHub Desktop.
My Sites Dashboard widget to show all user's sites on network
<?php
function mysites_network_dashboard_widget_setup() {
add_meta_box(
'dashboard_mysites_widget',
'My Sites',
'dashboard_mysites_widget',
'dashboard',
'side',
'high'
);
}
add_action( 'wp_dashboard_setup', 'mysites_network_dashboard_widget_setup', 99 );
function dashboard_mysites_widget() {
echo '<ul>';
$blogs = get_blogs_of_user( get_current_user_id() );
foreach ( $blogs as $blog ) {
echo '<li><a href="'. esc_url( get_admin_url( $blog->userblog_id ) ) .'" title="'. sprintf( esc_html__( '%s Dashboard', 'tees' ), $blog->blogname ) .'">'. esc_html( $blog->blogname ) .'</a></li>';
}
echo '</ul>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment