_wp_ajax_delete_comment_response

The timeline below displays how wordpress function _wp_ajax_delete_comment_response has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.5

//
// Ajax helpers.
//
/**
 * Sends back current comment total and new page links if they need to be updated.
 *
 * Contrary to normal success Ajax response ("1"), die with time() on success.
 *
 * @since 2.7.0
 * @access private
 *
 * @param int $comment_id
 * @param int $delta
 */
function _wp_ajax_delete_comment_response($comment_id, $delta = -1)
{
    $total = isset($_POST['_total']) ? (int) $_POST['_total'] : 0;
    $per_page = isset($_POST['_per_page']) ? (int) $_POST['_per_page'] : 0;
    $page = isset($_POST['_page']) ? (int) $_POST['_page'] : 0;
    $url = isset($_POST['_url']) ? sanitize_url($_POST['_url']) : '';
    // JS didn't send us everything we need to know. Just die with success message.
    if (!$total || !$per_page || !$page || !$url) {
        $time = time();
        $comment = get_comment($comment_id);
        $comment_status = '';
        $comment_link = '';
        if ($comment) {
            $comment_status = $comment->comment_approved;
        }
        if (1 === (int) $comment_status) {
            $comment_link = get_comment_link($comment);
        }
        $counts = wp_count_comments();
        $x = new WP_Ajax_Response(array(
            'what' => 'comment',
            // Here for completeness - not used.
            'id' => $comment_id,
            'supplemental' => array('status' => $comment_status, 'postId' => $comment ? $comment->comment_post_ID : '', 'time' => $time, 'in_moderation' => $counts->moderated, 'i18n_comments_text' => sprintf(
                /* translators: %s: Number of comments. */
                _n('%s Comment', '%s Comments', $counts->approved),
                number_format_i18n($counts->approved)
            ), 'i18n_moderation_text' => sprintf(
                /* translators: %s: Number of comments. */
                _n('%s Comment in moderation', '%s Comments in moderation', $counts->moderated),
                number_format_i18n($counts->moderated)
            ), 'comment_link' => $comment_link),
        ));
        $x->send();
    }
    $total += $delta;
    if ($total < 0) {
        $total = 0;
    }
    // Only do the expensive stuff on a page-break, and about 1 other time per page.
    if (0 == $total % $per_page || 1 == mt_rand(1, $per_page)) {
        $post_id = 0;
        // What type of comment count are we looking for?
        $status = 'all';
        $parsed = parse_url($url);
        if (isset($parsed['query'])) {
            parse_str($parsed['query'], $query_vars);
            if (!empty($query_vars['comment_status'])) {
                $status = $query_vars['comment_status'];
            }
            if (!empty($query_vars['p'])) {
                $post_id = (int) $query_vars['p'];
            }
            if (!empty($query_vars['comment_type'])) {
                $type = $query_vars['comment_type'];
            }
        }
        if (empty($type)) {
            // Only use the comment count if not filtering by a comment_type.
            $comment_count = wp_count_comments($post_id);
            // We're looking for a known type of comment count.
            if (isset($comment_count->{$status})) {
                $total = $comment_count->{$status};
            }
        }
        // Else use the decremented value from above.
    }
    // The time since the last comment count.
    $time = time();
    $comment = get_comment($comment_id);
    $counts = wp_count_comments();
    $x = new WP_Ajax_Response(array('what' => 'comment', 'id' => $comment_id, 'supplemental' => array(
        'status' => $comment ? $comment->comment_approved : '',
        'postId' => $comment ? $comment->comment_post_ID : '',
        /* translators: %s: Number of comments. */
        'total_items_i18n' => sprintf(_n('%s item', '%s items', $total), number_format_i18n($total)),
        'total_pages' => (int) ceil($total / $per_page),
        'total_pages_i18n' => number_format_i18n((int) ceil($total / $per_page)),
        'total' => $total,
        'time' => $time,
        'in_moderation' => $counts->moderated,
        'i18n_moderation_text' => sprintf(
            /* translators: %s: Number of comments. */
            _n('%s Comment in moderation', '%s Comments in moderation', $counts->moderated),
            number_format_i18n($counts->moderated)
        ),
    )));
    $x->send();
}

WordPress Version: 6.1

//
// Ajax helpers.
//
/**
 * Sends back current comment total and new page links if they need to be updated.
 *
 * Contrary to normal success Ajax response ("1"), die with time() on success.
 *
 * @since 2.7.0
 * @access private
 *
 * @param int $comment_id
 * @param int $delta
 */
