wp_xmlrpc_server::blogger_editPost(阵列 $个参数 ):真的|IXR_错误

编辑文章。

参数

$个参数阵列必修的
方法参数。注意:参数必须按照文档排序。
  • 整数
    博客ID(未使用)。
  • 1 整数
    帖子ID。
  • 2 一串
    用户名。
  • 一串
    密码。
  • 4 一串
    内容
  • 5 整数
    发布标志。0表示草稿,1表示发布。

返回

真的|IXR_错误完成后为true。

来源

公共功能blogger_editPost($args){$this->escape($args);$post_id=(int)$args[1];$username=$args[2];$password=$args[3];$content=$args[4];$publish=$args[5];$user=$this->登录($username,$password);if(!$user){返回$this->错误;}/**此操作记录在wp-includes/class-wp-xmlrpc-server.php中*/do_action('xmlrpc_call','blogger.editPost',$args,$this);$actual_post=获取post($post_id,ARRAY_A);if(!$actual_post||'post'!==$actual_post['post_type']){return new IXR_Error(404,__('对不起,没有这样的帖子');}$this->escape($actual_post);if(!current_user_can('edit_post',$post_id)){return new IXR_Error(401,__('对不起,您不能编辑此帖子。'));}if('publish'===$actual_post['post_status']&&!current_user_can('publishe_posts')){return new IXR_Error(401,__('对不起,您不能发布此帖子。'));}$postdata=array();$postdata['ID']=$actual_post['ID'];$postdata['post_content']=xmlrpc_removepostdata($content);$postdata['post_title']=xmlrpc_getposttitle($content);$postdata['post_category']=xmlrpc_getpostcategory($content);$postdata['post_status']=$actual_post['post_status'];$postdata['post_excerpt']=$actual_post['pose_excerpt'];$postdata['post_status']=$publish?'publish':'草稿';$result=wp_update_post($postdata);if(!$result){return new IXR_Error(500,__('对不起,文章无法更新。'));}$this->attach_uploads($actual_post['ID'],$postdata['post_content']);/***通过XML-RPC Blogger API成功更新帖子后激发。**@自3.4.0起**@param int$post_id更新帖子的id。*@param array$args要编辑的帖子的参数数组。*/do_action('xmlrpc_call_success_blogger_editPost',$post_id,$args);//phpcs:忽略WordPress。命名约定。有效挂钩名称。无小写返回true;}

挂钩

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

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

do_操作('xmlrpc_call_success_blogger_editPost',整数 $帖子id,阵列 $个参数 )

通过XML-RPC Blogger API成功更新帖子后激发。

变更日志

版本描述
1.5.0介绍。

用户贡献的笔记

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