Created
January 23, 2017 18:11
-
-
Save stephanieleary/c5f80584bdf104fa05fcf1e6d424883e to your computer and use it in GitHub Desktop.
My Sites Dashboard widget to show all user's sites on network
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 | |
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