Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/18/2011 10:43:22 PM (14 years ago)
Author:
djpaul
Message:

Add oembed support to activity stream items and forum posts. Fixes #2707, massive props r-a-y

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-functions.php

    r4674 r4709  
    117117 * @param int $secondary_item_id In the case of at-mentions, this is the mentioner's id
    118118 * @param int $total_items The total number of notifications to format
    119  * @param str $format 'string' to get a BuddyBar-compatible notification, 'array' otherwise 
     119 * @param str $format 'string' to get a BuddyBar-compatible notification, 'array' otherwise
    120120 */
    121121function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
     
    139139        break;
    140140    }
    141                
     141
    142142    if ( 'string' == $format ) {
    143143        $return = apply_filters( $filter, '<a href="' . $at_mention_link . '" title="' . $at_mention_title . '">' . $text . '</a>', $at_mention_link, (int)$total_items, $activity_id, $poster_user_id );
     
    994994}
    995995
     996/** Embeds *******************************************************************/
     997
     998/**
     999 * Grabs the activity ID and attempts to retrieve the oEmbed cache (if it exists)
     1000 * during the activity loop.  If no cache and link is embeddable, cache it.
     1001 *
     1002 * @see BP_Embed
     1003 * @see bp_embed_activity_cache()
     1004 * @see bp_embed_activity_save_cache()
     1005 * @package BuddyPress Activity
     1006 * @since 1.3
     1007 */
     1008function bp_activity_embed() {
     1009    add_filter( 'embed_post_id',         'bp_get_activity_id'                  );
     1010    add_filter( 'bp_embed_get_cache',    'bp_embed_activity_cache',      10, 3 );
     1011    add_action( 'bp_embed_update_cache', 'bp_embed_activity_save_cache', 10, 3 );
     1012}
     1013add_action( 'activity_loop_start', 'bp_activity_embed' );
     1014
     1015/**
     1016 * Wrapper function for {@link bp_activity_get_meta()}.
     1017 * Used during {@link BP_Embed::parse_oembed()} via {@link bp_activity_embed()}.
     1018 *
     1019 * @package BuddyPress Activity
     1020 * @since 1.3
     1021 */
     1022function bp_embed_activity_cache( $cache, $id, $cachekey ) {
     1023    return bp_activity_get_meta( $id, $cachekey );
     1024}
     1025
     1026/**
     1027 * Wrapper function for {@link bp_activity_update_meta()}.
     1028 * Used during {@link BP_Embed::parse_oembed()} via {@link bp_activity_embed()}.
     1029 *
     1030 * @package BuddyPress Activity
     1031 * @since 1.3
     1032 */
     1033function bp_embed_activity_save_cache( $cache, $cachekey, $id ) {
     1034    bp_activity_update_meta( $id, $cachekey, $cache );
     1035}
    9961036?>
Note: See TracChangeset for help on using the changeset viewer.