comments_template

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

WordPress Version: 6.5

/**
 * Loads the comment template specified in $file.
 *
 * Will not display the comments template if not on single post or page, or if
 * the post does not have comments.
 *
 * Uses the WordPress database object to query for the comments. The comments
 * are passed through the {@see 'comments_array'} filter hook with the list of comments
 * and the post ID respectively.
 *
 * The `$file` path is passed through a filter hook called {@see 'comments_template'},
 * which includes the template directory and $file combined. Tries the $filtered path
 * first and if it fails it will require the default comment template from the
 * default theme. If either does not exist, then the WordPress process will be
 * halted. It is advised for that reason, that the default theme is not deleted.
 *
 * Will not try to get the comments if the post has none.
 *
 * @since 1.5.0
 *
 * @global WP_Query   $wp_query           WordPress Query object.
 * @global WP_Post    $post               Global post object.
 * @global wpdb       $wpdb               WordPress database abstraction object.
 * @global int        $id
 * @global WP_Comment $comment            Global comment object.
 * @global string     $user_login
 * @global string     $user_identity
 * @global bool       $overridden_cpage
 * @global bool       $withcomments
 * @global string     $wp_stylesheet_path Path to current theme's stylesheet directory.
 * @global string     $wp_template_path   Path to current theme's template directory.
 *
 * @param string $file              Optional. The file to load. Default '/comments.php'.
 * @param bool   $separate_comments Optional. Whether to separate the comments by comment type.
 *                                  Default false.
 */
function comments_template($file = '/comments.php', $separate_comments = false)
{
    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_identity, $overridden_cpage, $wp_stylesheet_path, $wp_template_path;
    if (!(is_single() || is_page() || $withcomments) || empty($post)) {
        return;
    }
    if (empty($file)) {
        $file = '/comments.php';
    }
    $req = get_option('require_name_email');
    /*
     * Comment author information fetched from the comment cookies.
     */
    $commenter = wp_get_current_commenter();
    /*
     * The name of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author = $commenter['comment_author'];
    /*
     * The email address of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author_email = $commenter['comment_author_email'];
    /*
     * The URL of the current comment author escaped for use in attributes.
     */
    $comment_author_url = esc_url($commenter['comment_author_url']);
    $comment_args = array('orderby' => 'comment_date_gmt', 'order' => 'ASC', 'status' => 'approve', 'post_id' => $post->ID, 'no_found_rows' => false);
    if (get_option('thread_comments')) {
        $comment_args['hierarchical'] = 'threaded';
    } else {
        $comment_args['hierarchical'] = false;
    }
    if (is_user_logged_in()) {
        $comment_args['include_unapproved'] = array(get_current_user_id());
    } else {
        $unapproved_email = wp_get_unapproved_comment_author_email();
        if ($unapproved_email) {
            $comment_args['include_unapproved'] = array($unapproved_email);
        }
    }
    $per_page = 0;
    if (get_option('page_comments')) {
        $per_page = (int) get_query_var('comments_per_page');
        if (0 === $per_page) {
            $per_page = (int) get_option('comments_per_page');
        }
        $comment_args['number'] = $per_page;
        $page = (int) get_query_var('cpage');
        if ($page) {
            $comment_args['offset'] = ($page - 1) * $per_page;
        } elseif ('oldest' === get_option('default_comments_page')) {
            $comment_args['offset'] = 0;
        } else {
            // If fetching the first page of 'newest', we need a top-level comment count.
            $top_level_query = new WP_Comment_Query();
            $top_level_args = array('count' => true, 'orderby' => false, 'post_id' => $post->ID, 'status' => 'approve');
            if ($comment_args['hierarchical']) {
                $top_level_args['parent'] = 0;
            }
            if (isset($comment_args['include_unapproved'])) {
                $top_level_args['include_unapproved'] = $comment_args['include_unapproved'];
            }
            /**
             * Filters the arguments used in the top level comments query.
             *
             * @since 5.6.0
             *
             * @see WP_Comment_Query::__construct()
             *
             * @param array $top_level_args {
             *     The top level query arguments for the comments template.
             *
             *     @type bool         $count   Whether to return a comment count.
             *     @type string|array $orderby The field(s) to order by.
             *     @type int          $post_id The post ID.
             *     @type string|array $status  The comment status to limit results by.
             * }
             */
            $top_level_args = apply_filters('comments_template_top_level_query_args', $top_level_args);
            $top_level_count = $top_level_query->query($top_level_args);
            $comment_args['offset'] = ((int) ceil($top_level_count / $per_page) - 1) * $per_page;
        }
    }
    /**
     * Filters the arguments used to query comments in comments_template().
     *
     * @since 4.5.0
     *
     * @see WP_Comment_Query::__construct()
     *
     * @param array $comment_args {
     *     Array of WP_Comment_Query arguments.
     *
     *     @type string|array $orderby                   Field(s) to order by.
     *     @type string       $order                     Order of results. Accepts 'ASC' or 'DESC'.
     *     @type string       $status                    Comment status.
     *     @type array        $include_unapproved        Array of IDs or email addresses whose unapproved comments
     *                                                   will be included in results.
     *     @type int          $post_id                   ID of the post.
     *     @type bool         $no_found_rows             Whether to refrain from querying for found rows.
     *     @type bool         $update_comment_meta_cache Whether to prime cache for comment meta.
     *     @type bool|string  $hierarchical              Whether to query for comments hierarchically.
     *     @type int          $offset                    Comment offset.
     *     @type int          $number                    Number of comments to fetch.
     * }
     */
    $comment_args = apply_filters('comments_template_query_args', $comment_args);
    $comment_query = new WP_Comment_Query($comment_args);
    $_comments = $comment_query->comments;
    // Trees must be flattened before they're passed to the walker.
    if ($comment_args['hierarchical']) {
        $comments_flat = array();
        foreach ($_comments as $_comment) {
            $comments_flat[] = $_comment;
            $comment_children = $_comment->get_children(array('format' => 'flat', 'status' => $comment_args['status'], 'orderby' => $comment_args['orderby']));
            foreach ($comment_children as $comment_child) {
                $comments_flat[] = $comment_child;
            }
        }
    } else {
        $comments_flat = $_comments;
    }
    /**
     * Filters the comments array.
     *
     * @since 2.1.0
     *
     * @param array $comments Array of comments supplied to the comments template.
     * @param int   $post_id  Post ID.
     */
    $wp_query->comments = apply_filters('comments_array', $comments_flat, $post->ID);
    $comments =& $wp_query->comments;
    $wp_query->comment_count = count($wp_query->comments);
    $wp_query->max_num_comment_pages = $comment_query->max_num_pages;
    if ($separate_comments) {
        $wp_query->comments_by_type = separate_comments($comments);
        $comments_by_type =& $wp_query->comments_by_type;
    } else {
        $wp_query->comments_by_type = array();
    }
    $overridden_cpage = false;
    if ('' == get_query_var('cpage') && $wp_query->max_num_comment_pages > 1) {
        set_query_var('cpage', ('newest' === get_option('default_comments_page')) ? get_comment_pages_count() : 1);
        $overridden_cpage = true;
    }
    if (!defined('COMMENTS_TEMPLATE')) {
        define('COMMENTS_TEMPLATE', true);
    }
    $theme_template = trailingslashit($wp_stylesheet_path) . $file;
    /**
     * Filters the path to the theme template file used for the comments template.
     *
     * @since 1.5.1
     *
     * @param string $theme_template The path to the theme template file.
     */
    $include = apply_filters('comments_template', $theme_template);
    if (file_exists($include)) {
        require $include;
    } elseif (file_exists(trailingslashit($wp_template_path) . $file)) {
        require trailingslashit($wp_template_path) . $file;
    } else {
        // Backward compat code will be removed in a future release.
        require ABSPATH . WPINC . '/theme-compat/comments.php';
    }
}

WordPress Version: 6.4

/**
 * Loads the comment template specified in $file.
 *
 * Will not display the comments template if not on single post or page, or if
 * the post does not have comments.
 *
 * Uses the WordPress database object to query for the comments. The comments
 * are passed through the {@see 'comments_array'} filter hook with the list of comments
 * and the post ID respectively.
 *
 * The `$file` path is passed through a filter hook called {@see 'comments_template'},
 * which includes the template directory and $file combined. Tries the $filtered path
 * first and if it fails it will require the default comment template from the
 * default theme. If either does not exist, then the WordPress process will be
 * halted. It is advised for that reason, that the default theme is not deleted.
 *
 * Will not try to get the comments if the post has none.
 *
 * @since 1.5.0
 *
 * @global WP_Query   $wp_query         WordPress Query object.
 * @global WP_Post    $post             Global post object.
 * @global wpdb       $wpdb             WordPress database abstraction object.
 * @global int        $id
 * @global WP_Comment $comment          Global comment object.
 * @global string     $user_login
 * @global string     $user_identity
 * @global bool       $overridden_cpage
 * @global bool       $withcomments
 *
 * @param string $file              Optional. The file to load. Default '/comments.php'.
 * @param bool   $separate_comments Optional. Whether to separate the comments by comment type.
 *                                  Default false.
 */
function comments_template($file = '/comments.php', $separate_comments = false)
{
    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_identity, $overridden_cpage;
    if (!(is_single() || is_page() || $withcomments) || empty($post)) {
        return;
    }
    if (empty($file)) {
        $file = '/comments.php';
    }
    $req = get_option('require_name_email');
    /*
     * Comment author information fetched from the comment cookies.
     */
    $commenter = wp_get_current_commenter();
    /*
     * The name of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author = $commenter['comment_author'];
    /*
     * The email address of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author_email = $commenter['comment_author_email'];
    /*
     * The URL of the current comment author escaped for use in attributes.
     */
    $comment_author_url = esc_url($commenter['comment_author_url']);
    $comment_args = array('orderby' => 'comment_date_gmt', 'order' => 'ASC', 'status' => 'approve', 'post_id' => $post->ID, 'no_found_rows' => false);
    if (get_option('thread_comments')) {
        $comment_args['hierarchical'] = 'threaded';
    } else {
        $comment_args['hierarchical'] = false;
    }
    if (is_user_logged_in()) {
        $comment_args['include_unapproved'] = array(get_current_user_id());
    } else {
        $unapproved_email = wp_get_unapproved_comment_author_email();
        if ($unapproved_email) {
            $comment_args['include_unapproved'] = array($unapproved_email);
        }
    }
    $per_page = 0;
    if (get_option('page_comments')) {
        $per_page = (int) get_query_var('comments_per_page');
        if (0 === $per_page) {
            $per_page = (int) get_option('comments_per_page');
        }
        $comment_args['number'] = $per_page;
        $page = (int) get_query_var('cpage');
        if ($page) {
            $comment_args['offset'] = ($page - 1) * $per_page;
        } elseif ('oldest' === get_option('default_comments_page')) {
            $comment_args['offset'] = 0;
        } else {
            // If fetching the first page of 'newest', we need a top-level comment count.
            $top_level_query = new WP_Comment_Query();
            $top_level_args = array('count' => true, 'orderby' => false, 'post_id' => $post->ID, 'status' => 'approve');
            if ($comment_args['hierarchical']) {
                $top_level_args['parent'] = 0;
            }
            if (isset($comment_args['include_unapproved'])) {
                $top_level_args['include_unapproved'] = $comment_args['include_unapproved'];
            }
            /**
             * Filters the arguments used in the top level comments query.
             *
             * @since 5.6.0
             *
             * @see WP_Comment_Query::__construct()
             *
             * @param array $top_level_args {
             *     The top level query arguments for the comments template.
             *
             *     @type bool         $count   Whether to return a comment count.
             *     @type string|array $orderby The field(s) to order by.
             *     @type int          $post_id The post ID.
             *     @type string|array $status  The comment status to limit results by.
             * }
             */
            $top_level_args = apply_filters('comments_template_top_level_query_args', $top_level_args);
            $top_level_count = $top_level_query->query($top_level_args);
            $comment_args['offset'] = (ceil($top_level_count / $per_page) - 1) * $per_page;
        }
    }
    /**
     * Filters the arguments used to query comments in comments_template().
     *
     * @since 4.5.0
     *
     * @see WP_Comment_Query::__construct()
     *
     * @param array $comment_args {
     *     Array of WP_Comment_Query arguments.
     *
     *     @type string|array $orderby                   Field(s) to order by.
     *     @type string       $order                     Order of results. Accepts 'ASC' or 'DESC'.
     *     @type string       $status                    Comment status.
     *     @type array        $include_unapproved        Array of IDs or email addresses whose unapproved comments
     *                                                   will be included in results.
     *     @type int          $post_id                   ID of the post.
     *     @type bool         $no_found_rows             Whether to refrain from querying for found rows.
     *     @type bool         $update_comment_meta_cache Whether to prime cache for comment meta.
     *     @type bool|string  $hierarchical              Whether to query for comments hierarchically.
     *     @type int          $offset                    Comment offset.
     *     @type int          $number                    Number of comments to fetch.
     * }
     */
    $comment_args = apply_filters('comments_template_query_args', $comment_args);
    $comment_query = new WP_Comment_Query($comment_args);
    $_comments = $comment_query->comments;
    // Trees must be flattened before they're passed to the walker.
    if ($comment_args['hierarchical']) {
        $comments_flat = array();
        foreach ($_comments as $_comment) {
            $comments_flat[] = $_comment;
            $comment_children = $_comment->get_children(array('format' => 'flat', 'status' => $comment_args['status'], 'orderby' => $comment_args['orderby']));
            foreach ($comment_children as $comment_child) {
                $comments_flat[] = $comment_child;
            }
        }
    } else {
        $comments_flat = $_comments;
    }
    /**
     * Filters the comments array.
     *
     * @since 2.1.0
     *
     * @param array $comments Array of comments supplied to the comments template.
     * @param int   $post_id  Post ID.
     */
    $wp_query->comments = apply_filters('comments_array', $comments_flat, $post->ID);
    $comments =& $wp_query->comments;
    $wp_query->comment_count = count($wp_query->comments);
    $wp_query->max_num_comment_pages = $comment_query->max_num_pages;
    if ($separate_comments) {
        $wp_query->comments_by_type = separate_comments($comments);
        $comments_by_type =& $wp_query->comments_by_type;
    } else {
        $wp_query->comments_by_type = array();
    }
    $overridden_cpage = false;
    if ('' == get_query_var('cpage') && $wp_query->max_num_comment_pages > 1) {
        set_query_var('cpage', ('newest' === get_option('default_comments_page')) ? get_comment_pages_count() : 1);
        $overridden_cpage = true;
    }
    if (!defined('COMMENTS_TEMPLATE')) {
        define('COMMENTS_TEMPLATE', true);
    }
    $stylesheet_path = get_stylesheet_directory();
    $template_path = get_template_directory();
    $theme_template = $stylesheet_path . $file;
    /**
     * Filters the path to the theme template file used for the comments template.
     *
     * @since 1.5.1
     *
     * @param string $theme_template The path to the theme template file.
     */
    $include = apply_filters('comments_template', $theme_template);
    if (file_exists($include)) {
        require $include;
    } elseif (file_exists($template_path . $file)) {
        require $template_path . $file;
    } else {
        // Backward compat code will be removed in a future release.
        require ABSPATH . WPINC . '/theme-compat/comments.php';
    }
}

