Add some comment API and update comment popup templates to use them. Props David Hose. fixes #1892
git-svn-id: http://svn.automattic.com/wordpress/trunk@3115 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6154d26ea1
commit
5fdc8b56da
|
@ -32,8 +32,8 @@ foreach ($posts as $post) { start_wp();
|
|||
$comment_author = (isset($_COOKIE['comment_author_' . COOKIEHASH])) ? trim($_COOKIE['comment_author_'. COOKIEHASH]) : '';
|
||||
$comment_author_email = (isset($_COOKIE['comment_author_email_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_email_'. COOKIEHASH]) : '';
|
||||
$comment_author_url = (isset($_COOKIE['comment_author_url_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_url_'. COOKIEHASH]) : '';
|
||||
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1' ORDER BY comment_date");
|
||||
$commentstatus = $wpdb->get_row("SELECT comment_status, post_password FROM $wpdb->posts WHERE ID = $id");
|
||||
$comments = get_approved_comments($id);
|
||||
$commentstatus = get_post($id);
|
||||
if (!empty($commentstatus->post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH] != $commentstatus->post_password) { // and it doesn't match the cookie
|
||||
echo(get_the_password_form());
|
||||
} else { ?>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
<?php get_sidebar(); ?>
|
||||
|
||||
<p class="credit"><!--<?php echo $wpdb->num_queries; ?> queries. <?php timer_stop(1); ?> seconds. --> <cite><?php echo sprintf(__("Powered by <a href='http://wordpress.org/' title='%s'><strong>WordPress</strong></a>"), __("Powered by WordPress, state-of-the-art semantic personal publishing platform.")); ?></cite></p>
|
||||
<p class="credit"><!--<?php echo get_num_queries(); ?> queries. <?php timer_stop(1); ?> seconds. --> <cite><?php echo sprintf(__("Powered by <a href='http://wordpress.org/' title='%s'><strong>WordPress</strong></a>"), __("Powered by WordPress, state-of-the-art semantic personal publishing platform.")); ?></cite></p>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
@ -32,9 +32,9 @@ foreach ($posts as $post) { start_wp();
|
|||
$comment_author = (isset($_COOKIE['comment_author_' . COOKIEHASH])) ? trim($_COOKIE['comment_author_'. COOKIEHASH]) : '';
|
||||
$comment_author_email = (isset($_COOKIE['comment_author_email_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_email_'. COOKIEHASH]) : '';
|
||||
$comment_author_url = (isset($_COOKIE['comment_author_url_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_url_'. COOKIEHASH]) : '';
|
||||
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1' ORDER BY comment_date");
|
||||
$commentstatus = $wpdb->get_row("SELECT comment_status, post_password FROM $wpdb->posts WHERE ID = $id");
|
||||
if (!empty($commentstatus->post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH] != $commentstatus->post_password) { // and it doesn't match the cookie
|
||||
$comments = get_approved_comments($id);
|
||||
$post = get_post($id);
|
||||
if (!empty($post->post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
|
||||
echo(get_the_password_form());
|
||||
} else { ?>
|
||||
|
||||
|
@ -52,7 +52,7 @@ if (!empty($commentstatus->post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH
|
|||
<p>No comments yet.</p>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ('open' == $commentstatus->comment_status) { ?>
|
||||
<?php if ('open' == $post->comment_status) { ?>
|
||||
<h2>Leave a comment</h2>
|
||||
<p>Line and paragraph breaks automatic, e-mail address never displayed, <acronym title="Hypertext Markup Language">HTML</acronym> allowed: <code><?php echo allowed_tags(); ?></code></p>
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<a href="http://wordpress.org/">WordPress</a>
|
||||
<br /><a href="feed:<?php bloginfo('rss2_url'); ?>">Entries (RSS)</a>
|
||||
and <a href="feed:<?php bloginfo('comments_rss2_url'); ?>">Comments (RSS)</a>.
|
||||
<!-- <?php echo $wpdb->num_queries; ?> queries. <?php timer_stop(1); ?> seconds. -->
|
||||
<!-- <?php echo get_num_queries(); ?> queries. <?php timer_stop(1); ?> seconds. -->
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -863,4 +863,9 @@ function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $
|
|||
return true;
|
||||
}
|
||||
|
||||
function get_approved_comments($post_id) {
|
||||
global $wpdb;
|
||||
return $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post_id AND comment_approved = '1' ORDER BY comment_date");
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -2146,4 +2146,9 @@ function plugin_basename($file) {
|
|||
return $file;
|
||||
}
|
||||
|
||||
?>
|
||||
function get_num_queries() {
|
||||
global $wpdb;
|
||||
return $wpdb->num_queries;
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue