wp_defer_comment_counting

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

WordPress Version: 6.1

/**
 * Determines whether to defer comment counting.
 *
 * When setting $defer to true, all post comment counts will not be updated
 * until $defer is set to false. When $defer is set to false, then all
 * previously deferred updated post comment counts will then be automatically
 * updated without having to call wp_update_comment_count() after.
 *
 * @since 2.5.0
 *
 * @param bool $defer
 * @return bool
 */
function wp_defer_comment_counting($defer = null)
{
    static $_defer = false;
    if (is_bool($defer)) {
        $_defer = $defer;
        // Flush any deferred counts.
        if (!$defer) {
            wp_update_comment_count(null, true);
        }
    }
    return $_defer;
}

WordPress Version: 5.5

/**
 * Whether to defer comment counting.
 *
 * When setting $defer to true, all post comment counts will not be updated
 * until $defer is set to false. When $defer is set to false, then all
 * previously deferred updated post comment counts will then be automatically
 * updated without having to call wp_update_comment_count() after.
 *
 * @since 2.5.0
 *
 * @param bool $defer
 * @return bool
 */
function wp_defer_comment_counting($defer = null)
{
    static $_defer = false;
    if (is_bool($defer)) {
        $_defer = $defer;
        // Flush any deferred counts.
        if (!$defer) {
            wp_update_comment_count(null, true);
        }
    }
    return $_defer;
}

WordPress Version: 5.4

/**
 * Whether to defer comment counting.
 *
 * When setting $defer to true, all post comment counts will not be updated
 * until $defer is set to false. When $defer is set to false, then all
 * previously deferred updated post comment counts will then be automatically
 * updated without having to call wp_update_comment_count() after.
 *
 * @since 2.5.0
 * @staticvar bool $_defer
 *
 * @param bool $defer
 * @return bool
 */
function wp_defer_comment_counting($defer = null)
{
    static $_defer = false;
    if (is_bool($defer)) {
        $_defer = $defer;
        // Flush any deferred counts.
        if (!$defer) {
            wp_update_comment_count(null, true);
        }
    }
    return $_defer;
}

WordPress Version: 4.1

/**
 * Whether to defer comment counting.
 *
 * When setting $defer to true, all post comment counts will not be updated
 * until $defer is set to false. When $defer is set to false, then all
 * previously deferred updated post comment counts will then be automatically
 * updated without having to call wp_update_comment_count() after.
 *
 * @since 2.5.0
 * @staticvar bool $_defer
 *
 * @param bool $defer
 * @return bool
 */
function wp_defer_comment_counting($defer = null)
{
    static $_defer = false;
    if (is_bool($defer)) {
        $_defer = $defer;
        // flush any deferred counts
        if (!$defer) {
            wp_update_comment_count(null, true);
        }
    }
    return $_defer;
}

WordPress Version: 3.7

/**
 * Whether to defer comment counting.
 *
 * When setting $defer to true, all post comment counts will not be updated
 * until $defer is set to false. When $defer is set to false, then all
 * previously deferred updated post comment counts will then be automatically
 * updated without having to call wp_update_comment_count() after.
 *
 * @since 2.5.0
 * @staticvar bool $_defer
 *
 * @param bool $defer
 * @return unknown
 */
function wp_defer_comment_counting($defer = null)
{
    static $_defer = false;
    if (is_bool($defer)) {
        $_defer = $defer;
        // flush any deferred counts
        if (!$defer) {
            wp_update_comment_count(null, true);
        }
    }
    return $_defer;
}