Make WordPress Core

Ticket #1485: user-trail.diff

File user-trail.diff, 10.7 KB (added by MathiasBynens, 20 years ago)
  • wp-includes/template-functions-general.php

     
    301301        if ($arcresults) {
    302302            $afterafter = $after;
    303303            foreach ($arcresults as $arcresult) {
    304                 $url  = get_month_link($arcresult->year,  $arcresult->month);
     304                $url = get_month_link($arcresult->year, $arcresult->month);
    305305                if ($show_post_count) {
    306306                    $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year);
    307                     $after = ' ('.$arcresult->posts.')' . $afterafter;
     307                    $after = ' (' . $arcresult->posts . ')' . $afterafter;
    308308                } else {
    309                     $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year);
     309                    $text = sprintf('%s %d', $month[zeroise($arcresult->month, 2)], $arcresult->year);
    310310                }
    311311                echo get_archives_link($url, $text, $format, $before, $after);
    312312            }
  • wp-includes/template-functions-category.php

     
    2121
    2222function get_category_link($category_id) {
    2323        global $wp_rewrite;
    24         $catlink = $wp_rewrite->get_category_permastruct();
     24        $catlink = user_trailing_slash($wp_rewrite->get_category_permastruct());
    2525
    2626        if ( empty($catlink) ) {
    2727                $file = get_settings('home') . '/' . get_settings('blogfilename');
     
    3434                        $category_nicename = get_category_parents($parent, false, '/', true) . $category_nicename . '/';
    3535
    3636                $catlink = str_replace('%category%', $category_nicename, $catlink);
    37                 $catlink = get_settings('home') . trailingslashit($catlink);
     37                $catlink = get_settings('home') . $catlink;
    3838        }
    3939        return apply_filters('category_link', $catlink, $category_id);
    4040}
  • wp-includes/classes.php

     
    813813        }                                       
    814814
    815815        function using_index_permalinks() {
    816     if (empty($this->permalink_structure)) {
     816                if (empty($this->permalink_structure)) {
    817817                        return false;
    818     }
     818        }
    819819
    820820    // If the index is not in the permalink, we're using mod_rewrite.
    821821    if (preg_match('#^/*' . $this->index . '#', $this->permalink_structure)) {
     
    833833        }                                       
    834834
    835835        function preg_index($number) {
    836     $match_prefix = '$';
    837     $match_suffix = '';
     836                $match_prefix = '$';
     837                $match_suffix = '';
    838838   
    839     if (! empty($this->matches)) {
     839                if (! empty($this->matches)) {
    840840                        $match_prefix = '$' . $this->matches . '[';
    841841                        $match_suffix = ']';
    842     }       
     842                }
    843843   
    844     return "$match_prefix$number$match_suffix";       
     844                return "$match_prefix$number$match_suffix";
    845845        }
    846846
    847847        function page_rewrite_rules() {
     
    849849
    850850                $rewrite_rules = array();
    851851                $page_structure = $this->get_page_permastruct();
    852                 if( is_array( $uris ) )
    853                         {
     852                if( is_array( $uris ) ) {
    854853                                foreach ($uris as $uri => $pagename) {
    855854                                        $this->add_rewrite_tag('%pagename%', "($uri)", 'pagename=');
    856855                                        $rewrite_rules += $this->generate_rewrite_rules($page_structure);
     
    910909                        return false;
    911910                }
    912911
    913                 $structure = str_replace('%monthnum%', '', $structure);
    914                 $structure = str_replace('%day%', '', $structure);
     912                $structure = str_replace('/%monthnum%', '', $structure);
     913                $structure = str_replace('/%day%', '', $structure);
    915914
    916915                $structure = preg_replace('#/+#', '/', $structure);
    917916
     
    925924                        return false;
    926925                }
    927926
    928                 $structure = str_replace('%day%', '', $structure);
     927                $structure = str_replace('/%day%', '', $structure);
    929928
    930929                $structure = preg_replace('#/+#', '/', $structure);
    931930
     
    941940                        return $this->category_structure;
    942941                }
    943942
    944     if (empty($this->permalink_structure)) {
     943                if (empty($this->permalink_structure)) {
    945944                        $this->category_structure = '';
    946945                        return false;
    947946                }
  • wp-includes/template-functions-links.php

     
    8989        if ('' != $pagestruct) {
    9090                $link = get_page_uri($id);
    9191                $link = str_replace('%pagename%', $link, $pagestruct);
    92                 $link = get_settings('home') . "/$link/";
     92                $link = user_trailing_slash(get_settings('home') . '/' . $link);
    9393        } else {
    94                 $link = get_settings('home') . "/?page_id=$id";
     94                $link = get_settings('home') . '/?page_id=' . $id;
    9595        }
    9696
    9797        return apply_filters('page_link', $link, $id);
     
    103103                $yearlink = $wp_rewrite->get_year_permastruct();
    104104    if (!empty($yearlink)) {
    105105        $yearlink = str_replace('%year%', $year, $yearlink);
    106         return apply_filters('year_link', get_settings('home') . trailingslashit($yearlink), $year);
     106        return apply_filters('year_link', get_settings('home') . $yearlink, $year);
    107107    } else {
    108108        return apply_filters('year_link', get_settings('home') . '/?m=' . $year, $year);
    109109    }
     
    111111
    112112function get_month_link($year, $month) {
    113113    global $wp_rewrite;
    114     if (!$year) $year = gmdate('Y', time()+(get_settings('gmt_offset') * 3600));
    115     if (!$month) $month = gmdate('m', time()+(get_settings('gmt_offset') * 3600));
     114    if (!$year) $year = gmdate('Y', time() + (get_settings('gmt_offset') * 3600));
     115    if (!$month) $month = gmdate('m', time() + (get_settings('gmt_offset') * 3600));
    116116                $monthlink = $wp_rewrite->get_month_permastruct();
    117117    if (!empty($monthlink)) {
    118118        $monthlink = str_replace('%year%', $year, $monthlink);
    119119        $monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink);
    120         return apply_filters('month_link', get_settings('home') . trailingslashit($monthlink), $year, $month);
     120        return apply_filters('month_link', get_settings('home') . $monthlink, $year, $month);
    121121    } else {
    122122        return apply_filters('month_link', get_settings('home') . '/?m=' . $year . zeroise($month, 2), $year, $month);
    123123    }
     
    134134        $daylink = str_replace('%year%', $year, $daylink);
    135135        $daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink);
    136136        $daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink);
    137         return apply_filters('day_link', get_settings('home') . trailingslashit($daylink), $year, $month, $day);
     137        return apply_filters('day_link', get_settings('home') . $daylink, $year, $month, $day);
    138138    } else {
    139139        return apply_filters('day_link', get_settings('home') . '/?m=' . $year . zeroise($month, 2) . zeroise($day, 2), $year, $month, $day);
    140140    }
     
    157157                        $feed = '';
    158158
    159159                $permalink = str_replace('%feed%', $feed, $permalink);
    160                 $permalink = preg_replace('#/+#', '/', "/$permalink/");
     160                $permalink = preg_replace('#/+#', '/', "/$permalink");
    161161                $output =  get_settings('home') . $permalink;
    162162        } else {
    163163                if ( false !== strpos($feed, 'comments_') )
  • wp-includes/template-functions-post.php

     
    289289        }
    290290
    291291        $pages = $wpdb->get_results("SELECT * " .
    292                                                                                                                         "FROM $wpdb->posts " .
    293                                                                                                                         "WHERE post_status = 'static' " .
    294                                                                                                                         "$exclusions " .
    295                                                                                                                         "ORDER BY " . $r['sort_column'] . " " . $r['sort_order']);
     292                                                        "FROM $wpdb->posts " .
     293                                                        "WHERE post_status = 'static' " .
     294                                                        "$exclusions " .
     295                                                        "ORDER BY " . $r['sort_column'] . " " . $r['sort_order']);
    296296
    297297        if ( empty($pages) )
    298298                return array();
     
    373373
    374374        if($depth)
    375375                $indent = str_repeat("\t", $depth);
    376         //$indent = join('', array_fill(0,$depth,"\t"));
     376        //$indent = join('', array_fill(0, $depth, "\t"));
    377377
    378378        foreach($page_tree[$parent]['children'] as $page_id) {
    379379                $cur_page = $page_tree[$page_id];
  • wp-includes/comment-functions.php

     
    307307        $tb_url = get_settings('siteurl') . '/wp-trackback.php?p=' . $id;
    308308
    309309        if ( '' != get_settings('permalink_structure') )
    310                 $tb_url = trailingslashit(get_permalink()) . 'trackback/';
     310                $tb_url = user_trailing_slash(trailingslashit(get_permalink()) . 'trackback');
    311311
    312312        return $tb_url;
    313313}
  • wp-includes/feed-functions.php

     
    8282        global $id;
    8383
    8484        if ('' != get_settings('permalink_structure'))
    85                 $url = trailingslashit( get_permalink() ) . 'feed/';
     85                $url = user_trailing_slash(trailingslashit(get_permalink()) . 'feed');
    8686        else
    8787                $url = get_settings('home') . "/$commentsrssfilename?feed=rss2&p=$id";
    8888
     
    9797                                 $link = get_settings('home') . '?feed=rss2&author=' . $author_id;
    9898       } else {
    9999                                 $link = get_author_link(0, $author_id, $author_nicename);
    100                                  $link = $link . "feed/";
     100                                 $link = user_trailing_slash($link . 'feed');
    101101       }
    102102                         
    103103                         $link = apply_filters('author_feed_link', $link);
     
    113113                                 $link = get_settings('home') . '?feed=rss2&cat=' . $cat_ID;
    114114       } else {
    115115                                 $link = get_category_link($cat_ID);
    116                                  $link = $link . "feed/";
     116                                 $link = user_trailing_slash($link . 'feed');
    117117       }
    118118
    119119                         $link = apply_filters('category_feed_link', $link);
  • wp-includes/functions-formatting.php

     
    515515        return $string;
    516516}
    517517
    518 function trailingslashit($string) {
    519     if ( '/' != substr($string, -1)) {
    520         $string .= '/';
    521     }
    522     return $string;
     518function trailingslashit($iri) {
     519        if ('/' != substr($iri, -1)) {
     520                $iri .= '/';
     521        }
     522        return $iri;
    523523}
    524524
     525function user_trailing_slash($iri) {
     526        if (('/' == substr(get_settings('permalink_structure'), -1)) && ('/' != substr($iri, -1))) {
     527                $iri .= '/';
     528        }
     529        return $iri;
     530}
     531
    525532function addslashes_gpc($gpc) {
    526533        if (!get_magic_quotes_gpc()) {
    527534                $gpc = addslashes($gpc);