comments_template ( [$file])
Description
No description provided yet.
No detailed description provided.
Returns
Type: Unknown
No return info provided yet.
Parameters
- $file
- Type: Unknown Default: '/comments.php'
No description provided yet.
No detailed description provided.
Location
- File
- wp-includes/comment-functions.php
- Lines
- 5-45
Related Links
PHPDoc
/**
* No description provided yet.
* @param $file
* @link http://redalt.com/fn/comments_template Detailed Documentation for comments_template at RedAlt
*/
Source
Click here to display source.
<?php
function comments_template( $file = '/comments.php' ) {
global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity;
if ( is_single() || is_page() || $withcomments ) :
$req = get_settings('require_name_email');
$comment_author = '';
if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) {
$comment_author = apply_filters('pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH]);
$comment_author = stripslashes($comment_author);
$comment_author = wp_specialchars($comment_author, true);
}
$comment_author_email = '';
if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) {
$comment_author_email = apply_filters('pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH]);
$comment_author_email = stripslashes($comment_author_email);
$comment_author_email = wp_specialchars($comment_author_email, true);
}
$comment_author_url = '';
if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) {
$comment_author_url = apply_filters('pre_comment_author_url', $_COOKIE['comment_author_url_'.COOKIEHASH]);
$comment_author_url = stripslashes($comment_author_url);
$comment_author_url = wp_specialchars($comment_author_url, true);
}
if ( empty($comment_author) ) {
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' ORDER BY comment_date");
} else {
$author_db = $wpdb->escape($comment_author);
$email_db = $wpdb->escape($comment_author_email);
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND ( comment_approved = '1' OR ( comment_author = '$author_db' AND comment_author_email = '$email_db' AND comment_approved = '0' ) ) ORDER BY comment_date");
}
define('COMMENTS_TEMPLATE', true);
$include = apply_filters('comments_template', TEMPLATEPATH . $file );
if ( file_exists( $include ) )
require( $include );
else
require( ABSPATH . 'wp-content/themes/default/comments.php');
endif;
}
?>
This function documentation, the functions themselves, and any incorporated Codex data are licensed under the GPL. This license extends only to the content of the function reference pages of RedAlt, and not neccessarily the code that runs it or any other pages on the site.
What is Red Alt?
Red Alt is an outlet for Owen Winkler's web tools and provides a consolidated and organized archive of other online web development tools and resources.

» Blogs that link here
