From 104b410bb7ddd5f8c58f3d61b5489c29460c65ff Mon Sep 17 00:00:00 2001
From: Erick Hitter <ehitter@gmail.com>
Date: Sat, 11 May 2013 13:51:15 -0500
Subject: [PATCH] If WordPress determines the request is a 404, such as when a
 user who can't read a specific privately-published posts attempts to do so,
 prevent plugin from acting by setting `is_print()` to false.

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

diff --git a/wp-print-friendly.php b/wp-print-friendly.php
index 7b48c5d..e620313 100644
--- a/wp-print-friendly.php
+++ b/wp-print-friendly.php
@@ -164,12 +164,15 @@ class wp_print_friendly {
 	/**
 	 * Determine if print template is being requested.
 	 *
+	 * If WordPress determined this request is a 404, do nothing and let the main theme handle things.
+	 *
 	 * @global $wp_query
+	 * @uses is_404()
 	 * @return bool
 	 */
 	public function is_print() {
 		global $wp_query;
-		return is_array( $wp_query->query ) && array_key_exists( $this->query_var, $wp_query->query );
+		return is_array( $wp_query->query ) && array_key_exists( $this->query_var, $wp_query->query ) && ! is_404();
 	}
 
 	/**
-- 
GitLab