Comment_Delete::logged_in()
Description #
Handle ajax for logged in users.
Source #
File: ajax/comment-delete.php
public function logged_in() {
$comment_id = $this->req( 'comment_id' );
$_comment = get_comment( $comment_id );
// Check if deleting comment is locked.
if ( ap_comment_delete_locked( $_comment->comment_ID ) && ! is_super_admin() ) {
$this->set_fail();
$this->snackbar(
sprintf(
// Translators: %s contain comment created date. i.e. 10 hours.
__( 'The comment is locked and cannot be deleted. Any comments posted before %s cannot be deleted.', 'anspress-question-answer' ),
human_time_diff( ap_get_current_timestamp() + ap_opt( 'disable_delete_after' ) )
)
);
$this->send();
}
$delete = wp_delete_comment( (int) $_comment->comment_ID, true );
if ( $delete ) {
do_action( 'ap_unpublish_comment', $_comment );
do_action( 'ap_after_deleting_comment', $_comment );
$count = get_comment_count( $_comment->comment_post_ID );
$this->set_success();
$this->snackbar( __( 'Comment successfully deleted', 'anspress-question-answer' ) );
$this->add_res( 'cb', 'commentDeleted' );
$this->add_res( 'post_ID', $_comment->comment_post_ID );
$this->add_res(
'commentsCount',
array(
'text' => sprintf(
// Translators: %d contain comment count.
_n( '%d Comment', '%d Comments', $count['all'], 'anspress-question-answer' ),
$count['all']
),
'number' => $count['all'],
'unapproved' => $count['awaiting_moderation'],
)
);
}
}
Expand full source code Collapse full source code View on GitHub: ajax/comment-delete.php:67
Add your comment