Ticket #5926: 5926.02.patch
File 5926.02.patch, 12.8 KB (added by , 10 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 1444c89..622efa1 100644
a b function bp_activity_delete_comment( $activity_id, $comment_id ) { 2515 2515 * 2516 2516 * @since BuddyPress (1.2.0) 2517 2517 * 2518 * @uses bp_get_root_domain()2519 * @uses bp_get_activity_root_slug()2520 * @uses apply_filters_ref_array() To call the 'bp_activity_get_permalink' hook.2521 *2522 2518 * @param int $activity_id The unique id of the activity object. 2523 2519 * @param object $activity_obj Optional. The activity object. 2524 2520 * @return string $link Permalink for the activity item. … … function bp_activity_get_permalink( $activity_id, $activity_obj = false ) { 2547 2543 2548 2544 if ( false !== array_search( $activity_obj->type, $use_primary_links ) ) { 2549 2545 $link = $activity_obj->primary_link; 2546 2550 2547 } else { 2551 2548 if ( 'activity_comment' == $activity_obj->type ) { 2552 $ link = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $activity_obj->item_id . '/';2549 $id = (int) $activity_obj->item_id; 2553 2550 } else { 2554 $ link = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $activity_obj->id . '/';2551 $id = (int) $activity_obj->id; 2555 2552 } 2553 2554 $link = bp_core_get_user_domain( $activity_obj->user_id ) . bp_get_activity_slug() . "/{$id}/"; 2556 2555 } 2557 2556 2558 2557 /** … … function bp_activity_get_permalink( $activity_id, $activity_obj = false ) { 2566 2565 } 2567 2566 2568 2567 /** 2568 * Get the shortlink for a single activity item. 2569 * 2570 * When only the $activity_id param is passed, BP has to instantiate a new 2571 * BP_Activity_Activity object. To save yourself some processing overhead, 2572 * be sure to pass the full $activity_obj parameter as well, if you already 2573 * have it available. 2574 * 2575 * @param int $activity_id The unique id of the activity object. 2576 * @param object $activity_obj Optional. The activity object. 2577 * @return string $link Permalink for the activity item. 2578 * @since BuddyPress (2.3.0) 2579 */ 2580 function bp_activity_get_shortlink( $activity_id, $activity_obj = false ) { 2581 $bp = buddypress(); 2582 2583 if ( empty( $activity_obj ) ) { 2584 $activity_obj = new BP_Activity_Activity( $activity_id ); 2585 } 2586 2587 if ( isset( $activity_obj->current_comment ) ) { 2588 $activity_obj = $activity_obj->current_comment; 2589 } 2590 2591 $use_primary_links = array( 2592 'new_blog_post', 2593 'new_blog_comment', 2594 'new_forum_topic', 2595 'new_forum_post', 2596 ); 2597 2598 if ( ! empty( $bp->activity->track ) ) { 2599 $use_primary_links = array_merge( $use_primary_links, array_keys( $bp->activity->track ) ); 2600 } 2601 2602 if ( false !== array_search( $activity_obj->type, $use_primary_links ) ) { 2603 $link = $activity_obj->primary_link; 2604 2605 } else { 2606 if ( 'activity_comment' == $activity_obj->type ) { 2607 $id = (int) $activity_obj->item_id; 2608 } else { 2609 $id = (int) $activity_obj->id; 2610 } 2611 2612 $link = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . "/p/{$id}/"; 2613 } 2614 2615 /** 2616 * Filters the activity shortlink for the specified activity item. 2617 * 2618 * @param array $array Array holding activity shortlink and activity item object. 2619 * @since BuddyPress (2.3.0) 2620 */ 2621 return apply_filters_ref_array( 'bp_activity_get_shortlink', array( $link, &$activity_obj ) ); 2622 } 2623 2624 /** 2569 2625 * Hide a user's activity. 2570 2626 * 2571 2627 * @since BuddyPress (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 0ace28f..f0fd222 100644
a b defined( 'ABSPATH' ) || exit; 20 20 * @uses bp_notifications_add_notification() 21 21 * @uses bp_get_user_meta() 22 22 * @uses bp_core_get_user_displayname() 23 * @uses bp_activity_get_permalink()24 * @uses bp_core_get_user_domain()25 23 * @uses bp_get_settings_slug() 26 24 * @uses bp_activity_filter_kses() 27 25 * @uses bp_core_get_core_userdata() … … function bp_activity_at_message_notification( $activity_id, $receiver_user_id ) 60 58 if ( 'no' != bp_get_user_meta( $receiver_user_id, 'notification_activity_new_mention', true ) ) { 61 59 $poster_name = bp_core_get_user_displayname( $activity->user_id ); 62 60 63 $message_link = bp_activity_get_ permalink( $activity_id );61 $message_link = bp_activity_get_shortlink( $activity_id ); 64 62 $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings'; 65 63 $settings_link = bp_core_get_user_domain( $receiver_user_id ) . $settings_slug . '/notifications/'; 66 64 … … To view and respond to the message, log in and visit: %3$s 155 153 * 156 154 * @uses bp_get_user_meta() 157 155 * @uses bp_core_get_user_displayname() 158 * @uses bp_activity_get_permalink()159 156 * @uses bp_core_get_user_domain() 160 157 * @uses bp_get_settings_slug() 161 158 * @uses bp_activity_filter_kses() … … function bp_activity_new_comment_notification( $comment_id = 0, $commenter_id = 189 186 190 187 if ( $original_activity->user_id != $commenter_id && 'no' != bp_get_user_meta( $original_activity->user_id, 'notification_activity_new_reply', true ) ) { 191 188 $poster_name = bp_core_get_user_displayname( $commenter_id ); 192 $thread_link = bp_activity_get_ permalink( $activity_id );189 $thread_link = bp_activity_get_shortlink( $activity_id ); 193 190 $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings'; 194 191 $settings_link = bp_core_get_user_domain( $original_activity->user_id ) . $settings_slug . '/notifications/'; 195 192 … … To view your original update and all comments, log in and visit: %3$s 276 273 277 274 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 ) ) { 278 275 $poster_name = bp_core_get_user_displayname( $commenter_id ); 279 $thread_link = bp_activity_get_ permalink( $activity_id );276 $thread_link = bp_activity_get_shortlink( $activity_id ); 280 277 $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings'; 281 278 $settings_link = bp_core_get_user_domain( $parent_comment->user_id ) . $settings_slug . '/notifications/'; 282 279 -
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 e4a8cc7..58b600a 100644
a b function bp_insert_activity_meta( $content ) { 1852 1852 * 1853 1853 * @since BuddyPress (1.2.0) 1854 1854 * 1855 * @param array $value Array containing the html markup for the activity permalink, after being parsed by sprintf and current activity component.1855 * @param array $value Array containing the html markup for the activity shortlink, after being parsed by sprintf and current activity component. 1856 1856 */ 1857 $content = apply_filters_ref_array( 'bp_activity_permalink', array( sprintf( '%1$s <a href="%2$s" class="view activity-time-since" title="%3$s">%4$s</a>', $content, bp_activity_get_ permalink( $activities_template->activity->id, $activities_template->activity ), esc_attr__( 'View Discussion', 'buddypress' ), $time_since ), &$activities_template->activity ) );1857 $content = apply_filters_ref_array( 'bp_activity_permalink', array( sprintf( '%1$s <a href="%2$s" class="view activity-time-since" title="%3$s">%4$s</a>', $content, bp_activity_get_shortlink( $activities_template->activity->id, $activities_template->activity ), esc_attr__( 'View Discussion', 'buddypress' ), $time_since ), &$activities_template->activity ) ); 1858 1858 } else { 1859 1859 $content .= str_pad( $time_since, strlen( $time_since ) + 2, ' ', STR_PAD_BOTH ); 1860 1860 } … … function bp_activity_thread_permalink() { 2767 2767 } 2768 2768 2769 2769 /** 2770 * Output the activity thread shortlink. 2771 * 2772 * @since BuddyPress (2.3.0) 2773 */ 2774 function bp_activity_thread_shortlink() { 2775 echo bp_get_activity_thread_shortlink(); 2776 } 2777 2778 /** 2779 * Return the activity thread shortlink. 2780 * 2781 * @return string $link The activity thread shortlink. 2782 * @since BuddyPress (2.3.0) 2783 */ 2784 function bp_get_activity_thread_shortlink() { 2785 global $activities_template; 2786 2787 $link = bp_activity_get_shortlink( $activities_template->activity->id, $activities_template->activity ); 2788 return apply_filters( 'bp_get_activity_thread_shortlink', $link ); 2789 } 2790 2791 /** 2770 2792 * Output the activity comment permalink. 2771 2793 * 2772 2794 * @since BuddyPress (1.8.0) … … function bp_activity_comment_permalink() { 2814 2836 } 2815 2837 2816 2838 /** 2839 * Output the activity comment shortlink. 2840 * 2841 * @since BuddyPress (2.3.0) 2842 */ 2843 function bp_activity_comment_shortlink() { 2844 echo bp_get_activity_comment_shortlink(); 2845 } 2846 /** 2847 * Return the activity comment shortlink. 2848 * 2849 * @return string $link The activity comment shortlink. 2850 * @since BuddyPress (2.3.0) 2851 */ 2852 function bp_get_activity_comment_shortlink() { 2853 global $activities_template; 2854 2855 // Check that comment exists 2856 $comment_id = isset( $activities_template->activity->current_comment->id ) 2857 ? $activities_template->activity->current_comment->id 2858 : 0; 2859 2860 // Append comment ID to end of activity shortlink 2861 $comment_link = ! empty( $comment_id ) ? '#acomment-' . $comment_id : false; 2862 $link = bp_activity_get_shortlink( $activities_template->activity->id, $activities_template->activity ); 2863 2864 return apply_filters( 'bp_get_activity_comment_shortlink', $link . $comment_link, $comment_id ); 2865 } 2866 2867 /** 2817 2868 * Output the activity favorite link. 2818 2869 * 2819 2870 * @since BuddyPress (1.2.0) … … function bp_activity_latest_update( $user_id = 0 ) { 3104 3155 $latest_update = sprintf( 3105 3156 '%s <a href="%s">%s</a>', 3106 3157 $latest_update, 3107 esc_url_raw( bp_activity_get_ permalink( $update['id'] ) ),3158 esc_url_raw( bp_activity_get_shortlink( $update['id'] ) ), 3108 3159 esc_attr__( 'View', 'buddypress' ) 3109 3160 ); 3110 3161 -
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 030507f..2003cb5 100644
a b function bp_blogs_activity_comment_single_permalink( $retval, $activity ) { 1046 1046 return $retval; 1047 1047 } 1048 1048 add_filter( 'bp_activity_get_permalink', 'bp_blogs_activity_comment_single_permalink', 10, 2 ); 1049 add_filter( 'bp_activity_get_shortlink', 'bp_blogs_activity_comment_single_permalink', 10, 2 ); 1049 1050 1050 1051 /** 1051 1052 * 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 7eda78c..f848247 100644
a b function groups_at_message_notification( $content, $poster_user_id, $group_id, $ 339 339 if ( 'no' != bp_get_user_meta( $receiver_user_id, 'notification_activity_new_mention', true ) ) { 340 340 $poster_name = bp_core_get_user_displayname( $poster_user_id ); 341 341 342 $message_link = bp_activity_get_ permalink( $activity_id );342 $message_link = bp_activity_get_shortlink( $activity_id ); 343 343 $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings'; 344 344 $settings_link = bp_core_get_user_domain( $receiver_user_id ) . $settings_slug . '/notifications/'; 345 345 -
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 85929e5..9666746 100644
a b function bp_member_latest_update( $args = '' ) { 1085 1085 if ( $view_link && ( $update_content != $update['content'] ) ) { 1086 1086 $view = __( 'View', 'buddypress' ); 1087 1087 1088 $update_content .= '<span class="activity-read-more"><a href="' . bp_activity_get_ permalink( $update['id'] ) . '" rel="nofollow">' . $view . '</a></span>';1088 $update_content .= '<span class="activity-read-more"><a href="' . bp_activity_get_shortlink( $update['id'] ) . '" rel="nofollow">' . $view . '</a></span>'; 1089 1089 } 1090 1090 1091 1091 /** -
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