WordPress Version: 6.3

/**
 * Loads the comment template specified in $file.
 *
 * Will not display the comments template if not on single post or page, or if
 * the post does not have comments.
 *
 * Uses the WordPress database object to query for the comments. The comments
 * are passed through the {@see 'comments_array'} filter hook with the list of comments
 * and the post ID respectively.
 *
 * The `$file` path is passed through a filter hook called {@see 'comments_template'},
 * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
 * first and if it fails it will require the default comment template from the
 * default theme. If either does not exist, then the WordPress process will be
 * halted. It is advised for that reason, that the default theme is not deleted.
 *
 * Will not try to get the comments if the post has none.
 *
 * @since 1.5.0
 *
 * @global WP_Query   $wp_query         WordPress Query object.
 * @global WP_Post    $post             Global post object.
 * @global wpdb       $wpdb             WordPress database abstraction object.
 * @global int        $id
 * @global WP_Comment $comment          Global comment object.
 * @global string     $user_login
 * @global string     $user_identity
 * @global bool       $overridden_cpage
 * @global bool       $withcomments
 *
 * @param string $file              Optional. The file to load. Default '/comments.php'.
 * @param bool   $separate_comments Optional. Whether to separate the comments by comment type.
 *                                  Default false.
 */
function comments_template($file = '/comments.php', $separate_comments = false)
{
    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_identity, $overridden_cpage;
    if (!(is_single() || is_page() || $withcomments) || empty($post)) {
        return;
    }
    if (empty($file)) {
        $file = '/comments.php';
    }
    $req = get_option('require_name_email');
    /*
     * Comment author information fetched from the comment cookies.
     */
    $commenter = wp_get_current_commenter();
    /*
     * The name of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author = $commenter['comment_author'];
    /*
     * The email address of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author_email = $commenter['comment_author_email'];
    /*
     * The URL of the current comment author escaped for use in attributes.
     */
    $comment_author_url = esc_url($commenter['comment_author_url']);
    $comment_args = array('orderby' => 'comment_date_gmt', 'order' => 'ASC', 'status' => 'approve', 'post_id' => $post->ID, 'no_found_rows' => false);
    if (get_option('thread_comments')) {
        $comment_args['hierarchical'] = 'threaded';
    } else {
        $comment_args['hierarchical'] = false;
    }
    if (is_user_logged_in()) {
        $comment_args['include_unapproved'] = array(get_current_user_id());
    } else {
        $unapproved_email = wp_get_unapproved_comment_author_email();
        if ($unapproved_email) {
            $comment_args['include_unapproved'] = array($unapproved_email);
        }
    }
    $per_page = 0;
    if (get_option('page_comments')) {
        $per_page = (int) get_query_var('comments_per_page');
        if (0 === $per_page) {
            $per_page = (int) get_option('comments_per_page');
        }
        $comment_args['number'] = $per_page;
        $page = (int) get_query_var('cpage');
        if ($page) {
            $comment_args['offset'] = ($page - 1) * $per_page;
        } elseif ('oldest' === get_option('default_comments_page')) {
            $comment_args['offset'] = 0;
        } else {
            // If fetching the first page of 'newest', we need a top-level comment count.
            $top_level_query = new WP_Comment_Query();
            $top_level_args = array('count' => true, 'orderby' => false, 'post_id' => $post->ID, 'status' => 'approve');
            if ($comment_args['hierarchical']) {
                $top_level_args['parent'] = 0;
            }
            if (isset($comment_args['include_unapproved'])) {
                $top_level_args['include_unapproved'] = $comment_args['include_unapproved'];
            }
            /**
             * Filters the arguments used in the top level comments query.
             *
             * @since 5.6.0
             *
             * @see WP_Comment_Query::__construct()
             *
             * @param array $top_level_args {
             *     The top level query arguments for the comments template.
             *
             *     @type bool         $count   Whether to return a comment count.
             *     @type string|array $orderby The field(s) to order by.
             *     @type int          $post_id The post ID.
             *     @type string|array $status  The comment status to limit results by.
             * }
             */
            $top_level_args = apply_filters('comments_template_top_level_query_args', $top_level_args);
            $top_level_count = $top_level_query->query($top_level_args);
            $comment_args['offset'] = (ceil($top_level_count / $per_page) - 1) * $per_page;
        }
    }
    /**
     * Filters the arguments used to query comments in comments_template().
     *
     * @since 4.5.0
     *
     * @see WP_Comment_Query::__construct()
     *
     * @param array $comment_args {
     *     Array of WP_Comment_Query arguments.
     *
     *     @type string|array $orderby                   Field(s) to order by.
     *     @type string       $order                     Order of results. Accepts 'ASC' or 'DESC'.
     *     @type string       $status                    Comment status.
     *     @type array        $include_unapproved        Array of IDs or email addresses whose unapproved comments
     *                                                   will be included in results.
     *     @type int          $post_id                   ID of the post.
     *     @type bool         $no_found_rows             Whether to refrain from querying for found rows.
     *     @type bool         $update_comment_meta_cache Whether to prime cache for comment meta.
     *     @type bool|string  $hierarchical              Whether to query for comments hierarchically.
     *     @type int          $offset                    Comment offset.
     *     @type int          $number                    Number of comments to fetch.
     * }
     */
    $comment_args = apply_filters('comments_template_query_args', $comment_args);
    $comment_query = new WP_Comment_Query($comment_args);
    $_comments = $comment_query->comments;
    // Trees must be flattened before they're passed to the walker.
    if ($comment_args['hierarchical']) {
        $comments_flat = array();
        foreach ($_comments as $_comment) {
            $comments_flat[] = $_comment;
            $comment_children = $_comment->get_children(array('format' => 'flat', 'status' => $comment_args['status'], 'orderby' => $comment_args['orderby']));
            foreach ($comment_children as $comment_child) {
                $comments_flat[] = $comment_child;
            }
        }
    } else {
        $comments_flat = $_comments;
    }
    /**
     * Filters the comments array.
     *
     * @since 2.1.0
     *
     * @param array $comments Array of comments supplied to the comments template.
     * @param int   $post_id  Post ID.
     */
    $wp_query->comments = apply_filters('comments_array', $comments_flat, $post->ID);
    $comments =& $wp_query->comments;
    $wp_query->comment_count = count($wp_query->comments);
    $wp_query->max_num_comment_pages = $comment_query->max_num_pages;
    if ($separate_comments) {
        $wp_query->comments_by_type = separate_comments($comments);
        $comments_by_type =& $wp_query->comments_by_type;
    } else {
        $wp_query->comments_by_type = array();
    }
    $overridden_cpage = false;
    if ('' == get_query_var('cpage') && $wp_query->max_num_comment_pages > 1) {
        set_query_var('cpage', ('newest' === get_option('default_comments_page')) ? get_comment_pages_count() : 1);
        $overridden_cpage = true;
    }
    if (!defined('COMMENTS_TEMPLATE')) {
        define('COMMENTS_TEMPLATE', true);
    }
    $theme_template = STYLESHEETPATH . $file;
    /**
     * Filters the path to the theme template file used for the comments template.
     *
     * @since 1.5.1
     *
     * @param string $theme_template The path to the theme template file.
     */
    $include = apply_filters('comments_template', $theme_template);
    if (file_exists($include)) {
        require $include;
    } elseif (file_exists(TEMPLATEPATH . $file)) {
        require TEMPLATEPATH . $file;
    } else {
        // Backward compat code will be removed in a future release.
        require ABSPATH . WPINC . '/theme-compat/comments.php';
    }
}

WordPress Version: 6.1

/**
 * Loads the comment template specified in $file.
 *
 * Will not display the comments template if not on single post or page, or if
 * the post does not have comments.
 *
 * Uses the WordPress database object to query for the comments. The comments
 * are passed through the {@see 'comments_array'} filter hook with the list of comments
 * and the post ID respectively.
 *
 * The `$file` path is passed through a filter hook called {@see 'comments_template'},
 * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
 * first and if it fails it will require the default comment template from the
 * default theme. If either does not exist, then the WordPress process will be
 * halted. It is advised for that reason, that the default theme is not deleted.
 *
 * Will not try to get the comments if the post has none.
 *
 * @since 1.5.0
 *
 * @global WP_Query   $wp_query         WordPress Query object.
 * @global WP_Post    $post             Global post object.
 * @global wpdb       $wpdb             WordPress database abstraction object.
 * @global int        $id
 * @global WP_Comment $comment          Global comment object.
 * @global string     $user_login
 * @global string     $user_identity
 * @global bool       $overridden_cpage
 * @global bool       $withcomments
 *
 * @param string $file              Optional. The file to load. Default '/comments.php'.
 * @param bool   $separate_comments Optional. Whether to separate the comments by comment type.
 *                                  Default false.
 */
function comments_template($file = '/comments.php', $separate_comments = false)
{
    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_identity, $overridden_cpage;
    if (!(is_single() || is_page() || $withcomments) || empty($post)) {
        return;
    }
    if (empty($file)) {
        $file = '/comments.php';
    }
    $req = get_option('require_name_email');
    /*
     * Comment author information fetched from the comment cookies.
     */
    $commenter = wp_get_current_commenter();
    /*
     * The name of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author = $commenter['comment_author'];
    /*
     * The email address of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author_email = $commenter['comment_author_email'];
    /*
     * The URL of the current comment author escaped for use in attributes.
     */
    $comment_author_url = esc_url($commenter['comment_author_url']);
    $comment_args = array('orderby' => 'comment_date_gmt', 'order' => 'ASC', 'status' => 'approve', 'post_id' => $post->ID, 'no_found_rows' => false, 'update_comment_meta_cache' => false);
    if (get_option('thread_comments')) {
        $comment_args['hierarchical'] = 'threaded';
    } else {
        $comment_args['hierarchical'] = false;
    }
    if (is_user_logged_in()) {
        $comment_args['include_unapproved'] = array(get_current_user_id());
    } else {
        $unapproved_email = wp_get_unapproved_comment_author_email();
        if ($unapproved_email) {
            $comment_args['include_unapproved'] = array($unapproved_email);
        }
    }
    $per_page = 0;
    if (get_option('page_comments')) {
        $per_page = (int) get_query_var('comments_per_page');
        if (0 === $per_page) {
            $per_page = (int) get_option('comments_per_page');
        }
        $comment_args['number'] = $per_page;
        $page = (int) get_query_var('cpage');
        if ($page) {
            $comment_args['offset'] = ($page - 1) * $per_page;
        } elseif ('oldest' === get_option('default_comments_page')) {
            $comment_args['offset'] = 0;
        } else {
            // If fetching the first page of 'newest', we need a top-level comment count.
            $top_level_query = new WP_Comment_Query();
            $top_level_args = array('count' => true, 'orderby' => false, 'post_id' => $post->ID, 'status' => 'approve');
            if ($comment_args['hierarchical']) {
                $top_level_args['parent'] = 0;
            }
            if (isset($comment_args['include_unapproved'])) {
                $top_level_args['include_unapproved'] = $comment_args['include_unapproved'];
            }
            /**
             * Filters the arguments used in the top level comments query.
             *
             * @since 5.6.0
             *
             * @see WP_Comment_Query::__construct()
             *
             * @param array $top_level_args {
             *     The top level query arguments for the comments template.
             *
             *     @type bool         $count   Whether to return a comment count.
             *     @type string|array $orderby The field(s) to order by.
             *     @type int          $post_id The post ID.
             *     @type string|array $status  The comment status to limit results by.
             * }
             */
            $top_level_args = apply_filters('comments_template_top_level_query_args', $top_level_args);
            $top_level_count = $top_level_query->query($top_level_args);
            $comment_args['offset'] = (ceil($top_level_count / $per_page) - 1) * $per_page;
        }
    }
    /**
     * Filters the arguments used to query comments in comments_template().
     *
     * @since 4.5.0
     *
     * @see WP_Comment_Query::__construct()
     *
     * @param array $comment_args {
     *     Array of WP_Comment_Query arguments.
     *
     *     @type string|array $orderby                   Field(s) to order by.
     *     @type string       $order                     Order of results. Accepts 'ASC' or 'DESC'.
     *     @type string       $status                    Comment status.
     *     @type array        $include_unapproved        Array of IDs or email addresses whose unapproved comments
     *                                                   will be included in results.
     *     @type int          $post_id                   ID of the post.
     *     @type bool         $no_found_rows             Whether to refrain from querying for found rows.
     *     @type bool         $update_comment_meta_cache Whether to prime cache for comment meta.
     *     @type bool|string  $hierarchical              Whether to query for comments hierarchically.
     *     @type int          $offset                    Comment offset.
     *     @type int          $number                    Number of comments to fetch.
     * }
     */
    $comment_args = apply_filters('comments_template_query_args', $comment_args);
    $comment_query = new WP_Comment_Query($comment_args);
    $_comments = $comment_query->comments;
    // Trees must be flattened before they're passed to the walker.
    if ($comment_args['hierarchical']) {
        $comments_flat = array();
        foreach ($_comments as $_comment) {
            $comments_flat[] = $_comment;
            $comment_children = $_comment->get_children(array('format' => 'flat', 'status' => $comment_args['status'], 'orderby' => $comment_args['orderby']));
            foreach ($comment_children as $comment_child) {
                $comments_flat[] = $comment_child;
            }
        }
    } else {
        $comments_flat = $_comments;
    }
    /**
     * Filters the comments array.
     *
     * @since 2.1.0
     *
     * @param array $comments Array of comments supplied to the comments template.
     * @param int   $post_id  Post ID.
     */
    $wp_query->comments = apply_filters('comments_array', $comments_flat, $post->ID);
    $comments =& $wp_query->comments;
    $wp_query->comment_count = count($wp_query->comments);
    $wp_query->max_num_comment_pages = $comment_query->max_num_pages;
    if ($separate_comments) {
        $wp_query->comments_by_type = separate_comments($comments);
        $comments_by_type =& $wp_query->comments_by_type;
    } else {
        $wp_query->comments_by_type = array();
    }
    $overridden_cpage = false;
    if ('' == get_query_var('cpage') && $wp_query->max_num_comment_pages > 1) {
        set_query_var('cpage', ('newest' === get_option('default_comments_page')) ? get_comment_pages_count() : 1);
        $overridden_cpage = true;
    }
    if (!defined('COMMENTS_TEMPLATE')) {
        define('COMMENTS_TEMPLATE', true);
    }
    $theme_template = STYLESHEETPATH . $file;
    /**
     * Filters the path to the theme template file used for the comments template.
     *
     * @since 1.5.1
     *
     * @param string $theme_template The path to the theme template file.
     */
    $include = apply_filters('comments_template', $theme_template);
    if (file_exists($include)) {
        require $include;
    } elseif (file_exists(TEMPLATEPATH . $file)) {
        require TEMPLATEPATH . $file;
    } else {
        // Backward compat code will be removed in a future release.
        require ABSPATH . WPINC . '/theme-compat/comments.php';
    }
}

