Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ijianbo
rest Api To Miniprogram
提交
7bd4add3
rest Api To Miniprogram
项目概览
ijianbo
/
rest Api To Miniprogram
通知
22
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
rest Api To Miniprogram
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
7bd4add3
编写于
4月 18, 2019
作者:
J
jianbo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加评论审核选项
上级
77508ef1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
36 addition
and
22 deletion
+36
-22
includes/api/ram-rest-comments-controller.php
includes/api/ram-rest-comments-controller.php
+36
-22
未找到文件。
includes/api/ram-rest-comments-controller.php
浏览文件 @
7bd4add3
...
...
@@ -138,16 +138,23 @@ class RAM_REST_Comments_Controller extends WP_REST_Controller{
$userid
=
isset
(
$request
[
'userid'
])
?
(
int
)
$request
[
'userid'
]
:
0
;
//被回复者
$formId
=
isset
(
$request
[
'formId'
])
?
$request
[
'formId'
]
:
""
;
$authorIp
=
get_client_ip
();
$authorIp
=
empty
(
$authorIp
)
?
''
:
$authorIp
;
$wf_enable_comment_check
=
get_option
(
'wf_enable_comment_check'
);
$comment_approved
=
"1"
;
if
(
!
empty
(
$wf_enable_comment_check
))
{
$comment_approved
=
"0"
;
}
global
$wpdb
;
$user_id
=
0
;
$useropenid
=
""
;
$sql
=
"SELECT ID FROM "
.
$wpdb
->
users
.
" WHERE user_login='"
.
$openid
.
"'"
;
$user_id
=
(
int
)
$wpdb
->
get_var
(
$sql
);
//评论者id
// $users = $wpdb->get_results($sql);
// foreach ($users as $user) {
// $user_id = (int) $user->ID;
// }
$commentdata
=
array
(
'comment_post_ID'
=>
$post
,
// to which post the comment will show up
'comment_author'
=>
$author_name
,
//fixed value - can be dynamic
...
...
@@ -157,12 +164,18 @@ class RAM_REST_Comments_Controller extends WP_REST_Controller{
'comment_type'
=>
''
,
//empty for regular comments, 'pingback' for pingbacks, 'trackback' for trackbacks
'comment_parent'
=>
$parent
,
//0 if it's not a reply to another comment; if it's a reply, mention the parent comment ID here
'user_id'
=>
$user_id
,
//passing current user ID or any predefined as per the demand
'comment_author_IP'
=>
get_client_ip
()
);
'comment_author_IP'
=>
$authorIp
,
'comment_approved'
=>
$comment_approved
);
$comment_id
=
wp_insert_comment
(
wp_filter_comment
(
$commentdata
));
if
(
$comment_id
)
if
(
empty
(
$comment_id
))
{
return
new
WP_Error
(
'error'
,
'添加评论失败'
,
array
(
'status'
=>
500
)
);
}
else
{
$useropenid
=
""
;
if
(
!
empty
(
$userid
))
...
...
@@ -178,28 +191,29 @@ class RAM_REST_Comments_Controller extends WP_REST_Controller{
}
$result
[
"code"
]
=
"success"
;
$message
=
'留言成功'
;
if
(
!
empty
(
$wf_enable_comment_check
))
{
$message
=
'留言已提交,需管理员审核方可显示。'
;
}
if
(
$addcommentmetaflag
)
{
$result
[
"
message
"
]
=
"添加评论和formId成功"
;
$result
[
"
formId
"
]
=
"添加评论和formId成功"
;
}
else
{
$result
[
"
message
"
]
=
"添加评论成功,添加formId失败"
;
$result
[
"
formId
"
]
=
"添加评论成功,添加formId失败"
;
}
$result
[
"status"
]
=
"200"
;
$result
[
"useropenid"
]
=
$useropenid
;
}
else
{
$result
[
"code"
]
=
"success"
;
$result
[
"message"
]
=
"添加评论失败"
;
$result
[
"status"
]
=
"500"
;
$result
[
"message"
]
=
$message
;
$result
[
"useropenid"
]
=
$useropenid
;
$response
=
rest_ensure_response
(
$result
);
return
$response
;
}
$response
=
rest_ensure_response
(
$result
);
return
$response
;
}
function
get_comments
(
$request
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录