Make WordPress Core

Ticket #3944: link-template-php.diff

File link-template-php.diff, 1.3 KB (added by jhodgdon, 18 years ago)

Fix to get_permalink that makes its date handling more consistent with the querying that will retrieve the post later

  • E:/EclipseWork/WordPressDev/wp-includes/link-template.php

     
    6767        $permalink = get_option('permalink_structure');
    6868
    6969        if ( '' != $permalink && 'draft' != $post->post_status ) {
    70                 $unixtime = strtotime($post->post_date);
    71 
     70 
    7271                $category = '';
    7372                if (strpos($permalink, '%category%') !== false) {
    7473                        $cats = get_the_category($post->ID);
     
    7978
    8079                $authordata = get_userdata($post->post_author);
    8180                $author = $authordata->user_nicename;
    82                 $date = explode(" ",date('Y m d H i s', $unixtime));
     81        // try to use the date info actually stored in the database, so it
     82        // will match the query when the user clicks on the permalink
     83        $date = array();
     84        if( preg_match( "/^(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/", $post->post_date, $matches )) {
     85            $date = array( $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6] );
     86        } else {   
     87            $unixtime = strtotime($post->post_date);
     88                    $date = explode(" ",date('Y m d H i s', $unixtime));
     89        }
    8390                $rewritereplace =
    8491                array(
    8592                        $date[0],