WordPress Version: 5.6

/**
 * Loads the comment template specified in $file.
 *
 * Will not display the comments template if not on single post or page, or if
 * the post does not have comments.
 *
 * Uses the WordPress database object to query for the comments. The comments
 * are passed through the {@see 'comments_array'} filter hook with the list of comments
 * and the post ID respectively.
 *
 * The `$file` path is passed through a filter hook called {@see 'comments_template'},
 * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
 * first and if it fails it will require the default comment template from the
 * default theme. If either does not exist, then the WordPress process will be
 * halted. It is advised for that reason, that the default theme is not deleted.
 *
 * Will not try to get the comments if the post has none.
 *
 * @since 1.5.0
 *
 * @global WP_Query   $wp_query         WordPress Query object.
 * @global WP_Post    $post             Global post object.
 * @global wpdb       $wpdb             WordPress database abstraction object.
 * @global int        $id
 * @global WP_Comment $comment          Global comment object.
 * @global string     $user_login
 * @global string     $user_identity
 * @global bool       $overridden_cpage
 * @global bool       $withcomments
 *
 * @param string $file              Optional. The file to load. Default '/comments.php'.
 * @param bool   $separate_comments Optional. Whether to separate the comments by comment type.
 *                                  Default false.
 */
function comments_template($file = '/comments.php', $separate_comments = false)
{
    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_identity, $overridden_cpage;
    if (!(is_single() || is_page() || $withcomments) || empty($post)) {
        return;
    }
    if (empty($file)) {
        $file = '/comments.php';
    }
    $req = get_option('require_name_email');
    /*
     * Comment author information fetched from the comment cookies.
     */
    $commenter = wp_get_current_commenter();
    /*
     * The name of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author = $commenter['comment_author'];
    /*
     * The email address of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author_email = $commenter['comment_author_email'];
    /*
     * The URL of the current comment author escaped for use in attributes.
     */
    $comment_author_url = esc_url($commenter['comment_author_url']);
    $comment_args = array('orderby' => 'comment_date_gmt', 'order' => 'ASC', 'status' => 'approve', 'post_id' => $post->ID, 'no_found_rows' => false, 'update_comment_meta_cache' => false);
    if (get_option('thread_comments')) {
        $comment_args['hierarchical'] = 'threaded';
    } else {
        $comment_args['hierarchical'] = false;
    }
    if (is_user_logged_in()) {
        $comment_args['include_unapproved'] = array(get_current_user_id());
    } else {
        $unapproved_email = wp_get_unapproved_comment_author_email();
        if ($unapproved_email) {
            $comment_args['include_unapproved'] = array($unapproved_email);
        }
    }
    $per_page = 0;
    if (get_option('page_comments')) {
        $per_page = (int) get_query_var('comments_per_page');
        if (0 === $per_page) {
            $per_page = (int) get_option('comments_per_page');
        }
        $comment_args['number'] = $per_page;
        $page = (int) get_query_var('cpage');
        if ($page) {
            $comment_args['offset'] = ($page - 1) * $per_page;
        } elseif ('oldest' === get_option('default_comments_page')) {
            $comment_args['offset'] = 0;
        } else {
            // If fetching the first page of 'newest', we need a top-level comment count.
            $top_level_query = new WP_Comment_Query();
            $top_level_args = array('count' => true, 'orderby' => false, 'post_id' => $post->ID, 'status' => 'approve');
            if ($comment_args['hierarchical']) {
                $top_level_args['parent'] = 0;
            }
            if (isset($comment_args['include_unapproved'])) {
                $top_level_args['include_unapproved'] = $comment_args['include_unapproved'];
            }
            /**
             * Filters the arguments used in the top level comments query.
             *
             * @since 5.6.0
             *
             * @see WP_Comment_Query::__construct()
             *
             * @param array $top_level_args {
             *     The top level query arguments for the comments template.
             *
             *     @type bool         $count   Whether to return a comment count.
             *     @type string|array $orderby The field(s) to order by.
             *     @type int          $post_id The post ID.
             *     @type string|array $status  The comment status to limit results by.
             * }
             */
            $top_level_args = apply_filters('comments_template_top_level_query_args', $top_level_args);
            $top_level_count = $top_level_query->query($top_level_args);
            $comment_args['offset'] = (ceil($top_level_count / $per_page) - 1) * $per_page;
        }
    }
    /**
     * Filters the arguments used to query comments in comments_template().
     *
     * @since 4.5.0
     *
     * @see WP_Comment_Query::__construct()
     *
     * @param array $comment_args {
     *     Array of WP_Comment_Query arguments.
     *
     *     @type string|array $orderby                   Field(s) to order by.
     *     @type string       $order                     Order of results. Accepts 'ASC' or 'DESC'.
     *     @type string       $status                    Comment status.
     *     @type array        $include_unapproved        Array of IDs or email addresses whose unapproved comments
     *                                                   will be included in results.
     *     @type int          $post_id                   ID of the post.
     *     @type bool         $no_found_rows             Whether to refrain from querying for found rows.
     *     @type bool         $update_comment_meta_cache Whether to prime cache for comment meta.
     *     @type bool|string  $hierarchical              Whether to query for comments hierarchically.
     *     @type int          $offset                    Comment offset.
     *     @type int          $number                    Number of comments to fetch.
     * }
     */
    $comment_args = apply_filters('comments_template_query_args', $comment_args);
    $comment_query = new WP_Comment_Query($comment_args);
    $_comments = $comment_query->comments;
    // Trees must be flattened before they're passed to the walker.
    if ($comment_args['hierarchical']) {
        $comments_flat = array();
        foreach ($_comments as $_comment) {
            $comments_flat[] = $_comment;
            $comment_children = $_comment->get_children(array('format' => 'flat', 'status' => $comment_args['status'], 'orderby' => $comment_args['orderby']));
            foreach ($comment_children as $comment_child) {
                $comments_flat[] = $comment_child;
            }
        }
    } else {
        $comments_flat = $_comments;
    }
    /**
     * Filters the comments array.
     *
     * @since 2.1.0
     *
     * @param array $comments Array of comments supplied to the comments template.
     * @param int   $post_ID  Post ID.
     */
    $wp_query->comments = apply_filters('comments_array', $comments_flat, $post->ID);
    $comments =& $wp_query->comments;
    $wp_query->comment_count = count($wp_query->comments);
    $wp_query->max_num_comment_pages = $comment_query->max_num_pages;
    if ($separate_comments) {
        $wp_query->comments_by_type = separate_comments($comments);
        $comments_by_type =& $wp_query->comments_by_type;
    } else {
        $wp_query->comments_by_type = array();
    }
    $overridden_cpage = false;
    if ('' == get_query_var('cpage') && $wp_query->max_num_comment_pages > 1) {
        set_query_var('cpage', ('newest' === get_option('default_comments_page')) ? get_comment_pages_count() : 1);
        $overridden_cpage = true;
    }
    if (!defined('COMMENTS_TEMPLATE')) {
        define('COMMENTS_TEMPLATE', true);
    }
    $theme_template = STYLESHEETPATH . $file;
    /**
     * Filters the path to the theme template file used for the comments template.
     *
     * @since 1.5.1
     *
     * @param string $theme_template The path to the theme template file.
     */
    $include = apply_filters('comments_template', $theme_template);
    if (file_exists($include)) {
        require $include;
    } elseif (file_exists(TEMPLATEPATH . $file)) {
        require TEMPLATEPATH . $file;
    } else {
        // Backward compat code will be removed in a future release.
        require ABSPATH . WPINC . '/theme-compat/comments.php';
    }
}

WordPress Version: 5.5

/**
 * Loads the comment template specified in $file.
 *
 * Will not display the comments template if not on single post or page, or if
 * the post does not have comments.
 *
 * Uses the WordPress database object to query for the comments. The comments
 * are passed through the {@see 'comments_array'} filter hook with the list of comments
 * and the post ID respectively.
 *
 * The `$file` path is passed through a filter hook called {@see 'comments_template'},
 * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
 * first and if it fails it will require the default comment template from the
 * default theme. If either does not exist, then the WordPress process will be
 * halted. It is advised for that reason, that the default theme is not deleted.
 *
 * Will not try to get the comments if the post has none.
 *
 * @since 1.5.0
 *
 * @global WP_Query   $wp_query         WordPress Query object.
 * @global WP_Post    $post             Global post object.
 * @global wpdb       $wpdb             WordPress database abstraction object.
 * @global int        $id
 * @global WP_Comment $comment          Global comment object.
 * @global string     $user_login
 * @global string     $user_identity
 * @global bool       $overridden_cpage
 * @global bool       $withcomments
 *
 * @param string $file              Optional. The file to load. Default '/comments.php'.
 * @param bool   $separate_comments Optional. Whether to separate the comments by comment type.
 *                                  Default false.
 */
function comments_template($file = '/comments.php', $separate_comments = false)
{
    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_identity, $overridden_cpage;
    if (!(is_single() || is_page() || $withcomments) || empty($post)) {
        return;
    }
    if (empty($file)) {
        $file = '/comments.php';
    }
    $req = get_option('require_name_email');
    /*
     * Comment author information fetched from the comment cookies.
     */
    $commenter = wp_get_current_commenter();
    /*
     * The name of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author = $commenter['comment_author'];
    /*
     * The email address of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author_email = $commenter['comment_author_email'];
    /*
     * The URL of the current comment author escaped for use in attributes.
     */
    $comment_author_url = esc_url($commenter['comment_author_url']);
    $comment_args = array('orderby' => 'comment_date_gmt', 'order' => 'ASC', 'status' => 'approve', 'post_id' => $post->ID, 'no_found_rows' => false, 'update_comment_meta_cache' => false);
    if (get_option('thread_comments')) {
        $comment_args['hierarchical'] = 'threaded';
    } else {
        $comment_args['hierarchical'] = false;
    }
    if (is_user_logged_in()) {
        $comment_args['include_unapproved'] = array(get_current_user_id());
    } else {
        $unapproved_email = wp_get_unapproved_comment_author_email();
        if ($unapproved_email) {
            $comment_args['include_unapproved'] = array($unapproved_email);
        }
    }
    $per_page = 0;
    if (get_option('page_comments')) {
        $per_page = (int) get_query_var('comments_per_page');
        if (0 === $per_page) {
            $per_page = (int) get_option('comments_per_page');
        }
        $comment_args['number'] = $per_page;
        $page = (int) get_query_var('cpage');
        if ($page) {
            $comment_args['offset'] = ($page - 1) * $per_page;
        } elseif ('oldest' === get_option('default_comments_page')) {
            $comment_args['offset'] = 0;
        } else {
            // If fetching the first page of 'newest', we need a top-level comment count.
            $top_level_query = new WP_Comment_Query();
            $top_level_args = array('count' => true, 'orderby' => false, 'post_id' => $post->ID, 'status' => 'approve');
            if ($comment_args['hierarchical']) {
                $top_level_args['parent'] = 0;
            }
            if (isset($comment_args['include_unapproved'])) {
                $top_level_args['include_unapproved'] = $comment_args['include_unapproved'];
            }
            $top_level_count = $top_level_query->query($top_level_args);
            $comment_args['offset'] = (ceil($top_level_count / $per_page) - 1) * $per_page;
        }
    }
    /**
     * Filters the arguments used to query comments in comments_template().
     *
     * @since 4.5.0
     *
     * @see WP_Comment_Query::__construct()
     *
     * @param array $comment_args {
     *     Array of WP_Comment_Query arguments.
     *
     *     @type string|array $orderby                   Field(s) to order by.
     *     @type string       $order                     Order of results. Accepts 'ASC' or 'DESC'.
     *     @type string       $status                    Comment status.
     *     @type array        $include_unapproved        Array of IDs or email addresses whose unapproved comments
     *                                                   will be included in results.
     *     @type int          $post_id                   ID of the post.
     *     @type bool         $no_found_rows             Whether to refrain from querying for found rows.
     *     @type bool         $update_comment_meta_cache Whether to prime cache for comment meta.
     *     @type bool|string  $hierarchical              Whether to query for comments hierarchically.
     *     @type int          $offset                    Comment offset.
     *     @type int          $number                    Number of comments to fetch.
     * }
     */
    $comment_args = apply_filters('comments_template_query_args', $comment_args);
    $comment_query = new WP_Comment_Query($comment_args);
    $_comments = $comment_query->comments;
    // Trees must be flattened before they're passed to the walker.
    if ($comment_args['hierarchical']) {
        $comments_flat = array();
        foreach ($_comments as $_comment) {
            $comments_flat[] = $_comment;
            $comment_children = $_comment->get_children(array('format' => 'flat', 'status' => $comment_args['status'], 'orderby' => $comment_args['orderby']));
            foreach ($comment_children as $comment_child) {
                $comments_flat[] = $comment_child;
            }
        }
    } else {
        $comments_flat = $_comments;
    }
    /**
     * Filters the comments array.
     *
     * @since 2.1.0
     *
     * @param array $comments Array of comments supplied to the comments template.
     * @param int   $post_ID  Post ID.
     */
    $wp_query->comments = apply_filters('comments_array', $comments_flat, $post->ID);
    $comments =& $wp_query->comments;
    $wp_query->comment_count = count($wp_query->comments);
    $wp_query->max_num_comment_pages = $comment_query->max_num_pages;
    if ($separate_comments) {
        $wp_query->comments_by_type = separate_comments($comments);
        $comments_by_type =& $wp_query->comments_by_type;
    } else {
        $wp_query->comments_by_type = array();
    }
    $overridden_cpage = false;
    if ('' == get_query_var('cpage') && $wp_query->max_num_comment_pages > 1) {
        set_query_var('cpage', ('newest' === get_option('default_comments_page')) ? get_comment_pages_count() : 1);
        $overridden_cpage = true;
    }
    if (!defined('COMMENTS_TEMPLATE')) {
        define('COMMENTS_TEMPLATE', true);
    }
    $theme_template = STYLESHEETPATH . $file;
    /**
     * Filters the path to the theme template file used for the comments template.
     *
     * @since 1.5.1
     *
     * @param string $theme_template The path to the theme template file.
     */
    $include = apply_filters('comments_template', $theme_template);
    if (file_exists($include)) {
        require $include;
    } elseif (file_exists(TEMPLATEPATH . $file)) {
        require TEMPLATEPATH . $file;
    } else {
        // Backward compat code will be removed in a future release.
        require ABSPATH . WPINC . '/theme-compat/comments.php';
    }
}

