bp_activity_post_type_comment (int$comment\u id,布尔is_approved美元=符合事实的,对象|空activity_post_object美元=无效的)
为新发布的文章类型评论创建活动项。
描述
参数
- $comment\u id
-
(int)(必选)评论的ID。
- is_approved美元
-
(布尔)(可选)评论是否被批准。
默认值:真
- activity_post_object美元
-
(对象|无效的)(可选)post类型跟踪参数对象。
默认值:空
回来
(null | WP | u错误| bool | int)成功时活动的ID。错误为False。
来源
文件:bp-activity/bp-activity-functions.php
函数bp_activity_post_type_comment($comment_id=0,$is_approved=true,$activity_post_object=null){//获取用户的评论$post_type_comment=Get_comment($comment_id);//如果(空($is_approved)){返回false;}则如果评论未被批准,则不记录活动//如果(空($post\u type\u comment->comment\u author\u email)){return false;}//如果评论已标记为垃圾邮件,则不记录活动如果('spam'==$is\u approved){return false;}//通过评论作者电子邮件获取用户。$user=Get\u user\u by('email',$post_-type_-comment->comment_-author_-email);//如果用户未注册,如果(空($user)){return false;}//获取用户id$user_-id=(int)$user->id;//获取日志和日志数据$blog_-id=获取当前日志_-blog_-id();//获取日志$post_-type_-comment->post=Get_-post($post_-type_-comment->-id);如果(!is_a($post_type_comment->post,'WP_post')){return false;}/***筛选是否发布有关post状态的评论的活动**@since BuddyPress 2.5.0**@param bool true to bail,否则为false。*/$is_post_status_not allowed=(bool)apply_筛选('bp_activity_post_type_is_post_status_allowed','publish'!=$post_type_comment->post->post_status|124;!empty($post_type_comment->post->post_password));//如果这是受密码保护的帖子,或者不是公共帖子,如果($is_post_status_not allowed),则不记录评论{返回false;}//设置帖子类型$post\u type=$post\u type\u comment->post->post\u type;if(空($activity\u post\u object)){//获取帖子类型跟踪参数。$activity\u post\u object=bp\u activity\u Get\u post\u type\u tracking\u args($post\u type);//如果活动类型不存在,if(空($activity\u post\u object->comments\u tracking\u tracking->action\u id)){返回false;}}//设置$activity\u comment\u object$activity\u comment\u object=$activity\u post\u object->comments\u tracking;/***过滤是否发布有关评论的活动。**这是一个变量过滤器,取决于帖子类型,*允许组件或插件在需要时提前退出。**因为BuddyPress 2.5.0**@param bool$value是否或者不继续。*@param int$blog_id当前站点。*@param int$post_id当前被评论的帖子。*@param int$user_id当前用户。*@param int$comment_id当前被评论的帖子。*/if(false==apply_过滤器(“bp_活动{$post_type}}\u pre_评论”,true,$blog\u id,$post\u type\u comment->post->id,$user\u id,$comment\u id)){return false;}//这是更新吗?$activity\u id=bp\u activity\u get\u activity\u id(数组)('user\u id'=>$user\u id',component'=>$activity\u comment\u object->component\u id',type'=>$activity\u comment\u object->action\u id',item\u id'=>$blog\u id',secondary\u item\u id'=>$comment\u id,);//在活动提要中记录此信息。$comment\u link=get\u comment\u link($post\u type\u comment\u comment->id);//博客组件的向后兼容性筛选器。如果('blogs'=$activity\u comment\u object->component\u id){$activity\u content=apply\u filters\u ref\u数组('bp\u blogs\u activity\u new\u comment\u content',array($post\u type\u comment->comment\u content,&$post\u type\u comment\u link));$activity\u primary\u link=apply\u filters\u ref\u数组('bp_blogs_activity_new_comment_primary_link',数组($comment_link,&$post_type_comment));}其他{$activity_content=$post_type_comment->comment_content;$activity_primary_link=$comment_link;}$activity_args=数组('id'=>$activity\u id,'user\u id'=>$user\u id,'content'=>$activity\u content,'primary\u link'=>$activity\u comment\u object->component\u id,'recorded\u time'=>$post\u type\u comment->comment\u date\u gmt,);如果(bp\u disable\u blogforum\u comments()){$blog\u url=get\u home\u url($blog\u id);$post\u url=add\u query\u arg('p',$post\u type\u comment->post->ID,trailingslashit('blog\u url));$activity\u args['type']=$activity\u comment\u object->action\u ID;$activity\u args['item\u ID']=$blog\u ID;$activity\u args['secondary\u item\u ID']=$post\u type\u comment->\u ID;如果(!empty($activity\u args['content'])){//创建摘录。$activity\u summary=bp\u activity\u Create\u summary($activity\u args['content',$activity\u args);//博客评论的向后兼容性筛选器。如果('blogs'=$activity\u post\u object->component\u id){$activity\u args['content']=应用筛选器('bp\u blogs\u record\u activity\u content',$activity\u args['content'],$activity\u args,$post\u type);}else{$activity\u args['content']=$activity\u summary;}使用格式函数设置操作。$activity\u args=array\u merge($activity\u args,array('post\u title'=>post\u type\u comment->post\u title,'post\u url'=>post\u url,'blog\u url'=>blog\u url,'blog\u name'=>get\u blog\u选项($blog_id,'blogname'),);$activity_args['action']=调用用户函数数组($activity_comment_object->format_callback, array( '', (object) $action_args ) ); // Make sure the action is set. if ( empty( $activity_args['action'] ) ) { return; } else { // Backward compatibility filter for the blogs component. if ( 'blogs' === $activity_post_object->component_id ) { $activity_args['action'] = apply_filters( 'bp_blogs_record_activity_action', $activity_args['action'] ); } } $activity_id = bp_activity_add( $activity_args ); } /** * Fires after the publishing of an activity item for a newly published post type post. * * @since BuddyPress 2.5.0 * * @param int $activity_id ID of the newly published activity item. * @param WP_Comment $post_type_comment Comment object. * @param array $activity_args Array of activity arguments. * @param object $activity_post_object the post type tracking args object. */ do_action_ref_array( 'bp_activity_post_type_comment', array( &$activity_id, $post_type_comment, $activity_args, $activity_post_object ) ); return $activity_id; }
更新日志
版本 | 描述 |
---|---|
BuddyPress 2.5.0 | 介绍。 |