Ticket #5926: 5926.03.patch
File 5926.03.patch, 12.6 KB (added by , 9 years ago) |
---|
-
src/bp-activity/bp-activity-functions.php
diff --git a/src/bp-activity/bp-activity-functions.php b/src/bp-activity/bp-activity-functions.php index d4f2328..a6072bc 100644
a b function bp_activity_delete_comment( $activity_id, $comment_id ) { 2540 2540 * 2541 2541 * @since 1.2.0 2542 2542 * 2543 * @uses bp_get_root_domain()2544 * @uses bp_get_activity_root_slug()2545 * @uses apply_filters_ref_array() To call the 'bp_activity_get_permalink' hook.2546 *2547 2543 * @param int $activity_id The unique id of the activity object. 2548 2544 * @param object|bool $activity_obj Optional. The activity object. 2549 2545 * … … function bp_activity_get_permalink( $activity_id, $activity_obj = false ) { 2573 2569 2574 2570 if ( false !== array_search( $activity_obj->type, $use_primary_links ) ) { 2575 2571 $link = $activity_obj->primary_link; 2572 2576 2573 } else { 2577 2574 if ( 'activity_comment' == $activity_obj->type ) { 2578 $ link = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $activity_obj->item_id . '/';2575 $id = (int) $activity_obj->item_id; 2579 2576 } else { 2580 $ link = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $activity_obj->id . '/';2577 $id = (int) $activity_obj->id; 2581 2578 } 2579 2580 $link = bp_core_get_user_domain( $activity_obj->user_id ) . bp_get_activity_slug() . "/{$id}/"; 2582 2581 } 2583 2582 2584 2583 /** … … function bp_activity_get_permalink( $activity_id, $activity_obj = false ) { 2592 2591 } 2593 2592 2594 2593 /** 2594 * Get the shortlink for a single activity item. 2595 * 2596 * When only the $activity_id param is passed, BP has to instantiate a new 2597 * BP_Activity_Activity object. To save yourself some processing overhead, 2598 * be sure to pass the full $activity_obj parameter as well, if you already 2599 * have it available. 2600 * 2601 * @param int $activity_id The unique id of the activity object. 2602 * @param object $activity_obj Optional. The activity object. 2603 * @return string $link Permalink for the activity item. 2604 * @since BuddyPress (2.3.0) 2605 */ 2606 function bp_activity_get_shortlink( $activity_id, $activity_obj = false ) { 2607 $bp = buddypress(); 2608 2609 if ( empty( $activity_obj ) ) { 2610 $activity_obj = new BP_Activity_Activity( $activity_id ); 2611 } 2612 2613 if ( isset( $activity_obj->current_comment ) ) { 2614 $activity_obj = $activity_obj->current_comment; 2615 } 2616 2617 $use_primary_links = array( 2618 'new_blog_post', 2619 'new_blog_comment', 2620 'new_forum_topic', 2621 'new_forum_post', 2622 ); 2623 2624 if ( ! empty( $bp->activity->track ) ) { 2625 $use_primary_links = array_merge( $use_primary_links, array_keys( $bp->activity->track ) ); 2626 } 2627 2628 if ( false !== array_search( $activity_obj->type, $use_primary_links ) ) { 2629 $link = $activity_obj->primary_link; 2630 2631 } else { 2632 if ( 'activity_comment' == $activity_obj->type ) { 2633 $id = (int) $activity_obj->item_id; 2634 } else { 2635 $id = (int) $activity_obj->id; 2636 } 2637 2638 $link = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . "/p/{$id}/"; 2639 } 2640 2641 /** 2642 * Filters the activity shortlink for the specified activity item. 2643 * 2644 * @param array $array Array holding activity shortlink and activity item object. 2645 * @since BuddyPress (2.3.0) 2646 */ 2647 return apply_filters_ref_array( 'bp_activity_get_shortlink', array( $link, &$activity_obj ) ); 2648 } 2649 2650 /** 2595 2651 * Hide a user's activity. 2596 2652 * 2597 2653 * @since 1.2.0 -
src/bp-activity/bp-activity-notifications.php
diff --git a/src/bp-activity/bp-activity-notifications.php b/src/bp-activity/bp-activity-notifications.php index 7c05630..0cda8cc 100644
a b defined( 'ABSPATH' ) || exit; 19 19 * @uses bp_notifications_add_notification() 20 20 * @uses bp_get_user_meta() 21 21 * @uses bp_core_get_user_displayname() 22 * @uses bp_activity_get_permalink()23 * @uses bp_core_get_user_domain()24 22 * @uses bp_get_settings_slug() 25 23 * @uses bp_activity_filter_kses() 26 24 * @uses bp_core_get_core_userdata() … … function bp_activity_at_message_notification( $activity_id, $receiver_user_id ) 59 57 if ( 'no' != bp_get_user_meta( $receiver_user_id, 'notification_activity_new_mention', true ) ) { 60 58 $poster_name = bp_core_get_user_displayname( $activity->user_id ); 61 59 62 $message_link = bp_activity_get_ permalink( $activity_id );60 $message_link = bp_activity_get_shortlink( $activity_id ); 63 61 $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings'; 64 62 $settings_link = bp_core_get_user_domain( $receiver_user_id ) . $settings_slug . '/notifications/'; 65 63 … … To view and respond to the message, log in and visit: %3$s 154 152 * 155 153 * @uses bp_get_user_meta() 156 154 * @uses bp_core_get_user_displayname() 157 * @uses bp_activity_get_permalink()158 155 * @uses bp_core_get_user_domain() 159 156 * @uses bp_get_settings_slug() 160 157 * @uses bp_activity_filter_kses() … … function bp_activity_new_comment_notification( $comment_id = 0, $commenter_id = 190 187 191 188 if ( $original_activity->user_id != $commenter_id && 'no' != bp_get_user_meta( $original_activity->user_id, 'notification_activity_new_reply', true ) ) { 192 189 $poster_name = bp_core_get_user_displayname( $commenter_id ); 193 $thread_link = bp_activity_get_ permalink( $activity_id );190 $thread_link = bp_activity_get_shortlink( $activity_id ); 194 191 $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings'; 195 192 $settings_link = bp_core_get_user_domain( $original_activity->user_id ) . $settings_slug . '/notifications/'; 196 193 … … To view your original update and all comments, log in and visit: %3$s 277 274 278 275 if ( $parent_comment->user_id != $commenter_id && $original_activity->user_id != $parent_comment->user_id && 'no' != bp_get_user_meta( $parent_comment->user_id, 'notification_activity_new_reply', true ) ) { 279 276 $poster_name = bp_core_get_user_displayname( $commenter_id ); 280 $thread_link = bp_activity_get_ permalink( $activity_id );277 $thread_link = bp_activity_get_shortlink( $activity_id ); 281 278 $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings'; 282 279 $settings_link = bp_core_get_user_domain( $parent_comment->user_id ) . $settings_slug . '/notifications/'; 283 280 -
src/bp-activity/bp-activity-template.php
diff --git a/src/bp-activity/bp-activity-template.php b/src/bp-activity/bp-activity-template.php index 973e72e..9a57bbb 100644
a b function bp_insert_activity_meta( $content = '' ) { 1962 1962 if ( ! bp_is_single_activity() ) { 1963 1963 1964 1964 // Setup variables for activity meta 1965 $activity_permalink = bp_activity_get_ permalink( $activities_template->activity->id, $activities_template->activity );1965 $activity_permalink = bp_activity_get_shortlink( $activities_template->activity->id, $activities_template->activity ); 1966 1966 $activity_meta = sprintf( '%1$s <a href="%2$s" class="view activity-time-since" title="%3$s">%4$s</a>', 1967 1967 $new_content, 1968 1968 $activity_permalink, … … function bp_insert_activity_meta( $content = '' ) { 1975 1975 * 1976 1976 * @since 1.2.0 1977 1977 * 1978 * @param array $value Array containing the html markup for the activity permalink, after being parsed by sprintf and current activity component.1978 * @param array $value Array containing the html markup for the activity shortlink, after being parsed by sprintf and current activity component. 1979 1979 */ 1980 1980 $new_content = apply_filters_ref_array( 'bp_activity_permalink', array( 1981 1981 $activity_meta, … … function bp_activity_thread_permalink() { 2934 2934 } 2935 2935 2936 2936 /** 2937 * Output the activity thread shortlink. 2938 * 2939 * @since BuddyPress (2.3.0) 2940 */ 2941 function bp_activity_thread_shortlink() { 2942 echo bp_get_activity_thread_shortlink(); 2943 } 2944 2945 /** 2946 * Return the activity thread shortlink. 2947 * 2948 * @return string $link The activity thread shortlink. 2949 * @since BuddyPress (2.3.0) 2950 */ 2951 function bp_get_activity_thread_shortlink() { 2952 global $activities_template; 2953 2954 $link = bp_activity_get_shortlink( $activities_template->activity->id, $activities_template->activity ); 2955 return apply_filters( 'bp_get_activity_thread_shortlink', $link ); 2956 } 2957 2958 /** 2937 2959 * Output the activity comment permalink. 2938 2960 * 2939 2961 * @since 1.8.0 … … function bp_activity_comment_permalink() { 2981 3003 } 2982 3004 2983 3005 /** 3006 * Output the activity comment shortlink. 3007 * 3008 * @since BuddyPress (2.3.0) 3009 */ 3010 function bp_activity_comment_shortlink() { 3011 echo bp_get_activity_comment_shortlink(); 3012 } 3013 /** 3014 * Return the activity comment shortlink. 3015 * 3016 * @return string $link The activity comment shortlink. 3017 * @since BuddyPress (2.3.0) 3018 */ 3019 function bp_get_activity_comment_shortlink() { 3020 global $activities_template; 3021 3022 // Check that comment exists 3023 $comment_id = isset( $activities_template->activity->current_comment->id ) 3024 ? $activities_template->activity->current_comment->id 3025 : 0; 3026 3027 // Append comment ID to end of activity shortlink 3028 $comment_link = ! empty( $comment_id ) ? '#acomment-' . $comment_id : false; 3029 $link = bp_activity_get_shortlink( $activities_template->activity->id, $activities_template->activity ); 3030 3031 return apply_filters( 'bp_get_activity_comment_shortlink', $link . $comment_link, $comment_id ); 3032 } 3033 3034 /** 2984 3035 * Output the activity favorite link. 2985 3036 * 2986 3037 * @since 1.2.0 … … function bp_activity_latest_update( $user_id = 0 ) { 3276 3327 $latest_update = sprintf( 3277 3328 '%s <a href="%s">%s</a>', 3278 3329 $latest_update, 3279 esc_url_raw( bp_activity_get_ permalink( $update['id'] ) ),3330 esc_url_raw( bp_activity_get_shortlink( $update['id'] ) ), 3280 3331 esc_attr__( 'View', 'buddypress' ) 3281 3332 ); 3282 3333 -
src/bp-blogs/bp-blogs-activity.php
diff --git a/src/bp-blogs/bp-blogs-activity.php b/src/bp-blogs/bp-blogs-activity.php index ddddb06..5bd09c0 100644
a b function bp_blogs_activity_comment_single_permalink( $retval, $activity ) { 1065 1065 return $retval; 1066 1066 } 1067 1067 add_filter( 'bp_activity_get_permalink', 'bp_blogs_activity_comment_single_permalink', 10, 2 ); 1068 add_filter( 'bp_activity_get_shortlink', 'bp_blogs_activity_comment_single_permalink', 10, 2 ); 1068 1069 1069 1070 /** 1070 1071 * Formats single activity comment entries to use the blog comment action. -
src/bp-core/deprecated/1.5.php
diff --git a/src/bp-core/deprecated/1.5.php b/src/bp-core/deprecated/1.5.php index fca0cd8..848a2d8 100644
a b function groups_at_message_notification( $content, $poster_user_id, $group_id, $ 345 345 if ( 'no' != bp_get_user_meta( $receiver_user_id, 'notification_activity_new_mention', true ) ) { 346 346 $poster_name = bp_core_get_user_displayname( $poster_user_id ); 347 347 348 $message_link = bp_activity_get_ permalink( $activity_id );348 $message_link = bp_activity_get_shortlink( $activity_id ); 349 349 $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings'; 350 350 $settings_link = bp_core_get_user_domain( $receiver_user_id ) . $settings_slug . '/notifications/'; 351 351 -
src/bp-members/bp-members-template.php
diff --git a/src/bp-members/bp-members-template.php b/src/bp-members/bp-members-template.php index 920d5af..c74525a 100644
a b function bp_member_latest_update( $args = '' ) { 1188 1188 if ( $view_link && ( $update_content != $update['content'] ) ) { 1189 1189 $view = __( 'View', 'buddypress' ); 1190 1190 1191 $update_content .= '<span class="activity-read-more"><a href="' . bp_activity_get_ permalink( $update['id'] ) . '" rel="nofollow">' . $view . '</a></span>';1191 $update_content .= '<span class="activity-read-more"><a href="' . bp_activity_get_shortlink( $update['id'] ) . '" rel="nofollow">' . $view . '</a></span>'; 1192 1192 } 1193 1193 1194 1194 /** -
tests/phpunit/testcases/routing/activity.php
diff --git a/tests/phpunit/testcases/routing/activity.php b/tests/phpunit/testcases/routing/activity.php index c76a465..797a9af 100644
a b class BP_Tests_Routing_Activity extends BP_UnitTestCase { 23 23 $this->assertEquals( bp_get_activity_root_slug(), bp_current_component() ); 24 24 } 25 25 26 /**27 * Can't test using bp_activity_get_permalink(); see bp_activity_action_permalink_router().28 */29 26 function test_activity_permalink() { 30 27 $a = $this->factory->activity->create(); 31 28 $activity = $this->factory->activity->get_object_by_id( $a ); 32 29 33 $url = bp_core_get_user_domain( $activity->user_id ) . bp_get_activity_slug() . '/' . $activity->id . '/'; 34 $this->go_to( $url ); 30 $this->go_to( bp_activity_get_permalink( $activity->id, $activity ) ); 31 $this->assertTrue( bp_is_single_activity() ); 32 } 33 34 function test_activity_shortlink() { 35 $a = $this->factory->activity->create(); 36 $activity = $this->factory->activity->get_object_by_id( $a ); 37 38 $this->go_to( bp_activity_get_shortlink( $activity->id, $activity ) ); 35 39 $this->assertTrue( bp_is_single_activity() ); 36 40 } 37 41