diff --git a/src/bp-activity/bp-activity-functions.php b/src/bp-activity/bp-activity-functions.php
index 7aede79..a59dc9e 100644
a
|
b
|
function bp_activity_delete_comment( $activity_id, $comment_id ) { |
1703 | 1703 | * be sure to pass the full $activity_obj parameter as well, if you already |
1704 | 1704 | * have it available. |
1705 | 1705 | * |
| 1706 | * @param int $activity_id The unique id of the activity object. |
| 1707 | * @param object $activity_obj Optional. The activity object. |
| 1708 | * @return string $link Permalink for the activity item. |
1706 | 1709 | * @since BuddyPress (1.2.0) |
| 1710 | */ |
| 1711 | function bp_activity_get_permalink( $activity_id, $activity_obj = false ) { |
| 1712 | if ( ! $activity_obj ) { |
| 1713 | $activity_obj = new BP_Activity_Activity( $activity_id ); |
| 1714 | } |
| 1715 | |
| 1716 | if ( isset( $activity_obj->current_comment ) ) { |
| 1717 | $activity_obj = $activity_obj->current_comment; |
| 1718 | } |
| 1719 | |
| 1720 | if ( 'new_blog_post' == $activity_obj->type || 'new_blog_comment' == $activity_obj->type || 'new_forum_topic' == $activity_obj->type || 'new_forum_post' == $activity_obj->type ) { |
| 1721 | $link = $activity_obj->primary_link; |
| 1722 | |
| 1723 | } else { |
| 1724 | if ( 'activity_comment' === $activity_obj->type ) { |
| 1725 | $id = $activity_obj->item_id; |
| 1726 | } else { |
| 1727 | $id = $activity_obj->id; |
| 1728 | } |
| 1729 | |
| 1730 | $link = bp_core_get_user_domain( $activity_obj->user_id ) . bp_get_activity_slug() . "/{$id}/"; |
| 1731 | } |
| 1732 | |
| 1733 | return apply_filters_ref_array( 'bp_activity_get_permalink', array( $link, &$activity_obj ) ); |
| 1734 | } |
| 1735 | |
| 1736 | /** |
| 1737 | * Get the shortlink for a single activity item. |
1707 | 1738 | * |
1708 | | * @uses bp_get_root_domain() |
1709 | | * @uses bp_get_activity_root_slug() |
1710 | | * @uses apply_filters_ref_array() To call the 'bp_activity_get_permalink' hook. |
| 1739 | * When only the $activity_id param is passed, BP has to instantiate a new |
| 1740 | * BP_Activity_Activity object. To save yourself some processing overhead, |
| 1741 | * be sure to pass the full $activity_obj parameter as well, if you already |
| 1742 | * have it available. |
1711 | 1743 | * |
1712 | 1744 | * @param int $activity_id The unique id of the activity object. |
1713 | 1745 | * @param object $activity_obj Optional. The activity object. |
1714 | 1746 | * @return string $link Permalink for the activity item. |
| 1747 | * @since BuddyPress (2.2.0) |
1715 | 1748 | */ |
1716 | | function bp_activity_get_permalink( $activity_id, $activity_obj = false ) { |
1717 | | |
1718 | | if ( empty( $activity_obj ) ) { |
| 1749 | function bp_activity_get_shortlink( $activity_id, $activity_obj = false ) { |
| 1750 | if ( ! $activity_obj ) { |
1719 | 1751 | $activity_obj = new BP_Activity_Activity( $activity_id ); |
1720 | 1752 | } |
1721 | 1753 | |
… |
… |
function bp_activity_get_permalink( $activity_id, $activity_obj = false ) { |
1725 | 1757 | |
1726 | 1758 | if ( 'new_blog_post' == $activity_obj->type || 'new_blog_comment' == $activity_obj->type || 'new_forum_topic' == $activity_obj->type || 'new_forum_post' == $activity_obj->type ) { |
1727 | 1759 | $link = $activity_obj->primary_link; |
| 1760 | |
1728 | 1761 | } else { |
1729 | 1762 | if ( 'activity_comment' == $activity_obj->type ) { |
1730 | | $link = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $activity_obj->item_id . '/'; |
| 1763 | $id = $activity_obj->item_id; |
1731 | 1764 | } else { |
1732 | | $link = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $activity_obj->id . '/'; |
| 1765 | $id = $activity_obj->id; |
1733 | 1766 | } |
| 1767 | |
| 1768 | $link = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . "/p/{$id}/"; |
1734 | 1769 | } |
1735 | 1770 | |
1736 | | return apply_filters_ref_array( 'bp_activity_get_permalink', array( $link, &$activity_obj ) ); |
| 1771 | return apply_filters_ref_array( 'bp_activity_get_shortlink', array( $link, &$activity_obj ) ); |
1737 | 1772 | } |
1738 | 1773 | |
1739 | 1774 | /** |
diff --git a/src/bp-activity/bp-activity-notifications.php b/src/bp-activity/bp-activity-notifications.php
index 005b4c7..ddc1e51 100644
a
|
b
|
if ( !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 |
117 | 115 | * |
118 | 116 | * @uses bp_get_user_meta() |
119 | 117 | * @uses bp_core_get_user_displayname() |
120 | | * @uses bp_activity_get_permalink() |
121 | 118 | * @uses bp_core_get_user_domain() |
122 | 119 | * @uses bp_get_settings_slug() |
123 | 120 | * @uses bp_activity_filter_kses() |
… |
… |
function bp_activity_new_comment_notification( $comment_id = 0, $commenter_id = |
151 | 148 | |
152 | 149 | if ( $original_activity->user_id != $commenter_id && 'no' != bp_get_user_meta( $original_activity->user_id, 'notification_activity_new_reply', true ) ) { |
153 | 150 | $poster_name = bp_core_get_user_displayname( $commenter_id ); |
154 | | $thread_link = bp_activity_get_permalink( $activity_id ); |
| 151 | $thread_link = bp_activity_get_shortlink( $activity_id ); |
155 | 152 | $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings'; |
156 | 153 | $settings_link = bp_core_get_user_domain( $original_activity->user_id ) . $settings_slug . '/notifications/'; |
157 | 154 | |
… |
… |
To view your original update and all comments, log in and visit: %3$s |
199 | 196 | |
200 | 197 | 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 ) ) { |
201 | 198 | $poster_name = bp_core_get_user_displayname( $commenter_id ); |
202 | | $thread_link = bp_activity_get_permalink( $activity_id ); |
| 199 | $thread_link = bp_activity_get_shortlink( $activity_id ); |
203 | 200 | $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings'; |
204 | 201 | $settings_link = bp_core_get_user_domain( $parent_comment->user_id ) . $settings_slug . '/notifications/'; |
205 | 202 | |
diff --git a/src/bp-activity/bp-activity-template.php b/src/bp-activity/bp-activity-template.php
index d291b7d..9b21163 100644
a
|
b
|
function bp_insert_activity_meta( $content ) { |
1649 | 1649 | |
1650 | 1650 | // Insert the permalink |
1651 | 1651 | if ( !bp_is_single_activity() ) |
1652 | | $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 ) ); |
| 1652 | $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 ) ); |
1653 | 1653 | else |
1654 | 1654 | $content .= str_pad( $time_since, strlen( $time_since ) + 2, ' ', STR_PAD_BOTH ); |
1655 | 1655 | |
… |
… |
function bp_activity_thread_permalink() { |
2397 | 2397 | } |
2398 | 2398 | |
2399 | 2399 | /** |
| 2400 | * Output the activity thread shortlink. |
| 2401 | * |
| 2402 | * @since BuddyPress (2.2) |
| 2403 | */ |
| 2404 | function bp_activity_thread_shortlink() { |
| 2405 | echo bp_get_activity_thread_shortlink(); |
| 2406 | } |
| 2407 | |
| 2408 | /** |
| 2409 | * Return the activity thread shortlink. |
| 2410 | * |
| 2411 | * @return string $link The activity thread shortlink. |
| 2412 | * @since BuddyPress (2.2) |
| 2413 | */ |
| 2414 | function bp_get_activity_thread_shortlink() { |
| 2415 | global $activities_template; |
| 2416 | |
| 2417 | $link = bp_activity_get_shortlink( $activities_template->activity->id, $activities_template->activity ); |
| 2418 | return apply_filters( 'bp_get_activity_thread_shortlink', $link ); |
| 2419 | } |
| 2420 | |
| 2421 | /** |
2400 | 2422 | * Output the activity comment permalink. |
2401 | 2423 | * |
2402 | 2424 | * @since BuddyPress (1.8) |
… |
… |
function bp_activity_comment_permalink() { |
2436 | 2458 | } |
2437 | 2459 | |
2438 | 2460 | /** |
| 2461 | * Output the activity comment shortlink. |
| 2462 | * |
| 2463 | * @since BuddyPress (2.2) |
| 2464 | */ |
| 2465 | function bp_activity_comment_shortlink() { |
| 2466 | echo bp_get_activity_comment_shortlink(); |
| 2467 | } |
| 2468 | /** |
| 2469 | * Return the activity comment shortlink. |
| 2470 | * |
| 2471 | * @return string $link The activity comment shortlink. |
| 2472 | * @since BuddyPress (2.2) |
| 2473 | */ |
| 2474 | function bp_get_activity_comment_shortlink() { |
| 2475 | global $activities_template; |
| 2476 | |
| 2477 | // Check that comment exists |
| 2478 | $comment_id = isset( $activities_template->activity->current_comment->id ) |
| 2479 | ? $activities_template->activity->current_comment->id |
| 2480 | : 0; |
| 2481 | |
| 2482 | // Setup the comment link |
| 2483 | $comment_link = ! empty( $comment_id ) |
| 2484 | ? '#acomment-' .$comment_id |
| 2485 | : false; |
| 2486 | |
| 2487 | // Append comment ID to end of activity shortlink |
| 2488 | $link = bp_activity_get_shortlink( $activities_template->activity->id, $activities_template->activity ) . $comment_link; |
| 2489 | |
| 2490 | return apply_filters( 'bp_get_activity_comment_shortlink', $link, $comment_id ); |
| 2491 | } |
| 2492 | |
| 2493 | /** |
2439 | 2494 | * Output the activity favorite link. |
2440 | 2495 | * |
2441 | 2496 | * @since BuddyPress (1.2) |
… |
… |
function bp_activity_latest_update( $user_id = 0 ) { |
2675 | 2730 | $latest_update = sprintf( |
2676 | 2731 | '%s <a href="%s">%s</a>', |
2677 | 2732 | $latest_update, |
2678 | | esc_url_raw( bp_activity_get_permalink( $update['id'] ) ), |
| 2733 | esc_url_raw( bp_activity_get_shortlink( $update['id'] ) ), |
2679 | 2734 | esc_attr__( 'View', 'buddypress' ) |
2680 | 2735 | ); |
2681 | 2736 | |
diff --git a/src/bp-blogs/bp-blogs-activity.php b/src/bp-blogs/bp-blogs-activity.php
index 8b67a16..ad32ad7 100644
a
|
b
|
function bp_blogs_activity_comment_single_permalink( $retval, $activity ) { |
952 | 952 | return $retval; |
953 | 953 | } |
954 | 954 | add_filter( 'bp_activity_get_permalink', 'bp_blogs_activity_comment_single_permalink', 10, 2 ); |
| 955 | add_filter( 'bp_activity_get_shortlink', 'bp_blogs_activity_comment_single_permalink', 10, 2 ); |
955 | 956 | |
956 | 957 | /** |
957 | 958 | * Formats single activity comment entries to use the blog comment action. |
diff --git a/src/bp-core/deprecated/1.5.php b/src/bp-core/deprecated/1.5.php
index b1931b5..8466d45 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 | |
diff --git a/src/bp-members/bp-members-template.php b/src/bp-members/bp-members-template.php
index dbce029..b775cf0 100644
a
|
b
|
function bp_member_latest_update( $args = '' ) { |
891 | 891 | if ( $view_link && ( $update_content != $update['content'] ) ) { |
892 | 892 | $view = __( 'View', 'buddypress' ); |
893 | 893 | |
894 | | $update_content .= '<span class="activity-read-more"><a href="' . bp_activity_get_permalink( $update['id'] ) . '" rel="nofollow">' . $view . '</a></span>'; |
| 894 | $update_content .= '<span class="activity-read-more"><a href="' . bp_activity_get_shortlink( $update['id'] ) . '" rel="nofollow">' . $view . '</a></span>'; |
895 | 895 | } |
896 | 896 | |
897 | 897 | return apply_filters( 'bp_get_member_latest_update', $update_content ); |
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 | |