提交 2e2e4b39 编写于 作者: J jianbo

修复与古腾堡编辑器不兼容的问题

上级 0ec56725
......@@ -376,40 +376,31 @@ class RAM_REST_Comments_Controller extends WP_REST_Controller{
if(get_post($post)==null || $post== 0 || !is_int($post))
{
return new WP_Error( 'error', 'postId 参数错误', array( 'status' => 500 ) );
return new WP_Error( 'error', 'postId参数错误', array( 'status' => 500 ) );
}
else
{
if(!comments_open($post))
{
return new WP_Error( 'error', '文章留言关闭', array( 'status' => 400 ) );
return new WP_Error( 'error', '文章留言关闭', array( 'status' => 500 ) );
}
global $wpdb;
$status = $wpdb->get_row($wpdb->prepare("SELECT post_status, comment_status FROM $wpdb->posts WHERE ID = %d", $post));
if ( in_array($status->post_status, array('draft', 'pending') ) ) {
return new WP_Error( 'error', '文章尚未发布', array( 'status' => 400 ) );
return new WP_Error( 'error', '文章尚未发布', array( 'status' => 500 ) );
}
}
if(!empty($formId) && strlen($formId>50))
if(!username_exists($openid))
{
return new WP_Error( 'error', 'fromId参数错误', array( 'status' => 400 ) );
return new WP_Error( 'error', '不允许提交', array('status' => 500 ));
}
if(!username_exists($openid))
{
return new WP_Error( 'error', '不允许提交', array('status' => 500 ));
}
else if(is_wp_error(get_post($post)))
{
return new WP_Error( 'error', 'postId 参数错误', array( 'status' => 500 ) );
}
else if(is_wp_error(get_post($post)))
{
return new WP_Error( 'error', 'postId 参数错误', array( 'status' => 500 ) );
}
return true;
}
......
......@@ -9,6 +9,10 @@ function custom_post_fields( $data, $post, $request) {
//$content =get_the_content();
$content=$_data['content']['rendered'];
$content_protected=$_data['content']['protected'];
$raw=empty($_data['content']['raw'])?'':$_data['content']['raw'];
$siteurl = get_option('siteurl');
$upload_dir = wp_upload_dir();
......@@ -45,18 +49,20 @@ function custom_post_fields( $data, $post, $request) {
$params = $request->get_params();
if ( isset( $params['id'] ) ) {
$vcontent =get_post_qq_video($content);
$vcontent =get_post_qq_video($content);//解析腾讯视频
if(!empty($vcontent))
{
$content=$vcontent;
}
$_content['rendered'] =$content;
$_content['raw'] =$raw;//古腾堡编辑器需要该属性,否则报错
$_content['protected'] =$content_protected;
$_data['content']= $_content;
$sql=$wpdb->prepare("SELECT meta_key , (SELECT id from ".$wpdb->users." WHERE user_login=substring(meta_key,2)) as id ,(SELECT display_name from ".$wpdb->users." WHERE user_login=substring(meta_key,2)) as display_name FROM ".$wpdb->postmeta." where meta_value='like' and post_id=%d",$post_id);
$likes = $wpdb->get_results($sql);
$_data['sql']=$sql;
//$_data['sql']=$sql;
$avatarurls =array();
foreach ($likes as $like) {
$userId = $like->id;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册