comment_exists()
最后更新于:2021-11-25 21:15:08
comment_exists( string$comment_author, string$comment_date, string$timezone=’blog’)Determine if a comment exists based on author and date.
参数
- $comment_author
-
(string) (Required) Author of the comment.
- $comment_date
-
(string) (Required) Date of the comment.
- $timezone
-
(string) (Optional) Timezone. Accepts ‘blog’ or ‘gmt’.
Default value: ‘blog’
响应
(string|null) Comment post ID on success.
源文件
文件: gc-admin/includes/comment.php
function comment_exists( $comment_author, $comment_date, $timezone = 'blog' ) {
global $gcdb;
$date_field = 'comment_date';
if ( 'gmt' === $timezone ) {
$date_field = 'comment_date_gmt';
}
return $gcdb->get_var(
$gcdb->prepare(
"SELECT comment_post_ID FROM $gcdb->comments
WHERE comment_author = %s AND $date_field = %s",
stripslashes( $comment_author ),
stripslashes( $comment_date )
)
);
}