mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-16 07:35:39 +01:00
get_author_permastruct()
git-svn-id: http://svn.automattic.com/wordpress/trunk@1933 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4ceffc2672
commit
7a580db825
@ -702,6 +702,7 @@ class WP_Rewrite {
|
|||||||
var $permalink_structure;
|
var $permalink_structure;
|
||||||
var $category_base;
|
var $category_base;
|
||||||
var $category_structure;
|
var $category_structure;
|
||||||
|
var $author_structure;
|
||||||
var $date_structure;
|
var $date_structure;
|
||||||
var $front;
|
var $front;
|
||||||
var $root = '';
|
var $root = '';
|
||||||
@ -877,6 +878,21 @@ class WP_Rewrite {
|
|||||||
return $this->category_structure;
|
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) {
|
function add_rewrite_tag($tag, $pattern, $query) {
|
||||||
$this->rewritecode[] = $tag;
|
$this->rewritecode[] = $tag;
|
||||||
$this->rewritereplace[] = $pattern;
|
$this->rewritereplace[] = $pattern;
|
||||||
@ -1004,8 +1020,7 @@ class WP_Rewrite {
|
|||||||
$category_rewrite = $this->generate_rewrite_rules($this->get_category_permastruct());
|
$category_rewrite = $this->generate_rewrite_rules($this->get_category_permastruct());
|
||||||
|
|
||||||
// Authors
|
// Authors
|
||||||
$author_structure = $this->front . 'author/%author%';
|
$author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct());
|
||||||
$author_rewrite = $this->generate_rewrite_rules($author_structure);
|
|
||||||
|
|
||||||
// Pages
|
// Pages
|
||||||
$page_rewrite = $this->page_rewrite_rules();
|
$page_rewrite = $this->page_rewrite_rules();
|
||||||
@ -1078,6 +1093,7 @@ class WP_Rewrite {
|
|||||||
}
|
}
|
||||||
$this->category_base = get_settings('category_base');
|
$this->category_base = get_settings('category_base');
|
||||||
unset($this->category_structure);
|
unset($this->category_structure);
|
||||||
|
unset($this->author_structure);
|
||||||
unset($this->date_structure);
|
unset($this->date_structure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,19 +77,17 @@ function the_author_posts_link($idmode='') {
|
|||||||
|
|
||||||
|
|
||||||
function get_author_link($echo = false, $author_id, $author_nicename) {
|
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;
|
$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');
|
$file = get_settings('home') . '/' . get_settings('blogfilename');
|
||||||
$link = $file.$querystring_start.'author'.$querystring_equal.$auth_ID;
|
$link = $file.$querystring_start.'author'.$querystring_equal.$auth_ID;
|
||||||
} else {
|
} else {
|
||||||
if ('' == $author_nicename) $author_nicename = $cache_userdata[$author_id]->author_nicename;
|
if ('' == $author_nicename) $author_nicename = $cache_userdata[$author_id]->author_nicename;
|
||||||
// Get any static stuff from the front
|
$link = str_replace('%author%', $author_nicename, $link);
|
||||||
$front = substr($permalink_structure, 0, strpos($permalink_structure, '%'));
|
$link = get_settings('home') . trailingslashit($link);
|
||||||
$link = get_settings('home') . $front . 'author/';
|
|
||||||
$link .= $author_nicename . '/';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($echo) echo $link;
|
if ($echo) echo $link;
|
||||||
|
Loading…
Reference in New Issue
Block a user