BP_REST_活动_端点::为_数据库准备_项_(WP_REST_请求$request)

为创建或更新准备活动。

描述

参数

$request

(WP_REST_请求)(必选)请求对象。

返回

(stdClass| WP|U错误)对象或WP_错误。

来源

文件:bp-activity /类/ class-bp-rest-activity-endpoint.php

受保护函数prepare_item_for_database($request){$prepared_activity=new stdClass();$schema=$this->get_item_schema();$activity=$this->get_activity对象($request);if(!empty($schema['properties']['id'])empty($activity->id)){$prepared_activity=$activity;$prepared_activity->id=$activity->id;$if('activity_comment'!==$request['type']){$prepared_activity->error_type='wp_error'}}//活动作者ID.if(!empty($schema['properties']['user_ID'])和&isset($request['user_ID']){$prepared_activity->user_ID=(int)$request['user_ID']}否则{$prepared_activity->user_ID=获取当前用户ID()//活动组件。如果(!empty($schema['properties']['component'])和&isset($request['component']){$prepared_Activity->component=$request['component'];}否则{$prepared_Activity->component=buddypress()->Activity->id;}//活动项id。//如果(!empty($schema['properties'['primary_Item.'id']))和&isset($request['primary_item_id']{$item_id=(int)$request['primary_item_id'];//设置活动的组id。如果(bp_处于活动状态('groups')&&isset($prepared_activity->component)&&buddypress()->groups->id==$prepared_activity->component){$prepared_activity->groups_id=$item_id;$status=bp_get_组状态($item_id));//对其他组件使用通用项ID。}else{$prepared_activity->item_ID=$item_ID;}}//次要项ID.if(!empty($schema['properties']['Secondary_item_ID'])和&isset($request['Secondary_item_ID']){$prepared_activity->Secondary_item_ID=(int)$request['Secondary_item__ID'}//活动类型['properties']['type']]&&isset($request['type']){$prepared_activity->type=$request['type'];}///活动内容。if(!empty($schema['properties']['content'])和&isset($request['content']){$if(is_string($request['content']){$prepared_activity->content=$request['content']}elseif(isset($request['content'['content']raw'])){$prepared_activity->content=$request['content']['raw'];}//activity站点范围的可见性。如果(!empty($schema['properties']['hidden'])和&isset($request['hidden']){$prepared_activity->hide_siteware=(bool)$request['hidden'];//activity.if(!empty($schema['properties'['Privacy'])and&isset($request['Privacy'])){$prepared_activity->privacy=$request['privacy']}else{if(!empty($activity->privacy)){$prepared_activity->privacy=$activity->privacy;}else{$prepared_activity->privacy='public'.}if(!empty($status)&&in_数组('status,array('hidden','private'),true)){$prepared_activity->隐藏站点范围=true;}//在发布到组时忽略传递的隐私。如果(!empty($status)){$prepared_activity->privacy='public';}/***在通过REST API插入或更新活动之前对其进行过滤。**@param stdClass$prepared\u activity为插入或更新数据库而准备的对象。*@param WP\u REST\u Request$Request Request object.*@自0.1.0*/返回应用过滤器('bp\u REST\u activity\u pre\u insert\u value',$prepared\u activity,$Request)}

变更日志

变更日志
版本 描述
0.1.0 介绍。

问题?

我们随时乐意为您提供代码或其他问题的帮助!搜索我们的开发者文档,联系支持,或与我们联系销售团队.