AnsPress_Comment_Hooks::approve_comment()
Description #
Ajax callback to approve comment.
Source #
File: includes/comments.php
public static function approve_comment() { $comment_id = (int) ap_sanitize_unslash( 'comment_id', 'r' ); if ( ! anspress_verify_nonce( 'approve_comment_' . $comment_id ) || ! ap_user_can_approve_comment() ) { ap_ajax_json( array( 'success' => false, 'snackbar' => array( 'message' => __( 'Sorry, unable to approve comment', 'anspress-question-answer' ) ), ) ); } $success = wp_set_comment_status( $comment_id, 'approve' ); $_comment = get_comment( $comment_id ); $count = get_comment_count( $_comment->comment_post_ID ); if ( $success ) { $_comment = get_comment( $comment_id ); ap_ajax_json( array( 'success' => true, 'cb' => 'commentApproved', 'comment_ID' => $comment_id, 'post_ID' => $_comment->comment_post_ID, 'commentsCount' => array( 'text' => sprintf( // translators: %d is comments count. _n( '%d Comment', '%d Comments', $count['all'], 'anspress-question-answer' ), $count['all'] ), 'number' => $count['all'], 'unapproved' => $count['awaiting_moderation'], ), 'snackbar' => array( 'message' => __( 'Comment approved successfully.', 'anspress-question-answer' ) ), ) ); } }
Expand full source code Collapse full source code View on GitHub: includes/comments.php:121
Add your comment