Skip to:
Content

BuddyPress.org

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#7321 closed enhancement (fixed)

Make hard-coded activity excerpt length a filterable function

Reported by: slaffik's profile slaFFik Owned by: boonebgorges's profile boonebgorges
Milestone: 2.8 Priority: normal
Severity: normal Version:
Component: Activity Keywords: good-first-bug has-patch
Cc:

Description

Currently there are 2 places:

// bp-activity/bp-activity-filters.php
$excerpt_length = apply_filters( 'bp_activity_excerpt_length', 358 );
// bp-activity/bp-activity-template.php
$latest_update = apply_filters( 'bp_get_activity_latest_update_excerpt', trim( strip_tags( bp_create_excerpt( $update['content'], 358 ) ) ), $user_id );

I propose to create bp_activity_get_excerpt_length(), with bp_activity_excerpt_length filter in it.

function bp_activity_get_excerpt_length() {
    return apply_filters( 'bp_activity_excerpt_length', 358 );
}

And the 1st usage will be changed to a direct function usage without filters, and the second to this:

$latest_update = apply_filters( 
    'bp_get_activity_latest_update_excerpt', 
    trim( strip_tags( bp_create_excerpt( $update['content'], bp_activity_get_excerpt_length() ) ) ), 
    $user_id 
);

Attachments (1)

7321.patch (2.3 KB) - added by sanket.parmar 8 years ago.

Download all attachments as: .zip

Change History (9)

#1 @boonebgorges
8 years ago

  • Keywords needs-patch added
  • Type changed from defect (bug) to enhancement

Good idea.

#2 @espellcaste
8 years ago

I agree, good idea!

@sanket.parmar
8 years ago

#3 @sanket.parmar
8 years ago

  • Keywords has-patch added; needs-patch removed

#4 @DJPaul
8 years ago

Hi @sanket.parmar
Thanks for the patch, we'll look at it as soon as we can.

Just a tip - when you add a patch onto a ticket, please leave a comment, too. Most people don't receive a email notification about a change on a Trac ticket, unless a comment is also left.

#5 @boonebgorges
8 years ago

@sanket.parmar Thanks for the excellent patch! The one change I'll make is this: the @since version on the filter documentation shouldn't change to 2.8.0, since it's the same filter name as we introduced in 1.5.0.

#6 @boonebgorges
8 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 11280:

Introduce bp_activity_excerpt_length().

This function provides a centralized filter for controlling
the length of activity excerpts generated throughout BP.

Props sanket.parmar.
Fixes #7321.

#7 @sanket.parmar
8 years ago

Hi @DJPaul

Surely. I'll keep that tip in mind from next time.

Thank you.

#8 @sanket.parmar
8 years ago

Hi @boonebgorges

Yes, it is the same filter. Thanks for pointing this out. :)

Note: See TracTickets for help on using tickets.