--- buddypress/bp-core/bp-core-classes.php	Tue Jun 28 01:57:04 2011
+++ buddypress/bp-core/bp-core-classes.php	Tue Jun 28 02:28:36 2011
@@ -1080,4 +1080,165 @@
 	}
 }
 
+/**
+ * BP_Embed
+ *
+ * Extends WP_Embed class for use with BuddyPress.
+ *
+ * @package BuddyPress Core
+ * @since 1.3
+ * @see WP_Embed
+ */
+class BP_Embed extends WP_Embed {
+
+	/**
+	 * PHP4 constructor
+	 */
+	function BP_Embed() {
+		return $this->__construct();
+	}
+
+	/**
+	 * Class constructor
+	 */
+	function __construct() {
+		global $wp_embed;
+
+		// Make sure we populate the WP_Embed handlers array.
+		// These are providers that use a regex callback on the URL in question.
+		// Do not confuse with oEmbed providers, which require an external ping.
+		// Used in WP_Embed::shortcode()
+		$this->handlers = $wp_embed->handlers;
+
+		if( !defined( 'BP_EMBED_DISABLE_ACTIVITY' ) ) {
+			add_filter( 'bp_get_activity_content_body', 	array( &$this, 'autoembed' ), 8 );
+			add_filter( 'bp_get_activity_content_body', 	array( &$this, 'run_shortcode' ), 7 );
+		}
+
+		if( !defined( 'BP_EMBED_DISABLE_ACTIVITY_REPLIES' ) ) {
+			add_filter( 'bp_get_activity_content', 		array( &$this, 'autoembed' ), 8 );
+			add_filter( 'bp_get_activity_content', 		array( &$this, 'run_shortcode' ), 7 );
+		}
+
+		if( !defined( 'BP_EMBED_DISABLE_FORUM_POSTS' ) ) {
+			add_filter( 'bp_get_the_topic_post_content', 	array( &$this, 'autoembed' ), 8 );
+			add_filter( 'bp_get_the_topic_post_content', 	array( &$this, 'run_shortcode' ), 7 );
+		}
+	}
+
+	/**
+	 * The {@link do_shortcode()} callback function.
+	 *
+	 * Attempts to convert a URL into embed HTML. Starts by checking the URL against the regex of the registered embed handlers.
+	 * Next, checks the URL against the regex of registered {@link WP_oEmbed} providers if oEmbed discovery is false.
+	 * If none of the regex matches and it's enabled, then the URL will be passed to {@link BP_Embed::parse_oembed()} for oEmbed parsing.
+	 *
+	 * @uses wp_parse_args()
+	 * @uses wp_embed_defaults()
+	 * @uses author_can()
+	 * @uses _wp_oembed_get_object()
+	 * @uses WP_Embed::maybe_make_link()
+	 *
+	 * @param array $attr Shortcode attributes.
+	 * @param string $url The URL attempting to be embeded.
+	 * @return string The embed HTML on success, otherwise the original URL.
+	 */
+	function shortcode( $attr, $url = '' ) {
+
+		if ( empty( $url ) )
+			return '';
+
+		$rawattr = $attr;
+		$attr = wp_parse_args( $attr, wp_embed_defaults() );
+
+		// kses converts & into &amp; and we need to undo this
+		// See http://core.trac.wordpress.org/ticket/11311
+		$url = str_replace( '&amp;', '&', $url );
+
+		// Look for known internal handlers
+		ksort( $this->handlers );
+		foreach ( $this->handlers as $priority => $handlers ) {
+			foreach ( $handlers as $id => $handler ) {
+				if ( preg_match( $handler['regex'], $url, $matches ) && is_callable( $handler['callback'] ) ) {
+					if ( false !== $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ) )
+						return apply_filters( 'embed_handler_html', $return, $url, $attr );
+				}
+			}
+		}
+
+		// Get object ID
+		$id = apply_filters( 'embed_post_id', $id );
+
+		// Is oEmbed discovery on?
+		$attr['discover'] = ( apply_filters( 'bp_embed_oembed_discover', false ) && author_can( $id, 'unfiltered_html' ) );
+
+		// Set up a new WP oEmbed object to check URL with registered oEmbed providers
+		require_once( ABSPATH . WPINC . '/class-oembed.php' );
+		$oembed_obj = _wp_oembed_get_object();
+
+		// If oEmbed discovery is true, skip oEmbed provider check
+		$is_oembed_link = false;
+		if ( !$attr['discover'] ) {
+			foreach ( (array)$oembed_obj->providers as $provider_matchmask => $provider ) {
+				$regex = ( $is_regex = $provider[1] ) ? $provider_matchmask : '#' . str_replace( '___wildcard___', '(.+)', preg_quote( str_replace( '*', '___wildcard___', $provider_matchmask ), '#' ) ) . '#i';
+
+				if ( preg_match( $regex, $url ) )
+					$is_oembed_link = true;
+			}
+
+			// If url doesn't match a WP oEmbed provider, stop parsing
+			if ( !$is_oembed_link )
+				return $this->maybe_make_link( $url );
+		}
+
+		return $this->parse_oembed( $id, $url, $attr, $rawattr );
+	}
+
+	/**
+	 * Base function so BP components / plugins can parse links to be embedded.
+	 * View an example to add support in {@link bp_activity_embed()}.
+	 *
+	 * @uses apply_filters() Filters cache.
+	 * @uses do_action() To save cache.
+	 * @uses wp_oembed_get() Connects to oEmbed provider and returns HTML on success.
+	 * @uses WP_Embed::maybe_make_link() Process URL for hyperlinking on oEmbed failure.
+	 * @param int $id ID to do the caching for.
+	 * @param string $url The URL attempting to be embedded.
+	 * @param array $attr Shortcode attributes from {@link WP_Embed::shortcode()}.
+	 * @param array $rawattr Untouched shortcode attributes from {@link WP_Embed::shortcode()}.
+	 * @return string The embed HTML on success, otherwise the original URL.
+	 */
+	function parse_oembed( $id, $url, $attr, $rawattr ) {
+
+		if ( $id ) {
+
+			// Setup the cachekey
+			$cachekey = '_oembed_' . md5( $url . serialize( $attr ) );
+
+			// Let components / plugins grab their cache
+			$cache = apply_filters( 'bp_embed_get_cache', $cache, $id, $cachekey, $url, $attr, $rawattr );
+
+			// Grab cache and return it if available
+			if ( !empty( $cache ) ) {
+				return apply_filters( 'embed_oembed_html', $cache, $url, $attr, $rawattr );
+			}
+			// If no cache, ping the oEmbed provider and cache the result
+			else {
+				$html = wp_oembed_get( $url, $attr );
+				$cache = ( $html ) ? $html : $url;
+
+				// Let components / plugins save their cache
+				do_action( 'bp_embed_update_cache', $cache, $cachekey, $id );
+
+				// If there was a result, return it
+				if ( $html )
+					return apply_filters( 'embed_oembed_html', $html, $url, $attr, $rawattr );
+			}
+		}
+
+		// Still unknown
+		return $this->maybe_make_link( $url );
+	}
+}
+
 ?>
