Opened 8 years ago
Closed 8 years ago
#7374 closed enhancement (fixed)
Add new filter to bp_activity_do_heartbeat()
Reported by: | wordpressrene | Owned by: | boonebgorges |
---|---|---|---|
Milestone: | 2.8 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Activity | Keywords: | good-first-bug has-patch commit |
Cc: |
Description
If you use the activity loop on another page than the activity page of BuddyPress, the automatic loading of new posts via heartbeat API is disabled, because the function "bp_activity_do_heartbeat()" returns false. This seems logic, because it is neither the activity directory nor the group activity.
If there is a filter in "bp_activity_do_heartbeat()" it would be possible to use the heartbeat functions in this case. Simply change return $retval;
to return apply_filters( 'bp_activity_do_heartbeat', $retval );
in bp-activity/bp-activity-functions.php:3764
Attachments (2)
Change History (11)
#1
@
8 years ago
- Keywords needs-patch good-first-bug added
- Milestone changed from Awaiting Review to Future Release
#2
@
8 years ago
- Keywords has-patch added; needs-patch removed
- Milestone changed from Future Release to 2.8
- Summary changed from Filter "bp_activity_do_heartbeat()" to Add new filter to bp_activity_do_heartbeat()
- Type changed from defect (bug) to enhancement
- Version 2.7.2 deleted
#3
@
8 years ago
Great, thanks for the patch @wordpressrene. We'll look at it soon!
Just a tip -- if you attach a patch to a Trac ticket, it's best to write a comment at the same time. Most people don't receive email updates about a Trac ticket unless a comment is left.
#4
@
8 years ago
- Keywords needs-docs added; has-patch removed
@wordpressrene Thank you very much for the patch! A few comments:
- New filters should be documented according to WordPress's inline documentation standards: https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/php/#4-hooks-actions-and-filters.
- Please use tabs instead of spaces when indenting.
- We currently return early if
! bp_is_activity_heartbeat_active()
. If we're going to add a filter to the function, perhaps we want to refactor so that this value will be run through the filter as well.
Would you like to revise your patch, @wordpressrene ?
#5
follow-up:
↓ 8
@
8 years ago
I will correct the code.
I don't know if somebody, who hasn't activated the heartbeat refresh needs to have the filter when returning early. In addition to this you can filter the return value of bp_is_activity_heartbeat_active()
to prevent returning early. So I think we don't need to add the filter here. What do you think @boonebgorges?
#7
@
8 years ago
- Keywords commit added
Patch looks good (whoever commits it, merge the two if
s into a one liner, they don't need to be nested).
#8
in reply to:
↑ 5
@
8 years ago
- Owner set to boonebgorges
- Status changed from new to assigned
Replying to wordpressrene:
I will correct the code.
I don't know if somebody, who hasn't activated the heartbeat refresh needs to have the filter when returning early. In addition to this you can filter the return value of
bp_is_activity_heartbeat_active()
to prevent returning early. So I think we don't need to add the filter here. What do you think @boonebgorges?
I agree it's unlikely that the filter would be useful in this case, but for consistency's sake, I think it makes sense for the return value always to be filtered. Thanks for the patch!
Sure thing, @wordpressrene. Do you fancy patching it up?