Skip to:
Content

BuddyPress.org

Ticket #3429: 3429.03.patch

File 3429.03.patch, 6.6 KB (added by r-a-y, 13 years ago)
  • bp-activity/bp-activity-functions.php

    function bp_activity_get_permalink( $activity_id, $activity_obj = false ) { 
    923923        if ( isset( $activity_obj->current_comment ) ) {
    924924                $activity_obj = $activity_obj->current_comment;
    925925        }
    926        
     926
    927927        if ( 'new_blog_post' == $activity_obj->type || 'new_blog_comment' == $activity_obj->type || 'new_forum_topic' == $activity_obj->type || 'new_forum_post' == $activity_obj->type )
    928928                $link = $activity_obj->primary_link;
    929929        else {
    function bp_activity_thumbnail_content_images( $content, $link = false ) { 
    994994/** Embeds *******************************************************************/
    995995
    996996/**
    997  * Grabs the activity ID and attempts to retrieve the oEmbed cache (if it exists)
     997 * Grabs the activity update ID and attempts to retrieve the oEmbed cache (if it exists)
    998998 * during the activity loop.  If no cache and link is embeddable, cache it.
    999999 *
     1000 * This does not cover recursive activity comments, as they do not use a real loop.
     1001 * For that, see {@link bp_activity_comment_embed()}.
     1002 *
    10001003 * @see BP_Embed
    10011004 * @see bp_embed_activity_cache()
    10021005 * @see bp_embed_activity_save_cache()
    function bp_activity_embed() { 
    10111014add_action( 'activity_loop_start', 'bp_activity_embed' );
    10121015
    10131016/**
     1017 * Grabs the activity comment ID and attempts to retrieve the oEmbed cache (if it exists)
     1018 * when BP is recursing through activity comments {@link bp_activity_recurse_comments()}.
     1019 * If no cache and link is embeddable, cache it.
     1020 *
     1021 * @see BP_Embed
     1022 * @see bp_embed_activity_cache()
     1023 * @see bp_embed_activity_save_cache()
     1024 * @package BuddyPress Activity
     1025 * @since 1.5
     1026 */
     1027function bp_activity_comment_embed() {
     1028        add_filter( 'embed_post_id',         'bp_get_activity_comment_id' );
     1029        add_filter( 'bp_embed_get_cache',    'bp_embed_activity_cache',      10, 3 );
     1030        add_action( 'bp_embed_update_cache', 'bp_embed_activity_save_cache', 10, 3 );
     1031}
     1032add_action( 'bp_before_activity_comment', 'bp_activity_comment_embed' );
     1033
     1034/**
     1035 * Removes the 'embed_post_id' filter after {@link bp_activity_recurse_comments()}
     1036 * is rendered to avoid conflict with the 'embed_post_id' filter in
     1037 * {@link bp_activity_embed()} or any other component embeds.
     1038 *
     1039 * @see bp_activity_comment_embed()
     1040 * @package BuddyPress Activity
     1041 * @since 1.5
     1042 */
     1043function bp_activity_comment_embed_after_recurse() {
     1044        remove_filter( 'embed_post_id',      'bp_get_activity_comment_id' );
     1045}
     1046add_action( 'bp_after_activity_comment', 'bp_activity_comment_embed_after_recurse' );
     1047
     1048/**
    10141049 * Wrapper function for {@link bp_activity_get_meta()}.
    10151050 * Used during {@link BP_Embed::parse_oembed()} via {@link bp_activity_embed()}.
    10161051 *
  • bp-core/bp-core-classes.php

    class BP_Embed extends WP_Embed { 
    11681168                // Look for known internal handlers
    11691169                ksort( $this->handlers );
    11701170                foreach ( $this->handlers as $priority => $handlers ) {
    1171                         foreach ( $handlers as $id => $handler ) {
     1171                        foreach ( $handlers as $hid => $handler ) {
    11721172                                if ( preg_match( $handler['regex'], $url, $matches ) && is_callable( $handler['callback'] ) ) {
    11731173                                        if ( false !== $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ) )
    11741174                                                return apply_filters( 'embed_handler_html', $return, $url, $attr );
    class BP_Embed extends WP_Embed { 
    11771177                }
    11781178
    11791179                // Get object ID
     1180                $id = '';
    11801181                $id = apply_filters( 'embed_post_id', $id );
    11811182
    11821183                // Is oEmbed discovery on?
    class BP_Embed extends WP_Embed { 
    12191220         * @return string The embed HTML on success, otherwise the original URL.
    12201221         */
    12211222        function parse_oembed( $id, $url, $attr, $rawattr ) {
    1222                 if ( $id ) {
     1223                if ( is_numeric( $id ) ) {
    12231224                        // Setup the cachekey
    12241225                        $cachekey = '_oembed_' . md5( $url . serialize( $attr ) );
    12251226
    class BP_Embed extends WP_Embed { 
    12291230
    12301231                        // Grab cache and return it if available
    12311232                        if ( !empty( $cache ) ) {
    1232                                 return apply_filters( 'embed_oembed_html', $cache, $url, $attr, $rawattr );
     1233                                return apply_filters( 'bp_embed_oembed_html', $cache, $url, $attr, $rawattr );
    12331234
    12341235                        // If no cache, ping the oEmbed provider and cache the result
    12351236                        } else {
  • bp-themes/bp-default/_inc/ajax.php

    function bp_dtheme_get_single_activity_content() { 
    339339        if ( !$activity )
    340340                exit(); // todo: error?
    341341
     342        do_action( 'bp_activity_action_get_single_activity_content', $_POST['activity_id'] );
     343
    342344        // Activity content retrieved through AJAX should run through normal filters, but not be
    343345        // truncated
    344346        remove_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 );
  • bp-themes/bp-default/functions.php

    if ( !function_exists( 'bp_dtheme_enqueue_scripts' ) ) : 
    134134 * @since 1.5
    135135 */
    136136function bp_dtheme_enqueue_scripts() {
    137        
     137
    138138        // Bump this when changes are made to bust cache
    139139        $version = '20110729';
    140        
     140
    141141        // Enqueue the global JS - Ajax will not work without it
    142142        wp_enqueue_script( 'dtheme-ajax-js', get_template_directory_uri() . '/_inc/global.js', array( 'jquery' ), $version );
    143143
    function bp_dtheme_enqueue_styles() { 
    169169
    170170        // Bump this when changes are made to bust cache
    171171        $version = '20110731b';
    172        
     172
    173173        // Default CSS
    174174        wp_enqueue_style( 'bp-default-main', get_template_directory_uri() . '/_inc/css/default.css', array(), $version );
    175175
    function bp_dtheme_content_nav( $nav_id ) { 
    702702                </div><!-- #<?php echo $nav_id; ?> -->
    703703        <?php endif;
    704704}
     705
     706if ( !function_exists( 'bp_dtheme_embed_expanded_activity' ) ) :
     707/**
     708 * When a user clicks on a "Read More" item, make sure embeds are correctly parsed and shown
     709 * for the expanded content.
     710 *
     711 * @param int $activity_id The activity ID that is being expanded
     712 * @since 1.5
     713 * @see BP_Embed
     714 */
     715function bp_dtheme_embed_expanded_activity( $activity_id ) {
     716        add_filter( 'embed_post_id',            create_function( '', 'return $activity_id;' ) );
     717        add_filter( 'bp_embed_get_cache',       'bp_embed_activity_cache',      10, 3 );
     718        add_action( 'bp_embed_update_cache',    'bp_embed_activity_save_cache', 10, 3 );
     719}
     720add_action( 'bp_activity_action_get_single_activity_content', 'bp_dtheme_embed_expanded_activity' );
     721endif;
     722
    705723?>