Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/19/2016 05:58:25 PM (6 years ago)
Author:
r-a-y
Message:

Notifications: Pass the notification ID to the notification format callback.

When formatting notifications for a component, there are some cases where
you might want to reference the notification ID.

This is especially important if you want to grab some notification meta
without having to re-query just for the notification ID.

This commit adds the notification ID to our notification format callbacks:

  • For those registered by the BP_Component class ($bp->COMPONENT->notification_callback)
  • For non-BP components via the 'bp_notifications_get_notifications_for_user' filter.

Fixes #7066.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-notifications/bp-notifications-template.php

    r10785 r10790  
    472472        // Callback function exists.
    473473        if ( isset( $bp->{ $notification->component_name }->notification_callback ) && is_callable( $bp->{ $notification->component_name }->notification_callback ) ) {
    474             $description = call_user_func( $bp->{ $notification->component_name }->notification_callback, $notification->component_action, $notification->item_id, $notification->secondary_item_id, 1 );
     474            $description = call_user_func( $bp->{ $notification->component_name }->notification_callback, $notification->component_action, $notification->item_id, $notification->secondary_item_id, 1, 'string', $notification->id );
    475475
    476476        // @deprecated format_notification_function - 1.5
     
    482482
    483483            /** This filter is documented in bp-notifications/bp-notifications-functions.php */
    484             $description = apply_filters_ref_array( 'bp_notifications_get_notifications_for_user', array( $notification->component_action, $notification->item_id, $notification->secondary_item_id, 1, 'string', $notification->component_action, $notification->component_name ) );
     484            $description = apply_filters_ref_array( 'bp_notifications_get_notifications_for_user', array( $notification->component_action, $notification->item_id, $notification->secondary_item_id, 1, 'string', $notification->component_action, $notification->component_name, $notification->id ) );
    485485        }
    486486
Note: See TracChangeset for help on using the changeset viewer.