Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.