WordPress Version: 5.4

/**
 * Loads the comment template specified in $file.
 *
 * Will not display the comments template if not on single post or page, or if
 * the post does not have comments.
 *
 * Uses the WordPress database object to query for the comments. The comments
 * are passed through the {@see 'comments_array'} filter hook with the list of comments
 * and the post ID respectively.
 *
 * The `$file` path is passed through a filter hook called {@see 'comments_template'},
 * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
 * first and if it fails it will require the default comment template from the
 * default theme. If either does not exist, then the WordPress process will be
 * halted. It is advised for that reason, that the default theme is not deleted.
 *
 * Will not try to get the comments if the post has none.
 *
 * @since 1.5.0
 *
 * @global WP_Query   $wp_query         WordPress Query object.
 * @global WP_Post    $post             Global post object.
 * @global wpdb       $wpdb             WordPress database abstraction object.
 * @global int        $id
 * @global WP_Comment $comment          Global comment object.
 * @global string     $user_login
 * @global int        $user_ID
 * @global string     $user_identity
 * @global bool       $overridden_cpage
 * @global bool       $withcomments
 *
 * @param string $file              Optional. The file to load. Default '/comments.php'.
 * @param bool   $separate_comments Optional. Whether to separate the comments by comment type.
 *                                  Default false.
 */
function comments_template($file = '/comments.php', $separate_comments = false)
{
    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
    if (!(is_single() || is_page() || $withcomments) || empty($post)) {
        return;
    }
    if (empty($file)) {
        $file = '/comments.php';
    }
    $req = get_option('require_name_email');
    /*
     * Comment author information fetched from the comment cookies.
     */
    $commenter = wp_get_current_commenter();
    /*
     * The name of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author = $commenter['comment_author'];
    /*
     * The email address of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author_email = $commenter['comment_author_email'];
    /*
     * The URL of the current comment author escaped for use in attributes.
     */
    $comment_author_url = esc_url($commenter['comment_author_url']);
    $comment_args = array('orderby' => 'comment_date_gmt', 'order' => 'ASC', 'status' => 'approve', 'post_id' => $post->ID, 'no_found_rows' => false, 'update_comment_meta_cache' => false);
    if (get_option('thread_comments')) {
        $comment_args['hierarchical'] = 'threaded';
    } else {
        $comment_args['hierarchical'] = false;
    }
    if ($user_ID) {
        $comment_args['include_unapproved'] = array($user_ID);
    } else {
        $unapproved_email = wp_get_unapproved_comment_author_email();
        if ($unapproved_email) {
            $comment_args['include_unapproved'] = array($unapproved_email);
        }
    }
    $per_page = 0;
    if (get_option('page_comments')) {
        $per_page = (int) get_query_var('comments_per_page');
        if (0 === $per_page) {
            $per_page = (int) get_option('comments_per_page');
        }
        $comment_args['number'] = $per_page;
        $page = (int) get_query_var('cpage');
        if ($page) {
            $comment_args['offset'] = ($page - 1) * $per_page;
        } elseif ('oldest' === get_option('default_comments_page')) {
            $comment_args['offset'] = 0;
        } else {
            // If fetching the first page of 'newest', we need a top-level comment count.
            $top_level_query = new WP_Comment_Query();
            $top_level_args = array('count' => true, 'orderby' => false, 'post_id' => $post->ID, 'status' => 'approve');
            if ($comment_args['hierarchical']) {
                $top_level_args['parent'] = 0;
            }
            if (isset($comment_args['include_unapproved'])) {
                $top_level_args['include_unapproved'] = $comment_args['include_unapproved'];
            }
            $top_level_count = $top_level_query->query($top_level_args);
            $comment_args['offset'] = (ceil($top_level_count / $per_page) - 1) * $per_page;
        }
    }
    /**
     * Filters the arguments used to query comments in comments_template().
     *
     * @since 4.5.0
     *
     * @see WP_Comment_Query::__construct()
     *
     * @param array $comment_args {
     *     Array of WP_Comment_Query arguments.
     *
     *     @type string|array $orderby                   Field(s) to order by.
     *     @type string       $order                     Order of results. Accepts 'ASC' or 'DESC'.
     *     @type string       $status                    Comment status.
     *     @type array        $include_unapproved        Array of IDs or email addresses whose unapproved comments
     *                                                   will be included in results.
     *     @type int          $post_id                   ID of the post.
     *     @type bool         $no_found_rows             Whether to refrain from querying for found rows.
     *     @type bool         $update_comment_meta_cache Whether to prime cache for comment meta.
     *     @type bool|string  $hierarchical              Whether to query for comments hierarchically.
     *     @type int          $offset                    Comment offset.
     *     @type int          $number                    Number of comments to fetch.
     * }
     */
    $comment_args = apply_filters('comments_template_query_args', $comment_args);
    $comment_query = new WP_Comment_Query($comment_args);
    $_comments = $comment_query->comments;
    // Trees must be flattened before they're passed to the walker.
    if ($comment_args['hierarchical']) {
        $comments_flat = array();
        foreach ($_comments as $_comment) {
            $comments_flat[] = $_comment;
            $comment_children = $_comment->get_children(array('format' => 'flat', 'status' => $comment_args['status'], 'orderby' => $comment_args['orderby']));
            foreach ($comment_children as $comment_child) {
                $comments_flat[] = $comment_child;
            }
        }
    } else {
        $comments_flat = $_comments;
    }
    /**
     * Filters the comments array.
     *
     * @since 2.1.0
     *
     * @param array $comments Array of comments supplied to the comments template.
     * @param int   $post_ID  Post ID.
     */
    $wp_query->comments = apply_filters('comments_array', $comments_flat, $post->ID);
    $comments =& $wp_query->comments;
    $wp_query->comment_count = count($wp_query->comments);
    $wp_query->max_num_comment_pages = $comment_query->max_num_pages;
    if ($separate_comments) {
        $wp_query->comments_by_type = separate_comments($comments);
        $comments_by_type =& $wp_query->comments_by_type;
    } else {
        $wp_query->comments_by_type = array();
    }
    $overridden_cpage = false;
    if ('' == get_query_var('cpage') && $wp_query->max_num_comment_pages > 1) {
        set_query_var('cpage', ('newest' == get_option('default_comments_page')) ? get_comment_pages_count() : 1);
        $overridden_cpage = true;
    }
    if (!defined('COMMENTS_TEMPLATE')) {
        define('COMMENTS_TEMPLATE', true);
    }
    $theme_template = STYLESHEETPATH . $file;
    /**
     * Filters the path to the theme template file used for the comments template.
     *
     * @since 1.5.1
     *
     * @param string $theme_template The path to the theme template file.
     */
    $include = apply_filters('comments_template', $theme_template);
    if (file_exists($include)) {
        require $include;
    } elseif (file_exists(TEMPLATEPATH . $file)) {
        require TEMPLATEPATH . $file;
    } else {
        // Backward compat code will be removed in a future release.
        require ABSPATH . WPINC . '/theme-compat/comments.php';
    }
}

WordPress Version: 5.3

/**
 * Load the comment template specified in $file.
 *
 * Will not display the comments template if not on single post or page, or if
 * the post does not have comments.
 *
 * Uses the WordPress database object to query for the comments. The comments
 * are passed through the {@see 'comments_array'} filter hook with the list of comments
 * and the post ID respectively.
 *
 * The `$file` path is passed through a filter hook called {@see 'comments_template'},
 * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
 * first and if it fails it will require the default comment template from the
 * default theme. If either does not exist, then the WordPress process will be
 * halted. It is advised for that reason, that the default theme is not deleted.
 *
 * Will not try to get the comments if the post has none.
 *
 * @since 1.5.0
 *
 * @global WP_Query   $wp_query         WordPress Query object.
 * @global WP_Post    $post             Global post object.
 * @global wpdb       $wpdb             WordPress database abstraction object.
 * @global int        $id
 * @global WP_Comment $comment          Global comment object.
 * @global string     $user_login
 * @global int        $user_ID
 * @global string     $user_identity
 * @global bool       $overridden_cpage
 * @global bool       $withcomments
 *
 * @param string $file              Optional. The file to load. Default '/comments.php'.
 * @param bool   $separate_comments Optional. Whether to separate the comments by comment type.
 *                                  Default false.
 */
function comments_template($file = '/comments.php', $separate_comments = false)
{
    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
    if (!(is_single() || is_page() || $withcomments) || empty($post)) {
        return;
    }
    if (empty($file)) {
        $file = '/comments.php';
    }
    $req = get_option('require_name_email');
    /*
     * Comment author information fetched from the comment cookies.
     */
    $commenter = wp_get_current_commenter();
    /*
     * The name of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author = $commenter['comment_author'];
    /*
     * The email address of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author_email = $commenter['comment_author_email'];
    /*
     * The url of the current comment author escaped for use in attributes.
     */
    $comment_author_url = esc_url($commenter['comment_author_url']);
    $comment_args = array('orderby' => 'comment_date_gmt', 'order' => 'ASC', 'status' => 'approve', 'post_id' => $post->ID, 'no_found_rows' => false, 'update_comment_meta_cache' => false);
    if (get_option('thread_comments')) {
        $comment_args['hierarchical'] = 'threaded';
    } else {
        $comment_args['hierarchical'] = false;
    }
    if ($user_ID) {
        $comment_args['include_unapproved'] = array($user_ID);
    } else {
        $unapproved_email = wp_get_unapproved_comment_author_email();
        if ($unapproved_email) {
            $comment_args['include_unapproved'] = array($unapproved_email);
        }
    }
    $per_page = 0;
    if (get_option('page_comments')) {
        $per_page = (int) get_query_var('comments_per_page');
        if (0 === $per_page) {
            $per_page = (int) get_option('comments_per_page');
        }
        $comment_args['number'] = $per_page;
        $page = (int) get_query_var('cpage');
        if ($page) {
            $comment_args['offset'] = ($page - 1) * $per_page;
        } elseif ('oldest' === get_option('default_comments_page')) {
            $comment_args['offset'] = 0;
        } else {
            // If fetching the first page of 'newest', we need a top-level comment count.
            $top_level_query = new WP_Comment_Query();
            $top_level_args = array('count' => true, 'orderby' => false, 'post_id' => $post->ID, 'status' => 'approve');
            if ($comment_args['hierarchical']) {
                $top_level_args['parent'] = 0;
            }
            if (isset($comment_args['include_unapproved'])) {
                $top_level_args['include_unapproved'] = $comment_args['include_unapproved'];
            }
            $top_level_count = $top_level_query->query($top_level_args);
            $comment_args['offset'] = (ceil($top_level_count / $per_page) - 1) * $per_page;
        }
    }
    /**
     * Filters the arguments used to query comments in comments_template().
     *
     * @since 4.5.0
     *
     * @see WP_Comment_Query::__construct()
     *
     * @param array $comment_args {
     *     Array of WP_Comment_Query arguments.
     *
     *     @type string|array $orderby                   Field(s) to order by.
     *     @type string       $order                     Order of results. Accepts 'ASC' or 'DESC'.
     *     @type string       $status                    Comment status.
     *     @type array        $include_unapproved        Array of IDs or email addresses whose unapproved comments
     *                                                   will be included in results.
     *     @type int          $post_id                   ID of the post.
     *     @type bool         $no_found_rows             Whether to refrain from querying for found rows.
     *     @type bool         $update_comment_meta_cache Whether to prime cache for comment meta.
     *     @type bool|string  $hierarchical              Whether to query for comments hierarchically.
     *     @type int          $offset                    Comment offset.
     *     @type int          $number                    Number of comments to fetch.
     * }
     */
    $comment_args = apply_filters('comments_template_query_args', $comment_args);
    $comment_query = new WP_Comment_Query($comment_args);
    $_comments = $comment_query->comments;
    // Trees must be flattened before they're passed to the walker.
    if ($comment_args['hierarchical']) {
        $comments_flat = array();
        foreach ($_comments as $_comment) {
            $comments_flat[] = $_comment;
            $comment_children = $_comment->get_children(array('format' => 'flat', 'status' => $comment_args['status'], 'orderby' => $comment_args['orderby']));
            foreach ($comment_children as $comment_child) {
                $comments_flat[] = $comment_child;
            }
        }
    } else {
        $comments_flat = $_comments;
    }
    /**
     * Filters the comments array.
     *
     * @since 2.1.0
     *
     * @param array $comments Array of comments supplied to the comments template.
     * @param int   $post_ID  Post ID.
     */
    $wp_query->comments = apply_filters('comments_array', $comments_flat, $post->ID);
    $comments =& $wp_query->comments;
    $wp_query->comment_count = count($wp_query->comments);
    $wp_query->max_num_comment_pages = $comment_query->max_num_pages;
    if ($separate_comments) {
        $wp_query->comments_by_type = separate_comments($comments);
        $comments_by_type =& $wp_query->comments_by_type;
    } else {
        $wp_query->comments_by_type = array();
    }
    $overridden_cpage = false;
    if ('' == get_query_var('cpage') && $wp_query->max_num_comment_pages > 1) {
        set_query_var('cpage', ('newest' == get_option('default_comments_page')) ? get_comment_pages_count() : 1);
        $overridden_cpage = true;
    }
    if (!defined('COMMENTS_TEMPLATE')) {
        define('COMMENTS_TEMPLATE', true);
    }
    $theme_template = STYLESHEETPATH . $file;
    /**
     * Filters the path to the theme template file used for the comments template.
     *
     * @since 1.5.1
     *
     * @param string $theme_template The path to the theme template file.
     */
    $include = apply_filters('comments_template', $theme_template);
    if (file_exists($include)) {
        require $include;
    } elseif (file_exists(TEMPLATEPATH . $file)) {
        require TEMPLATEPATH . $file;
    } else {
        // Backward compat code will be removed in a future release
        require ABSPATH . WPINC . '/theme-compat/comments.php';
    }
}

WordPress Version: 5.1

