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工作流
一辆停在混凝土墙前运动型SUV捷豹概念车
一个全脸彩绘和纹身的超级名模ComfyUI工作流
文生图工作流:树枝上站着一只鸟
一群蜜蜂和一个六边形蜂巢ComfyUI工作流
一个黄色的海绵宝宝ComfyUI工作流
迷人的月光,发光的花朵
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

利用css3做一个动态loading效果
做一个好玩的时钟翻牌效果
自动打字效果(惊喜在后面)
纯html+css做一个3d统计效果
利用CSS3代码编写45款按钮效果
利用js做一个炫酷音乐背景效果
canvas空间文本射线










