Make WordPress Core

Changeset 2410


Ignore:
Timestamp:
03/05/2005 06:13:31 PM (19 years ago)
Author:
ryan
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/classes.php

    r2332 r2410  
    859859
    860860        $this->date_structure = '';
     861        $date_endian = '';
    861862
    862863        foreach ($endians as $endian) {
    863864            if (false !== strpos($this->permalink_structure, $endian)) {
    864                 $this->date_structure = $this->front . $endian;
     865                $date_endian= $endian;
    865866                break;
    866867            }
    867868        }
     869
     870        if ( empty($date_endian) )
     871            $date_endian = '%year%/%monthnum%/%day%';
    868872
    869873        // Do not allow the date tags and %post_id% to overlap in the permalink
    870874        // structure. If they do, move the date tags to $front/date/. 
    871875        $front = $this->front;
    872         if ( false !== strpos($this->permalink_structure, $this->front . '%post_id%') )
    873             $front = $front . 'date/';
    874              
    875         if (empty($this->date_structure)) {
    876             $this->date_structure = $front . '%year%/%monthnum%/%day%';
    877         }
     876        preg_match_all('/%.+?%/', $this->permalink_structure, $tokens);
     877        $tok_index = 1;
     878        foreach ($tokens[0] as $token) {
     879            if ( ($token == '%post_id%') && ($tok_index <= 3) ) {
     880                $front = $front . 'date/';
     881                break;
     882            }
     883        }
     884
     885        $this->date_structure = $front . $date_endian;
    878886
    879887        return $this->date_structure;
Note: See TracChangeset for help on using the changeset viewer.