Changeset 12851
- Timestamp:
- 02/21/2021 08:10:55 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-update.php
r12617 r12851 274 274 bp_update_to_5_0(); 275 275 } 276 277 // Version 8.0.0. 278 if ( $raw_db_version < 12850 ) { 279 bp_update_to_8_0(); 280 } 276 281 } 277 282 … … 591 596 592 597 /** 598 * 8.0.0 update routine. 599 * 600 * - Edit the `new_avatar` activity type's component to `members`. 601 * 602 * @since 8.0.0 603 */ 604 function bp_update_to_8_0() { 605 global $wpdb; 606 $bp_prefix = bp_core_get_table_prefix(); 607 608 // Update the `new_avatar` activity type's component to `members`. 609 $wpdb->update( 610 $bp_prefix . 'bp_activity', 611 array( 612 'component' => 'members', 613 ), 614 array( 615 'type' => 'new_avatar', 616 ), 617 array( 618 '%s', 619 ), 620 array( 621 '%s', 622 ) 623 ); 624 } 625 626 /** 593 627 * Updates the component field for new_members type. 594 628 * -
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' ); -
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 * -
trunk/src/class-buddypress.php
r12821 r12851 305 305 306 306 $this->version = '8.0.0-alpha'; 307 $this->db_version = 12 385;307 $this->db_version = 12850; 308 308 309 309 /** Loading ***********************************************************/ -
trunk/tests/phpunit/testcases/members/activity.php
r11737 r12851 20 20 21 21 $expected = sprintf( __( '%s became a registered member', 'buddypress' ), bp_core_get_userlink( $u ) ); 22 23 $a_obj = new BP_Activity_Activity( $a ); 24 25 $this->assertSame( $expected, $a_obj->action ); 26 } 27 28 /** 29 * @group activity_action 30 * @group bp_members_format_activity_action_new_avatar 31 */ 32 public function test_bp_members_format_activity_action_new_avatar() { 33 $u = self::factory()->user->create(); 34 $a = self::factory()->activity->create( array( 35 'component' => 'members', 36 'type' => 'new_avatar', 37 'user_id' => $u, 38 ) ); 39 40 $expected = sprintf( __( '%s changed their profile picture', 'buddypress' ), bp_core_get_userlink( $u ) ); 22 41 23 42 $a_obj = new BP_Activity_Activity( $a ); -
trunk/tests/phpunit/testcases/xprofile/activity.php
r12599 r12851 297 297 /** 298 298 * @group activity_action 299 * @group bp_xprofile_format_activity_action_new_avatar300 */301 public function test_bp_xprofile_format_activity_action_new_avatar() {302 $u = self::factory()->user->create();303 $a = self::factory()->activity->create( array(304 'component' => 'profile',305 'type' => 'new_avatar',306 'user_id' => $u,307 ) );308 309 $expected = sprintf( __( '%s changed their profile picture', 'buddypress' ), bp_core_get_userlink( $u ) );310 311 $a_obj = new BP_Activity_Activity( $a );312 313 $this->assertSame( $expected, $a_obj->action );314 }315 316 /**317 * @group activity_action318 299 * @group bp_xprofile_format_activity_action_updated_profile 319 300 */
Note: See TracChangeset
for help on using the changeset viewer.