From 4de3e431904d3f50fb20622d48acac7ee40d7713 Mon Sep 17 00:00:00 2001
From: Erick Hitter <ehitter@gmail.com>
Date: Sat, 11 May 2013 14:05:03 -0500
Subject: [PATCH] Before making any changes to post content or outputting any
 information gleaned from the post content, check if a password is required
 and has been provided if needed.

See https://github.com/ethitter/WP-Print-Friendly/pull/4.
---
 wp-print-friendly.php | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/wp-print-friendly.php b/wp-print-friendly.php
index 95218d3..d592528 100644
--- a/wp-print-friendly.php
+++ b/wp-print-friendly.php
@@ -327,12 +327,13 @@ class wp_print_friendly {
 	 * Filter post content to support printing entire post on one page.
 	 *
 	 * @param string $content
+	 * @uses post_password_required
 	 * @uses get_query_var
 	 * @filter the_content
 	 * @return string
 	 */
 	public function filter_the_content( $content ) {
-		if ( $this->is_print() ) {
+		if ( $this->is_print() && ! post_password_required() ) {
 			$print = get_query_var( $this->query_var );
 
 			if ( $print == 'all' || $print == '/all' || empty( $print ) ) {
@@ -402,12 +403,14 @@ class wp_print_friendly {
 	 * Convert links to endnotes if desired.
 	 *
 	 * @param string $content
-	 * @uses $this::is_print, $this::get_options
+	 * @uses this::is_print
+	 * @uses post_password_required
+	 * @uses this::get_options
 	 * @filter the_content
 	 * @return string
 	 */
 	public function filter_the_content_late( $content ) {
-		if ( $this->is_print() ) {
+		if ( $this->is_print() && ! post_password_required() ) {
 			global $post;
 
 			$options = $this->get_options();
@@ -796,11 +799,14 @@ class wp_print_friendly {
 	 * @param string $before
 	 * @param string $separator
 	 * @param string $after
-	 * @uses $this::is_print, get_query_var, get_post_field
+	 * @uses this::is_print
+	 * @uses post_password_required
+	 * @uses get_query_var
+	 * @uses get_post_field
 	 * @return string or false
 	 */
 	public function page_numbers( $post_id = false, $before = 'Page ', $separator = ' of ', $after = '' ) {
-		if ( ! $this->is_print() )
+		if ( ! $this->is_print() || post_password_required() )
 			return false;
 
 		//Don't display on views that include all pages of a post
-- 
GitLab