Patch: Breadcrumb trail compatibility with Buddypress

Hi, here is the code (actually in my wp theme functions.php file) to manage conditionnal Buddypress pages in the trail:
/**
 * Conditionally Buddypress Override : Yoast SEO Breadcrumb Trail
 * fork by Mecanographik
 * http://plugins.svn.wordpress.org/wordpress-seo/trunk/frontend/class-breadcrumbs.php
 * -----------------------------------------------------------------------------------
 */

add_filter( 'wpseo_breadcrumb_links', 'wpse_100012_override_yoast_breadcrumb_trail' );

function wpse_100012_override_yoast_breadcrumb_trail( $links ) {

    // manage buddypress components in the trail
	if ( function_exists('bp_is_active') ) {

		global $post; 
		global $bp;

		if (is_buddypress()){

			$current_bp_component = bp_current_component();
		
			$breadcrumb[] = array(
	            'url' => $bp->current_component,
	            'text' => $current_bp_component,
	        );

        	array_splice( $links, 2, -2, $breadcrumb );
		}
		
	}

    return $links;
}