function _wp_ajax_delete_comment_response($comment_id, $delta = -1)
{
    $total = isset($_POST['_total']) ? (int) $_POST['_total'] : 0;
    $per_page = isset($_POST['_per_page']) ? (int) $_POST['_per_page'] : 0;
    $page = isset($_POST['_page']) ? (int) $_POST['_page'] : 0;
    $url = isset($_POST['_url']) ? sanitize_url($_POST['_url']) : '';
    // JS didn't send us everything we need to know. Just die with success message.
    if (!$total || !$per_page || !$page || !$url) {
        $time = time();
        $comment = get_comment($comment_id);
        $comment_status = '';
        $comment_link = '';
        if ($comment) {
            $comment_status = $comment->comment_approved;
        }
        if (1 === (int) $comment_status) {
            $comment_link = get_comment_link($comment);
        }
        $counts = wp_count_comments();
        $x = new WP_Ajax_Response(array(
            'what' => 'comment',
            // Here for completeness - not used.
            'id' => $comment_id,
            'supplemental' => array('status' => $comment_status, 'postId' => $comment ? $comment->comment_post_ID : '', 'time' => $time, 'in_moderation' => $counts->moderated, 'i18n_comments_text' => sprintf(
                /* translators: %s: Number of comments. */
                _n('%s Comment', '%s Comments', $counts->approved),
                number_format_i18n($counts->approved)
            ), 'i18n_moderation_text' => sprintf(
                /* translators: %s: Number of comments. */
                _n('%s Comment in moderation', '%s Comments in moderation', $counts->moderated),
                number_format_i18n($counts->moderated)
            ), 'comment_link' => $comment_link),
        ));
        $x->send();
    }
    $total += $delta;
    if ($total < 0) {
        $total = 0;
    }
    // Only do the expensive stuff on a page-break, and about 1 other time per page.
    if (0 == $total % $per_page || 1 == mt_rand(1, $per_page)) {
        $post_id = 0;
        // What type of comment count are we looking for?
        $status = 'all';
        $parsed = parse_url($url);
        if (isset($parsed['query'])) {
            parse_str($parsed['query'], $query_vars);
            if (!empty($query_vars['comment_status'])) {
                $status = $query_vars['comment_status'];
            }
            if (!empty($query_vars['p'])) {
                $post_id = (int) $query_vars['p'];
            }
            if (!empty($query_vars['comment_type'])) {
                $type = $query_vars['comment_type'];
            }
        }
        if (empty($type)) {
            // Only use the comment count if not filtering by a comment_type.
            $comment_count = wp_count_comments($post_id);
            // We're looking for a known type of comment count.
            if (isset($comment_count->{$status})) {
                $total = $comment_count->{$status};
            }
        }
        // Else use the decremented value from above.
    }
    // The time since the last comment count.
    $time = time();
    $comment = get_comment($comment_id);
    $counts = wp_count_comments();
    $x = new WP_Ajax_Response(array('what' => 'comment', 'id' => $comment_id, 'supplemental' => array(
        'status' => $comment ? $comment->comment_approved : '',
        'postId' => $comment ? $comment->comment_post_ID : '',
        /* translators: %s: Number of comments. */
        'total_items_i18n' => sprintf(_n('%s item', '%s items', $total), number_format_i18n($total)),
        'total_pages' => ceil($total / $per_page),
        'total_pages_i18n' => number_format_i18n(ceil($total / $per_page)),
        'total' => $total,
        'time' => $time,
        'in_moderation' => $counts->moderated,
        'i18n_moderation_text' => sprintf(
            /* translators: %s: Number of comments. */
            _n('%s Comment in moderation', '%s Comments in moderation', $counts->moderated),
            number_format_i18n($counts->moderated)
        ),
    )));
    $x->send();
}

WordPress Version: 5.5

//
// Ajax helpers.
//
/**
 * Sends back current comment total and new page links if they need to be updated.
 *
 * Contrary to normal success Ajax response ("1"), die with time() on success.
 *
 * @since 2.7.0
 * @access private
 *
 * @param int $comment_id
 * @param int $delta
 */
function _wp_ajax_delete_comment_response($comment_id, $delta = -1)
{
    $total = isset($_POST['_total']) ? (int) $_POST['_total'] : 0;
    $per_page = isset($_POST['_per_page']) ? (int) $_POST['_per_page'] : 0;
    $page = isset($_POST['_page']) ? (int) $_POST['_page'] : 0;
    $url = isset($_POST['_url']) ? esc_url_raw($_POST['_url']) : '';
    // JS didn't send us everything we need to know. Just die with success message.
    if (!$total || !$per_page || !$page || !$url) {
        $time = time();
        $comment = get_comment($comment_id);
        $comment_status = '';
        $comment_link = '';
        if ($comment) {
            $comment_status = $comment->comment_approved;
        }
        if (1 === (int) $comment_status) {
            $comment_link = get_comment_link($comment);
        }
        $counts = wp_count_comments();
        $x = new WP_Ajax_Response(array(
            'what' => 'comment',
            // Here for completeness - not used.
            'id' => $comment_id,
            'supplemental' => array('status' => $comment_status, 'postId' => $comment ? $comment->comment_post_ID : '', 'time' => $time, 'in_moderation' => $counts->moderated, 'i18n_comments_text' => sprintf(
                /* translators: %s: Number of comments. */
                _n('%s Comment', '%s Comments', $counts->approved),
                number_format_i18n($counts->approved)
            ), 'i18n_moderation_text' => sprintf(
                /* translators: %s: Number of comments. */
                _n('%s Comment in moderation', '%s Comments in moderation', $counts->moderated),
                number_format_i18n($counts->moderated)
            ), 'comment_link' => $comment_link),
        ));
        $x->send();
    }
    $total += $delta;
    if ($total < 0) {
        $total = 0;
    }
    // Only do the expensive stuff on a page-break, and about 1 other time per page.
    if (0 == $total % $per_page || 1 == mt_rand(1, $per_page)) {
        $post_id = 0;
        // What type of comment count are we looking for?
        $status = 'all';
        $parsed = parse_url($url);
        if (isset($parsed['query'])) {
            parse_str($parsed['query'], $query_vars);
            if (!empty($query_vars['comment_status'])) {
                $status = $query_vars['comment_status'];
            }
            if (!empty($query_vars['p'])) {
                $post_id = (int) $query_vars['p'];
            }
            if (!empty($query_vars['comment_type'])) {
                $type = $query_vars['comment_type'];
            }
        }
        if (empty($type)) {
            // Only use the comment count if not filtering by a comment_type.
            $comment_count = wp_count_comments($post_id);
            // We're looking for a known type of comment count.
            if (isset($comment_count->{$status})) {
                $total = $comment_count->{$status};
            }
        }
        // Else use the decremented value from above.
    }
    // The time since the last comment count.
    $time = time();
    $comment = get_comment($comment_id);
    $counts = wp_count_comments();
    $x = new WP_Ajax_Response(array('what' => 'comment', 'id' => $comment_id, 'supplemental' => array(
        'status' => $comment ? $comment->comment_approved : '',
        'postId' => $comment ? $comment->comment_post_ID : '',
        /* translators: %s: Number of comments. */
        'total_items_i18n' => sprintf(_n('%s item', '%s items', $total), number_format_i18n($total)),
        'total_pages' => ceil($total / $per_page),
        'total_pages_i18n' => number_format_i18n(ceil($total / $per_page)),
        'total' => $total,
        'time' => $time,
        'in_moderation' => $counts->moderated,
        'i18n_moderation_text' => sprintf(
            /* translators: %s: Number of comments. */
            _n('%s Comment in moderation', '%s Comments in moderation', $counts->moderated),
            number_format_i18n($counts->moderated)
        ),
    )));
    $x->send();
}

WordPress Version: 5.4

