Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/21/2021 08:10:55 PM (6 years ago)
Author:
imath
Message:

The new_avatar activity belongs to the Members component

The activity generated when members add/update their profile photo wasn't migrated to the Members component during the 6.0.0 milestone. This commit's goal is to repare this oversight.

See #8156
See #8407
Fixes #8408

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/bp-xprofile-activity.php

    r12812 r12851  
    2121 */
    2222function xprofile_register_activity_actions() {
    23 
    24         // Register the activity stream actions for this component.
    25         bp_activity_set_action(
    26                 // Older avatar activity items use 'profile' for component. See r4273.
    27                 'profile',
    28                 'new_avatar',
    29                 __( 'Member changed profile picture', 'buddypress' ),
    30                 'bp_xprofile_format_activity_action_new_avatar',
    31                 __( 'Updated Profile Photos', 'buddypress' )
    32         );
    3323
    3424        bp_activity_set_action(
     
    4939}
    5040add_action( 'bp_register_activity_actions', 'xprofile_register_activity_actions' );
    51 
    52 /**
    53  * Format 'new_avatar' activity actions.
    54  *
    55  * @since 2.0.0
    56  *
    57  * @param string $action   Static activity action.
    58  * @param object $activity Activity object.
    59  * @return string
    60  */
    61 function bp_xprofile_format_activity_action_new_avatar( $action, $activity ) {
    62         $userlink = bp_core_get_userlink( $activity->user_id );
    63 
    64         /* translators: %s: user link */
    65         $action = sprintf( esc_html__( '%s changed their profile picture', 'buddypress' ), $userlink );
    66 
    67         // Legacy filter - pass $user_id instead of $activity.
    68         if ( has_filter( 'bp_xprofile_new_avatar_action' ) ) {
    69                 $action = apply_filters( 'bp_xprofile_new_avatar_action', $action, $activity->user_id );
    70         }
    71 
    72         /**
    73          * Filters the formatted 'new_avatar' activity stream action.
    74          *
    75          * @since 2.0.0
    76          *
    77          * @param string $action   Formatted action for activity stream.
    78          * @param object $activity Activity object.
    79          */
    80         return apply_filters( 'bp_xprofile_format_activity_action_new_avatar', $action, $activity );
    81 }
    8241
    8342/**
     
    201160
    202161/**
    203  * Adds an activity stream item when a user has uploaded a new avatar.
    204  *
    205  * @since 1.0.0
    206  * @since 2.3.4 Add new parameter to get the user id the avatar was set for.
    207  *
    208  *                         specific activity
    209  *
    210  * @param int $user_id The user id the avatar was set for.
    211  * @return bool
    212  */
    213 function bp_xprofile_new_avatar_activity( $user_id = 0 ) {
    214 
    215         // Bail if activity component is not active.
    216         if ( ! bp_is_active( 'activity' ) ) {
    217                 return false;
    218         }
    219 
    220         if ( empty( $user_id ) ) {
    221                 $user_id = bp_displayed_user_id();
    222         }
    223 
    224         /**
    225          * Filters the user ID when a user has uploaded a new avatar.
    226          *
    227          * @since 1.5.0
    228          *
    229          * @param int $user_id ID of the user the avatar was set for.
    230          */
    231         $user_id = apply_filters( 'bp_xprofile_new_avatar_user_id', $user_id );
    232 
    233         // Add the activity.
    234         bp_activity_add( array(
    235                 'user_id'   => $user_id,
    236                 'component' => 'profile',
    237                 'type'      => 'new_avatar'
    238         ) );
    239 }
    240 add_action( 'bp_members_avatar_uploaded', 'bp_xprofile_new_avatar_activity' );
    241 
    242 /**
    243162 * Add an activity item when a user has updated his profile.
    244163 *
Note: See TracChangeset for help on using the changeset viewer.