wordpress如何利用wp_delete_comment删除评论,下面web建站小编给大家简单介绍一下具体代码!
wp_delete_comment源码:
function wp_delete_comment( $comment_id, $force_delete = false ) {
global $wpdb;
$comment = get_comment( $comment_id );
if ( ! $comment ) {
return false;
}
if ( ! $force_delete && EMPTY_TRASH_DAYS && ! in_array(
wp_get_comment_status( $comment ), array( 'trash', 'spam' ), true ) ) {
return wp_trash_comment( $comment_id );
}
do_action( 'delete_comment', $comment->comment_ID, $comment );
$children = $wpdb->get_col( $wpdb->prepare(
"SELECT comment_ID FROM $wpdb->comments WHERE comment_parent = %d", $comment->comment_ID ) );
if ( ! empty( $children ) ) {
$wpdb->update( $wpdb->comments, array(
'comment_parent' => $comment->comment_parent ), array( 'comment_parent' => $comment->comment_ID ) );
clean_comment_cache( $children );
}
$meta_ids = $wpdb->get_col( $wpdb->prepare(
"SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d", $comment->comment_ID ) );
foreach ( $meta_ids as $mid ) {
delete_metadata_by_mid( 'comment', $mid );
}
if ( ! $wpdb->delete( $wpdb->comments, array(
'comment_ID' => $comment->comment_ID ) ) ) {
return false;
}
do_action( 'deleted_comment', $comment->comment_ID, $comment );
$post_id = $comment->comment_post_ID;
if ( $post_id && 1 == $comment->comment_approved ) {
wp_update_comment_count( $post_id );
}
clean_comment_cache( $comment->comment_ID );
do_action( 'wp_set_comment_status', $comment->comment_ID, 'delete' );
wp_transition_comment_status(
'delete', $comment->comment_approved, $comment );
return true;
}
wp_delete_comment调用:
wp_delete_comment(27, true); //删除id=27
WordPress版本如何使用str_starts_with和str_ends_with函数
wordpress教程如何输出用于回复评论的隐藏输入html
上面是“wordpress如何利用wp_delete_comment删除评论”的全面内容,想了解更多关于 wordpress 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_3731.html
workflows工作流
一朵在晨光中带着露珠的蓝玫瑰
一个精致透明的朱红色水晶凤凰
沙漠里一只红黑相间的蝎子
图生图生成动漫效果ComfyUI工作流
奇幻绘画风格:一只巨大蜗牛ComfyUI工作流
一个精心制作的微型赛车场ComfyUI工作流
一朵染血的白玫瑰ComfyUI工作流
一只由粉色水晶与羽毛组成的巨型高跟鞋
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

利用html5+css3实现滚雪球效果(附代码)
js实现下雪特效
css3搭积木叠加图形
纯CSS饼图效果
js实现table表格动态新增行和列表
如何利用svg做一个有趣的loading动画加载
利用js做一个炫酷音乐背景效果
做一个好玩的时钟翻牌效果