//
// Ajax helpers.
//
/**
 * Sends back current comment total and new page links if they need to be updated.
 *
 * Contrary to normal success Ajax response ("1"), die with time() on success.
 *
 * @access private
 * @since 2.7.0
 *
 * @param int $comment_id
 * @param int $delta
 */
function _wp_ajax_delete_comment_response($comment_id, $delta = -1)
{
    $total = isset($_POST['_total']) ? (int) $_POST['_total'] : 0;
    $per_page = isset($_POST['_per_page']) ? (int) $_POST['_per_page'] : 0;
    $page = isset($_POST['_page']) ? (int) $_POST['_page'] : 0;
    $url = isset($_POST['_url']) ? esc_url_raw($_POST['_url']) : '';
    // JS didn't send us everything we need to know. Just die with success message.
    if (!$total || !$per_page || !$page || !$url) {
        $time = time();
        $comment = get_comment($comment_id);
        $comment_status = '';
        $comment_link = '';
        if ($comment) {
            $comment_status = $comment->comment_approved;
        }
        if (1 === (int) $comment_status) {
            $comment_link = get_comment_link($comment);
        }
        $counts = wp_count_comments();
        $x = new WP_Ajax_Response(array(
            'what' => 'comment',
            // Here for completeness - not used.
            'id' => $comment_id,
            'supplemental' => array('status' => $comment_status, 'postId' => $comment ? $comment->comment_post_ID : '', 'time' => $time, 'in_moderation' => $counts->moderated, 'i18n_comments_text' => sprintf(
                /* translators: %s: Number of comments. */
                _n('%s Comment', '%s Comments', $counts->approved),
                number_format_i18n($counts->approved)
            ), 'i18n_moderation_text' => sprintf(
                /* translators: %s: Number of comments. */
                _n('%s Comment in moderation', '%s Comments in moderation', $counts->moderated),
                number_format_i18n($counts->moderated)
            ), 'comment_link' => $comment_link),
        ));
        $x->send();
    }
    $total += $delta;
    if ($total < 0) {
        $total = 0;
    }
    // Only do the expensive stuff on a page-break, and about 1 other time per page.
    if (0 == $total % $per_page || 1 == mt_rand(1, $per_page)) {
        $post_id = 0;
        // What type of comment count are we looking for?
        $status = 'all';
        $parsed = parse_url($url);
        if (isset($parsed['query'])) {
            parse_str($parsed['query'], $query_vars);
            if (!empty($query_vars['comment_status'])) {
                $status = $query_vars['comment_status'];
            }
            if (!empty($query_vars['p'])) {
                $post_id = (int) $query_vars['p'];
            }
            if (!empty($query_vars['comment_type'])) {
                $type = $query_vars['comment_type'];
            }
        }
        if (empty($type)) {
            // Only use the comment count if not filtering by a comment_type.
            $comment_count = wp_count_comments($post_id);
            // We're looking for a known type of comment count.
            if (isset($comment_count->{$status})) {
                $total = $comment_count->{$status};
            }
        }
        // Else use the decremented value from above.
    }
    // The time since the last comment count.
    $time = time();
    $comment = get_comment($comment_id);
    $counts = wp_count_comments();
    $x = new WP_Ajax_Response(array('what' => 'comment', 'id' => $comment_id, 'supplemental' => array(
        'status' => $comment ? $comment->comment_approved : '',
        'postId' => $comment ? $comment->comment_post_ID : '',
        /* translators: %s: Number of comments. */
        'total_items_i18n' => sprintf(_n('%s item', '%s items', $total), number_format_i18n($total)),
        'total_pages' => ceil($total / $per_page),
        'total_pages_i18n' => number_format_i18n(ceil($total / $per_page)),
        'total' => $total,
        'time' => $time,
        'in_moderation' => $counts->moderated,
        'i18n_moderation_text' => sprintf(
            /* translators: %s: Number of comments. */
            _n('%s Comment in moderation', '%s Comments in moderation', $counts->moderated),
            number_format_i18n($counts->moderated)
        ),
    )));
    $x->send();
}

WordPress Version: 5.3

//
// Ajax helpers.
//
/**
 * Sends back current comment total and new page links if they need to be updated.
 *
 * Contrary to normal success Ajax response ("1"), die with time() on success.
 *
 * @access private
 * @since 2.7.0
 *
 * @param int $comment_id
 * @param int $delta
 */
function _wp_ajax_delete_comment_response($comment_id, $delta = -1)
{
    $total = isset($_POST['_total']) ? (int) $_POST['_total'] : 0;
    $per_page = isset($_POST['_per_page']) ? (int) $_POST['_per_page'] : 0;
    $page = isset($_POST['_page']) ? (int) $_POST['_page'] : 0;
    $url = isset($_POST['_url']) ? esc_url_raw($_POST['_url']) : '';
    // JS didn't send us everything we need to know. Just die with success message
    if (!$total || !$per_page || !$page || !$url) {
        $time = time();
        $comment = get_comment($comment_id);
        $comment_status = '';
        $comment_link = '';
        if ($comment) {
            $comment_status = $comment->comment_approved;
        }
        if (1 === (int) $comment_status) {
            $comment_link = get_comment_link($comment);
        }
        $counts = wp_count_comments();
        $x = new WP_Ajax_Response(array(
            'what' => 'comment',
            // Here for completeness - not used.
            'id' => $comment_id,
            'supplemental' => array('status' => $comment_status, 'postId' => $comment ? $comment->comment_post_ID : '', 'time' => $time, 'in_moderation' => $counts->moderated, 'i18n_comments_text' => sprintf(
                /* translators: %s: Number of comments. */
                _n('%s Comment', '%s Comments', $counts->approved),
                number_format_i18n($counts->approved)
            ), 'i18n_moderation_text' => sprintf(
                /* translators: %s: Number of comments. */
                _n('%s Comment in moderation', '%s Comments in moderation', $counts->moderated),
                number_format_i18n($counts->moderated)
            ), 'comment_link' => $comment_link),
        ));
        $x->send();
    }
    $total += $delta;
    if ($total < 0) {
        $total = 0;
    }
    // Only do the expensive stuff on a page-break, and about 1 other time per page
    if (0 == $total % $per_page || 1 == mt_rand(1, $per_page)) {
        $post_id = 0;
        // What type of comment count are we looking for?
        $status = 'all';
        $parsed = parse_url($url);
        if (isset($parsed['query'])) {
            parse_str($parsed['query'], $query_vars);
            if (!empty($query_vars['comment_status'])) {
                $status = $query_vars['comment_status'];
            }
            if (!empty($query_vars['p'])) {
                $post_id = (int) $query_vars['p'];
            }
            if (!empty($query_vars['comment_type'])) {
                $type = $query_vars['comment_type'];
            }
        }
        if (empty($type)) {
            // Only use the comment count if not filtering by a comment_type.
            $comment_count = wp_count_comments($post_id);
            // We're looking for a known type of comment count.
            if (isset($comment_count->{$status})) {
                $total = $comment_count->{$status};
            }
        }
        // Else use the decremented value from above.
    }
    // The time since the last comment count.
    $time = time();
    $comment = get_comment($comment_id);
    $counts = wp_count_comments();
    $x = new WP_Ajax_Response(array('what' => 'comment', 'id' => $comment_id, 'supplemental' => array(
        'status' => $comment ? $comment->comment_approved : '',
        'postId' => $comment ? $comment->comment_post_ID : '',
        /* translators: %s: Number of comments. */
        'total_items_i18n' => sprintf(_n('%s item', '%s items', $total), number_format_i18n($total)),
        'total_pages' => ceil($total / $per_page),
        'total_pages_i18n' => number_format_i18n(ceil($total / $per_page)),
        'total' => $total,
        'time' => $time,
        'in_moderation' => $counts->moderated,
        'i18n_moderation_text' => sprintf(
            /* translators: %s: Number of comments. */
            _n('%s Comment in moderation', '%s Comments in moderation', $counts->moderated),
            number_format_i18n($counts->moderated)
        ),
    )));
    $x->send();
}