/**
 * Load the comment template specified in $file.
 *
 * Will not display the comments template if not on single post or page, or if
 * the post does not have comments.
 *
 * Uses the WordPress database object to query for the comments. The comments
 * are passed through the {@see 'comments_array'} filter hook with the list of comments
 * and the post ID respectively.
 *
 * The `$file` path is passed through a filter hook called {@see 'comments_template'},
 * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
 * first and if it fails it will require the default comment template from the
 * default theme. If either does not exist, then the WordPress process will be
 * halted. It is advised for that reason, that the default theme is not deleted.
 *
 * Will not try to get the comments if the post has none.
 *
 * @since 1.5.0
 *
 * @global WP_Query   $wp_query
 * @global WP_Post    $post
 * @global wpdb       $wpdb
 * @global int        $id
 * @global WP_Comment $comment
 * @global string     $user_login
 * @global int        $user_ID
 * @global string     $user_identity
 * @global bool       $overridden_cpage
 * @global bool       $withcomments
 *
 * @param string $file              Optional. The file to load. Default '/comments.php'.
 * @param bool   $separate_comments Optional. Whether to separate the comments by comment type.
 *                                  Default false.
 */
function comments_template($file = '/comments.php', $separate_comments = false)
{
    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
    if (!(is_single() || is_page() || $withcomments) || empty($post)) {
        return;
    }
    if (empty($file)) {
        $file = '/comments.php';
    }
    $req = get_option('require_name_email');
    /*
     * Comment author information fetched from the comment cookies.
     */
    $commenter = wp_get_current_commenter();
    /*
     * The name of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author = $commenter['comment_author'];
    /*
     * The email address of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author_email = $commenter['comment_author_email'];
    /*
     * The url of the current comment author escaped for use in attributes.
     */
    $comment_author_url = esc_url($commenter['comment_author_url']);
    $comment_args = array('orderby' => 'comment_date_gmt', 'order' => 'ASC', 'status' => 'approve', 'post_id' => $post->ID, 'no_found_rows' => false, 'update_comment_meta_cache' => false);
    if (get_option('thread_comments')) {
        $comment_args['hierarchical'] = 'threaded';
    } else {
        $comment_args['hierarchical'] = false;
    }
    if ($user_ID) {
        $comment_args['include_unapproved'] = array($user_ID);
    } else {
        $unapproved_email = wp_get_unapproved_comment_author_email();
        if ($unapproved_email) {
            $comment_args['include_unapproved'] = array($unapproved_email);
        }
    }
    $per_page = 0;
    if (get_option('page_comments')) {
        $per_page = (int) get_query_var('comments_per_page');
        if (0 === $per_page) {
            $per_page = (int) get_option('comments_per_page');
        }
        $comment_args['number'] = $per_page;
        $page = (int) get_query_var('cpage');
        if ($page) {
            $comment_args['offset'] = ($page - 1) * $per_page;
        } elseif ('oldest' === get_option('default_comments_page')) {
            $comment_args['offset'] = 0;
        } else {
            // If fetching the first page of 'newest', we need a top-level comment count.
            $top_level_query = new WP_Comment_Query();
            $top_level_args = array('count' => true, 'orderby' => false, 'post_id' => $post->ID, 'status' => 'approve');
            if ($comment_args['hierarchical']) {
                $top_level_args['parent'] = 0;
            }
            if (isset($comment_args['include_unapproved'])) {
                $top_level_args['include_unapproved'] = $comment_args['include_unapproved'];
            }
            $top_level_count = $top_level_query->query($top_level_args);
            $comment_args['offset'] = (ceil($top_level_count / $per_page) - 1) * $per_page;
        }
    }
    /**
     * Filters the arguments used to query comments in comments_template().
     *
     * @since 4.5.0
     *
     * @see WP_Comment_Query::__construct()
     *
     * @param array $comment_args {
     *     Array of WP_Comment_Query arguments.
     *
     *     @type string|array $orderby                   Field(s) to order by.
     *     @type string       $order                     Order of results. Accepts 'ASC' or 'DESC'.
     *     @type string       $status                    Comment status.
     *     @type array        $include_unapproved        Array of IDs or email addresses whose unapproved comments
     *                                                   will be included in results.
     *     @type int          $post_id                   ID of the post.
     *     @type bool         $no_found_rows             Whether to refrain from querying for found rows.
     *     @type bool         $update_comment_meta_cache Whether to prime cache for comment meta.
     *     @type bool|string  $hierarchical              Whether to query for comments hierarchically.
     *     @type int          $offset                    Comment offset.
     *     @type int          $number                    Number of comments to fetch.
     * }
     */
    $comment_args = apply_filters('comments_template_query_args', $comment_args);
    $comment_query = new WP_Comment_Query($comment_args);
    $_comments = $comment_query->comments;
    // Trees must be flattened before they're passed to the walker.
    if ($comment_args['hierarchical']) {
        $comments_flat = array();
        foreach ($_comments as $_comment) {
            $comments_flat[] = $_comment;
            $comment_children = $_comment->get_children(array('format' => 'flat', 'status' => $comment_args['status'], 'orderby' => $comment_args['orderby']));
            foreach ($comment_children as $comment_child) {
                $comments_flat[] = $comment_child;
            }
        }
    } else {
        $comments_flat = $_comments;
    }
    /**
     * Filters the comments array.
     *
     * @since 2.1.0
     *
     * @param array $comments Array of comments supplied to the comments template.
     * @param int   $post_ID  Post ID.
     */
    $wp_query->comments = apply_filters('comments_array', $comments_flat, $post->ID);
    $comments =& $wp_query->comments;
    $wp_query->comment_count = count($wp_query->comments);
    $wp_query->max_num_comment_pages = $comment_query->max_num_pages;
    if ($separate_comments) {
        $wp_query->comments_by_type = separate_comments($comments);
        $comments_by_type =& $wp_query->comments_by_type;
    } else {
        $wp_query->comments_by_type = array();
    }
    $overridden_cpage = false;
    if ('' == get_query_var('cpage') && $wp_query->max_num_comment_pages > 1) {
        set_query_var('cpage', ('newest' == get_option('default_comments_page')) ? get_comment_pages_count() : 1);
        $overridden_cpage = true;
    }
    if (!defined('COMMENTS_TEMPLATE')) {
        define('COMMENTS_TEMPLATE', true);
    }
    $theme_template = STYLESHEETPATH . $file;
    /**
     * Filters the path to the theme template file used for the comments template.
     *
     * @since 1.5.1
     *
     * @param string $theme_template The path to the theme template file.
     */
    $include = apply_filters('comments_template', $theme_template);
    if (file_exists($include)) {
        require $include;
    } elseif (file_exists(TEMPLATEPATH . $file)) {
        require TEMPLATEPATH . $file;
    } else {
        // Backward compat code will be removed in a future release
        require ABSPATH . WPINC . '/theme-compat/comments.php';
    }
}

WordPress Version: 4.6

/**
 * Load the comment template specified in $file.
 *
 * Will not display the comments template if not on single post or page, or if
 * the post does not have comments.
 *
 * Uses the WordPress database object to query for the comments. The comments
 * are passed through the {@see 'comments_array'} filter hook with the list of comments
 * and the post ID respectively.
 *
 * The `$file` path is passed through a filter hook called {@see 'comments_template'},
 * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
 * first and if it fails it will require the default comment template from the
 * default theme. If either does not exist, then the WordPress process will be
 * halted. It is advised for that reason, that the default theme is not deleted.
 *
 * Will not try to get the comments if the post has none.
 *
 * @since 1.5.0
 *
 * @global WP_Query   $wp_query
 * @global WP_Post    $post
 * @global wpdb       $wpdb
 * @global int        $id
 * @global WP_Comment $comment
 * @global string     $user_login
 * @global int        $user_ID
 * @global string     $user_identity
 * @global bool       $overridden_cpage
 * @global bool       $withcomments
 *
 * @param string $file              Optional. The file to load. Default '/comments.php'.
 * @param bool   $separate_comments Optional. Whether to separate the comments by comment type.
 *                                  Default false.
 */
function comments_template($file = '/comments.php', $separate_comments = false)
{
    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
    if (!(is_single() || is_page() || $withcomments) || empty($post)) {
        return;
    }
    if (empty($file)) {
        $file = '/comments.php';
    }
    $req = get_option('require_name_email');
    /*
     * Comment author information fetched from the comment cookies.
     */
    $commenter = wp_get_current_commenter();
    /*
     * The name of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author = $commenter['comment_author'];
    /*
     * The email address of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author_email = $commenter['comment_author_email'];
    /*
     * The url of the current comment author escaped for use in attributes.
     */
    $comment_author_url = esc_url($commenter['comment_author_url']);
    $comment_args = array('orderby' => 'comment_date_gmt', 'order' => 'ASC', 'status' => 'approve', 'post_id' => $post->ID, 'no_found_rows' => false, 'update_comment_meta_cache' => false);
    if (get_option('thread_comments')) {
        $comment_args['hierarchical'] = 'threaded';
    } else {
        $comment_args['hierarchical'] = false;
    }
    if ($user_ID) {
        $comment_args['include_unapproved'] = array($user_ID);
    } elseif (!empty($comment_author_email)) {
        $comment_args['include_unapproved'] = array($comment_author_email);
    }
    $per_page = 0;
    if (get_option('page_comments')) {
        $per_page = (int) get_query_var('comments_per_page');
        if (0 === $per_page) {
            $per_page = (int) get_option('comments_per_page');
        }
        $comment_args['number'] = $per_page;
        $page = (int) get_query_var('cpage');
        if ($page) {
            $comment_args['offset'] = ($page - 1) * $per_page;
        } elseif ('oldest' === get_option('default_comments_page')) {
            $comment_args['offset'] = 0;
        } else {
            // If fetching the first page of 'newest', we need a top-level comment count.
            $top_level_query = new WP_Comment_Query();
            $top_level_args = array('count' => true, 'orderby' => false, 'post_id' => $post->ID, 'status' => 'approve');
            if ($comment_args['hierarchical']) {
                $top_level_args['parent'] = 0;
            }
            if (isset($comment_args['include_unapproved'])) {
                $top_level_args['include_unapproved'] = $comment_args['include_unapproved'];
            }
            $top_level_count = $top_level_query->query($top_level_args);
            $comment_args['offset'] = (ceil($top_level_count / $per_page) - 1) * $per_page;
        }
    }
    /**
     * Filters the arguments used to query comments in comments_template().
     *
     * @since 4.5.0
     *
     * @see WP_Comment_Query::__construct()
     *
     * @param array $comment_args {
     *     Array of WP_Comment_Query arguments.
     *
     *     @type string|array $orderby                   Field(s) to order by.
     *     @type string       $order                     Order of results. Accepts 'ASC' or 'DESC'.
     *     @type string       $status                    Comment status.
     *     @type array        $include_unapproved        Array of IDs or email addresses whose unapproved comments
     *                                                   will be included in results.
     *     @type int          $post_id                   ID of the post.
     *     @type bool         $no_found_rows             Whether to refrain from querying for found rows.
     *     @type bool         $update_comment_meta_cache Whether to prime cache for comment meta.
     *     @type bool|string  $hierarchical              Whether to query for comments hierarchically.
     *     @type int          $offset                    Comment offset.
     *     @type int          $number                    Number of comments to fetch.
     * }
     */
    $comment_args = apply_filters('comments_template_query_args', $comment_args);
    $comment_query = new WP_Comment_Query($comment_args);
    $_comments = $comment_query->comments;
    // Trees must be flattened before they're passed to the walker.
    if ($comment_args['hierarchical']) {
        $comments_flat = array();
        foreach ($_comments as $_comment) {
            $comments_flat[] = $_comment;
            $comment_children = $_comment->get_children(array('format' => 'flat', 'status' => $comment_args['status'], 'orderby' => $comment_args['orderby']));
            foreach ($comment_children as $comment_child) {
                $comments_flat[] = $comment_child;
            }
        }
    } else {
        $comments_flat = $_comments;
    }
    /**
     * Filters the comments array.
     *
     * @since 2.1.0
     *
     * @param array $comments Array of comments supplied to the comments template.
     * @param int   $post_ID  Post ID.
     */
    $wp_query->comments = apply_filters('comments_array', $comments_flat, $post->ID);
    $comments =& $wp_query->comments;
    $wp_query->comment_count = count($wp_query->comments);
    $wp_query->max_num_comment_pages = $comment_query->max_num_pages;
    if ($separate_comments) {
        $wp_query->comments_by_type = separate_comments($comments);
        $comments_by_type =& $wp_query->comments_by_type;
    } else {
        $wp_query->comments_by_type = array();
    }
    $overridden_cpage = false;
    if ('' == get_query_var('cpage') && $wp_query->max_num_comment_pages > 1) {
        set_query_var('cpage', ('newest' == get_option('default_comments_page')) ? get_comment_pages_count() : 1);
        $overridden_cpage = true;
    }
    if (!defined('COMMENTS_TEMPLATE')) {
        define('COMMENTS_TEMPLATE', true);
    }
    $theme_template = STYLESHEETPATH . $file;
    /**
     * Filters the path to the theme template file used for the comments template.
     *
     * @since 1.5.1
     *
     * @param string $theme_template The path to the theme template file.
     */
    $include = apply_filters('comments_template', $theme_template);
    if (file_exists($include)) {
        require $include;
    } elseif (file_exists(TEMPLATEPATH . $file)) {
        require TEMPLATEPATH . $file;
    } else {
        // Backward compat code will be removed in a future release
        require ABSPATH . WPINC . '/theme-compat/comments.php';
    }
}

WordPress Version: 4.5

/**
 * Load the comment template specified in $file.
 *
 * Will not display the comments template if not on single post or page, or if
 * the post does not have comments.
 *
 * Uses the WordPress database object to query for the comments. The comments
 * are passed through the 'comments_array' filter hook with the list of comments
 * and the post ID respectively.
 *
 * The $file path is passed through a filter hook called, 'comments_template'
 * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
 * first and if it fails it will require the default comment template from the
 * default theme. If either does not exist, then the WordPress process will be
 * halted. It is advised for that reason, that the default theme is not deleted.
 *
 * Will not try to get the comments if the post has none.
 *
 * @since 1.5.0
 *
 * @global WP_Query   $wp_query
 * @global WP_Post    $post
 * @global wpdb       $wpdb
 * @global int        $id
 * @global WP_Comment $comment
 * @global string     $user_login
 * @global int        $user_ID
 * @global string     $user_identity
 * @global bool       $overridden_cpage
 * @global bool       $withcomments
 *
 * @param string $file              Optional. The file to load. Default '/comments.php'.
 * @param bool   $separate_comments Optional. Whether to separate the comments by comment type.
 *                                  Default false.
 */
