Last active
August 29, 2015 14:10
-
-
Save goblindegook/91d00003ca17adf994ca to your computer and use it in GitHub Desktop.
WordPress: Sort user sites by name in the Admin Bar
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 | |
/** | |
* Sorts user sites by name in the Admin Bar. | |
* | |
* @param object $wp_admin_bar Admin Bar instance. | |
*/ | |
function goblindegook_admin_bar_sort_sites( &$wp_admin_bar ) { | |
if ( ! is_user_logged_in() ) { | |
return; | |
} | |
usort( $wp_admin_bar->user->blogs, function ( $a, $b ) { | |
return strcmp( $a->blogname, $b->blogname ); | |
} ); | |
} | |
add_action( 'admin_bar_menu', 'goblindegook_admin_bar_sort_sites' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment