From c85db8e8d74e688ba06b098a36a956b5c4acccb9 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 28 Apr 2009 00:05:43 +0000 Subject: [PATCH] Don't show password protected posts in searches for non-logged in users. Props coffee2code. fixes #9559 git-svn-id: http://svn.automattic.com/wordpress/trunk@11106 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/query.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index 280466416..f723f97bb 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -1759,8 +1759,11 @@ class WP_Query { if (empty($q['sentence']) && count($q['search_terms']) > 1 && $q['search_terms'][0] != $q['s'] ) $search .= " OR ($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}')"; - if ( !empty($search) ) + if ( !empty($search) ) { $search = " AND ({$search}) "; + if ( !is_user_logged_in() ) + $search .= " AND ($wpdb->posts.post_password = '') "; + } } // Category stuff