Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/06/2011 07:10:08 PM (13 years ago)
Author:
boonebgorges
Message:

Provides initial support for Notifications menu in WP Admin Bar. Refactors group and friendship notifications to return values compatible with the WP Admin Bar constructor. Modifies bp_core_get_notifications_for_user() in order to provide WP Admin Bar support in addition to BuddyBar backpat. References #3294

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-members/bp-members-notifications.php

    r4605 r4620  
    4444}
    4545
    46 function bp_core_get_notifications_for_user( $user_id ) {
     46function bp_core_get_notifications_for_user( $user_id, $format = 'simple' ) {
    4747    global $bp;
    4848
     
    7272            if ( isset( $bp->{$component_name}->format_notification_function ) && function_exists( $bp->{$component_name}->format_notification_function ) ) {
    7373                $renderable[] = call_user_func( $bp->{$component_name}->format_notification_function, $component_action_name, $component_action_items[0]->item_id, $component_action_items[0]->secondary_item_id, $action_item_count );
    74             } elseif ( isset( $bp->{$component_name}->notification_callback ) && function_exists( $bp->{$component_name}->notification_callback ) ) {
    75                 $renderable[] = call_user_func( $bp->{$component_name}->notification_callback, $component_action_name, $component_action_items[0]->item_id, $component_action_items[0]->secondary_item_id, $action_item_count );
     74            } elseif ( isset( $bp->{$component_name}->notification_callback ) && function_exists( $bp->{$component_name}->notification_callback ) ) {
     75                if ( 'object' == $format ) {
     76                    $content = call_user_func( $bp->{$component_name}->notification_callback, $component_action_name, $component_action_items[0]->item_id, $component_action_items[0]->secondary_item_id, $action_item_count, 'array' );
     77                   
     78                    // Minimal backpat with non-compatible notification
     79                    // callback functions
     80                    if ( is_string( $content ) ) {
     81                        $notification->content = $content;
     82                        $notification->href    = bp_loggedin_user_domain();
     83                    } else {
     84                        $notification->content = $content['text'];
     85                        $notification->href    = $content['link'];
     86                    }
     87                   
     88                    $renderable[]          = $notification;
     89                } else {
     90                    $content = call_user_func( $bp->{$component_name}->notification_callback, $component_action_name, $component_action_items[0]->item_id, $component_action_items[0]->secondary_item_id, $action_item_count );
     91                    $renderable[] = $content;
     92                }
    7693            }
    7794        }
Note: See TracChangeset for help on using the changeset viewer.