bp_update_activity_feed_of_post( $post, $request, $action )
Update the post activity feed after the attachment attached to that particular post.
Description
Parameters
- $post
-
(Required)
- $request
-
(Required)
- $action
-
(Required)
Source
File: bp-activity/bp-activity-functions.php
5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 | function bp_update_activity_feed_of_post( $post , $request , $action ) { // check is WP_Post if not then return if ( ! is_a ( $post , 'WP_Post' ) ) { return ; } $enabled = bp_is_post_type_feed_enable( $post ->post_type ); // If enabled update the activity. if ( $enabled ) { // Get the post type tracking args. $activity_post_object = bp_activity_get_post_type_tracking_args( $post ->post_type ); if ( empty ( $activity_post_object ->action_id ) ) { return ; } // Get the existing activity id based on the post. $activity_id = bp_activity_get_activity_id( array ( 'component' => $activity_post_object ->component_id, 'item_id' => get_current_blog_id(), 'secondary_item_id' => $post ->ID, 'type' => $activity_post_object ->action_id, ) ); // Activity ID doesn't exist, so stop! if ( empty ( $activity_id ) ) { return ; } // Delete the activity if the post was updated with a password. if ( ! empty ( $post ->post_password ) ) { bp_activity_delete( array ( 'id' => $activity_id ) ); } // Update the activity entry. $activity = new BP_Activity_Activity( $activity_id ); // get the excerpt first of post. $excerpt = get_the_excerpt( $post ->ID ); // if excert found then take content as a excerpt otherwise take the content as a post content. $content = ( $excerpt ) ?: $post ->post_content; // If content not empty. if ( ! empty ( $content ) ) { $activity_summary = bp_activity_create_summary( $content , ( array ) $activity ); // Backward compatibility filter for the blogs component. if ( 'blogs' == $activity_post_object ->component_id ) { $activity ->content = apply_filters( 'bp_update_activity_feed_of_custom_post_content' , $activity_summary , $content , ( array ) $activity , $post ->post_type ); } else { $activity ->content = $activity_summary ; } } else { $src = wp_get_attachment_image_src( get_post_thumbnail_id( $post ->ID ), 'full' , false ); $activity_summary = '' ; if ( isset( $src [0] ) ) { $activity_summary = sprintf( ' <img src="%s">' , esc_url( $src [0] ) ); } // Backward compatibility filter for the blogs component. if ( 'blogs' == $activity_post_object ->component_id ) { $activity ->content = apply_filters( 'bp_update_activity_feed_of_custom_post_content' , $activity_summary , $post ->post_content, ( array ) $activity , $post ->post_type ); } else { $activity ->content = $activity_summary ; } } // Save the updated activity. $updated = $activity ->save(); } } |
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.