--- buddypress/bp-core/bp-core-functions.php	Tue Jun 28 02:00:54 2011
+++ buddypress/bp-core/bp-core-functions.php	Tue Jun 28 02:05:50 2011
@@ -18,7 +18,7 @@
  */
 function bp_get_option( $option_name, $default = false ) {
 	$value = get_blog_option( bp_get_option_blog_id( $option_name ), $option_name, $default );
-	
+
 	return apply_filters( 'bp_get_option', $value );
 }
 
@@ -83,7 +83,7 @@
 	$blog_specific_options = apply_filters( 'bp_blog_specific_options', array(
 		'bp-pages'
 	) );
-	
+
 	if ( in_array( $option_name, $blog_specific_options ) ) {
 		if ( defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ) {
 			$blog_id = get_current_blog_id();
@@ -120,11 +120,11 @@
  */
 function bp_core_get_page_meta() {
 	$page_ids = bp_get_option( 'bp-pages' );
-  
+
   	// Upgrading from an earlier version of BP pre-1.3
 	if ( !isset( $page_ids['members'] ) && $ms_page_ids = get_site_option( 'bp-pages' ) ) {
 		$is_enable_multiblog = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? true : false;
-  
+
 		$page_blog_id = $is_enable_multiblog ? get_current_blog_id() : BP_ROOT_BLOG;
 
 		if ( isset( $ms_page_ids[$page_blog_id] ) ) {
@@ -133,7 +133,7 @@
 			bp_update_option( 'bp-pages', $page_ids );
 		}
   	}
-  	
+
 	return apply_filters( 'bp_core_get_page_meta', $page_ids );
 }
 
@@ -503,6 +503,17 @@
 add_action( 'admin_init', 'bp_core_activation_notice' );
 
 /**
+ * Starts {@link BP_Embed} when BP is initialized.
+ *
+ * @package BuddyPress Core
+ * @since 1.3
+ */
+function bp_embed_init() {
+        $bp_embed = new BP_Embed();
+}
+add_action( 'bp_init', 'bp_embed_init' );
+
+/**
  * Returns the domain for the root blog.
  * eg: http://domain.com/ OR https://domain.com
  *
@@ -1007,7 +1018,7 @@
 	$meta_keys = "'" . implode( "','", (array)$site_options ) ."'";
 
 	$site_meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" );
-	
+
 	// Backward compatibility - moves sitemeta to the blog
 	if ( empty( $site_meta ) || ( count( $site_meta ) < count( $site_options ) ) ) {
 		if ( is_multisite() ) {
@@ -1015,7 +1026,7 @@
 		} else {
 			$ms_site_meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" );
 		}
-		
+
 		$settings_to_move = array(
 			'bp-deactivated-components',
 			'bp-blogs-first-install',
@@ -1030,11 +1041,11 @@
 			'bb-config-location',
 			'hide-loggedout-adminbar',
 		);
-		
-		foreach( (array)$ms_site_meta as $meta ) {	
+
+		foreach( (array)$ms_site_meta as $meta ) {
 			if ( isset( $meta->name ) && in_array( $meta->name, $settings_to_move ) ) {
 				bp_update_option( $meta->name, $meta->value );
-						
+
 				if ( empty( $site_meta[$meta->name] ) ) {
 					$site_meta[$meta->name] = $meta->value;
 				}
@@ -1270,8 +1281,8 @@
 
 	do_action( 'bp_do_404', $redirect );
 
-	$wp_query->set_404(); 
-	status_header( 404 ); 
+	$wp_query->set_404();
+	status_header( 404 );
 	nocache_headers();
 
 	if ( 'remove_canonical_direct' == $redirect )
--- buddypress/bp-activity/bp-activity-functions.php	Tue Jun 28 02:09:00 2011
+++ buddypress/bp-activity/bp-activity-functions.php	Tue Jun 28 02:18:59 2011
@@ -962,4 +962,45 @@
 	return apply_filters( 'bp_activity_thumbnail_content_images', $content, $matches );
 }
 
+/** Embeds *******************************************************************/
+
+/**
+ * Grabs the activity ID and attempts to retrieve the oEmbed cache (if it exists)
+ * during the activity loop.  If no cache and link is embeddable, cache it.
+ *
+ * @see BP_Embed
+ * @see bp_embed_activity_cache()
+ * @see bp_embed_activity_save_cache()
+ * @package BuddyPress Activity
+ * @since 1.3
+ */
+function bp_activity_embed() {
+        add_filter( 'embed_post_id',		'bp_get_activity_id' );
+        add_filter( 'bp_embed_get_cache',	'bp_embed_activity_cache', 10, 3 );
+        add_action( 'bp_embed_update_cache',	'bp_embed_activity_save_cache', 10, 3 );
+}
+add_action( 'activity_loop_start', 'bp_activity_embed' );
+
+	/**
+	 * Wrapper function for {@link bp_activity_get_meta()}.
+	 * Used during {@link BP_Embed::parse_oembed()} via {@link bp_activity_embed()}.
+	 *
+	 * @package BuddyPress Activity
+	 * @since 1.3
+	 */
+        function bp_embed_activity_cache( $cache, $id, $cachekey ) {
+                return bp_activity_get_meta( $id, $cachekey );
+        }
+
+	/**
+	 * Wrapper function for {@link bp_activity_update_meta()}.
+	 * Used during {@link BP_Embed::parse_oembed()} via {@link bp_activity_embed()}.
+	 *
+	 * @package BuddyPress Activity
+	 * @since 1.3
+	 */
+        function bp_embed_activity_save_cache( $cache, $cachekey, $id ) {
+                bp_activity_update_meta( $id, $cachekey, $cache );
+        }
+
 ?>
--- buddypress/bp-forums/bp-forums-filters.php	Tue Jun 28 02:21:51 2011
+++ buddypress/bp-forums/bp-forums-filters.php	Tue Jun 28 02:24:45 2011
@@ -1,49 +1,52 @@
 <?php
 
 /* Apply WordPress defined filters */
-add_filter( 'bp_forums_bbconfig_location', 'wp_filter_kses', 1 );
-add_filter( 'bp_forums_bbconfig_location', 'esc_attr', 1 );
+add_filter( 'bp_forums_bbconfig_location', 		'wp_filter_kses', 1 );
+add_filter( 'bp_forums_bbconfig_location', 		'esc_attr', 1 );
 
-add_filter( 'bp_get_the_topic_title', 'wp_filter_kses', 1 );
-add_filter( 'bp_get_the_topic_latest_post_excerpt', 'bp_forums_filter_kses', 1 );
-add_filter( 'bp_get_the_topic_post_content', 'bp_forums_filter_kses', 1 );
-
-add_filter( 'bp_get_the_topic_title', 'force_balance_tags' );
-add_filter( 'bp_get_the_topic_latest_post_excerpt', 'force_balance_tags' );
-add_filter( 'bp_get_the_topic_post_content', 'force_balance_tags' );
-
-add_filter( 'bp_get_the_topic_title', 'wptexturize' );
-add_filter( 'bp_get_the_topic_poster_name', 'wptexturize' );
-add_filter( 'bp_get_the_topic_last_poster_name', 'wptexturize' );
-add_filter( 'bp_get_the_topic_post_content', 'wptexturize' );
-add_filter( 'bp_get_the_topic_post_poster_name', 'wptexturize' );
-
-add_filter( 'bp_get_the_topic_title', 'convert_smilies' );
-add_filter( 'bp_get_the_topic_latest_post_excerpt', 'convert_smilies' );
-add_filter( 'bp_get_the_topic_post_content', 'convert_smilies' );
-
-add_filter( 'bp_get_the_topic_title', 'convert_chars' );
-add_filter( 'bp_get_the_topic_latest_post_excerpt', 'convert_chars' );
-add_filter( 'bp_get_the_topic_post_content', 'convert_chars' );
-
-add_filter( 'bp_get_the_topic_post_content', 'wpautop' );
-add_filter( 'bp_get_the_topic_latest_post_excerpt', 'wpautop' );
-
-add_filter( 'bp_get_the_topic_post_content', 'stripslashes_deep' );
-add_filter( 'bp_get_the_topic_title', 'stripslashes_deep' );
-add_filter( 'bp_get_the_topic_latest_post_excerpt', 'stripslashes_deep' );
-add_filter( 'bp_get_the_topic_poster_name', 'stripslashes_deep' );
-add_filter( 'bp_get_the_topic_last_poster_name', 'stripslashes_deep' );
-add_filter( 'bp_get_the_topic_object_name', 'stripslashes_deep' );
-
-add_filter( 'bp_get_the_topic_post_content', 'make_clickable', 9 );
-
-add_filter( 'bp_get_forum_topic_count_for_user', 'bp_core_number_format' );
-add_filter( 'bp_get_forum_topic_count', 'bp_core_number_format' );
-
-add_filter( 'bp_get_the_topic_title', 'bp_forums_make_nofollow_filter' );
-add_filter( 'bp_get_the_topic_latest_post_excerpt', 'bp_forums_make_nofollow_filter' );
-add_filter( 'bp_get_the_topic_post_content', 'bp_forums_make_nofollow_filter' );
+add_filter( 'bp_get_the_topic_title',			'wp_filter_kses', 1 );
+add_filter( 'bp_get_the_topic_latest_post_excerpt',	'bp_forums_filter_kses', 1 );
+add_filter( 'bp_get_the_topic_post_content',		'bp_forums_filter_kses', 1 );
+
+add_filter( 'bp_get_the_topic_title', 			'force_balance_tags' );
+add_filter( 'bp_get_the_topic_latest_post_excerpt', 	'force_balance_tags' );
+add_filter( 'bp_get_the_topic_post_content', 		'force_balance_tags' );
+
+add_filter( 'bp_get_the_topic_title', 			'wptexturize' );
+add_filter( 'bp_get_the_topic_poster_name', 		'wptexturize' );
+add_filter( 'bp_get_the_topic_last_poster_name', 	'wptexturize' );
+add_filter( 'bp_get_the_topic_post_content', 		'wptexturize' );
+add_filter( 'bp_get_the_topic_post_poster_name', 	'wptexturize' );
+
+add_filter( 'bp_get_the_topic_title', 			'convert_smilies' );
+add_filter( 'bp_get_the_topic_latest_post_excerpt', 	'convert_smilies' );
+add_filter( 'bp_get_the_topic_post_content', 		'convert_smilies' );
+
+add_filter( 'bp_get_the_topic_title', 			'convert_chars' );
+add_filter( 'bp_get_the_topic_latest_post_excerpt', 	'convert_chars' );
+add_filter( 'bp_get_the_topic_post_content', 		'convert_chars' );
+
+add_filter( 'bp_get_the_topic_post_content', 		'wpautop' );
+add_filter( 'bp_get_the_topic_latest_post_excerpt', 	'wpautop' );
+
+add_filter( 'bp_get_the_topic_post_content', 		'stripslashes_deep' );
+add_filter( 'bp_get_the_topic_title', 			'stripslashes_deep' );
+add_filter( 'bp_get_the_topic_latest_post_excerpt', 	'stripslashes_deep' );
+add_filter( 'bp_get_the_topic_poster_name', 		'stripslashes_deep' );
+add_filter( 'bp_get_the_topic_last_poster_name', 	'stripslashes_deep' );
+add_filter( 'bp_get_the_topic_object_name', 		'stripslashes_deep' );
+
+add_filter( 'bp_get_the_topic_post_content', 		'make_clickable', 9 );
+
+add_filter( 'bp_get_forum_topic_count_for_user', 	'bp_core_number_format' );
+add_filter( 'bp_get_forum_topic_count', 		'bp_core_number_format' );
+
+add_filter( 'bp_get_the_topic_title', 			'bp_forums_make_nofollow_filter' );
+add_filter( 'bp_get_the_topic_latest_post_excerpt', 	'bp_forums_make_nofollow_filter' );
+add_filter( 'bp_get_the_topic_post_content', 		'bp_forums_make_nofollow_filter' );
+
+// Allow shortcodes in activity posts
+add_filter( 'bp_get_the_topic_post_content', 		'do_shortcode' ); 
 
 function bp_forums_filter_kses( $content ) {
 	global $allowedtags;
--- buddypress/bp-forums/bp-forums-functions.php	Tue Jun 28 02:16:15 2011
+++ buddypress/bp-forums/bp-forums-functions.php	Tue Jun 28 02:20:04 2011
@@ -502,4 +502,45 @@
 add_action( 'bp_forums_new_topic', 'bp_core_clear_cache' );
 add_action( 'bp_forums_new_post',  'bp_core_clear_cache' );
 
+/** Embeds *******************************************************************/
+
+/**
+ * Grabs the topic post ID and attempts to retrieve the oEmbed cache (if it exists)
+ * during the forum topic loop.  If no cache and link is embeddable, cache it.
+ *
+ * @see BP_Embed
+ * @see bp_embed_forum_cache()
+ * @see bp_embed_forum_save_cache()
+ * @package BuddyPress_Forums
+ * @since 1.3
+ */
+function bp_forums_embed() {
+        add_filter( 'embed_post_id',		'bp_get_the_topic_post_id' );
+        add_filter( 'bp_embed_get_cache',	'bp_embed_forum_cache', 10, 3 );
+        add_action( 'bp_embed_update_cache',	'bp_embed_forum_save_cache', 10, 3 );
+}
+add_action( 'topic_loop_start', 'bp_forums_embed' );
+
+	/**
+	 * Wrapper function for {@link bb_get_postmeta()}.
+	 * Used during {@link BP_Embed::parse_oembed()} via {@link bp_forums_embed()}.
+	 *
+	 * @package BuddyPress_Forums
+	 * @since 1.3
+	 */
+        function bp_embed_forum_cache( $cache, $id, $cachekey ) {
+                return bb_get_postmeta( $id, $cachekey );
+        }
+
+	/**
+	 * Wrapper function for {@link bb_update_postmeta()}.
+	 * Used during {@link BP_Embed::parse_oembed()} via {@link bp_forums_embed()}.
+	 *
+	 * @package BuddyPress_Forums
+	 * @since 1.3
+	 */
+        function bp_embed_forum_save_cache( $cache, $cachekey, $id ) {
+                bb_update_postmeta( $id, $cachekey, $cache );
+        }
+
 ?>
