Skip to:
Content

BuddyPress.org

Changeset 10725


Ignore:
Timestamp:
04/27/2016 07:18:01 PM (3 years ago)
Author:
r-a-y
Message:

Notifications: Introduce two new parameters to the 'bp_notifications_get_notifications_for_user' filter.

This commit:

  • Adds $component_action_name and $component_name as the 6th and 7th parameters to the filter.
  • Updates the DocBlock for the filter.

In the DocBlock, we are deprecating the first parameter, which is the
component action name. It is recommended to do notification action name
checks against the 6th parameter from now on.

The reason why we are deprecating the first parameter is due to potential
plugin conflicts. If a plugin is doing a specific check on the notification
action and changes the return value for the filter, then no other plugin
can do checks for that same notification action. Also see #6669.

Fixes #7020.

Location:
trunk/src/bp-notifications
Files:
2 edited

Legend:

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

    r10437 r10725  
    271271                    $component_action_items[0]->secondary_item_id,
    272272                    $action_item_count,
    273                     $format
     273                    $format,
     274                    $component_action_name, // Duplicated so plugins can check the canonical action name.
     275                    $component_name
    274276                );
    275277
     
    278280
    279281                    /**
    280                      * Filters the notifications for a user.
     282                     * Filters the notification content for notifications created by plugins.
     283                     *
     284                     * If your plugin extends the {@link BP_Component} class, you should use the
     285                     * 'notification_callback' parameter in your extended
     286                     * {@link BP_Component::setup_globals()} method instead.
    281287                     *
    282288                     * @since 1.9.0
     289                     * @since 2.6.0 Added $component_action_name and $component_name as parameters.
    283290                     *
    284                      * @param array $ref_array Array of properties for the current notification being rendered.
     291                     * @param string $content               Component action. Deprecated. Do not do checks against this! Use
     292                     *                                      the 6th parameter instead - $component_action_name.
     293                     * @param int    $item_id               Notification item ID.
     294                     * @param int    $secondary_item_id     Notification secondary item ID.
     295                     * @param int    $action_item_count     Number of notifications with the same action.
     296                     * @param string $format                Format of return. Either 'string' or 'object'.
     297                     * @param string $component_action_name Canonical notification action.
     298                     * @param string $component_name        Notification component ID.
     299                     *
     300                     * @return string|array If $format is 'string', return a string of the notification content.
     301                     *                      If $format is 'object', return an array formatted like:
     302                     *                      array( 'text' => 'CONTENT', 'link' => 'LINK' )
    285303                     */
    286304                    $content = apply_filters_ref_array( 'bp_notifications_get_notifications_for_user', $ref_array );
  • trunk/src/bp-notifications/bp-notifications-template.php

    r10715 r10725  
    480480
    481481            /** This filter is documented in bp-notifications/bp-notifications-functions.php */
    482             $description = apply_filters_ref_array( 'bp_notifications_get_notifications_for_user', array( $notification->component_action, $notification->item_id, $notification->secondary_item_id, 1 ) );
     482            $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 ) );
    483483        }
    484484
Note: See TracChangeset for help on using the changeset viewer.