Changeset 12851 for trunk/src/bp-xprofile/bp-xprofile-activity.php
- Timestamp:
- 02/21/2021 08:10:55 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-xprofile/bp-xprofile-activity.php
r12812 r12851 21 21 */ 22 22 function 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 );33 23 34 24 bp_activity_set_action( … … 49 39 } 50 40 add_action( 'bp_register_activity_actions', 'xprofile_register_activity_actions' ); 51 52 /**53 * Format 'new_avatar' activity actions.54 *55 * @since 2.0.056 *57 * @param string $action Static activity action.58 * @param object $activity Activity object.59 * @return string60 */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.076 *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 }82 41 83 42 /** … … 201 160 202 161 /** 203 * Adds an activity stream item when a user has uploaded a new avatar.204 *205 * @since 1.0.0206 * @since 2.3.4 Add new parameter to get the user id the avatar was set for.207 *208 * specific activity209 *210 * @param int $user_id The user id the avatar was set for.211 * @return bool212 */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.0228 *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 /**243 162 * Add an activity item when a user has updated his profile. 244 163 *
Note: See TracChangeset
for help on using the changeset viewer.