Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function bp_activity_add( $args = '' ) {
- $r = bp_parse_args( $args, array(
- 'id' => false,
- 'action' => '',
- 'content' => '',
- 'component' => false,
- 'type' => false,
- 'primary_link' => '',
- 'user_id' => bp_loggedin_user_id(),
- 'item_id' => false,
- 'secondary_item_id' => false,
- 'recorded_time' => bp_core_current_time(),
- 'hide_sitewide' => false,
- 'new_row' => '', //MY NEW ROW!
- 'is_spam' => false,
- 'error_type' => 'bool'
- ), 'activity_add' );
- // Make sure we are backwards compatible.
- if ( empty( $r['component'] ) && !empty( $r['component_name'] ) ) {
- $r['component'] = $r['component_name'];
- }
- if ( empty( $r['type'] ) && !empty( $r['component_action'] ) ) {
- $r['type'] = $r['component_action'];
- }
- // Setup activity to be added.
- $activity = new BP_Activity_Activity( $r['id'] );
- $activity->user_id = $r['user_id'];
- $activity->component = $r['component'];
- $activity->type = $r['type'];
- $activity->content = $r['content'];
- $activity->primary_link = $r['primary_link'];
- $activity->item_id = $r['item_id'];
- $activity->secondary_item_id = $r['secondary_item_id'];
- $activity->new_row = $r['new_row']; //MY NEW ROW!
- $activity->date_recorded = $r['recorded_time'];
- $activity->hide_sitewide = $r['hide_sitewide'];
- $activity->is_spam = $r['is_spam'];
- $activity->error_type = $r['error_type'];
- $activity->action = ! empty( $r['action'] )
- ? $r['action']
- : bp_activity_generate_action_string( $activity );
- $save = $activity->save();
- if ( 'wp_error' === $r['error_type'] && is_wp_error( $save ) ) {
- return $save;
- } elseif ('bool' === $r['error_type'] && false === $save ) {
- return false;
- }
- // If this is an activity comment, rebuild the tree.
- if ( 'activity_comment' === $activity->type ) {
- // Also clear the comment cache for the parent activity ID.
- wp_cache_delete( $activity->item_id, 'bp_activity_comments' );
- BP_Activity_Activity::rebuild_activity_comment_tree( $activity->item_id );
- }
- wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
- /**
- * Fires at the end of the execution of adding a new activity item, before returning the new activity item ID.
- *
- * @since 1.1.0
- * @since 4.0.0 Added the `$activity_id` parameter.
- *
- * @param array $r Array of parsed arguments for the activity item being added.
- * @param int $activity_id The id of the activity item being added.
- */
- do_action( 'bp_activity_add', $r, $activity->id );
- return $activity->id;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement