bp_activity_post_type_update

Update the activity item for a custom post type entry.

Description

bp_activity_post_type_update( (null) $post = null ); 

Parameters (1)

0. $post — Optional. (null) => null
Post item.

Usage

  1. if ( !function_exists( 'bp_activity_post_type_update' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-functions.php'; 
  3.  
  4. // Post item. 
  5. $post = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_activity_post_type_update($post); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-activity/bp-activity-functions.php  
  1. function bp_activity_post_type_update( $post = null ) { 
  2.  
  3. if ( ! is_a( $post, 'WP_Post' ) ) { 
  4. return; 
  5.  
  6. // Get the post type tracking args. 
  7. $activity_post_object = bp_activity_get_post_type_tracking_args( $post->post_type ); 
  8.  
  9. if ( empty( $activity_post_object->action_id ) ) { 
  10. return; 
  11.  
  12. $activity_id = bp_activity_get_activity_id( array( 
  13. 'component' => $activity_post_object->component_id,  
  14. 'item_id' => get_current_blog_id(),  
  15. 'secondary_item_id' => $post->ID,  
  16. 'type' => $activity_post_object->action_id,  
  17. ) ); 
  18.  
  19. // Activity ID doesn't exist, so stop! 
  20. if ( empty( $activity_id ) ) { 
  21. return; 
  22.  
  23. // Delete the activity if the post was updated with a password. 
  24. if ( ! empty( $post->post_password ) ) { 
  25. bp_activity_delete( array( 'id' => $activity_id ) ); 
  26.  
  27. // Update the activity entry. 
  28. $activity = new BP_Activity_Activity( $activity_id ); 
  29.  
  30. if ( ! empty( $post->post_content ) ) { 
  31. $activity_summary = bp_activity_create_summary( $post->post_content, (array) $activity ); 
  32.  
  33. // Backward compatibility filter for the blogs component. 
  34. if ( 'blogs' == $activity_post_object->component_id ) { 
  35. $activity->content = apply_filters( 'bp_blogs_record_activity_content', $activity_summary, $post->post_content, (array) $activity, $post->post_type ); 
  36. } else { 
  37. $activity->content = $activity_summary; 
  38.  
  39. // Save the updated activity. 
  40. $updated = $activity->save(); 
  41.  
  42. /** 
  43. * Fires after the updating of an activity item for a custom post type entry. 
  44. * @since 2.2.0 
  45. * @since 2.5.0 Add the post type tracking args parameter 
  46. * @param WP_Post $post Post object. 
  47. * @param BP_Activity_Activity $activity Activity object. 
  48. * @param object $activity_post_object The post type tracking args object. 
  49. */ 
  50. do_action( 'bp_activity_post_type_updated', $post, $activity, $activity_post_object ); 
  51.  
  52. return $updated;