Comments should not visible on password protected post until password entered.

git-svn-id: https://develop.svn.wordpress.org/trunk@374 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mike Little 2003-09-20 00:03:21 +00:00
parent a67d1752fd
commit 15f2dc914f
2 changed files with 31 additions and 17 deletions

View File

@ -1157,13 +1157,19 @@ function comments_popup_script($width=400, $height=400, $file='b2commentspopup.p
} }
function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') { function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') {
global $id, $b2commentspopupfile, $b2commentsjavascript, $post, $wpdb, $tablecomments; global $id, $b2commentspopupfile, $b2commentsjavascript, $post, $wpdb, $tablecomments, $HTTP_COOKIE_VARS;
global $querystring_start, $querystring_equal, $querystring_separator, $siteurl; global $querystring_start, $querystring_equal, $querystring_separator, $siteurl;
$number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id"); $number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id");
if (0 == $number && 'closed' == $post->comment_status) { if (0 == $number && 'closed' == $post->comment_status) {
echo $none; echo $none;
return; return;
} else { } else {
if (!empty($post->post_password)) { // if there's a password
if ($HTTP_COOKIE_VARS['wp-postpass'] != $post->post_password) { // and it doesn't match the cookie
echo("Enter your password to view comments");
return;
}
}
echo "<a href=\"$siteurl/"; echo "<a href=\"$siteurl/";
if ($b2commentsjavascript) { if ($b2commentsjavascript) {
echo $b2commentspopupfile.$querystring_start.'p'.$querystring_equal.$id.$querystring_separator.'c'.$querystring_equal.'1'; echo $b2commentspopupfile.$querystring_start.'p'.$querystring_equal.$id.$querystring_separator.'c'.$querystring_equal.'1';
@ -1180,6 +1186,7 @@ function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Com
comments_number($zero, $one, $more); comments_number($zero, $one, $more);
echo '</a>'; echo '</a>';
} }
} }
function comment_ID() { function comment_ID() {

View File

@ -3,6 +3,13 @@
die ('Please do not load this page directly. Thanks!'); die ('Please do not load this page directly. Thanks!');
if (($withcomments) or ($c)) { if (($withcomments) or ($c)) {
if (!empty($post->post_password)) { // if there's a password
if ($HTTP_COOKIE_VARS['wp-postpass'] != $post->post_password) { // and it doesn't match the cookie
echo("Enter your password to view comments");
return;
}
}
$comment_author = (empty($HTTP_COOKIE_VARS["comment_author"])) ? "name" : $HTTP_COOKIE_VARS["comment_author"]; $comment_author = (empty($HTTP_COOKIE_VARS["comment_author"])) ? "name" : $HTTP_COOKIE_VARS["comment_author"];
$comment_author_email = (empty($HTTP_COOKIE_VARS["comment_author"])) ? "email" : trim($HTTP_COOKIE_VARS["comment_author_email"]); $comment_author_email = (empty($HTTP_COOKIE_VARS["comment_author"])) ? "email" : trim($HTTP_COOKIE_VARS["comment_author_email"]);
$comment_author_url = (empty($HTTP_COOKIE_VARS["comment_author"])) ? "url" : trim($HTTP_COOKIE_VARS["comment_author_url"]); $comment_author_url = (empty($HTTP_COOKIE_VARS["comment_author"])) ? "url" : trim($HTTP_COOKIE_VARS["comment_author_url"]);