From cddfd974e080b234d01cda0f7ad7d0b358816cd2 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 3 Sep 2008 19:54:14 +0000 Subject: [PATCH] post_password_required(). fixes #7679 git-svn-id: http://svn.automattic.com/wordpress/trunk@8800 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-content/themes/classic/comments-popup.php | 2 +- wp-content/themes/classic/comments.php | 2 +- wp-content/themes/default/comments-popup.php | 2 +- wp-content/themes/default/comments.php | 13 ++---- wp-includes/comment-template.php | 8 ++-- wp-includes/feed.php | 6 +-- wp-includes/post-template.php | 43 +++++++++++++++----- 7 files changed, 45 insertions(+), 31 deletions(-) diff --git a/wp-content/themes/classic/comments-popup.php b/wp-content/themes/classic/comments-popup.php index 4e0a6057e..b28156436 100644 --- a/wp-content/themes/classic/comments-popup.php +++ b/wp-content/themes/classic/comments-popup.php @@ -33,7 +33,7 @@ $commenter = wp_get_current_commenter(); extract($commenter); $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 +if ( post_password_required($commentstatus) ) { // and it doesn't match the cookie echo(get_the_password_form()); } else { ?> diff --git a/wp-content/themes/classic/comments.php b/wp-content/themes/classic/comments.php index 4f92f65f7..dc995776f 100644 --- a/wp-content/themes/classic/comments.php +++ b/wp-content/themes/classic/comments.php @@ -1,4 +1,4 @@ -post_password) && $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) : ?> +

diff --git a/wp-content/themes/default/comments-popup.php b/wp-content/themes/default/comments-popup.php index a57ff21ce..5f739208f 100644 --- a/wp-content/themes/default/comments-popup.php +++ b/wp-content/themes/default/comments-popup.php @@ -33,7 +33,7 @@ $commenter = wp_get_current_commenter(); extract($commenter); $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 +if ( post_password_required($post) ) { // and it doesn't match the cookie echo(get_the_password_form()); } else { ?> diff --git a/wp-content/themes/default/comments.php b/wp-content/themes/default/comments.php index 50c594067..8a70c2d9c 100644 --- a/wp-content/themes/default/comments.php +++ b/wp-content/themes/default/comments.php @@ -2,15 +2,10 @@ if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) die ('Please do not load this page directly. Thanks!'); - if (!empty($post->post_password)) { // if there's a password - if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie - ?> - -

This post is password protected. Enter the password to view comments.

- - +

This post is password protected. Enter the password to view comments.

+ post_password) ) { // if there's a password - if ( !isset($_COOKIE['wp-postpass_' . COOKIEHASH]) || $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password ) { // and it doesn't match the cookie - echo __('Enter your password to view comments'); - return; - } + if ( post_password_required() ) { + echo __('Enter your password to view comments'); + return; } echo '