Ticket #6663: 6663.02.patch
File 6663.02.patch, 3.9 KB (added by , 9 years ago) |
---|
-
src/bp-notifications/bp-notifications-functions.php
diff --git src/bp-notifications/bp-notifications-functions.php src/bp-notifications/bp-notifications-functions.php index 33796ba..4face99 100644
function bp_notifications_get_notifications_for_user( $user_id, $format = 'strin 200 200 // Calculate a renderable output for each notification type 201 201 foreach ( $grouped_notifications as $component_name => $action_arrays ) { 202 202 203 // We prefer that extended profile component-related notifications use 204 // the component_name of 'xprofile'. However, the extended profile child 205 // object in the $bp object is keyed as 'profile', which is where we need 206 // to look for the registered notification callback. 207 if ( 'xprofile' == $component_name ) { 208 $component_name = 'profile'; 209 } 210 203 211 // Skip if group is empty 204 212 if ( empty( $action_arrays ) ) { 205 213 continue; … … function bp_notifications_get_registered_components() { 611 619 if ( !empty( $bp->$component->notification_callback ) ) { 612 620 $component_names[] = $component; 613 621 } 622 // The extended profile component is identified in the active_components array as 'xprofile'. 623 // However, the extended profile child object has the key 'profile' in the $bp object. 624 if ( 'xprofile' == $component && ! empty( $bp->profile->notification_callback ) ) { 625 $component_names[] = $component; 626 } 614 627 } 615 628 616 629 /** -
src/bp-xprofile/bp-xprofile-loader.php
diff --git src/bp-xprofile/bp-xprofile-loader.php src/bp-xprofile/bp-xprofile-loader.php index 7bd8123..8fdbdd5 100644
class BP_XProfile_Component extends BP_Component { 67 67 'settings', 68 68 'template', 69 69 'functions', 70 'notifications', 70 71 ); 71 72 72 73 if ( is_admin() ) { -
new file src/bp-xprofile/bp-xprofile-notifications.php
diff --git src/bp-xprofile/bp-xprofile-notifications.php src/bp-xprofile/bp-xprofile-notifications.php new file mode 100644 index 0000000..c377734
- + 1 <?php 2 /** Notifications *************************************************************/ 3 4 /** 5 * Format notifications for the extended profile (Xprofile) component. 6 * 7 * @since 2.4.0 8 * 9 * @param string $action The kind of notification being rendered. 10 * @param int $item_id The primary item ID. 11 * @param int $secondary_item_id The secondary item ID. 12 * @param int $total_items The total number of messaging-related notifications 13 * waiting for the user. 14 * @param string $format 'string' for BuddyBar-compatible notifications; 'array' 15 * for WP Toolbar. Default: 'string'. 16 * 17 * @return string 18 */ 19 function xprofile_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) { 20 switch ( $action ) { 21 default: 22 23 /** 24 * Allows plugins to filter extended profile-related custom notifications. 25 * Notifications must have a 'component_name' of 'xprofile' to be routed 26 * to this function. 27 * 28 * 29 * @since 2.4.0 30 * 31 * @param string $notification Null value. 32 * @param int $item_id The primary item ID. 33 * @param int $secondary_item_id The secondary item ID. 34 * @param int $total_items The total number of messaging-related notifications 35 * waiting for the user. 36 * @param string $format 'string' for BuddyBar-compatible notifications; 37 * 'array' for WP Toolbar. 38 */ 39 $custom_action_notification = apply_filters( 'bp_xprofile_' . $action . '_notification', null, $item_id, $secondary_item_id, $total_items, $format ); 40 41 if ( ! is_null( $custom_action_notification ) ) { 42 return $custom_action_notification; 43 } 44 45 break; 46 } 47 48 return false; 49 } 50 No newline at end of file