Multisite: Replace is_super_admin() with manage_network in get_dashboard_url().

Unit tests for `get_dashboard_url()` have been added.

Props iaaxpage.
Fixes #39065. See #37616.


git-svn-id: https://develop.svn.wordpress.org/trunk@39589 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Felix Arntz
2016-12-12 22:40:03 +00:00
parent 539b85406d
commit b4317ea053
2 changed files with 79 additions and 2 deletions
+2 -2
View File
@@ -3472,13 +3472,13 @@ function get_dashboard_url( $user_id = 0, $path = '', $scheme = 'admin' ) {
$user_id = $user_id ? (int) $user_id : get_current_user_id();
$blogs = get_blogs_of_user( $user_id );
if ( ! is_super_admin() && empty($blogs) ) {
if ( is_multisite() && ! user_can( $user_id, 'manage_network' ) && empty($blogs) ) {
$url = user_admin_url( $path, $scheme );
} elseif ( ! is_multisite() ) {
$url = admin_url( $path, $scheme );
} else {
$current_blog = get_current_blog_id();
if ( $current_blog && ( is_super_admin( $user_id ) || in_array( $current_blog, array_keys( $blogs ) ) ) ) {
if ( $current_blog && ( user_can( $user_id, 'manage_network' ) || in_array( $current_blog, array_keys( $blogs ) ) ) ) {
$url = admin_url( $path, $scheme );
} else {
$active = get_active_blog_for_user( $user_id );