From 5fdc8b56da22fab6236dc2c20d9c9d6062e3174e Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 16 Nov 2005 23:48:12 +0000 Subject: [PATCH] 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 --- wp-content/themes/classic/comments-popup.php | 4 ++-- wp-content/themes/classic/footer.php | 2 +- wp-content/themes/default/comments-popup.php | 8 ++++---- wp-content/themes/default/footer.php | 2 +- wp-includes/comment-functions.php | 5 +++++ wp-includes/functions.php | 7 ++++++- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/wp-content/themes/classic/comments-popup.php b/wp-content/themes/classic/comments-popup.php index 4d22c93c7..f42d38dce 100644 --- a/wp-content/themes/classic/comments-popup.php +++ b/wp-content/themes/classic/comments-popup.php @@ -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 { ?> diff --git a/wp-content/themes/classic/footer.php b/wp-content/themes/classic/footer.php index 047982e9d..0894f78ed 100644 --- a/wp-content/themes/classic/footer.php +++ b/wp-content/themes/classic/footer.php @@ -3,7 +3,7 @@ -

WordPress"), __("Powered by WordPress, state-of-the-art semantic personal publishing platform.")); ?>

+

WordPress"), __("Powered by WordPress, state-of-the-art semantic personal publishing platform.")); ?>

diff --git a/wp-content/themes/default/comments-popup.php b/wp-content/themes/default/comments-popup.php index 980717b90..d5dd17638 100644 --- a/wp-content/themes/default/comments-popup.php +++ b/wp-content/themes/default/comments-popup.php @@ -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

No comments yet.

-comment_status) { ?> +comment_status) { ?>

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed:

diff --git a/wp-content/themes/default/footer.php b/wp-content/themes/default/footer.php index 2973ab602..a6cfd870a 100644 --- a/wp-content/themes/default/footer.php +++ b/wp-content/themes/default/footer.php @@ -6,7 +6,7 @@ WordPress
Entries (RSS) and Comments (RSS). - +

diff --git a/wp-includes/comment-functions.php b/wp-includes/comment-functions.php index ee1a666fe..243800abb 100644 --- a/wp-includes/comment-functions.php +++ b/wp-includes/comment-functions.php @@ -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"); +} + ?> diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 281bd613e..ff653eb9c 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -2146,4 +2146,9 @@ function plugin_basename($file) { return $file; } -?> +function get_num_queries() { + global $wpdb; + return $wpdb->num_queries; +} + +?> \ No newline at end of file