Conditional hook based on the core function that is calling it
Much probably, using debug_backtrace in this fashion is wild hackerism… Based on @toscho’s tip, the following achieves the same results: add_filter( ‘get_blogs_of_user’, ‘reorder_users_sites’ ); function reorder_users_sites( $blogs ) { if( !did_action( ‘wp_before_admin_bar_render’ ) ) uasort( $blogs, ‘bf_uasort_by_blogname’ ); else uasort( $blogs, ‘bf_uasort_by_domain’ ); return $blogs; }