bp_blogs_activity_content_with_read_more( $content,  $activity )

Function which set the content on activity blog post.

Description

Parameters

$content

(Required)

$activity

(Required)

Return

(string)

Source

File: bp-activity/bp-activity-filters.php

2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
function bp_blogs_activity_content_with_read_more( $content, $activity ) {
 
    if( ( 'blogs' === $activity->component ) && isset( $activity->secondary_item_id ) && 'new_blog_' . get_post_type( $activity->secondary_item_id ) === $activity->type ) {
        $blog_post = get_post( $activity->secondary_item_id );
        // If we converted $content to an object earlier, flip it back to a string.
        if( is_a( $blog_post, 'WP_Post' ) ) {
            $content = bp_create_excerpt( html_entity_decode( $blog_post->post_content ) );
            if( false !== strrpos( $content, __( '…', 'buddyboss' ) ) ) {
                $content     = str_replace( ' […]', '…', $content );
                $append_text = apply_filters( 'bp_activity_excerpt_append_text', __( ' Read more', 'buddyboss' ) );
                $content     = sprintf( '%1$s<span class="activity-blog-post-link"><a href="%2$s" rel="nofollow">%3$s</a></span>', $content, get_permalink( $blog_post ), $append_text );
                $content     = apply_filters_ref_array( 'bp_get_activity_content', array( $content, $activity ) );
                preg_match( '/<iframe.*src=\"(.*)\".*><\/iframe>/isU', $content, $matches );
                if( isset( $matches ) && array_key_exists( 0, $matches ) && ! empty( $matches[0] ) ) {
                    $iframe  = $matches[0];
                    $content = strip_tags( preg_replace( '/<iframe.*?\/iframe>/i', '', $content ), '<a>' );
                    $content .= $iframe;
                } else {
                    $src = wp_get_attachment_image_src( get_post_thumbnail_id( $blog_post->ID ), 'full', false );
                    if( isset( $src[0] ) ) {
                        $content .= sprintf( ' <img src="%s">', esc_url( $src[0] ) );
                    }
                }
 
            } else {
                $content = apply_filters_ref_array( 'bp_get_activity_content', array( $content, $activity ) );
                $content = strip_tags( $content, '<a><iframe>' );
                preg_match( '/<iframe.*src=\"(.*)\".*><\/iframe>/isU', $content, $matches );
                if( isset( $matches ) && array_key_exists( 0, $matches ) && ! empty( $matches[0] ) ) {
                    $content = $content;
                } else {
                    $src = wp_get_attachment_image_src( get_post_thumbnail_id( $blog_post->ID ), 'full', false );
                    if( isset( $src[0] ) ) {
                        $content .= sprintf( ' <img src="%s">', esc_url( $src[0] ) );
                    }
                }
            }
        }
 
    }
 
    return $content;
 
}

Changelog

Changelog
Version Description
BuddyBoss 1.5.5 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.