WordPress.org

Make WordPress Core

Ticket #5305: 5305.3.diff

File 5305.3.diff, 1.6 KB (added by valendesigns, 5 years ago)
  • src/wp-includes/rewrite.php

    diff --git src/wp-includes/rewrite.php src/wp-includes/rewrite.php
    index 984fbbe..d696325 100644
    class WP_Rewrite { 
    895895         * one is used. If none matches, then the default will be used, which is
    896896         * year, month, day.
    897897         *
    898          * Prevents post ID and date permalinks from overlapping. In the case of
    899          * post_id, the date permalink will be prepended with front permalink with
    900          * 'date/' before the actual permalink to form the complete date permalink
    901          * structure.
     898         * Prevents post ID or slug and date permalinks from overlapping. In the case of
     899         * post_id or a postname only structure, the date permalink will be prepended
     900         * with front permalink and 'date/' before the actual permalink to form the
     901         * complete date permalink structure.
    902902         *
    903903         * @since 1.5.0
    904904         * @access public
    class WP_Rewrite { 
    930930                if ( empty($date_endian) )
    931931                        $date_endian = '%year%/%monthnum%/%day%';
    932932
    933                 // Do not allow the date tags and %post_id% to overlap in the permalink
    934                 // structure. If they do, move the date tags to $front/date/.
     933                /*
     934                 * Do not allow the date tags and %post_id% or %postname% to overlap in the
     935                 * permalink structure. If they do, move the date tags to $front/date/.
     936                 */
    935937                $front = $this->front;
    936938                preg_match_all('/%.+?%/', $this->permalink_structure, $tokens);
    937939                $tok_index = 1;
    938940                foreach ( (array) $tokens[0] as $token) {
    939                         if ( '%post_id%' == $token && ($tok_index <= 3) ) {
     941                        if ( in_array( $token, array( '%post_id%', '%postname%' ) ) && $tok_index <= 3 ) {
    940942                                $front = $front . 'date/';
    941943                                break;
    942944                        }