WordPress Version: 5.2

//
// Ajax helpers.
//
/**
 * Sends back current comment total and new page links if they need to be updated.
 *
 * Contrary to normal success Ajax response ("1"), die with time() on success.
 *
 * @access private
 * @since 2.7.0
 *
 * @param int $comment_id
 * @param int $delta
 */
function _wp_ajax_delete_comment_response($comment_id, $delta = -1)
{
    $total = isset($_POST['_total']) ? (int) $_POST['_total'] : 0;
    $per_page = isset($_POST['_per_page']) ? (int) $_POST['_per_page'] : 0;
    $page = isset($_POST['_page']) ? (int) $_POST['_page'] : 0;
    $url = isset($_POST['_url']) ? esc_url_raw($_POST['_url']) : '';
    // JS didn't send us everything we need to know. Just die with success message
    if (!$total || !$per_page || !$page || !$url) {
        $time = time();
        $comment = get_comment($comment_id);
        $comment_status = '';
        $comment_link = '';
        if ($comment) {
            $comment_status = $comment->comment_approved;
        }
        if (1 === (int) $comment_status) {
            $comment_link = get_comment_link($comment);
        }
        $counts = wp_count_comments();
        $x = new WP_Ajax_Response(array(
            'what' => 'comment',
            // Here for completeness - not used.
            'id' => $comment_id,
            'supplemental' => array('status' => $comment_status, 'postId' => $comment ? $comment->comment_post_ID : '', 'time' => $time, 'in_moderation' => $counts->moderated, 'i18n_comments_text' => sprintf(
                /* translators: %s: number of comments approved */
                _n('%s Comment', '%s Comments', $counts->approved),
                number_format_i18n($counts->approved)
            ), 'i18n_moderation_text' => sprintf(
                /* translators: %s: number of comments in moderation */
                _n('%s Comment in moderation', '%s Comments in moderation', $counts->moderated),
                number_format_i18n($counts->moderated)
            ), 'comment_link' => $comment_link),
        ));
        $x->send();
    }
    $total += $delta;
    if ($total < 0) {
        $total = 0;
    }
    // Only do the expensive stuff on a page-break, and about 1 other time per page
    if (0 == $total % $per_page || 1 == mt_rand(1, $per_page)) {
        $post_id = 0;
        // What type of comment count are we looking for?
        $status = 'all';
        $parsed = parse_url($url);
        if (isset($parsed['query'])) {
            parse_str($parsed['query'], $query_vars);
            if (!empty($query_vars['comment_status'])) {
                $status = $query_vars['comment_status'];
            }
            if (!empty($query_vars['p'])) {
                $post_id = (int) $query_vars['p'];
            }
            if (!empty($query_vars['comment_type'])) {
                $type = $query_vars['comment_type'];
            }
        }
        if (empty($type)) {
            // Only use the comment count if not filtering by a comment_type.
            $comment_count = wp_count_comments($post_id);
            // We're looking for a known type of comment count.
            if (isset($comment_count->{$status})) {
                $total = $comment_count->{$status};
            }
        }
        // Else use the decremented value from above.
    }
    // The time since the last comment count.
    $time = time();
    $comment = get_comment($comment_id);
    $counts = wp_count_comments();
    $x = new WP_Ajax_Response(array('what' => 'comment', 'id' => $comment_id, 'supplemental' => array(
        'status' => $comment ? $comment->comment_approved : '',
        'postId' => $comment ? $comment->comment_post_ID : '',
        /* translators: %s: number of comments */
        'total_items_i18n' => sprintf(_n('%s item', '%s items', $total), number_format_i18n($total)),
        'total_pages' => ceil($total / $per_page),
        'total_pages_i18n' => number_format_i18n(ceil($total / $per_page)),
        'total' => $total,
        'time' => $time,
        'in_moderation' => $counts->moderated,
        'i18n_moderation_text' => sprintf(
            /* translators: %s: number of comments in moderation */
            _n('%s Comment in moderation', '%s Comments in moderation', $counts->moderated),
            number_format_i18n($counts->moderated)
        ),
    )));
    $x->send();
}

WordPress Version: 5.1

//
// Ajax helpers.
//
/**
 * Sends back current comment total and new page links if they need to be updated.
 *
 * Contrary to normal success Ajax response ("1"), die with time() on success.
 *
 * @access private
 * @since 2.7.0
 *
 * @param int $comment_id
 * @param int $delta
 */
