Changeset 13305 for trunk/src/bp-activity/bp-activity-functions.php
- Timestamp:
- 07/26/2022 02:08:37 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/bp-activity-functions.php
r13298 r13305 3461 3461 ); 3462 3462 3463 $post_url = ''; 3463 $post_url = ''; 3464 $post_title = ''; 3465 $bp_excerpt_args = array( 3466 'html' => false, 3467 'filter_shortcodes' => true, 3468 'strip_tags' => true, 3469 'remove_links' => true, 3470 ); 3464 3471 // Get the WP_Post object if this activity type is a blog post. 3465 3472 if ( $activity['type'] === 'new_blog_post' ) { 3466 $content = get_post( $activity['secondary_item_id'] ); 3467 $post_url = $content->guid; 3473 $content = get_post( $activity['secondary_item_id'] ); 3474 $post_url = $content->guid; 3475 $post_title = sprintf( 3476 '<strong><a href="%1$s">%2$s</a></strong>', 3477 esc_url( $post_url ), 3478 esc_html( $content->post_title ) 3479 ); 3480 3481 $more_text = sprintf( 3482 '<span>%s</span>', 3483 trim( __( ' […]', 'buddypress' ) ) 3484 ); 3485 3486 /** This filter is documented in wp-admin/includes/post-template.php */ 3487 $bp_excerpt_args['ending'] = apply_filters( 3488 'the_content_more_link', 3489 sprintf( 3490 ' <a href="%1$s">%2$s</a>', 3491 esc_url( $post_url ), 3492 $more_text 3493 ), 3494 $more_text 3495 ); 3468 3496 } 3469 3497 … … 3580 3608 3581 3609 // Generate a text excerpt for this activity item (and remove any oEmbeds URLs). 3582 $summary = bp_create_excerpt( html_entity_decode( $content ), 225, array( 3583 'html' => false, 3584 'filter_shortcodes' => true, 3585 'strip_tags' => true, 3586 'remove_links' => true 3587 ) ); 3610 $summary_parts = array( 3611 str_replace( 3612 array( "\n", "\r" ), 3613 ' ', 3614 trim( bp_create_excerpt( html_entity_decode( $content ), 225, $bp_excerpt_args ) ) 3615 ), 3616 ); 3588 3617 3589 3618 if ( $use_media_type === 'embeds' ) { 3590 $summary .= PHP_EOL . PHP_EOL . $extracted_media['url'];3619 $summary_parts[] = PHP_EOL . PHP_EOL . $extracted_media['url']; 3591 3620 } elseif ( $use_media_type === 'images' ) { 3592 3621 $extracted_media_url = isset( $extracted_media['url'] ) ? $extracted_media['url'] : ''; 3622 $image_tag = sprintf( '<img src="%s"> ', esc_url( $extracted_media_url ) ); 3593 3623 3594 3624 if ( $post_url ) { 3595 $summary .= sprintf( '<a href="%1$s" class="activity-post-featured-image"><img src="%2$s"></a>', esc_url( $post_url ), esc_url( $extracted_media_url ) ); 3596 } else { 3597 $summary .= sprintf( ' <img src="%s">', esc_url( $extracted_media_url ) ); 3625 $image_tag = sprintf( '<a href="%1$s" class="activity-post-featured-image">%2$s</a> ', esc_url( $post_url ), trim( $image_tag ) ); 3626 array_unshift( $summary_parts, $image_tag ); 3598 3627 } 3599 3628 } elseif ( in_array( $use_media_type, array( 'audio', 'videos' ), true ) ) { 3600 $summary .= PHP_EOL . PHP_EOL . $extracted_media['original']; // Full shortcode. 3601 } 3629 $summary_parts[] = PHP_EOL . PHP_EOL . $extracted_media['original']; // Full shortcode. 3630 } 3631 3632 if ( $post_title ) { 3633 array_unshift( $summary_parts, $post_title ); 3634 } 3635 3636 // Join summary parts. 3637 $summary = implode( '', $summary_parts ); 3602 3638 3603 3639 /**
Note: See TracChangeset
for help on using the changeset viewer.