function comments_template($file = '/comments.php', $separate_comments = false)
{
    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
    if (!(is_single() || is_page() || $withcomments) || empty($post)) {
        return;
    }
    if (empty($file)) {
        $file = '/comments.php';
    }
    $req = get_option('require_name_email');
    /*
     * Comment author information fetched from the comment cookies.
     */
    $commenter = wp_get_current_commenter();
    /*
     * The name of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author = $commenter['comment_author'];
    /*
     * The email address of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author_email = $commenter['comment_author_email'];
    /*
     * The url of the current comment author escaped for use in attributes.
     */
    $comment_author_url = esc_url($commenter['comment_author_url']);
    $comment_args = array('orderby' => 'comment_date_gmt', 'order' => 'ASC', 'status' => 'approve', 'post_id' => $post->ID, 'no_found_rows' => false, 'update_comment_meta_cache' => false);
    if (get_option('thread_comments')) {
        $comment_args['hierarchical'] = 'threaded';
    } else {
        $comment_args['hierarchical'] = false;
    }
    if ($user_ID) {
        $comment_args['include_unapproved'] = array($user_ID);
    } elseif (!empty($comment_author_email)) {
        $comment_args['include_unapproved'] = array($comment_author_email);
    }
    $per_page = 0;
    if (get_option('page_comments')) {
        $per_page = (int) get_query_var('comments_per_page');
        if (0 === $per_page) {
            $per_page = (int) get_option('comments_per_page');
        }
        $comment_args['number'] = $per_page;
        $page = (int) get_query_var('cpage');
        if ($page) {
            $comment_args['offset'] = ($page - 1) * $per_page;
        } elseif ('oldest' === get_option('default_comments_page')) {
            $comment_args['offset'] = 0;
        } else {
            // If fetching the first page of 'newest', we need a top-level comment count.
            $top_level_query = new WP_Comment_Query();
            $top_level_args = array('count' => true, 'orderby' => false, 'post_id' => $post->ID, 'status' => 'approve');
            if ($comment_args['hierarchical']) {
                $top_level_args['parent'] = 0;
            }
            if (isset($comment_args['include_unapproved'])) {
                $top_level_args['include_unapproved'] = $comment_args['include_unapproved'];
            }
            $top_level_count = $top_level_query->query($top_level_args);
            $comment_args['offset'] = (ceil($top_level_count / $per_page) - 1) * $per_page;
        }
    }
    /**
     * Filters the arguments used to query comments in comments_template().
     *
     * @since 4.5.0
     *
     * @see WP_Comment_Query::__construct()
     *
     * @param array $comment_args {
     *     Array of WP_Comment_Query arguments.
     *
     *     @type string|array $orderby                   Field(s) to order by.
     *     @type string       $order                     Order of results. Accepts 'ASC' or 'DESC'.
     *     @type string       $status                    Comment status.
     *     @type array        $include_unapproved        Array of IDs or email addresses whose unapproved comments
     *                                                   will be included in results.
     *     @type int          $post_id                   ID of the post.
     *     @type bool         $no_found_rows             Whether to refrain from querying for found rows.
     *     @type bool         $update_comment_meta_cache Whether to prime cache for comment meta.
     *     @type bool|string  $hierarchical              Whether to query for comments hierarchically.
     *     @type int          $offset                    Comment offset.
     *     @type int          $number                    Number of comments to fetch.
     * }
     */
    $comment_args = apply_filters('comments_template_query_args', $comment_args);
    $comment_query = new WP_Comment_Query($comment_args);
    $_comments = $comment_query->comments;
    // Trees must be flattened before they're passed to the walker.
    if ($comment_args['hierarchical']) {
        $comments_flat = array();
        foreach ($_comments as $_comment) {
            $comments_flat[] = $_comment;
            $comment_children = $_comment->get_children(array('format' => 'flat', 'status' => $comment_args['status'], 'orderby' => $comment_args['orderby']));
            foreach ($comment_children as $comment_child) {
                $comments_flat[] = $comment_child;
            }
        }
    } else {
        $comments_flat = $_comments;
    }
    /**
     * Filter the comments array.
     *
     * @since 2.1.0
     *
     * @param array $comments Array of comments supplied to the comments template.
     * @param int   $post_ID  Post ID.
     */
    $wp_query->comments = apply_filters('comments_array', $comments_flat, $post->ID);
    $comments =& $wp_query->comments;
    $wp_query->comment_count = count($wp_query->comments);
    $wp_query->max_num_comment_pages = $comment_query->max_num_pages;
    if ($separate_comments) {
        $wp_query->comments_by_type = separate_comments($comments);
        $comments_by_type =& $wp_query->comments_by_type;
    } else {
        $wp_query->comments_by_type = array();
    }
    $overridden_cpage = false;
    if ('' == get_query_var('cpage') && $wp_query->max_num_comment_pages > 1) {
        set_query_var('cpage', ('newest' == get_option('default_comments_page')) ? get_comment_pages_count() : 1);
        $overridden_cpage = true;
    }
    if (!defined('COMMENTS_TEMPLATE')) {
        define('COMMENTS_TEMPLATE', true);
    }
    $theme_template = STYLESHEETPATH . $file;
    /**
     * Filter the path to the theme template file used for the comments template.
     *
     * @since 1.5.1
     *
     * @param string $theme_template The path to the theme template file.
     */
    $include = apply_filters('comments_template', $theme_template);
    if (file_exists($include)) {
        require $include;
    } elseif (file_exists(TEMPLATEPATH . $file)) {
        require TEMPLATEPATH . $file;
    } else {
        // Backward compat code will be removed in a future release
        require ABSPATH . WPINC . '/theme-compat/comments.php';
    }
}

WordPress Version: .10

/**
 * Load the comment template specified in $file.
 *
 * Will not display the comments template if not on single post or page, or if
 * the post does not have comments.
 *
 * Uses the WordPress database object to query for the comments. The comments
 * are passed through the 'comments_array' filter hook with the list of comments
 * and the post ID respectively.
 *
 * The $file path is passed through a filter hook called, 'comments_template'
 * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
 * first and if it fails it will require the default comment template from the
 * default theme. If either does not exist, then the WordPress process will be
 * halted. It is advised for that reason, that the default theme is not deleted.
 *
 * @uses $withcomments Will not try to get the comments if the post has none.
 *
 * @since 1.5.0
 *
 * @global WP_Query   $wp_query
 * @global WP_Post    $post
 * @global wpdb       $wpdb
 * @global int        $id
 * @global WP_Comment $comment
 * @global string     $user_login
 * @global int        $user_ID
 * @global string     $user_identity
 * @global bool       $overridden_cpage
 *
 * @param string $file              Optional. The file to load. Default '/comments.php'.
 * @param bool   $separate_comments Optional. Whether to separate the comments by comment type.
 *                                  Default false.
 */
function comments_template($file = '/comments.php', $separate_comments = false)
{
    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
    if (!(is_single() || is_page() || $withcomments) || empty($post)) {
        return;
    }
    if (empty($file)) {
        $file = '/comments.php';
    }
    $req = get_option('require_name_email');
    /*
     * Comment author information fetched from the comment cookies.
     */
    $commenter = wp_get_current_commenter();
    /*
     * The name of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author = $commenter['comment_author'];
    /*
     * The email address of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author_email = $commenter['comment_author_email'];
    /*
     * The url of the current comment author escaped for use in attributes.
     */
    $comment_author_url = esc_url($commenter['comment_author_url']);
    $comment_args = array('orderby' => 'comment_date_gmt', 'order' => 'ASC', 'status' => 'approve', 'post_id' => $post->ID, 'no_found_rows' => false, 'update_comment_meta_cache' => false);
    if (get_option('thread_comments')) {
        $comment_args['hierarchical'] = 'threaded';
    } else {
        $comment_args['hierarchical'] = false;
    }
    if ($user_ID) {
        $comment_args['include_unapproved'] = array($user_ID);
    } elseif (!empty($comment_author_email)) {
        $comment_args['include_unapproved'] = array($comment_author_email);
    }
    $per_page = 0;
    if (get_option('page_comments')) {
        $per_page = (int) get_query_var('comments_per_page');
        if (0 === $per_page) {
            $per_page = (int) get_option('comments_per_page');
        }
        $comment_args['number'] = $per_page;
        $page = (int) get_query_var('cpage');
        if ($page) {
            $comment_args['offset'] = ($page - 1) * $per_page;
        } elseif ('oldest' === get_option('default_comments_page')) {
            $comment_args['offset'] = 0;
        } else {
            // If fetching the first page of 'newest', we need a top-level comment count.
            $top_level_query = new WP_Comment_Query();
            $top_level_args = array('count' => true, 'orderby' => false, 'post_id' => $post->ID, 'status' => 'approve');
            if ($comment_args['hierarchical']) {
                $top_level_args['parent'] = 0;
            }
            if (isset($comment_args['include_unapproved'])) {
                $top_level_args['include_unapproved'] = $comment_args['include_unapproved'];
            }
            $top_level_count = $top_level_query->query($top_level_args);
            $comment_args['offset'] = (ceil($top_level_count / $per_page) - 1) * $per_page;
        }
    }
    $comment_query = new WP_Comment_Query($comment_args);
    $_comments = $comment_query->comments;
    // Trees must be flattened before they're passed to the walker.
    if ($comment_args['hierarchical']) {
        $comments_flat = array();
        foreach ($_comments as $_comment) {
            $comments_flat[] = $_comment;
            $comment_children = $_comment->get_children(array('format' => 'flat', 'status' => $comment_args['status'], 'orderby' => $comment_args['orderby']));
            foreach ($comment_children as $comment_child) {
                $comments_flat[] = $comment_child;
            }
        }
    } else {
        $comments_flat = $_comments;
    }
    /**
     * Filter the comments array.
     *
     * @since 2.1.0
     *
     * @param array $comments Array of comments supplied to the comments template.
     * @param int   $post_ID  Post ID.
     */
    $wp_query->comments = apply_filters('comments_array', $comments_flat, $post->ID);
    // Set up lazy-loading for comment metadata.
    add_action('get_comment_metadata', array($wp_query, 'lazyload_comment_meta'), 10, 2);
    $comments =& $wp_query->comments;
    $wp_query->comment_count = count($wp_query->comments);
    $wp_query->max_num_comment_pages = $comment_query->max_num_pages;
    if ($separate_comments) {
        $wp_query->comments_by_type = separate_comments($comments);
        $comments_by_type =& $wp_query->comments_by_type;
    } else {
        $wp_query->comments_by_type = array();
    }
    $overridden_cpage = false;
    if ('' == get_query_var('cpage') && $wp_query->max_num_comment_pages > 1) {
        set_query_var('cpage', ('newest' == get_option('default_comments_page')) ? get_comment_pages_count() : 1);
        $overridden_cpage = true;
    }
    if (!defined('COMMENTS_TEMPLATE')) {
        define('COMMENTS_TEMPLATE', true);
    }
    $theme_template = STYLESHEETPATH . $file;
    /**
     * Filter the path to the theme template file used for the comments template.
     *
     * @since 1.5.1
     *
     * @param string $theme_template The path to the theme template file.
     */
    $include = apply_filters('comments_template', $theme_template);
    if (file_exists($include)) {
        require $include;
    } elseif (file_exists(TEMPLATEPATH . $file)) {
        require TEMPLATEPATH . $file;
    } else {
        // Backward compat code will be removed in a future release
        require ABSPATH . WPINC . '/theme-compat/comments.php';
    }
}

WordPress Version: 4.1

/**
 * Load the comment template specified in $file.
 *
 * Will not display the comments template if not on single post or page, or if
 * the post does not have comments.
 *
 * Uses the WordPress database object to query for the comments. The comments
 * are passed through the 'comments_array' filter hook with the list of comments
 * and the post ID respectively.
 *
 * The $file path is passed through a filter hook called, 'comments_template'
 * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
 * first and if it fails it will require the default comment template from the
 * default theme. If either does not exist, then the WordPress process will be
 * halted. It is advised for that reason, that the default theme is not deleted.
 *
 * @uses $withcomments Will not try to get the comments if the post has none.
 *
 * @since 1.5.0
 *
 * @global WP_Query   $wp_query
 * @global WP_Post    $post
 * @global wpdb       $wpdb
 * @global int        $id
 * @global WP_Comment $comment
 * @global string     $user_login
 * @global int        $user_ID
 * @global string     $user_identity
 * @global bool       $overridden_cpage
 *
 * @param string $file              Optional. The file to load. Default '/comments.php'.
 * @param bool   $separate_comments Optional. Whether to separate the comments by comment type.
 *                                  Default false.
 */
