wp_xmlrpc_server::mw_getPost(阵列 $个参数 ):阵列|IXR_错误

检索帖子。

参数

$个参数阵列必修的
方法参数。注意:参数必须按照文档排序。
  • 整数
    帖子ID。
  • 1 一串
    用户名。
  • 2 一串
    密码。

返回

阵列|IXR_错误

来源

公共函数mw_getPost($args){$this->escape($args);$post_id=(int)$args[0];$username=$args[1];$password=$args[2];$user=$this->登录($username,$password);if(!$user){返回$this->错误;}$postdata=获取post($post_id,ARRAY_A);if(!$postdata){return new IXR_Error(404,__('帖子ID无效'));}if(!current_user_can('edit_post',$post_id)){return new IXR_Error(401,__('对不起,您不能编辑此帖子。'));}/**此操作记录在wp-includes/class-wp-xmlrpc-server.php中*/do_action('xmlrpc_call','metaWeblog.getPost',$args,$this);if(''!==$postdata['post_date']){$post_date=$this->_convert_date($postdata['post_date']);$post_date_gmt=$this->_convert_date_gmt($postdata['post_date_cmt'],$postdate['posd_date']);$post_modified=$this->_convert_date($postdata['post_modified']);$post_modified_gmt=$this->_convert_date_gmt($postdata['post_modificated_gmt'],$postdate['post-modified']);$categories=数组();$catids=wp_get_post_categories($post_id);foreach($catid作为$catid){$categories[]=获取cat_name($catid);}$tagnames=数组();$tags=wp_get_post_tags($post_id);if(!空($tags)){foreach($tags作为$tag){$tagnames[]=$tag->name;}$tagnames=内爆(',',$tagname);}其他{$tagnames='';}$post=获取扩展($postdata['post_content']);$link=获取永久链接($postdata['ID']);//获取作者信息。$author=获取用户数据($postdata['post_author']);$allow_comments=('open'===$postdata['comment_status'])?1 : 0;$allow_pings=('open'===$postdata['pingstatus'])?1 : 0;//考虑未来发布的帖子。if(“未来”===$postdata['post_status']){$postdata['post_status']='发布';}//获取帖子格式。$post_format=获取成本格式($post_id);if(空($post_format)){$post_format=“标准”;}$stick=false;if(is_sticky($post_id)){$sticky=true;}$enclosure=数组();foreach((数组)get_post_custom($post_id)as$key=>$val){if(“enclosure”===$key){foreach((数组)$val作为$enc){$encdata=爆炸(“\n”,$enc);$enclosure['url']=修剪(htmlspecialchars($encdata[0]));$enclosure['length']=(int)修剪($encdata[1]);$enclosure['type']=修剪($encdata[2]);断裂2;}}}$resp=数组(“dateCreated”=>$post_date,“userid”=>$postdata['post_author'],“postid”=>$postdata['ID'],'description'=>$post['main'],“title”=>$postdata['post_title'],“link”=>$link,“permaLink”=>$link,//发表评论是因为似乎没有其他工具使用此功能。//“content”=>$entry['post_content'],“类别”=>$categories,“mt_excerpt”=>$postdata['post_excerpt'],“mt_text_more”=>$post['extended'],“wp_more_text”=>$post['more_text'],'mt_allow_comments'=>$allow_comments,'mt_allow_pings'=>$allow_pings,“mt_keywords”=>$标记名,“wp_slug”=>$postdata['post_name'],“wp_password”=>$postdata['post_password'],“wp_author_id”=>(字符串)$author->id,'wp_author_display_name'=>$author->display_name,“date_created_gmt”=>$post_date_gmt,“post_status”=>$postdata[“post_status”],“自定义字段”=>$this->get_custom_fields($post_id),“wp_post_format”=>$post_format,“sticky”=>$sticky,'date_modified'=>$post_modified,“date_modified_gmt”=>$post_modified_gmt,);if(!空($enclosure)){$resp['enclosure']=$enclosure;}$resp['wp_post_thumbnail']=get_post_thombnail_id($postdata['id']);返回$resp;}其他{return new IXR_Error(404,__('对不起,没有这样的帖子');}}

挂钩

do_操作('xmlrpc_call',一串 $名称,数组|字符串 $个参数,wp_xmlrpc服务器 $服务器 )

在XML-RPC用户经过身份验证后,但在方法逻辑的其余部分开始之前激发。

变更日志

版本说明
1.5.0介绍。

用户贡献的笔记

你必须登录在能够发表注释或反馈之前。