diff --git a/wp-includes/classes.php b/wp-includes/classes.php index c07a5fe54..7beb0e9f8 100644 --- a/wp-includes/classes.php +++ b/wp-includes/classes.php @@ -702,6 +702,7 @@ class WP_Rewrite { var $permalink_structure; var $category_base; var $category_structure; + var $author_structure; var $date_structure; var $front; var $root = ''; @@ -877,6 +878,21 @@ class WP_Rewrite { return $this->category_structure; } + function get_author_permastruct() { + if (isset($this->author_structure)) { + return $this->author_structure; + } + + if (empty($this->permalink_structure)) { + $this->author_structure = ''; + return false; + } + + $this->author_structure = $this->front . 'author/%author%'; + + return $this->author_structure; + } + function add_rewrite_tag($tag, $pattern, $query) { $this->rewritecode[] = $tag; $this->rewritereplace[] = $pattern; @@ -1004,8 +1020,7 @@ class WP_Rewrite { $category_rewrite = $this->generate_rewrite_rules($this->get_category_permastruct()); // Authors - $author_structure = $this->front . 'author/%author%'; - $author_rewrite = $this->generate_rewrite_rules($author_structure); + $author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct()); // Pages $page_rewrite = $this->page_rewrite_rules(); @@ -1078,6 +1093,7 @@ class WP_Rewrite { } $this->category_base = get_settings('category_base'); unset($this->category_structure); + unset($this->author_structure); unset($this->date_structure); } diff --git a/wp-includes/template-functions-author.php b/wp-includes/template-functions-author.php index 96064aacb..0f01367e6 100644 --- a/wp-includes/template-functions-author.php +++ b/wp-includes/template-functions-author.php @@ -77,19 +77,17 @@ function the_author_posts_link($idmode='') { function get_author_link($echo = false, $author_id, $author_nicename) { - global $wpdb, $post, $querystring_start, $querystring_equal, $cache_userdata; + global $wpdb, $wp_rewrite, $post, $querystring_start, $querystring_equal, $cache_userdata; $auth_ID = $author_id; - $permalink_structure = get_settings('permalink_structure'); + $link = $wp_rewrite->get_author_permastruct(); - if ('' == $permalink_structure) { + if (empty($link)) { $file = get_settings('home') . '/' . get_settings('blogfilename'); $link = $file.$querystring_start.'author'.$querystring_equal.$auth_ID; } else { if ('' == $author_nicename) $author_nicename = $cache_userdata[$author_id]->author_nicename; - // Get any static stuff from the front - $front = substr($permalink_structure, 0, strpos($permalink_structure, '%')); - $link = get_settings('home') . $front . 'author/'; - $link .= $author_nicename . '/'; + $link = str_replace('%author%', $author_nicename, $link); + $link = get_settings('home') . trailingslashit($link); } if ($echo) echo $link;