function _wp_ajax_delete_comment_response($comment_id, $delta = -1)
{
    $total = isset($_POST['_total']) ? (int) $_POST['_total'] : 0;
    $per_page = isset($_POST['_per_page']) ? (int) $_POST['_per_page'] : 0;
    $page = isset($_POST['_page']) ? (int) $_POST['_page'] : 0;
    $url = isset($_POST['_url']) ? esc_url_raw($_POST['_url']) : '';
    // JS didn't send us everything we need to know. Just die with success message
    if (!$total || !$per_page || !$page || !$url) {
        $time = time();
        $comment = get_comment($comment_id);
        $comment_status = '';
        $comment_link = '';
        if ($comment) {
            $comment_status = $comment->comment_approved;
        }
        if (1 === (int) $comment_status) {
            $comment_link = get_comment_link($comment);
        }
        $counts = wp_count_comments();
        $x = new WP_Ajax_Response(array(
            'what' => 'comment',
            // Here for completeness - not used.
            'id' => $comment_id,
            'supplemental' => array('status' => $comment_status, 'postId' => $comment ? $comment->comment_post_ID : '', 'time' => $time, 'in_moderation' => $counts->moderated, 'i18n_comments_text' => sprintf(
                /* translators: %s: number of comments approved */
                _n('%s Comment', '%s Comments', $counts->approved),
                number_format_i18n($counts->approved)
            ), 'i18n_moderation_text' => sprintf(
                /* translators: %s: number of comments in moderation */
                _nx('%s in moderation', '%s in moderation', $counts->moderated, 'comments'),
                number_format_i18n($counts->moderated)
            ), 'comment_link' => $comment_link),
        ));
        $x->send();
    }
    $total += $delta;
    if ($total < 0) {
        $total = 0;
    }
    // Only do the expensive stuff on a page-break, and about 1 other time per page
    if (0 == $total % $per_page || 1 == mt_rand(1, $per_page)) {
        $post_id = 0;
        // What type of comment count are we looking for?
        $status = 'all';
        $parsed = parse_url($url);
        if (isset($parsed['query'])) {
            parse_str($parsed['query'], $query_vars);
            if (!empty($query_vars['comment_status'])) {
                $status = $query_vars['comment_status'];
            }
            if (!empty($query_vars['p'])) {
                $post_id = (int) $query_vars['p'];
            }
            if (!empty($query_vars['comment_type'])) {
                $type = $query_vars['comment_type'];
            }
        }
        if (empty($type)) {
            // Only use the comment count if not filtering by a comment_type.
            $comment_count = wp_count_comments($post_id);
            // We're looking for a known type of comment count.
            if (isset($comment_count->{$status})) {
                $total = $comment_count->{$status};
            }
        }
        // Else use the decremented value from above.
    }
    // The time since the last comment count.
    $time = time();
    $comment = get_comment($comment_id);
    $x = new WP_Ajax_Response(array(
        'what' => 'comment',
        // Here for completeness - not used.
        'id' => $comment_id,
        'supplemental' => array(
            'status' => $comment ? $comment->comment_approved : '',
            'postId' => $comment ? $comment->comment_post_ID : '',
            /* translators: %s: number of comments */
            'total_items_i18n' => sprintf(_n('%s item', '%s items', $total), number_format_i18n($total)),
            'total_pages' => ceil($total / $per_page),
            'total_pages_i18n' => number_format_i18n(ceil($total / $per_page)),
            'total' => $total,
            'time' => $time,
        ),
    ));
    $x->send();
}

WordPress Version: 4.6

//
// Ajax helpers.
//
/**
 * Sends back current comment total and new page links if they need to be updated.
 *
 * Contrary to normal success Ajax response ("1"), die with time() on success.
 *
 * @access private
 * @since 2.7.0
 *
 * @param int $comment_id
 * @param int $delta
 */
function _wp_ajax_delete_comment_response($comment_id, $delta = -1)
{
    $total = isset($_POST['_total']) ? (int) $_POST['_total'] : 0;
    $per_page = isset($_POST['_per_page']) ? (int) $_POST['_per_page'] : 0;
    $page = isset($_POST['_page']) ? (int) $_POST['_page'] : 0;
    $url = isset($_POST['_url']) ? esc_url_raw($_POST['_url']) : '';
    // JS didn't send us everything we need to know. Just die with success message
    if (!$total || !$per_page || !$page || !$url) {
        $time = time();
        $comment = get_comment($comment_id);
        $comment_status = '';
        $comment_link = '';
        if ($comment) {
            $comment_status = $comment->comment_approved;
        }
        if (1 === (int) $comment_status) {
            $comment_link = get_comment_link($comment);
        }
        $counts = wp_count_comments();
        $x = new WP_Ajax_Response(array(
            'what' => 'comment',
            // Here for completeness - not used.
            'id' => $comment_id,
            'supplemental' => array('status' => $comment_status, 'postId' => $comment ? $comment->comment_post_ID : '', 'time' => $time, 'in_moderation' => $counts->moderated, 'i18n_comments_text' => sprintf(_n('%s Comment', '%s Comments', $counts->approved), number_format_i18n($counts->approved)), 'i18n_moderation_text' => sprintf(_nx('%s in moderation', '%s in moderation', $counts->moderated, 'comments'), number_format_i18n($counts->moderated)), 'comment_link' => $comment_link),
        ));
        $x->send();
    }
    $total += $delta;
    if ($total < 0) {
        $total = 0;
    }
    // Only do the expensive stuff on a page-break, and about 1 other time per page
    if (0 == $total % $per_page || 1 == mt_rand(1, $per_page)) {
        $post_id = 0;
        // What type of comment count are we looking for?
        $status = 'all';
        $parsed = parse_url($url);
        if (isset($parsed['query'])) {
            parse_str($parsed['query'], $query_vars);
            if (!empty($query_vars['comment_status'])) {
                $status = $query_vars['comment_status'];
            }
            if (!empty($query_vars['p'])) {
                $post_id = (int) $query_vars['p'];
            }
            if (!empty($query_vars['comment_type'])) {
                $type = $query_vars['comment_type'];
            }
        }
        if (empty($type)) {
            // Only use the comment count if not filtering by a comment_type.
            $comment_count = wp_count_comments($post_id);
            // We're looking for a known type of comment count.
            if (isset($comment_count->{$status})) {
                $total = $comment_count->{$status};
            }
        }
        // Else use the decremented value from above.
    }
    // The time since the last comment count.
    $time = time();
    $comment = get_comment($comment_id);
    $x = new WP_Ajax_Response(array(
        'what' => 'comment',
        // Here for completeness - not used.
        'id' => $comment_id,
        'supplemental' => array('status' => $comment ? $comment->comment_approved : '', 'postId' => $comment ? $comment->comment_post_ID : '', 'total_items_i18n' => sprintf(_n('%s item', '%s items', $total), number_format_i18n($total)), 'total_pages' => ceil($total / $per_page), 'total_pages_i18n' => number_format_i18n(ceil($total / $per_page)), 'total' => $total, 'time' => $time),
    ));
    $x->send();
}

