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,我们会在看到邮件的第一时间内为您处理!

纯CSS饼图效果
css3做一个风雨雷电天气动态图标
barcode条形码/qrcode二维码兼容所有浏览器(含ie6/ie7/ie8)
css3+js菜单点击动态效果
纯css制作卡通头像(随鼠标转头)
canvas空间文本射线
canvas经线动画走到效果
如何利用css3+js做一个下雨效果











