From 9a9521e01e343df74f60d1d10b0f80a6cf1c6f14 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 4 Dec 2007 00:40:00 +0000 Subject: [PATCH] Avoid unnecesary call to get_userdata in get_permalink function. Props xknown. fixes #5414 git-svn-id: http://svn.automattic.com/wordpress/trunk@6352 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/link-template.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index c3b7ed751..a7bbafabe 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -73,7 +73,7 @@ function get_permalink($id = 0) { $unixtime = strtotime($post->post_date); $category = ''; - if (strpos($permalink, '%category%') !== false) { + if ( strpos($permalink, '%category%') !== false ) { $cats = get_the_category($post->ID); if ( $cats ) usort($cats, '_usort_terms_by_ID'); // order by ID @@ -82,8 +82,12 @@ function get_permalink($id = 0) { $category = get_category_parents($parent, FALSE, '/', TRUE) . $category; } - $authordata = get_userdata($post->post_author); - $author = $authordata->user_nicename; + $author = ''; + if ( strpos($permalink, '%author%') !== false ) { + $authordata = get_userdata($post->post_author); + $author = $authordata->user_nicename; + } + $date = explode(" ",date('Y m d H i s', $unixtime)); $rewritereplace = array(