Changeset 12851 for trunk/src/bp-members/bp-members-activity.php
- Timestamp:
- 02/21/2021 08:10:55 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-members/bp-members-activity.php
r12591 r12851 26 26 __( 'New Members', 'buddypress' ), 27 27 array( 'activity' ) 28 ); 29 30 // Register the activity stream actions for this component. 31 bp_activity_set_action( 32 // Older avatar activity items use 'profile' for component. See r4273. 33 buddypress()->members->id, 34 'new_avatar', 35 __( 'Member changed profile picture', 'buddypress' ), 36 'bp_members_format_activity_action_new_avatar', 37 __( 'Updated Profile Photos', 'buddypress' ) 28 38 ); 29 39 … … 69 79 70 80 /** 81 * Format 'new_avatar' activity actions. 82 * 83 * @since 8.0.0 84 * 85 * @param string $action Static activity action. 86 * @param object $activity Activity object. 87 * @return string 88 */ 89 function bp_members_format_activity_action_new_avatar( $action, $activity ) { 90 $userlink = bp_core_get_userlink( $activity->user_id ); 91 92 /* translators: %s: user link */ 93 $action = sprintf( esc_html__( '%s changed their profile picture', 'buddypress' ), $userlink ); 94 95 // Legacy filter - pass $user_id instead of $activity. 96 if ( has_filter( 'bp_xprofile_new_avatar_action' ) ) { 97 $action = apply_filters( 'bp_xprofile_new_avatar_action', $action, $activity->user_id ); 98 } 99 100 /** This filter is documented in wp-includes/deprecated.php */ 101 $action = apply_filters_deprecated( 'bp_xprofile_format_activity_action_new_avatar', array( $action, $activity ), '8.0.0', 'bp_members_format_activity_action_new_avatar' ); 102 103 /** 104 * Filters the formatted 'new_avatar' activity stream action. 105 * 106 * @since 8.0.0 107 * 108 * @param string $action Formatted action for activity stream. 109 * @param object $activity Activity object. 110 */ 111 return apply_filters( 'bp_members_format_activity_action_new_avatar', $action, $activity ); 112 } 113 114 /** 71 115 * Create a "became a registered user" activity item when a user activates his account. 72 116 * … … 98 142 } 99 143 add_action( 'bp_core_activated_user', 'bp_core_new_user_activity' ); 144 145 /** 146 * Adds an activity stream item when a user has uploaded a new avatar. 147 * 148 * @since 8.0.0 149 * 150 * @param int $user_id The user id the avatar was set for. 151 */ 152 function bp_members_new_avatar_activity( $user_id = 0 ) { 153 154 // Bail if activity component is not active. 155 if ( ! bp_is_active( 'activity' ) ) { 156 return false; 157 } 158 159 if ( empty( $user_id ) ) { 160 $user_id = bp_displayed_user_id(); 161 } 162 163 /** This filter is documented in wp-includes/deprecated.php */ 164 $user_id = apply_filters_deprecated( 'bp_xprofile_new_avatar_user_id', array( $user_id ), '8.0.0', 'bp_members_new_avatar_user_id' ); 165 166 /** 167 * Filters the user ID when a user has uploaded a new avatar. 168 * 169 * @since 8.0.0 170 * 171 * @param int $user_id ID of the user the avatar was set for. 172 */ 173 $user_id = apply_filters( 'bp_members_new_avatar_user_id', $user_id ); 174 175 // Add the activity. 176 bp_activity_add( array( 177 'user_id' => $user_id, 178 'component' => buddypress()->members->id, 179 'type' => 'new_avatar' 180 ) ); 181 } 182 add_action( 'bp_members_avatar_uploaded', 'bp_members_new_avatar_activity' );
Note: See TracChangeset
for help on using the changeset viewer.