From 8b0bd629d48be64b534278c04dbc8d35133148cb Mon Sep 17 00:00:00 2001 From: Adam Bowen Date: Tue, 13 Sep 2011 12:31:50 -0300 Subject: [PATCH 1/3] Fixes "Trying to get property of non-object" error on 404 pages `$post` is not set if you are on a 404 page, so we need to check if it is set before we call `$post->post_name`, etc. (note that you would have to have `WP_DEBUG` set to `true` in wp-config.php in order to see this issue) --- header.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/header.php b/header.php index b04d48b..e22e881 100644 --- a/header.php +++ b/header.php @@ -25,7 +25,12 @@ -post_name; body_class($page_slug); ?>> +post_name; + body_class($page_slug); + } else { + body_class(); + }?>>
From 4d8ac40e68919864dd7b94a0dfa89311c95820af Mon Sep 17 00:00:00 2001 From: Adam Bowen Date: Tue, 13 Sep 2011 12:36:51 -0300 Subject: [PATCH 2/3] Removes needless assignment of `$page_slug = $post->post_name` Removing this assignment, since `$page_slug` is unused elsewhere in the theme, and there is no need to obfuscate what we are passing to `body_class`. --- header.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/header.php b/header.php index e22e881..11897a2 100644 --- a/header.php +++ b/header.php @@ -26,8 +26,7 @@ post_name; - body_class($page_slug); + body_class($post->post_name); } else { body_class(); }?>> From 9e83a9f72336acf2b8da6ca57812e67db8f1de7a Mon Sep 17 00:00:00 2001 From: Adam Bowen Date: Tue, 13 Sep 2011 13:41:15 -0300 Subject: [PATCH 3/3] inlines body_class() logic --- header.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/header.php b/header.php index 11897a2..a095ce5 100644 --- a/header.php +++ b/header.php @@ -25,11 +25,7 @@ -post_name); - } else { - body_class(); - }?>> +post_name); } else { body_class(); }?>>