Ticket #8408: 8408.patch
| File 8408.patch, 11.5 KB (added by , 6 years ago) |
|---|
-
src/bp-core/bp-core-update.php
diff --git src/bp-core/bp-core-update.php src/bp-core/bp-core-update.php index eda45ead0..eedf3a1f3 100644
function bp_version_updater() { 273 273 if ( $raw_db_version < 12385 ) { 274 274 bp_update_to_5_0(); 275 275 } 276 277 // Version 8.0.0. 278 if ( $raw_db_version < 12836 ) { 279 bp_update_to_8_0(); 280 } 276 281 } 277 282 278 283 /* All done! *************************************************************/ … … function bp_update_to_5_0() { 589 594 } 590 595 } 591 596 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 592 626 /** 593 627 * Updates the component field for new_members type. 594 628 * -
new file src/bp-core/deprecated/8.0.php
diff --git src/bp-core/deprecated/8.0.php src/bp-core/deprecated/8.0.php new file mode 100644 index 000000000..acee31af0
- + 1 <?php 2 3 /** 4 * Deprecated functions. 5 * 6 * @deprecated 8.0.0 7 */ 8 9 // Exit if accessed directly. 10 defined( 'ABSPATH' ) || exit; 11 12 /** 13 * Format 'new_avatar' activity actions. 14 * 15 * @since 2.0.0 16 * @deprecated 8.0.0 17 * 18 * @param string $action Static activity action. 19 * @param object $activity Activity object. 20 * @return string 21 */ 22 function bp_xprofile_format_activity_action_new_avatar( $action, $activity ) { 23 _deprecated_function( __FUNCTION__, '8.0.0', 'bp_members_format_activity_action_new_avatar()' ); 24 return bp_members_format_activity_action_new_avatar( $action, $activity ); 25 } 26 27 /** 28 * Adds an activity stream item when a user has uploaded a new avatar. 29 * 30 * @since 1.0.0 31 * @since 2.3.4 Add new parameter to get the user id the avatar was set for. 32 * @deprecated 8.0.0 33 * 34 * @param int $user_id The user id the avatar was set for. 35 * @return bool 36 */ 37 function bp_xprofile_new_avatar_activity( $user_id = 0 ) { 38 _deprecated_function( __FUNCTION__, '8.0.0', 'bp_members_new_avatar_activity()' ); 39 return bp_members_new_avatar_activity( $user_id ); 40 } -
src/bp-members/bp-members-activity.php
diff --git src/bp-members/bp-members-activity.php src/bp-members/bp-members-activity.php index 30775dd6d..8907d0a7e 100644
function bp_members_register_activity_actions() { 27 27 array( 'activity' ) 28 28 ); 29 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' ) 38 ); 39 30 40 /** 31 41 * Fires after the default 'new member' activity types are registered. 32 42 * … … function bp_members_format_activity_action_new_member( $action, $activity ) { 67 77 return apply_filters( 'bp_members_format_activity_action_new_member', $action, $activity ); 68 78 } 69 79 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 70 114 /** 71 115 * Create a "became a registered user" activity item when a user activates his account. 72 116 * … … function bp_core_new_user_activity( $user ) { 97 141 ) ); 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' ); -
src/bp-xprofile/bp-xprofile-activity.php
diff --git src/bp-xprofile/bp-xprofile-activity.php src/bp-xprofile/bp-xprofile-activity.php index 1adfae605..1e007dde4 100644
defined( 'ABSPATH' ) || exit; 21 21 */ 22 22 function xprofile_register_activity_actions() { 23 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 34 24 bp_activity_set_action( 35 25 buddypress()->profile->id, 36 26 'updated_profile', … … function xprofile_register_activity_actions() { 49 39 } 50 40 add_action( 'bp_register_activity_actions', 'xprofile_register_activity_actions' ); 51 41 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 83 42 /** 84 43 * Format 'updated_profile' activity actions. 85 44 * … … function xprofile_register_activity_action( $key, $value ) { 199 158 return apply_filters( 'xprofile_register_activity_action', bp_activity_set_action( buddypress()->profile->id, $key, $value ), $key, $value ); 200 159 } 201 160 202 /**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 161 /** 243 162 * Add an activity item when a user has updated his profile. 244 163 * -
src/class-buddypress.php
diff --git src/class-buddypress.php src/class-buddypress.php index aad6f163b..6d93bc2e4 100644
class BuddyPress { 304 304 /** Versions **********************************************************/ 305 305 306 306 $this->version = '8.0.0-alpha'; 307 $this->db_version = 12 385;307 $this->db_version = 12836; 308 308 309 309 /** Loading ***********************************************************/ 310 310 -
tests/phpunit/testcases/members/activity.php
diff --git tests/phpunit/testcases/members/activity.php tests/phpunit/testcases/members/activity.php index a4a48e395..07ec30406 100644
class BP_Tests_Members_Activity extends BP_UnitTestCase { 25 25 $this->assertSame( $expected, $a_obj->action ); 26 26 } 27 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 ) ); 41 42 $a_obj = new BP_Activity_Activity( $a ); 43 44 $this->assertSame( $expected, $a_obj->action ); 45 } 46 28 47 /** 29 48 * @group bp_migrate_new_member_activity_component 30 49 */ -
tests/phpunit/testcases/xprofile/activity.php
diff --git tests/phpunit/testcases/xprofile/activity.php tests/phpunit/testcases/xprofile/activity.php index 7a1b42db2..ee0e5e9cb 100644
class BP_Tests_XProfile_Activity extends BP_UnitTestCase { 294 294 $this->assertTrue( bp_xprofile_updated_profile_activity( $d['u'], array( $d['f'] ), false, $old_values, $new_values ) ); 295 295 } 296 296 297 /**298 * @group activity_action299 * @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 297 /** 317 298 * @group activity_action 318 299 * @group bp_xprofile_format_activity_action_updated_profile
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)