bp_activity_document_add (美元的文档)
为上传的每个文档创建文档活动
描述
参数
- 美元的文档
-
(必需)
源
文件:bp-activity / bp-activity-filters.php
函数bp_activity_document_add($document) {global $bp_document_upload_count, $bp_new_activity_comment;如果(!空($document)) {$parent_activity_id = false;if (isset($_POST['bp_activity_update']) && isset($_POST['bp_activity_id']) {$parent_activity_id = (int) $_POST['bp_activity_id']);} if ($bp_document_upload_count > 1 || !Empty ($bp_new_activity_comment)) {if (bp_is_active('groups') && !$document->group_id)) {$comment = new BP_Activity_Activity($bp_new_activity_comment);如果(!$comment_activity = new BP_Activity_Activity($comment->item_id); / /添加>item_id如果(! empty( $comment_activity->component ) && buddypress()->groups->id === $comment_activity->component ) { $document->group_id = $comment_activity->item_id; $document->privacy = 'grouponly'; } } } $args = array( 'hide_sitewide' => true, 'privacy' => 'document', ); if ( ! empty( $document->group_id ) && bp_is_active( 'groups' ) ) { $args['item_id'] = $document->group_id; $args['type'] = 'activity_update'; $current_group = groups_get_group( $document->group_id ); $args['action'] = sprintf( __( '%1$s posted an update in the group %2$s', 'buddyboss' ), bp_core_get_userlink( $document->user_id ), '' . esc_attr( $current_group->name ) . '' ); $activity_id = groups_record_activity( $args ); } else { $activity_id = bp_activity_post_update( $args ); } if ( $activity_id ) { // save document activity id in document. $document->activity_id = $activity_id; $document->save(); // update activity meta. bp_activity_update_meta( $activity_id, 'bp_document_activity', '1' ); // save attachment meta for activity. update_post_meta( $document->attachment_id, 'bp_document_activity_id', $activity_id ); if ( ! empty( $parent_activity_id ) ) { $document_activity = new BP_Activity_Activity( $activity_id ); $document_activity->secondary_item_id = $parent_activity_id; $document_activity->save(); // save parent activity id in attachment meta. update_post_meta( $document->attachment_id, 'bp_document_parent_activity_id', $parent_activity_id ); } } } else { if ( $parent_activity_id ) { //save document activity id $document->activity_id = $parent_activity_id; $document->save(); //save parent activity id in attachment meta update_post_meta( $document->attachment_id, 'bp_document_parent_activity_id', $parent_activity_id ); } } } }
更新日志
版本 | 描述 |
---|---|
BuddyBoss 1.2.0 | 介绍了。 |