Rewrite and %category% fixes.
git-svn-id: http://svn.automattic.com/wordpress/trunk@1388 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2f5ad1af00
commit
f8258351b4
|
@ -1238,7 +1238,10 @@ function generate_rewrite_rules($permalink_structure = '', $matches = '') {
|
|||
$queries[$i] .= $query_token;
|
||||
}
|
||||
|
||||
$structure = str_replace($front, '', $permalink_structure);
|
||||
$structure = $permalink_structure;
|
||||
if ($front != '/') {
|
||||
$structure = str_replace($front, '', $structure);
|
||||
}
|
||||
$structure = trim($structure, '/');
|
||||
$dirs = explode('/', $structure);
|
||||
$num_dirs = count($dirs);
|
||||
|
@ -1312,7 +1315,8 @@ function rewrite_rules($matches = '', $permalink_structure = '') {
|
|||
// If the permalink does not have year, month, and day, we need to create a
|
||||
// separate archive rule.
|
||||
$doarchive = false;
|
||||
if (! (strstr($permalink_structure, '%year') && strstr($permalink_structure, '%monthnum') && strstr($permalink_structure, '%day')) ) {
|
||||
if (! (strstr($permalink_structure, '%year%') && strstr($permalink_structure, '%monthnum%') && strstr($permalink_structure, '%day%')) ||
|
||||
preg_match('/%category%.*(%year%|%monthnum%|%day%)/', $permalink_structure)) {
|
||||
$doarchive = true;
|
||||
$archive_structure = $front . '%year%/%monthnum%/%day%/';
|
||||
$archive_rewrite = generate_rewrite_rules($archive_structure, $matches);
|
||||
|
|
|
@ -80,7 +80,8 @@ function get_month_link($year, $month) {
|
|||
|
||||
// If the permalink structure does not contain year and month, make
|
||||
// one that does.
|
||||
if (! (strstr($permalink, '%year') && strstr($permalink, '%monthnum')) ) {
|
||||
if (! (strstr($permalink, '%year%') && strstr($permalink, '%monthnum%'))
|
||||
|| preg_match('/%category%.*(%year%|%monthnum%|%day%)/', $permalink)) {
|
||||
$front = substr($permalink, 0, strpos($permalink, '%'));
|
||||
$permalink = $front . '%year%/%monthnum%/';
|
||||
}
|
||||
|
@ -92,6 +93,7 @@ function get_month_link($year, $month) {
|
|||
$monthlink = str_replace('%year%', $year, $monthlink);
|
||||
$monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink);
|
||||
$monthlink = str_replace('%post_id%', '', $monthlink);
|
||||
$monthlink = str_replace('%category%', '', $monthlink);
|
||||
return get_settings('home') . $monthlink;
|
||||
} else {
|
||||
return get_settings('home') .'/'. get_settings('blogfilename') .$querystring_start.'m'.$querystring_equal.$year.zeroise($month, 2);
|
||||
|
@ -108,7 +110,8 @@ function get_day_link($year, $month, $day) {
|
|||
|
||||
// If the permalink structure does not contain year, month, and day,
|
||||
// make one that does.
|
||||
if (! (strstr($permalink, '%year') && strstr($permalink, '%monthnum')) ) {
|
||||
if (! (strstr($permalink, '%year%') && strstr($permalink, '%monthnum%')&& strstr($permalink, '%day%'))
|
||||
|| preg_match('/%category%.*(%year%|%monthnum%|%day%)/', $permalink)) {
|
||||
$front = substr($permalink, 0, strpos($permalink, '%'));
|
||||
$permalink = $front . '%year%/%monthnum%/%day%/';
|
||||
}
|
||||
|
@ -121,6 +124,7 @@ function get_day_link($year, $month, $day) {
|
|||
$daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink);
|
||||
$daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink);
|
||||
$daylink = str_replace('%post_id%', '', $daylink);
|
||||
$daylink = str_replace('%category%', '', $daylink);
|
||||
return get_settings('home') . $daylink;
|
||||
} else {
|
||||
return get_settings('home') .'/'. get_settings('blogfilename') .$querystring_start.'m'.$querystring_equal.$year.zeroise($month, 2).zeroise($day, 2);
|
||||
|
|
Loading…
Reference in New Issue