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工作流
乒乓卡通3d人物
金属埃及人ComfyUI工作流
一只猫捧着一条鱼ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

数字滚动效果(兼容IE6/IE8)
利用html5+css3实现滚雪球效果(附代码)
如何利用svg做一个有趣的loading动画加载
jquery做一个漂亮挂墙动态时钟
jquery鼠标滑过图片边框特效(jquery.focus-follow插件)
3D彩色卡片
css3实现星球旋转
做一个好玩的时钟翻牌效果










