Skip to:
Content

BuddyPress.org

Changeset 9153


Ignore:
Timestamp:
11/18/2014 01:04:38 PM (10 years ago)
Author:
boonebgorges
Message:

Assemble the filters in friends_format_notifications() dynamically.

This makes them easier to document.

Props tw2113.
See #5970.

Location:
trunk
Files:
1 added
1 edited

Legend:

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

    r8169 r9153  
    137137            $link = trailingslashit( bp_loggedin_user_domain() . bp_get_friends_slug() . '/my-friends' );
    138138
     139            // $action and $amount are used to generate dynamic filter names.
     140            $action = 'accepted';
     141
    139142            // Set up the string and the filter
    140143            if ( (int) $total_items > 1 ) {
    141144                $text = sprintf( __( '%d friends accepted your friendship requests', 'buddypress' ), (int) $total_items );
    142                 $filter = 'bp_friends_multiple_friendship_accepted_notification';
     145                $amount = 'multiple';
    143146            } else {
    144147                $text = sprintf( __( '%s accepted your friendship request', 'buddypress' ),  bp_core_get_user_displayname( $item_id ) );
    145                 $filter = 'bp_friends_single_friendship_accepted_notification';
     148                $amount = 'single';
    146149            }
    147150
     
    150153        case 'friendship_request':
    151154            $link = bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/?new';
     155
     156            $action = 'request';
    152157
    153158            // Set up the string and the filter
    154159            if ( (int) $total_items > 1 ) {
    155160                $text = sprintf( __( 'You have %d pending friendship requests', 'buddypress' ), (int) $total_items );
    156                 $filter = 'bp_friends_multiple_friendship_request_notification';
     161                $amount = 'multiple';
    157162            } else {
    158163                $text = sprintf( __( 'You have a friendship request from %s', 'buddypress' ),  bp_core_get_user_displayname( $item_id ) );
    159                 $filter = 'bp_friends_single_friendship_request_notification';
     164                $amount = 'single';
    160165            }
    161166
     
    165170    // Return either an HTML link or an array, depending on the requested format
    166171    if ( 'string' == $format ) {
    167         $return = apply_filters( $filter, '<a href="' . esc_url( $link ) . '">' . esc_html( $text ) . '</a>', (int) $total_items, $item_id );
     172        $return = apply_filters( 'bp_friends_' . $amount . '_friendship_' . $action . '_notification', '<a href="' . esc_url( $link ) . '">' . esc_html( $text ) . '</a>', (int) $total_items, $item_id );
    168173    } else {
    169         $return = apply_filters( $filter, array(
     174        $return = apply_filters( 'bp_friends_' . $amount . '_friendship_' . $action . '_notification', array(
    170175            'link' => $link,
    171176            'text' => $text
Note: See TracChangeset for help on using the changeset viewer.