function comments_template($file = '/comments.php', $separate_comments = false)
{
    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
    if (!(is_single() || is_page() || $withcomments) || empty($post)) {
        return;
    }
    if (empty($file)) {
        $file = '/comments.php';
    }
    $req = get_option('require_name_email');
    /*
     * Comment author information fetched from the comment cookies.
     */
    $commenter = wp_get_current_commenter();
    /*
     * The name of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author = $commenter['comment_author'];
    /*
     * The email address of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author_email = $commenter['comment_author_email'];
    /*
     * The url of the current comment author escaped for use in attributes.
     */
    $comment_author_url = esc_url($commenter['comment_author_url']);
    $comment_args = array('orderby' => 'comment_date_gmt', 'order' => 'ASC', 'status' => 'approve', 'post_id' => $post->ID, 'hierarchical' => 'threaded', 'no_found_rows' => false, 'update_comment_meta_cache' => false);
    if ($user_ID) {
        $comment_args['include_unapproved'] = array($user_ID);
    } elseif (!empty($comment_author_email)) {
        $comment_args['include_unapproved'] = array($comment_author_email);
    }
    $per_page = 0;
    if (get_option('page_comments')) {
        $per_page = (int) get_query_var('comments_per_page');
        if (0 === $per_page) {
            $per_page = (int) get_option('comments_per_page');
        }
        $comment_args['number'] = $per_page;
        $page = (int) get_query_var('cpage');
        if ($page) {
            $comment_args['offset'] = ($page - 1) * $per_page;
        } elseif ('oldest' === get_option('default_comments_page')) {
            $comment_args['offset'] = 0;
        } else {
            // If fetching the first page of 'newest', we need a top-level comment count.
            $top_level_query = new WP_Comment_Query();
            $top_level_args = array('count' => true, 'orderby' => false, 'post_id' => $post->ID, 'parent' => 0, 'status' => 'approve');
            if (isset($comment_args['include_unapproved'])) {
                $top_level_args['include_unapproved'] = $comment_args['include_unapproved'];
            }
            $top_level_count = $top_level_query->query($top_level_args);
            $comment_args['offset'] = (ceil($top_level_count / $per_page) - 1) * $per_page;
        }
    }
    $comment_query = new WP_Comment_Query($comment_args);
    $_comments = $comment_query->comments;
    // Trees must be flattened before they're passed to the walker.
    $comments_flat = array();
    foreach ($_comments as $_comment) {
        $comments_flat[] = $_comment;
        $comment_children = $_comment->get_children(array('format' => 'flat', 'status' => $comment_args['status'], 'orderby' => $comment_args['orderby']));
        foreach ($comment_children as $comment_child) {
            $comments_flat[] = $comment_child;
        }
    }
    /**
     * Filter the comments array.
     *
     * @since 2.1.0
     *
     * @param array $comments Array of comments supplied to the comments template.
     * @param int   $post_ID  Post ID.
     */
    $wp_query->comments = apply_filters('comments_array', $comments_flat, $post->ID);
    // Set up lazy-loading for comment metadata.
    add_action('get_comment_metadata', array($wp_query, 'lazyload_comment_meta'), 10, 2);
    $comments =& $wp_query->comments;
    $wp_query->comment_count = count($wp_query->comments);
    $wp_query->max_num_comment_pages = $comment_query->max_num_pages;
    if ($separate_comments) {
        $wp_query->comments_by_type = separate_comments($comments);
        $comments_by_type =& $wp_query->comments_by_type;
    } else {
        $wp_query->comments_by_type = array();
    }
    $overridden_cpage = false;
    if ('' == get_query_var('cpage') && $wp_query->max_num_comment_pages > 1) {
        set_query_var('cpage', ('newest' == get_option('default_comments_page')) ? get_comment_pages_count() : 1);
        $overridden_cpage = true;
    }
    if (!defined('COMMENTS_TEMPLATE')) {
        define('COMMENTS_TEMPLATE', true);
    }
    $theme_template = STYLESHEETPATH . $file;
    /**
     * Filter the path to the theme template file used for the comments template.
     *
     * @since 1.5.1
     *
     * @param string $theme_template The path to the theme template file.
     */
    $include = apply_filters('comments_template', $theme_template);
    if (file_exists($include)) {
        require $include;
    } elseif (file_exists(TEMPLATEPATH . $file)) {
        require TEMPLATEPATH . $file;
    } else {
        // Backward compat code will be removed in a future release
        require ABSPATH . WPINC . '/theme-compat/comments.php';
    }
}

WordPress Version: 4.4

/**
 * Load the comment template specified in $file.
 *
 * Will not display the comments template if not on single post or page, or if
 * the post does not have comments.
 *
 * Uses the WordPress database object to query for the comments. The comments
 * are passed through the 'comments_array' filter hook with the list of comments
 * and the post ID respectively.
 *
 * The $file path is passed through a filter hook called, 'comments_template'
 * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
 * first and if it fails it will require the default comment template from the
 * default theme. If either does not exist, then the WordPress process will be
 * halted. It is advised for that reason, that the default theme is not deleted.
 *
 * @uses $withcomments Will not try to get the comments if the post has none.
 *
 * @since 1.5.0
 *
 * @global WP_Query   $wp_query
 * @global WP_Post    $post
 * @global wpdb       $wpdb
 * @global int        $id
 * @global WP_Comment $comment
 * @global string     $user_login
 * @global int        $user_ID
 * @global string     $user_identity
 * @global bool       $overridden_cpage
 *
 * @param string $file              Optional. The file to load. Default '/comments.php'.
 * @param bool   $separate_comments Optional. Whether to separate the comments by comment type.
 *                                  Default false.
 */
function comments_template($file = '/comments.php', $separate_comments = false)
{
    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
    if (!(is_single() || is_page() || $withcomments) || empty($post)) {
        return;
    }
    if (empty($file)) {
        $file = '/comments.php';
    }
    $req = get_option('require_name_email');
    /*
     * Comment author information fetched from the comment cookies.
     */
    $commenter = wp_get_current_commenter();
    /*
     * The name of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author = $commenter['comment_author'];
    /*
     * The email address of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author_email = $commenter['comment_author_email'];
    /*
     * The url of the current comment author escaped for use in attributes.
     */
    $comment_author_url = esc_url($commenter['comment_author_url']);
    $comment_args = array('orderby' => 'comment_date_gmt', 'order' => 'ASC', 'status' => 'approve', 'post_id' => $post->ID, 'hierarchical' => 'threaded', 'no_found_rows' => false, 'update_comment_meta_cache' => false);
    if ($user_ID) {
        $comment_args['include_unapproved'] = array($user_ID);
    } elseif (!empty($comment_author_email)) {
        $comment_args['include_unapproved'] = array($comment_author_email);
    }
    $per_page = 0;
    if (get_option('page_comments')) {
        $per_page = (int) get_query_var('comments_per_page');
        if (0 === $per_page) {
            $per_page = (int) get_option('comments_per_page');
        }
        $comment_args['number'] = $per_page;
        $page = (int) get_query_var('cpage');
        if ($page) {
            $comment_args['offset'] = ($page - 1) * $per_page;
        } elseif ('oldest' === get_option('default_comments_page')) {
            $comment_args['offset'] = 0;
        } else {
            // If fetching the first page of 'newest', we need a top-level comment count.
            $top_level_query = new WP_Comment_Query();
            $top_level_count = $top_level_query->query(array('count' => true, 'orderby' => false, 'post_id' => $post->ID, 'parent' => 0));
            $comment_args['offset'] = (ceil($top_level_count / $per_page) - 1) * $per_page;
        }
    }
    $comment_query = new WP_Comment_Query($comment_args);
    $_comments = $comment_query->comments;
    // Trees must be flattened before they're passed to the walker.
    $comments_flat = array();
    foreach ($_comments as $_comment) {
        $comments_flat = array_merge($comments_flat, array($_comment), $_comment->get_children(array('format' => 'flat', 'status' => $comment_args['status'], 'orderby' => $comment_args['orderby'])));
    }
    /**
     * Filter the comments array.
     *
     * @since 2.1.0
     *
     * @param array $comments Array of comments supplied to the comments template.
     * @param int   $post_ID  Post ID.
     */
    $wp_query->comments = apply_filters('comments_array', $comments_flat, $post->ID);
    // Set up lazy-loading for comment metadata.
    add_action('get_comment_metadata', array($wp_query, 'lazyload_comment_meta'), 10, 2);
    $comments =& $wp_query->comments;
    $wp_query->comment_count = count($wp_query->comments);
    $wp_query->max_num_comment_pages = $comment_query->max_num_pages;
    if ($separate_comments) {
        $wp_query->comments_by_type = separate_comments($comments);
        $comments_by_type =& $wp_query->comments_by_type;
    } else {
        $wp_query->comments_by_type = array();
    }
    $overridden_cpage = false;
    if ('' == get_query_var('cpage') && $wp_query->max_num_comment_pages > 1) {
        set_query_var('cpage', ('newest' == get_option('default_comments_page')) ? get_comment_pages_count() : 1);
        $overridden_cpage = true;
    }
    if (!defined('COMMENTS_TEMPLATE')) {
        define('COMMENTS_TEMPLATE', true);
    }
    $theme_template = STYLESHEETPATH . $file;
    /**
     * Filter the path to the theme template file used for the comments template.
     *
     * @since 1.5.1
     *
     * @param string $theme_template The path to the theme template file.
     */
    $include = apply_filters('comments_template', $theme_template);
    if (file_exists($include)) {
        require $include;
    } elseif (file_exists(TEMPLATEPATH . $file)) {
        require TEMPLATEPATH . $file;
    } else {
        // Backward compat code will be removed in a future release
        require ABSPATH . WPINC . '/theme-compat/comments.php';
    }
}

WordPress Version: 4.3

/**
 * Load the comment template specified in $file.
 *
 * Will not display the comments template if not on single post or page, or if
 * the post does not have comments.
 *
 * Uses the WordPress database object to query for the comments. The comments
 * are passed through the 'comments_array' filter hook with the list of comments
 * and the post ID respectively.
 *
 * The $file path is passed through a filter hook called, 'comments_template'
 * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
 * first and if it fails it will require the default comment template from the
 * default theme. If either does not exist, then the WordPress process will be
 * halted. It is advised for that reason, that the default theme is not deleted.
 *
 * @uses $withcomments Will not try to get the comments if the post has none.
 *
 * @since 1.5.0
 *
 * @global WP_Query $wp_query
 * @global WP_Post  $post
 * @global wpdb     $wpdb
 * @global int      $id
 * @global object   $comment
 * @global string   $user_login
 * @global int      $user_ID
 * @global string   $user_identity
 * @global bool     $overridden_cpage
 *
 * @param string $file              Optional. The file to load. Default '/comments.php'.
 * @param bool   $separate_comments Optional. Whether to separate the comments by comment type.
 *                                  Default false.
 */
function comments_template($file = '/comments.php', $separate_comments = false)
{
    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
    if (!(is_single() || is_page() || $withcomments) || empty($post)) {
        return;
    }
    if (empty($file)) {
        $file = '/comments.php';
    }
    $req = get_option('require_name_email');
    /*
     * Comment author information fetched from the comment cookies.
     */
    $commenter = wp_get_current_commenter();
    /*
     * The name of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author = $commenter['comment_author'];
    /*
     * The email address of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author_email = $commenter['comment_author_email'];
    /*
     * The url of the current comment author escaped for use in attributes.
     */
    $comment_author_url = esc_url($commenter['comment_author_url']);
    $comment_args = array('order' => 'ASC', 'orderby' => 'comment_date_gmt', 'status' => 'approve', 'post_id' => $post->ID);
    if ($user_ID) {
        $comment_args['include_unapproved'] = array($user_ID);
    } elseif (!empty($comment_author_email)) {
        $comment_args['include_unapproved'] = array($comment_author_email);
    }
    $comments = get_comments($comment_args);
    /**
     * Filter the comments array.
     *
     * @since 2.1.0
     *
     * @param array $comments Array of comments supplied to the comments template.
     * @param int   $post_ID  Post ID.
     */
    $wp_query->comments = apply_filters('comments_array', $comments, $post->ID);
    $comments =& $wp_query->comments;
    $wp_query->comment_count = count($wp_query->comments);
    if ($separate_comments) {
        $wp_query->comments_by_type = separate_comments($comments);
        $comments_by_type =& $wp_query->comments_by_type;
    }
    $overridden_cpage = false;
    if ('' == get_query_var('cpage') && get_option('page_comments')) {
        set_query_var('cpage', ('newest' == get_option('default_comments_page')) ? get_comment_pages_count() : 1);
        $overridden_cpage = true;
    }
    if (!defined('COMMENTS_TEMPLATE')) {
        define('COMMENTS_TEMPLATE', true);
    }
    $theme_template = STYLESHEETPATH . $file;
    /**
     * Filter the path to the theme template file used for the comments template.
     *
     * @since 1.5.1
     *
     * @param string $theme_template The path to the theme template file.
     */
    $include = apply_filters('comments_template', $theme_template);
    if (file_exists($include)) {
        require $include;
    } elseif (file_exists(TEMPLATEPATH . $file)) {
        require TEMPLATEPATH . $file;
    } else {
        // Backward compat code will be removed in a future release
        require ABSPATH . WPINC . '/theme-compat/comments.php';
    }
}

WordPress Version: 4.2

/**
 * Load the comment template specified in $file.
 *
 * Will not display the comments template if not on single post or page, or if
 * the post does not have comments.
 *
 * Uses the WordPress database object to query for the comments. The comments
 * are passed through the 'comments_array' filter hook with the list of comments
 * and the post ID respectively.
 *
 * The $file path is passed through a filter hook called, 'comments_template'
 * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
 * first and if it fails it will require the default comment template from the
 * default theme. If either does not exist, then the WordPress process will be
 * halted. It is advised for that reason, that the default theme is not deleted.
 *
 * @todo Document globals
 * @uses $withcomments Will not try to get the comments if the post has none.
 *
 * @since 1.5.0
 *
 * @param string $file              Optional. The file to load. Default '/comments.php'.
 * @param bool   $separate_comments Optional. Whether to separate the comments by comment type.
 *                                  Default false.
 * @return null Returns null if no comments appear.
 */
function comments_template($file = '/comments.php', $separate_comments = false)
{
    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
    if (!(is_single() || is_page() || $withcomments) || empty($post)) {
        return;
    }
    if (empty($file)) {
        $file = '/comments.php';
    }
    $req = get_option('require_name_email');
    /*
     * Comment author information fetched from the comment cookies.
     */
    $commenter = wp_get_current_commenter();
    /*
     * The name of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author = $commenter['comment_author'];
    /*
     * The email address of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author_email = $commenter['comment_author_email'];
    /*
     * The url of the current comment author escaped for use in attributes.
     */
    $comment_author_url = esc_url($commenter['comment_author_url']);
    $comment_args = array('order' => 'ASC', 'orderby' => 'comment_date_gmt', 'status' => 'approve', 'post_id' => $post->ID);
    if ($user_ID) {
        $comment_args['include_unapproved'] = array($user_ID);
    } elseif (!empty($comment_author_email)) {
        $comment_args['include_unapproved'] = array($comment_author_email);
    }
    $comments = get_comments($comment_args);
    /**
     * Filter the comments array.
     *
     * @since 2.1.0
     *
     * @param array $comments Array of comments supplied to the comments template.
     * @param int   $post_ID  Post ID.
     */
    $wp_query->comments = apply_filters('comments_array', $comments, $post->ID);
    $comments =& $wp_query->comments;
    $wp_query->comment_count = count($wp_query->comments);
    update_comment_cache($wp_query->comments);
    if ($separate_comments) {
        $wp_query->comments_by_type = separate_comments($comments);
        $comments_by_type =& $wp_query->comments_by_type;
    }
    $overridden_cpage = false;
    if ('' == get_query_var('cpage') && get_option('page_comments')) {
        set_query_var('cpage', ('newest' == get_option('default_comments_page')) ? get_comment_pages_count() : 1);
        $overridden_cpage = true;
    }
    if (!defined('COMMENTS_TEMPLATE')) {
        define('COMMENTS_TEMPLATE', true);
    }
    $theme_template = STYLESHEETPATH . $file;
    /**
     * Filter the path to the theme template file used for the comments template.
     *
     * @since 1.5.1
     *
     * @param string $theme_template The path to the theme template file.
     */
    $include = apply_filters('comments_template', $theme_template);
    if (file_exists($include)) {
        require $include;
    } elseif (file_exists(TEMPLATEPATH . $file)) {
        require TEMPLATEPATH . $file;
    } else {
        // Backward compat code will be removed in a future release
        require ABSPATH . WPINC . '/theme-compat/comments.php';
    }
}

