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-forums/bp-forums-functions.php

    r4658 r4709  
    515515add_action( 'bp_forums_new_post',  'bp_core_clear_cache' );
    516516
     517
     518/** Embeds *******************************************************************/
     519
     520/**
     521 * Grabs the topic post ID and attempts to retrieve the oEmbed cache (if it exists)
     522 * during the forum topic loop.  If no cache and link is embeddable, cache it.
     523 *
     524 * @see BP_Embed
     525 * @see bp_embed_forum_cache()
     526 * @see bp_embed_forum_save_cache()
     527 * @package BuddyPress_Forums
     528 * @since 1.3
     529 */
     530function bp_forums_embed() {
     531    add_filter( 'embed_post_id',         'bp_get_the_topic_post_id'         );
     532    add_filter( 'bp_embed_get_cache',    'bp_embed_forum_cache',      10, 3 );
     533    add_action( 'bp_embed_update_cache', 'bp_embed_forum_save_cache', 10, 3 );
     534}
     535add_action( 'topic_loop_start', 'bp_forums_embed' );
     536
     537/**
     538 * Wrapper function for {@link bb_get_postmeta()}.
     539 * Used during {@link BP_Embed::parse_oembed()} via {@link bp_forums_embed()}.
     540 *
     541 * @package BuddyPress_Forums
     542 * @since 1.3
     543 */
     544function bp_embed_forum_cache( $cache, $id, $cachekey ) {
     545    return bb_get_postmeta( $id, $cachekey );
     546}
     547
     548/**
     549 * Wrapper function for {@link bb_update_postmeta()}.
     550 * Used during {@link BP_Embed::parse_oembed()} via {@link bp_forums_embed()}.
     551 *
     552 * @package BuddyPress_Forums
     553 * @since 1.3
     554 */
     555function bp_embed_forum_save_cache( $cache, $cachekey, $id ) {
     556    bb_update_postmeta( $id, $cachekey, $cache );
     557}
    517558?>
Note: See TracChangeset for help on using the changeset viewer.