bp_nouveau_ajax_messages_send_message ()
AJAX发送消息并显示错误。
描述
源
文件:bp-templates / bp-nouveau包括/信息/ ajax.php
函数bp_nouveau_ajax_messages_send_message(){global$thread_template,$messages_template;$response=array('feedback'=>uuuu('Your message's not.ally's,请重试,'buddyboss'),'type'=>'error',;//验证nonce if(空($_POST['nonce'])124; |!wp_verifynonce($POST['nonce','messages发送消息')){wp_send_json_error($response);}//验证主题和邮件内容if(空($_POST['message_content']){$response['feedback']=uuu('您的邮件未发送。请输入一些内容','buddyboss');wp_send_json_error($response);}//验证收件人if(空($_POST['send_to']);!是$POST['send_uto'])数组($POST['send_to'])){$response['feedback']=uuu('请至少添加一个收件人','buddyboss');wp_send_json_error($response);}//Trim@from usernames/***筛选设置为接收消息的用户的用户名中的“@”字符的修剪结果。**@自BuddyPress 3.0.0以来**@param array$value trimmed usernames数组。*@param array$value提交的未修剪用户名数组。*/$recipients=apply_Filters('bp_messages_recipients',array_map(函数($username){return trim($username,@');},$\u POST['send\u to']);//尝试发送消息。$send=messages\u new\u消息(数组('recipients'=>$recipients','subject'=>wp\u trim\u words($\u POST['message\u content'],messages\u default\u subject\u length()),'content'=>$\u POST['messages\u content\u content'],'error\u error'>));//发送消息。if(true===is_int($Send)){$response=array();if(bp_有消息线程(array('include'=>$Send)){而(bp_消息线程()){bp_消息线程();$last_消息线程id=(int)$messages模板->线程->last_消息线程id;$response=array('id'=>bp_获取消息线程线程id(),'message id'=>(int)$last_message_id,'subject'=>strip_标记(bp_get_message_thread_subject()),'extract'=>strip_标记(bp_get_message_thread_extract()),'content'=>do_短代码(bp_get_message_thread_content()),'unread'=>bp_message_thread_线程未读(),'sender(sender_name'=>bp_core(()())user))))用户名=>,“发送者是你”=>messages\u template->thread->last\u sender\u id==bp\u loggedin\u user\u id(),“发送者链接”=>bp\u core\u get\u userlink($messages\u template->thread->last\u sender\u id,false,true),“发送者化身”=>esc\u url(bp\u core\u fetch\u userlink)(数组)('item\u id'=>$messages\u template->thread->last\u sender\u id,'object'=>'user','type'=>'thumb',width'=>BP\u AVATAR\u thumb\u width,'height'=>BP\u AVATAR\u thumb\u height,'html'=>false,),'count=>BP\u get\u message\u thread\u thread\u total\u count(),'date=>strottime(BP\u获取消息\u thumb\u thumb\u线程\u最后发布日期\u raw())*1000,'display_date'=>bp_nouveau_get_message_thread_last_post_date_raw(),'started_date'=>date(get_选项('date_format')、strottime($messages_template->thread->first_message_date));if(是数组($messages_template->thread->->->recipients)){foreach($messages_template->->thread->->->recipients as$recipients){if(空($recipient->is_deleted)){$response['recipients'][]=array('avatar'=>esc\u url(bp\u core\u fetch\u avatar(array)('item\u id'=>recipient->user\u id,'object'=>user',type'=>thumb',width'=>bp\u avatar\u thumb\u thumb\u高度,'html'=>false),'user\u link=>bp\u core\u获取userlink($recipient->user\u id,false,true),'user\u name'=>bp\u core\u get\u user\u displayname($recipient->user\u id),'is\u you=>recipient->user\u id==bp\u loggedin\u user\u id();}}}}如果(bp\u处于活动状态('messages','star star'){$star link bp\u获取消息\u star action\u链接(数组('thread id'=>bp\u get-message id()),'url),则为true$response['star_link']=$star_link;$star_link_data=explode('/',$star_link);$response['is_starred']=array_search('unstar',$star_link']=array_search('unstar',$star link']=data);//默认为最后一个$sm id=$last_message id;$if($response['is_started']){$sm id=(int)$sm id=(int)$star link数据[$response['is_started']1]=nonce}$response[$star创建nonce']('bp messages star-'.$sm_id);$response['starred_id']=$sm_id;}$thread_extra_content=bp_nouveau_messages_catch_hook_内容(数组('inboxListItem'=>'bp_messages_收件箱_列表_项目','threadOptions'=>'bp_messages_thread_选项'));if(数组过滤器($thread extra_内容)){$response=array_合并($response,$thread_extra_content);}}}if(empty($response)){$response=array('id'=>$send);}wp_send_json_success(array('feedback'=>。'Message successfully','buddyboss'),'type'=>'success','thread=>$response,);//消息无法发送。}否则{$response['feedback feed'=$send->获取错误消息();wp_send_json_error($response);}
更新日志
版本 | 描述 |
---|---|
BuddyPress 3.0.0 | 介绍了。 |