WordPress Version: 4.5

//
// Ajax helpers.
//
/**
 * Sends back current comment total and new page links if they need to be updated.
 *
 * Contrary to normal success AJAX response ("1"), die with time() on success.
 *
 * @access private
 * @since 2.7.0
 *
 * @param int $comment_id
 * @param int $delta
 */
function _wp_ajax_delete_comment_response($comment_id, $delta = -1)
{
    $total = isset($_POST['_total']) ? (int) $_POST['_total'] : 0;
    $per_page = isset($_POST['_per_page']) ? (int) $_POST['_per_page'] : 0;
    $page = isset($_POST['_page']) ? (int) $_POST['_page'] : 0;
    $url = isset($_POST['_url']) ? esc_url_raw($_POST['_url']) : '';
    // JS didn't send us everything we need to know. Just die with success message
    if (!$total || !$per_page || !$page || !$url) {
        $time = time();
        $comment = get_comment($comment_id);
        $counts = wp_count_comments();
        $x = new WP_Ajax_Response(array(
            'what' => 'comment',
            // Here for completeness - not used.
            'id' => $comment_id,
            'supplemental' => array('status' => $comment ? $comment->comment_approved : '', 'postId' => $comment ? $comment->comment_post_ID : '', 'time' => $time, 'in_moderation' => $counts->moderated, 'i18n_comments_text' => sprintf(_n('%s Comment', '%s Comments', $counts->approved), number_format_i18n($counts->approved)), 'i18n_moderation_text' => sprintf(_nx('%s in moderation', '%s in moderation', $counts->moderated, 'comments'), number_format_i18n($counts->moderated))),
        ));
        $x->send();
    }
    $total += $delta;
    if ($total < 0) {
        $total = 0;
    }
    // Only do the expensive stuff on a page-break, and about 1 other time per page
    if (0 == $total % $per_page || 1 == mt_rand(1, $per_page)) {
        $post_id = 0;
        // What type of comment count are we looking for?
        $status = 'all';
        $parsed = parse_url($url);
        if (isset($parsed['query'])) {
            parse_str($parsed['query'], $query_vars);
            if (!empty($query_vars['comment_status'])) {
                $status = $query_vars['comment_status'];
            }
            if (!empty($query_vars['p'])) {
                $post_id = (int) $query_vars['p'];
            }
        }
        $comment_count = wp_count_comments($post_id);
        // We're looking for a known type of comment count.
        if (isset($comment_count->{$status})) {
            $total = $comment_count->{$status};
        }
        // Else use the decremented value from above.
    }
    // The time since the last comment count.
    $time = time();
    $comment = get_comment($comment_id);
    $x = new WP_Ajax_Response(array(
        'what' => 'comment',
        // Here for completeness - not used.
        'id' => $comment_id,
        'supplemental' => array('status' => $comment ? $comment->comment_approved : '', 'postId' => $comment ? $comment->comment_post_ID : '', 'total_items_i18n' => sprintf(_n('%s item', '%s items', $total), number_format_i18n($total)), 'total_pages' => ceil($total / $per_page), 'total_pages_i18n' => number_format_i18n(ceil($total / $per_page)), 'total' => $total, 'time' => $time),
    ));
    $x->send();
}

WordPress Version: 4.4

//
// Ajax helpers.
//
/**
 * Sends back current comment total and new page links if they need to be updated.
 *
 * Contrary to normal success AJAX response ("1"), die with time() on success.
 *
 * @since 2.7.0
 *
 * @param int $comment_id
 * @param int $delta
 */
function _wp_ajax_delete_comment_response($comment_id, $delta = -1)
{
    $total = isset($_POST['_total']) ? (int) $_POST['_total'] : 0;
    $per_page = isset($_POST['_per_page']) ? (int) $_POST['_per_page'] : 0;
    $page = isset($_POST['_page']) ? (int) $_POST['_page'] : 0;
    $url = isset($_POST['_url']) ? esc_url_raw($_POST['_url']) : '';
    // JS didn't send us everything we need to know. Just die with success message
    if (!$total || !$per_page || !$page || !$url) {
        $time = time();
        $comment = get_comment($comment_id);
        $counts = wp_count_comments();
        $x = new WP_Ajax_Response(array(
            'what' => 'comment',
            // Here for completeness - not used.
            'id' => $comment_id,
            'supplemental' => array('status' => $comment ? $comment->comment_approved : '', 'postId' => $comment ? $comment->comment_post_ID : '', 'time' => $time, 'in_moderation' => $counts->moderated, 'i18n_comments_text' => sprintf(_n('%s Comment', '%s Comments', $counts->approved), number_format_i18n($counts->approved)), 'i18n_moderation_text' => sprintf(_nx('%s in moderation', '%s in moderation', $counts->moderated, 'comments'), number_format_i18n($counts->moderated))),
        ));
        $x->send();
    }
    $total += $delta;
    if ($total < 0) {
        $total = 0;
    }
    // Only do the expensive stuff on a page-break, and about 1 other time per page
    if (0 == $total % $per_page || 1 == mt_rand(1, $per_page)) {
        $post_id = 0;
        // What type of comment count are we looking for?
        $status = 'all';
        $parsed = parse_url($url);
        if (isset($parsed['query'])) {
            parse_str($parsed['query'], $query_vars);
            if (!empty($query_vars['comment_status'])) {
                $status = $query_vars['comment_status'];
            }
            if (!empty($query_vars['p'])) {
                $post_id = (int) $query_vars['p'];
            }
        }
        $comment_count = wp_count_comments($post_id);
        // We're looking for a known type of comment count.
        if (isset($comment_count->{$status})) {
            $total = $comment_count->{$status};
        }
        // Else use the decremented value from above.
    }
    // The time since the last comment count.
    $time = time();
    $comment = get_comment($comment_id);
    $x = new WP_Ajax_Response(array(
        'what' => 'comment',
        // Here for completeness - not used.
        'id' => $comment_id,
        'supplemental' => array('status' => $comment ? $comment->comment_approved : '', 'postId' => $comment ? $comment->comment_post_ID : '', 'total_items_i18n' => sprintf(_n('%s item', '%s items', $total), number_format_i18n($total)), 'total_pages' => ceil($total / $per_page), 'total_pages_i18n' => number_format_i18n(ceil($total / $per_page)), 'total' => $total, 'time' => $time),
    ));
    $x->send();
}