WordPress Version: 4.1

/**
 * Load the comment template specified in $file.
 *
 * Will not display the comments template if not on single post or page, or if
 * the post does not have comments.
 *
 * Uses the WordPress database object to query for the comments. The comments
 * are passed through the 'comments_array' filter hook with the list of comments
 * and the post ID respectively.
 *
 * The $file path is passed through a filter hook called, 'comments_template'
 * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
 * first and if it fails it will require the default comment template from the
 * default theme. If either does not exist, then the WordPress process will be
 * halted. It is advised for that reason, that the default theme is not deleted.
 *
 * @todo Document globals
 * @uses $withcomments Will not try to get the comments if the post has none.
 *
 * @since 1.5.0
 *
 * @param string $file              Optional. The file to load. Default '/comments.php'.
 * @param bool   $separate_comments Optional. Whether to separate the comments by comment type.
 *                                  Default false.
 * @return null Returns null if no comments appear.
 */
function comments_template($file = '/comments.php', $separate_comments = false)
{
    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
    if (!(is_single() || is_page() || $withcomments) || empty($post)) {
        return;
    }
    if (empty($file)) {
        $file = '/comments.php';
    }
    $req = get_option('require_name_email');
    /*
     * Comment author information fetched from the comment cookies.
     * Uuses wp_get_current_commenter().
     */
    $commenter = wp_get_current_commenter();
    /*
     * The name of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author = $commenter['comment_author'];
    /*
     * The email address of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author_email = $commenter['comment_author_email'];
    /*
     * The url of the current comment author escaped for use in attributes.
     */
    $comment_author_url = esc_url($commenter['comment_author_url']);
    $comment_args = array('order' => 'ASC', 'orderby' => 'comment_date_gmt', 'status' => 'approve', 'post_id' => $post->ID);
    if ($user_ID) {
        $comment_args['include_unapproved'] = array($user_ID);
    } else if (!empty($comment_author_email)) {
        $comment_args['include_unapproved'] = array($comment_author_email);
    }
    $comments = get_comments($comment_args);
    /**
     * Filter the comments array.
     *
     * @since 2.1.0
     *
     * @param array $comments Array of comments supplied to the comments template.
     * @param int   $post_ID  Post ID.
     */
    $wp_query->comments = apply_filters('comments_array', $comments, $post->ID);
    $comments =& $wp_query->comments;
    $wp_query->comment_count = count($wp_query->comments);
    update_comment_cache($wp_query->comments);
    if ($separate_comments) {
        $wp_query->comments_by_type = separate_comments($comments);
        $comments_by_type =& $wp_query->comments_by_type;
    }
    $overridden_cpage = false;
    if ('' == get_query_var('cpage') && get_option('page_comments')) {
        set_query_var('cpage', ('newest' == get_option('default_comments_page')) ? get_comment_pages_count() : 1);
        $overridden_cpage = true;
    }
    if (!defined('COMMENTS_TEMPLATE')) {
        define('COMMENTS_TEMPLATE', true);
    }
    $theme_template = STYLESHEETPATH . $file;
    /**
     * Filter the path to the theme template file used for the comments template.
     *
     * @since 1.5.1
     *
     * @param string $theme_template The path to the theme template file.
     */
    $include = apply_filters('comments_template', $theme_template);
    if (file_exists($include)) {
        require $include;
    } elseif (file_exists(TEMPLATEPATH . $file)) {
        require TEMPLATEPATH . $file;
    } else {
        // Backward compat code will be removed in a future release
        require ABSPATH . WPINC . '/theme-compat/comments.php';
    }
}

WordPress Version: 3.9

/**
 * Load the comment template specified in $file.
 *
 * Will not display the comments template if not on single post or page, or if
 * the post does not have comments.
 *
 * Uses the WordPress database object to query for the comments. The comments
 * are passed through the 'comments_array' filter hook with the list of comments
 * and the post ID respectively.
 *
 * The $file path is passed through a filter hook called, 'comments_template'
 * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
 * first and if it fails it will require the default comment template from the
 * default theme. If either does not exist, then the WordPress process will be
 * halted. It is advised for that reason, that the default theme is not deleted.
 *
 * @todo Document globals
 * @uses $withcomments Will not try to get the comments if the post has none.
 *
 * @since 1.5.0
 *
 * @param string $file              Optional. The file to load. Default '/comments.php'.
 * @param bool   $separate_comments Optional. Whether to separate the comments by comment type.
 *                                  Default false.
 * @return null Returns null if no comments appear.
 */
function comments_template($file = '/comments.php', $separate_comments = false)
{
    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
    if (!(is_single() || is_page() || $withcomments) || empty($post)) {
        return;
    }
    if (empty($file)) {
        $file = '/comments.php';
    }
    $req = get_option('require_name_email');
    /*
     * Comment author information fetched from the comment cookies.
     * Uuses wp_get_current_commenter().
     */
    $commenter = wp_get_current_commenter();
    /*
     * The name of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author = $commenter['comment_author'];
    /*
     * The email address of the current comment author escaped for use in attributes.
     * Escaped by sanitize_comment_cookies().
     */
    $comment_author_email = $commenter['comment_author_email'];
    /*
     * The url of the current comment author escaped for use in attributes.
     */
    $comment_author_url = esc_url($commenter['comment_author_url']);
    /** @todo Use API instead of SELECTs. */
    if ($user_ID) {
        $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) )  ORDER BY comment_date_gmt", $post->ID, $user_ID));
    } else if (empty($comment_author)) {
        $comments = get_comments(array('post_id' => $post->ID, 'status' => 'approve', 'order' => 'ASC'));
    } else {
        $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, wp_specialchars_decode($comment_author, ENT_QUOTES), $comment_author_email));
    }
    /**
     * Filter the comments array.
     *
     * @since 2.1.0
     *
     * @param array $comments Array of comments supplied to the comments template.
     * @param int   $post_ID  Post ID.
     */
    $wp_query->comments = apply_filters('comments_array', $comments, $post->ID);
    $comments =& $wp_query->comments;
    $wp_query->comment_count = count($wp_query->comments);
    update_comment_cache($wp_query->comments);
    if ($separate_comments) {
        $wp_query->comments_by_type = separate_comments($comments);
        $comments_by_type =& $wp_query->comments_by_type;
    }
    $overridden_cpage = false;
    if ('' == get_query_var('cpage') && get_option('page_comments')) {
        set_query_var('cpage', ('newest' == get_option('default_comments_page')) ? get_comment_pages_count() : 1);
        $overridden_cpage = true;
    }
    if (!defined('COMMENTS_TEMPLATE')) {
        define('COMMENTS_TEMPLATE', true);
    }
    $theme_template = STYLESHEETPATH . $file;
    /**
     * Filter the path to the theme template file used for the comments template.
     *
     * @since 1.5.1
     *
     * @param string $theme_template The path to the theme template file.
     */
    $include = apply_filters('comments_template', $theme_template);
    if (file_exists($include)) {
        require $include;
    } elseif (file_exists(TEMPLATEPATH . $file)) {
        require TEMPLATEPATH . $file;
    } else {
        // Backward compat code will be removed in a future release
        require ABSPATH . WPINC . '/theme-compat/comments.php';
    }
}

WordPress Version: 3.8

/**
 * Load the comment template specified in $file.
 *
 * Will not display the comments template if not on single post or page, or if
 * the post does not have comments.
 *
 * Uses the WordPress database object to query for the comments. The comments
 * are passed through the 'comments_array' filter hook with the list of comments
 * and the post ID respectively.
 *
 * The $file path is passed through a filter hook called, 'comments_template'
 * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
 * first and if it fails it will require the default comment template from the
 * default theme. If either does not exist, then the WordPress process will be
 * halted. It is advised for that reason, that the default theme is not deleted.
 *
 * @todo Document globals
 * @uses $withcomments Will not try to get the comments if the post has none.
 *
 * @since 1.5.0
 *
 * @param string $file              Optional. The file to load. Default '/comments.php'.
 * @param bool   $separate_comments Optional. Whether to separate the comments by comment type. Default false.
 * @return null Returns null if no comments appear.
 */
function comments_template($file = '/comments.php', $separate_comments = false)
{
    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
    if (!(is_single() || is_page() || $withcomments) || empty($post)) {
        return;
    }
    if (empty($file)) {
        $file = '/comments.php';
    }
    $req = get_option('require_name_email');
    /**
     * Comment author information fetched from the comment cookies.
     *
     * @uses wp_get_current_commenter()
     */
    $commenter = wp_get_current_commenter();
    /**
     * The name of the current comment author escaped for use in attributes.
     */
    $comment_author = $commenter['comment_author'];
    // Escaped by sanitize_comment_cookies()
    /**
     * The email address of the current comment author escaped for use in attributes.
     */
    $comment_author_email = $commenter['comment_author_email'];
    // Escaped by sanitize_comment_cookies()
    /**
     * The url of the current comment author escaped for use in attributes.
     */
    $comment_author_url = esc_url($commenter['comment_author_url']);
    /** @todo Use API instead of SELECTs. */
    if ($user_ID) {
        $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) )  ORDER BY comment_date_gmt", $post->ID, $user_ID));
    } else if (empty($comment_author)) {
        $comments = get_comments(array('post_id' => $post->ID, 'status' => 'approve', 'order' => 'ASC'));
    } else {
        $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, wp_specialchars_decode($comment_author, ENT_QUOTES), $comment_author_email));
    }
    // keep $comments for legacy's sake
    /**
     * Filter the comments array.
     *
     * @since 2.1.0
     *
     * @param array $comments The array of comments supplied to the comments template.
     * @param int   $post->ID The post ID.
     */
    $wp_query->comments = apply_filters('comments_array', $comments, $post->ID);
    $comments =& $wp_query->comments;
    $wp_query->comment_count = count($wp_query->comments);
    update_comment_cache($wp_query->comments);
    if ($separate_comments) {
        $wp_query->comments_by_type = separate_comments($comments);
        $comments_by_type =& $wp_query->comments_by_type;
    }
    $overridden_cpage = false;
    if ('' == get_query_var('cpage') && get_option('page_comments')) {
        set_query_var('cpage', ('newest' == get_option('default_comments_page')) ? get_comment_pages_count() : 1);
        $overridden_cpage = true;
    }
    if (!defined('COMMENTS_TEMPLATE')) {
        define('COMMENTS_TEMPLATE', true);
    }
    $theme_template = STYLESHEETPATH . $file;
    /**
     * Filter the path to the theme template file used for the comments template.
     *
     * @since 1.5.1
     *
     * @param string $theme_template The path to the theme template file.
     */
    $include = apply_filters('comments_template', $theme_template);
    if (file_exists($include)) {
        require $include;
    } elseif (file_exists(TEMPLATEPATH . $file)) {
        require TEMPLATEPATH . $file;
    } else {
        // Backward compat code will be removed in a future release
        require ABSPATH . WPINC . '/theme-compat/comments.php';
    }
}

WordPress Version: 3.7

/**
 * Load the comment template specified in $file.
 *
 * Will not display the comments template if not on single post or page, or if
 * the post does not have comments.
 *
 * Uses the WordPress database object to query for the comments. The comments
 * are passed through the 'comments_array' filter hook with the list of comments
 * and the post ID respectively.
 *
 * The $file path is passed through a filter hook called, 'comments_template'
 * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
 * first and if it fails it will require the default comment template from the
 * default theme. If either does not exist, then the WordPress process will be
 * halted. It is advised for that reason, that the default theme is not deleted.
 *
 * @todo Document globals
 * @uses $withcomments Will not try to get the comments if the post has none.
 *
 * @since 1.5.0
 *
 * @param string $file              Optional. The file to load. Default '/comments.php'.
 * @param bool   $separate_comments Optional. Whether to separate the comments by comment type. Default false.
 * @return null Returns null if no comments appear.
 */
function comments_template($file = '/comments.php', $separate_comments = false)
{
    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
    if (!(is_single() || is_page() || $withcomments) || empty($post)) {
        return;
    }
    if (empty($file)) {
        $file = '/comments.php';
    }
    $req = get_option('require_name_email');
    /**
     * Comment author information fetched from the comment cookies.
     *
     * @uses wp_get_current_commenter()
     */
    $commenter = wp_get_current_commenter();
    /**
     * The name of the current comment author escaped for use in attributes.
     */
    $comment_author = $commenter['comment_author'];
    // Escaped by sanitize_comment_cookies()
    /**
     * The email address of the current comment author escaped for use in attributes.
     */
    $comment_author_email = $commenter['comment_author_email'];
    // Escaped by sanitize_comment_cookies()
    /**
     * The url of the current comment author escaped for use in attributes.
     */
    $comment_author_url = esc_url($commenter['comment_author_url']);
    /** @todo Use API instead of SELECTs. */
    if ($user_ID) {
        $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) )  ORDER BY comment_date_gmt", $post->ID, $user_ID));
    } else if (empty($comment_author)) {
        $comments = get_comments(array('post_id' => $post->ID, 'status' => 'approve', 'order' => 'ASC'));
    } else {
        $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, wp_specialchars_decode($comment_author, ENT_QUOTES), $comment_author_email));
    }
    // keep $comments for legacy's sake
    /**
     * Filter the comments array.
     *
     * @since 2.1.0
     *
     * @param array $comments The array of comments supplied to the comments template.
     * @param int   $post->ID The post ID.
     */
    $wp_query->comments = apply_filters('comments_array', $comments, $post->ID);
    $comments =& $wp_query->comments;
    $wp_query->comment_count = count($wp_query->comments);
    update_comment_cache($wp_query->comments);
    if ($separate_comments) {
        $wp_query->comments_by_type = separate_comments($comments);
        $comments_by_type =& $wp_query->comments_by_type;
    }
    $overridden_cpage = false;
    if ('' == get_query_var('cpage') && get_option('page_comments')) {
        set_query_var('cpage', ('newest' == get_option('default_comments_page')) ? get_comment_pages_count() : 1);
        $overridden_cpage = true;
    }
    if (!defined('COMMENTS_TEMPLATE')) {
        define('COMMENTS_TEMPLATE', true);
    }
    $theme_template = STYLESHEETPATH . $file;
    /**
     * Filter the path to the theme template file used for the comments template.
     *
     * @since 1.5.2
     *
     * @param string $theme_template The path to the theme template file.
     */
    $include = apply_filters('comments_template', $theme_template);
    if (file_exists($include)) {
        require $include;
    } elseif (file_exists(TEMPLATEPATH . $file)) {
        require TEMPLATEPATH . $file;
    } else {
        // Backward compat code will be removed in a future release
        require ABSPATH . WPINC . '/theme-compat/comments.php';
    }
}