Created
September 10, 2011 16:23
-
-
Save scribu/1208492 to your computer and use it in GitHub Desktop.
Network Quick-Switch
This file contains 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 | |
/* | |
Plugin Name: Network Quick-Switch | |
Version: 1.0 | |
Description: Adds the ability to quickly switch between site and network admin screens. | |
Author: scribu | |
Author URI: http://scribu.net/ | |
*/ | |
if ( is_multisite() ) { | |
add_action( 'admin_footer', 'network_quick_switch' ); | |
add_filter( 'admin_user_info_links', 'remove_network_link' ); | |
} | |
function network_quick_switch() { | |
$current_screen = get_current_screen(); | |
if ( is_network_admin() ) { | |
$base = 'admin_url'; | |
$text = __( 'Site Admin' ); | |
} else { | |
$base = 'network_admin_url'; | |
$text = __( 'Network Admin' ); | |
} | |
if ( in_array( $current_screen->parent_file, array( 'plugins.php', 'themes.php', 'users.php' ) ) ) { | |
$url = $base( $current_screen->parent_file ); | |
} else { | |
$url = $base(); | |
} | |
?> | |
<a id="network-quick-switch" href="<?php echo $url; ?>"><?php echo $text; ?></a> | |
<style type="text/css"> | |
#network-quick-switch { | |
background-color: #f1f1f1; | |
border-radius: 3px; | |
float: right; | |
margin: 4px 8px 0 0; | |
padding: 3px 8px; | |
} | |
</style> | |
<script type="text/javascript"> | |
jQuery(function ($) { | |
$('#user_info').after( $('#network-quick-switch') ); | |
}); | |
</script> | |
<?php | |
} | |
function remove_network_link( $links ) { | |
unset( $links[10] ); | |
return $links; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Context: http://core.trac.wordpress.org/ticket/18301