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

检索最近发布的列表。

参数

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

返回

阵列|IXR_错误

来源

公共函数mw_getRecentPosts($args){$this->escape($args);$username=$args[1];$password=$args[2];if(isset($args[3])){$query=数组('numberposts'=>absint($args[3]));}其他{$query=数组();}$user=$this->登录($username,$password);if(!$user){返回$this->错误;}if(!current_user_can('edit_posts')){return new IXR_Error(401,__('对不起,您不能编辑帖子。'));}/**此操作记录在wp-includes/class-wp-xmlrpc-server.php中*/do_action('xmlrpc_call','metaWeblog.getRecentPosts',$args,$this);$posts_list=wp_get_recent_posts($query);if(!$posts_list){返回数组();}$recent_posts=数组();foreach($posts_list作为$entry){if(!current_user_can('edit_post',$entry['ID'])){继续;}$post_date=$this->_convert_date($entry['post_date']);$post_date_gmt=$this->_convert_date_gmt($entry[‘post_date_ gmt’],$entry['post_date']);$post_modified=$this->_convert_date($entry[“post_modificated”]);$post_modified_gmt=$this->_convert_date_gmt($entry['post_modificated_gmt'],$entry['post_modified']);$categories=数组();$catids=wp_get_post_categories($entry[ID']);foreach($catid作为$catid){$categories[]=获取cat_name($catid);}$tagnames=数组();$tags=wp_get_post_tags($entry['ID']);if(!空($tags)){foreach($tags作为$tag){$tagnames[]=$tag->name;}$tagnames=内爆(',',$tagname);}其他{$tagnames='';}$post=get_extended($entry['post_content']);$link=获取永久链接($entry['ID']);//获取文章作者信息。$author=get_userdata($entry['post_author']);$allow_comments=('open'===$entry['comment_status'])?1 : 0;$allow_pings=('open'===$entry['pingstatus'])?1 : 0;//考虑未来发布的帖子。if('future'===$entry['post_status']){$entry['post_status']='publish';}//获取帖子格式。$post_format=获取成本格式($entry['ID']);if(空($post_format)){$post_format=“标准”;}$recent_posts[]=数组(“dateCreated”=>$post_date,“userid”=>$entry['post_author'],“postid”=>(字符串)$entry[“ID”],'description'=>$post['main'],'title'=>$entry['post_title'],“link”=>$link,“permaLink”=>$link,//发表评论是因为似乎没有其他工具使用此功能。//“content”=>$entry['post_content'],“类别”=>$categories,“mt_excerpt”=>$entry['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”=>$entry['post_name'],“wp_password”=>$entry[“post_password”],“wp_author_id”=>(字符串)$author->id,'wp_author_display_name'=>$author->display_name,“date_created_gmt”=>$post_date_gmt,“post_status”=>$entry['post_status'],'custom_fields'=>$this->get_custom_fields($entry['ID']),“wp_post_format”=>$post_format,'date_modified'=>$post_modified,“date_modified_gmt”=>$post_modified_gmt,“sticky”=>(“post”===$entry[“post_type”]&&is_sticky($entry['ID'])),“wp_post_thumbnail”=>get_post_theumbnail_id($entry['id']),);}返回$recent_posts;}

挂钩

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

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

变更日志

版本说明
1.5.0介绍。

用户贡献的笔记

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