Skip to content

Instantly share code, notes, and snippets.

@goblindegook
Last active August 29, 2015 14:10
Show Gist options
  • Save goblindegook/91d00003ca17adf994ca to your computer and use it in GitHub Desktop.
Save goblindegook/91d00003ca17adf994ca to your computer and use it in GitHub Desktop.
WordPress: Sort user sites by name in the Admin Bar
<?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