[buddypress-trac] [BuddyPress Trac] #5970: Remove $filter variables holding hook names.

buddypress-trac noreply at wordpress.org
Wed Oct 29 02:58:41 UTC 2014


#5970: Remove $filter variables holding hook names.
-------------------------+-----------------------------
 Reporter:  tw2113       |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Core         |    Version:
 Severity:  normal       |   Keywords:
-------------------------+-----------------------------
 There are currently four files that create a `$filter` variable that holds
 the filter hook name and are passed in to `apply_filters()`. The four
 files are `bp-activity-notifications`, `bp-groups-notifications`, `bp-
 friends-notifications`, and `bp-messages-notifications` because of how
 these are done, it's notably more difficult to set up documentation for
 the hooks, as well as makes things a bit more complex than they need to
 be.

 I think a more optimal solution is to make parts of the hook names
 variable, depending on context in the surrounding code, instead of the
 whole hook. Think `wp_insert_{$post->post_type}`

 For the activity one, it's simple enough as there's only two to deal with,
 and it's `bp_activity_multiple_at_mentions_notification` vs
 `bp_activity_single_at_mentions_notification`. In place of the whole hook,
 I have a diff ready to be created that changes $filter to $amount, and the
 `apply_filters()` become `bp_activity_' . $amount .
 '_at_mentions_notification` or
 `bp_activity_{$amount}_at_mentions_notification` depending on your
 preference for single vs double quotes.

 Messages will be the same situation, except the hook is
 `bp_messages_{$amount}_new_message_notification`

 Friends will be a bit more, except there will be two spots to change out.
 `bp_friends_{$amount}_friendship_{$action}_notification` with `$amount`
 being the same as above, and `$action` being "accepted" or "request".

 Lastly, the Group notifications actually does the variable needlessly, as
 the `apply_filters` calls are all done within their respective if/else
 blocks. It'd be better to just remove that usage completely.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/5970>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list