Fix %post_id% and date collision avoidance. http://mosquito.wordpress.org/view.php?id=1027

git-svn-id: http://svn.automattic.com/wordpress/trunk@2410 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2005-03-05 18:13:31 +00:00
parent c84f9a4325
commit 3a0fc8bf43
1 changed files with 14 additions and 6 deletions

View File

@ -858,24 +858,32 @@ class WP_Rewrite {
$endians = array('%year%/%monthnum%/%day%', '%day%/%monthnum%/%year%', '%monthnum%/%day%/%year%');
$this->date_structure = '';
$date_endian = '';
foreach ($endians as $endian) {
if (false !== strpos($this->permalink_structure, $endian)) {
$this->date_structure = $this->front . $endian;
$date_endian= $endian;
break;
}
}
if ( empty($date_endian) )
$date_endian = '%year%/%monthnum%/%day%';
// Do not allow the date tags and %post_id% to overlap in the permalink
// structure. If they do, move the date tags to $front/date/.
$front = $this->front;
if ( false !== strpos($this->permalink_structure, $this->front . '%post_id%') )
$front = $front . 'date/';
if (empty($this->date_structure)) {
$this->date_structure = $front . '%year%/%monthnum%/%day%';
preg_match_all('/%.+?%/', $this->permalink_structure, $tokens);
$tok_index = 1;
foreach ($tokens[0] as $token) {
if ( ($token == '%post_id%') && ($tok_index <= 3) ) {
$front = $front . 'date/';
break;
}
}
$this->date_structure = $front . $date_endian;
return $this->date_structure;
}