WordPress Version: 4.3

//
// Ajax helpers.
//
/**
 * Sends back current comment total and new page links if they need to be updated.
 *
 * Contrary to normal success AJAX response ("1"), die with time() on success.
 *
 * @since 2.7.0
 *
 * @param int $comment_id
 * @param int $delta
 */
function _wp_ajax_delete_comment_response($comment_id, $delta = -1)
{
    $total = isset($_POST['_total']) ? (int) $_POST['_total'] : 0;
    $per_page = isset($_POST['_per_page']) ? (int) $_POST['_per_page'] : 0;
    $page = isset($_POST['_page']) ? (int) $_POST['_page'] : 0;
    $url = isset($_POST['_url']) ? esc_url_raw($_POST['_url']) : '';
    // JS didn't send us everything we need to know. Just die with success message
    if (!$total || !$per_page || !$page || !$url) {
        wp_die(time());
    }
    $total += $delta;
    if ($total < 0) {
        $total = 0;
    }
    // Only do the expensive stuff on a page-break, and about 1 other time per page
    if (0 == $total % $per_page || 1 == mt_rand(1, $per_page)) {
        $post_id = 0;
        $status = 'total_comments';
        // What type of comment count are we looking for?
        $parsed = parse_url($url);
        if (isset($parsed['query'])) {
            parse_str($parsed['query'], $query_vars);
            if (!empty($query_vars['comment_status'])) {
                $status = $query_vars['comment_status'];
            }
            if (!empty($query_vars['p'])) {
                $post_id = (int) $query_vars['p'];
            }
        }
        $comment_count = wp_count_comments($post_id);
        // We're looking for a known type of comment count.
        if (isset($comment_count->{$status})) {
            $total = $comment_count->{$status};
        }
        // Else use the decremented value from above.
    }
    // The time since the last comment count.
    $time = time();
    $x = new WP_Ajax_Response(array(
        'what' => 'comment',
        // Here for completeness - not used.
        'id' => $comment_id,
        'supplemental' => array('total_items_i18n' => sprintf(_n('%s item', '%s items', $total), number_format_i18n($total)), 'total_pages' => ceil($total / $per_page), 'total_pages_i18n' => number_format_i18n(ceil($total / $per_page)), 'total' => $total, 'time' => $time),
    ));
    $x->send();
}

WordPress Version: 4.2

//
// Ajax helpers.
//
/**
 * Sends back current comment total and new page links if they need to be updated.
 *
 * Contrary to normal success AJAX response ("1"), die with time() on success.
 *
 * @since 2.7.0
 *
 * @param int $comment_id
 * @return die
 */
function _wp_ajax_delete_comment_response($comment_id, $delta = -1)
{
    $total = isset($_POST['_total']) ? (int) $_POST['_total'] : 0;
    $per_page = isset($_POST['_per_page']) ? (int) $_POST['_per_page'] : 0;
    $page = isset($_POST['_page']) ? (int) $_POST['_page'] : 0;
    $url = isset($_POST['_url']) ? esc_url_raw($_POST['_url']) : '';
    // JS didn't send us everything we need to know. Just die with success message
    if (!$total || !$per_page || !$page || !$url) {
        wp_die(time());
    }
    $total += $delta;
    if ($total < 0) {
        $total = 0;
    }
    // Only do the expensive stuff on a page-break, and about 1 other time per page
    if (0 == $total % $per_page || 1 == mt_rand(1, $per_page)) {
        $post_id = 0;
        $status = 'total_comments';
        // What type of comment count are we looking for?
        $parsed = parse_url($url);
        if (isset($parsed['query'])) {
            parse_str($parsed['query'], $query_vars);
            if (!empty($query_vars['comment_status'])) {
                $status = $query_vars['comment_status'];
            }
            if (!empty($query_vars['p'])) {
                $post_id = (int) $query_vars['p'];
            }
        }
        $comment_count = wp_count_comments($post_id);
        // We're looking for a known type of comment count.
        if (isset($comment_count->{$status})) {
            $total = $comment_count->{$status};
        }
        // Else use the decremented value from above.
    }
    // The time since the last comment count.
    $time = time();
    $x = new WP_Ajax_Response(array(
        'what' => 'comment',
        // Here for completeness - not used.
        'id' => $comment_id,
        'supplemental' => array('total_items_i18n' => sprintf(_n('%s item', '%s items', $total), number_format_i18n($total)), 'total_pages' => ceil($total / $per_page), 'total_pages_i18n' => number_format_i18n(ceil($total / $per_page)), 'total' => $total, 'time' => $time),
    ));
    $x->send();
}

WordPress Version: 4.0

//
// Ajax helpers.
//
/**
 * Sends back current comment total and new page links if they need to be updated.
 *
 * Contrary to normal success AJAX response ("1"), die with time() on success.
 *
 * @since 2.7.0
 *
 * @param int $comment_id
 * @return die
 */
