diff --git a/includes/api/ram-rest-comments-controller.php b/includes/api/ram-rest-comments-controller.php index 8e3dc03ecac10c90956692cdec8a4647465ab99e..5b9224ab9f308d93831452a23e3f3818e4ea7bc2 100644 --- a/includes/api/ram-rest-comments-controller.php +++ b/includes/api/ram-rest-comments-controller.php @@ -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; } diff --git a/includes/filter/ram-custom-post-fields.php b/includes/filter/ram-custom-post-fields.php index e5e01bdd8c3804a627062d99b06c4a2d0e08a86a..911b1996f5bed89af8786e6a9bb9b340ed6e9f89 100644 --- a/includes/filter/ram-custom-post-fields.php +++ b/includes/filter/ram-custom-post-fields.php @@ -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;