Make WordPress Core


Ignore:
Timestamp:
05/31/2004 05:22:25 PM (20 years ago)
Author:
rboren
Message:

Revamp rewrite rule generation. Add clean page links. Credit to Jaykul for get_pagenum_link().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/template-functions-links.php

    r1355 r1373  
    8484    if (!$month) $month = gmdate('m', time()+(get_settings('gmt_offset') * 3600));
    8585    if ('' != get_settings('permalink_structure')) {
    86         $off = strpos(get_settings('permalink_structure'), '%monthnum%');
     86        $permalink = get_settings('permalink_structure');
     87
     88        // If the permalink structure does not contain year and month, make
     89        // one that does.
     90        if (! (strstr($permalink, '%year') && strstr($permalink, '%monthnum')) ) {
     91            $front = substr($permalink, 0, strpos($permalink, '%'));
     92            $permalink = $front . '%year%/%monthnum%/';
     93        }
     94
     95        $off = strpos($permalink, '%monthnum%');
    8796        $offset = $off + 11;
    88         $monthlink = substr(get_settings('permalink_structure'), 0, $offset);
     97        $monthlink = substr($permalink, 0, $offset);
    8998        if ('/' != substr($monthlink, -1)) $monthlink = substr($monthlink, 0, -1);
    9099        $monthlink = str_replace('%year%', $year, $monthlink);
     
    103112    if (!$day) $day = gmdate('j', time()+(get_settings('gmt_offset') * 3600));
    104113    if ('' != get_settings('permalink_structure')) {
    105         $off = strpos(get_settings('permalink_structure'), '%day%');
     114        $permalink = get_settings('permalink_structure');
     115
     116        // If the permalink structure does not contain year, month, and day,
     117        // make one that does.
     118        if (! (strstr($permalink, '%year') && strstr($permalink, '%monthnum')) ) {
     119            $front = substr($permalink, 0, strpos($permalink, '%'));
     120            $permalink = $front . '%year%/%monthnum%/%day%/';
     121        }
     122
     123        $off = strpos($permalink, '%day%');
    106124        $offset = $off + 6;
    107         $daylink = substr(get_settings('permalink_structure'), 0, $offset);
     125        $daylink = substr($permalink, 0, $offset);
    108126        if ('/' != substr($daylink, -1)) $daylink = substr($daylink, 0, -1);
    109127        $daylink = str_replace('%year%', $year, $daylink);
Note: See TracChangeset for help on using the changeset viewer.