function _wp_ajax_delete_comment_response($comment_id, $delta = -1)
{
    $total = isset($_POST['_total']) ? (int) $_POST['_total'] : 0;
    $per_page = isset($_POST['_per_page']) ? (int) $_POST['_per_page'] : 0;
    $page = isset($_POST['_page']) ? (int) $_POST['_page'] : 0;
    $url = isset($_POST['_url']) ? esc_url_raw($_POST['_url']) : '';
    // JS didn't send us everything we need to know. Just die with success message
    if (!$total || !$per_page || !$page || !$url) {
        wp_die(time());
    }
    $total += $delta;
    if ($total < 0) {
        $total = 0;
    }
    // Only do the expensive stuff on a page-break, and about 1 other time per page
    if (0 == $total % $per_page || 1 == mt_rand(1, $per_page)) {
        $post_id = 0;
        $status = 'total_comments';
        // What type of comment count are we looking for?
        $parsed = parse_url($url);
        if (isset($parsed['query'])) {
            parse_str($parsed['query'], $query_vars);
            if (!empty($query_vars['comment_status'])) {
                $status = $query_vars['comment_status'];
            }
            if (!empty($query_vars['p'])) {
                $post_id = (int) $query_vars['p'];
            }
        }
        $comment_count = wp_count_comments($post_id);
        // We're looking for a known type of comment count.
        if (isset($comment_count->{$status})) {
            $total = $comment_count->{$status};
        }
        // Else use the decremented value from above.
    }
    // The time since the last comment count.
    $time = time();
    $x = new WP_Ajax_Response(array(
        'what' => 'comment',
        // Here for completeness - not used.
        'id' => $comment_id,
        'supplemental' => array('total_items_i18n' => sprintf(_n('1 item', '%s items', $total), number_format_i18n($total)), 'total_pages' => ceil($total / $per_page), 'total_pages_i18n' => number_format_i18n(ceil($total / $per_page)), 'total' => $total, 'time' => $time),
    ));
    $x->send();
}

WordPress Version: 3.9

/*
 * Ajax helper.
 */
/**
 * Sends back current comment total and new page links if they need to be updated.
 *
 * Contrary to normal success AJAX response ("1"), die with time() on success.
 *
 * @since 2.7.0
 *
 * @param int $comment_id
 * @return die
 */
function _wp_ajax_delete_comment_response($comment_id, $delta = -1)
{
    $total = isset($_POST['_total']) ? (int) $_POST['_total'] : 0;
    $per_page = isset($_POST['_per_page']) ? (int) $_POST['_per_page'] : 0;
    $page = isset($_POST['_page']) ? (int) $_POST['_page'] : 0;
    $url = isset($_POST['_url']) ? esc_url_raw($_POST['_url']) : '';
    // JS didn't send us everything we need to know. Just die with success message
    if (!$total || !$per_page || !$page || !$url) {
        wp_die(time());
    }
    $total += $delta;
    if ($total < 0) {
        $total = 0;
    }
    // Only do the expensive stuff on a page-break, and about 1 other time per page
    if (0 == $total % $per_page || 1 == mt_rand(1, $per_page)) {
        $post_id = 0;
        $status = 'total_comments';
        // What type of comment count are we looking for?
        $parsed = parse_url($url);
        if (isset($parsed['query'])) {
            parse_str($parsed['query'], $query_vars);
            if (!empty($query_vars['comment_status'])) {
                $status = $query_vars['comment_status'];
            }
            if (!empty($query_vars['p'])) {
                $post_id = (int) $query_vars['p'];
            }
        }
        $comment_count = wp_count_comments($post_id);
        if (isset($comment_count->{$status})) {
            // We're looking for a known type of comment count
            $total = $comment_count->{$status};
        }
        // else use the decremented value from above
    }
    $time = time();
    // The time since the last comment count
    $x = new WP_Ajax_Response(array(
        'what' => 'comment',
        'id' => $comment_id,
        // here for completeness - not used
        'supplemental' => array('total_items_i18n' => sprintf(_n('1 item', '%s items', $total), number_format_i18n($total)), 'total_pages' => ceil($total / $per_page), 'total_pages_i18n' => number_format_i18n(ceil($total / $per_page)), 'total' => $total, 'time' => $time),
    ));
    $x->send();
}

WordPress Version: 3.7

/*
 * Ajax helper.
 */
/**
 * Sends back current comment total and new page links if they need to be updated.
 *
 * Contrary to normal success AJAX response ("1"), die with time() on success.
 *
 * @since 2.7
 *
 * @param int $comment_id
 * @return die
 */
function _wp_ajax_delete_comment_response($comment_id, $delta = -1)
{
    $total = isset($_POST['_total']) ? (int) $_POST['_total'] : 0;
    $per_page = isset($_POST['_per_page']) ? (int) $_POST['_per_page'] : 0;
    $page = isset($_POST['_page']) ? (int) $_POST['_page'] : 0;
    $url = isset($_POST['_url']) ? esc_url_raw($_POST['_url']) : '';
    // JS didn't send us everything we need to know. Just die with success message
    if (!$total || !$per_page || !$page || !$url) {
        wp_die(time());
    }
    $total += $delta;
    if ($total < 0) {
        $total = 0;
    }
    // Only do the expensive stuff on a page-break, and about 1 other time per page
    if (0 == $total % $per_page || 1 == mt_rand(1, $per_page)) {
        $post_id = 0;
        $status = 'total_comments';
        // What type of comment count are we looking for?
        $parsed = parse_url($url);
        if (isset($parsed['query'])) {
            parse_str($parsed['query'], $query_vars);
            if (!empty($query_vars['comment_status'])) {
                $status = $query_vars['comment_status'];
            }
            if (!empty($query_vars['p'])) {
                $post_id = (int) $query_vars['p'];
            }
        }
        $comment_count = wp_count_comments($post_id);
        if (isset($comment_count->{$status})) {
            // We're looking for a known type of comment count
            $total = $comment_count->{$status};
        }
        // else use the decremented value from above
    }
    $time = time();
    // The time since the last comment count
    $x = new WP_Ajax_Response(array(
        'what' => 'comment',
        'id' => $comment_id,
        // here for completeness - not used
        'supplemental' => array('total_items_i18n' => sprintf(_n('1 item', '%s items', $total), number_format_i18n($total)), 'total_pages' => ceil($total / $per_page), 'total_pages_i18n' => number_format_i18n(ceil($total / $per_page)), 'total' => $total, 'time' => $time),
    ));
    $x->send();
}