Changeset 8344 for branches/2.0/bp-blogs/bp-blogs-activity.php
- Timestamp:
- 05/02/2014 08:12:10 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0/bp-blogs/bp-blogs-activity.php
r8259 r8344 853 853 } 854 854 add_filter( 'bp_get_activity_comment_permalink', 'bp_blogs_activity_comment_permalink' ); 855 856 /** 857 * Changes single activity comment entries to use the blog comment permalink. 858 * 859 * This is only done if the activity comment is associated with a blog comment. 860 * 861 * @since BuddyPress (2.0.1) 862 * 863 * @param string $retval The activity permalink 864 * @param BP_Activity_Activity $activity 865 * @return string 866 */ 867 function bp_blogs_activity_comment_single_permalink( $retval, $activity ) { 868 if ( 'activity_comment' !== $activity->type ) { 869 return $retval; 870 } 871 872 $blog_comment_id = bp_activity_get_meta( $activity->id, 'bp_blogs_post_comment_id' ); 873 874 if ( ! empty( $blog_comment_id ) ) { 875 $retval = $activity->primary_link; 876 } 877 878 return $retval; 879 } 880 add_filter( 'bp_activity_get_permalink', 'bp_blogs_activity_comment_single_permalink', 10, 2 ); 881 882 /** 883 * Formats single activity comment entries to use the blog comment action. 884 * 885 * This is only done if the activity comment is associated with a blog comment. 886 * 887 * @since BuddyPress (2.0.1) 888 * 889 * @param string $retval The activity action 890 * @param BP_Activity_Activity $activity 891 * @return string 892 */ 893 function bp_blogs_activity_comment_single_action( $retval, $activity ) { 894 if ( 'activity_comment' !== $activity->type ) { 895 return $retval; 896 } 897 898 $blog_comment_id = bp_activity_get_meta( $activity->id, 'bp_blogs_post_comment_id' ); 899 900 if ( ! empty( $blog_comment_id ) ) { 901 // fetch the parent blog post activity item 902 $parent_blog_post_activity = new BP_Activity_Activity( $activity->item_id ); 903 904 // fake a 'new_blog_comment' activity object 905 $object = $activity; 906 907 // override 'item_id' to use blog ID 908 $object->item_id = $parent_blog_post_activity->item_id; 909 910 // override 'secondary_item_id' to use comment ID 911 $object->secondary_item_id = $blog_comment_id; 912 913 // now format the activity action using the 'new_blog_comment' action callback 914 $retval = bp_blogs_format_activity_action_new_blog_comment( '', $object ); 915 } 916 917 return $retval; 918 } 919 add_filter( 'bp_get_activity_action_pre_meta', 'bp_blogs_activity_comment_single_action', 10, 2 );
Note: See TracChangeset
for help on using the changeset viewer.