Changeset 4886 for trunk/wp-includes/link-template.php
- Timestamp:
- 02/15/2007 07:07:12 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/link-template.php
r4721 r4886 9 9 function permalink_link() { // For backwards compatibility 10 10 echo apply_filters('the_permalink', get_permalink()); 11 } 12 13 14 /** 15 * Conditionally adds a trailing slash if the permalink structure 16 * has a trailing slash, strips the trailing slash if not 17 * @global object Uses $wp_rewrite 18 * @param $string string a URL with or without a trailing slash 19 * @return string 20 */ 21 function user_trailingslashit($string) { 22 global $wp_rewrite; 23 if ( $wp_rewrite->use_trailing_slashes ) 24 $string = trailingslashit($string); 25 else 26 $string = preg_replace('|/$|', '', $string); // untrailing slash 27 return $string; 11 28 } 12 29 … … 117 134 $link = get_page_uri($id); 118 135 $link = str_replace('%pagename%', $link, $pagestruct); 119 $link = get_option('home') . "/$link/"; 136 $link = get_option('home') . "/$link"; 137 $link = user_trailingslashit($link); 120 138 } else { 121 139 $link = get_option('home') . "/?page_id=$id"; … … 159 177 if ( !empty($yearlink) ) { 160 178 $yearlink = str_replace('%year%', $year, $yearlink); 161 return apply_filters('year_link', get_option('home') . trailingslashit($yearlink), $year);179 return apply_filters('year_link', get_option('home') . user_trailingslashit($yearlink), $year); 162 180 } else { 163 181 return apply_filters('year_link', get_option('home') . '/?m=' . $year, $year); … … 175 193 $monthlink = str_replace('%year%', $year, $monthlink); 176 194 $monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink); 177 return apply_filters('month_link', get_option('home') . trailingslashit($monthlink), $year, $month);195 return apply_filters('month_link', get_option('home') . user_trailingslashit($monthlink), $year, $month); 178 196 } else { 179 197 return apply_filters('month_link', get_option('home') . '/?m=' . $year . zeroise($month, 2), $year, $month); … … 195 213 $daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink); 196 214 $daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink); 197 return apply_filters('day_link', get_option('home') . trailingslashit($daylink), $year, $month, $day);215 return apply_filters('day_link', get_option('home') . user_trailingslashit($daylink), $year, $month, $day); 198 216 } else { 199 217 return apply_filters('day_link', get_option('home') . '/?m=' . $year . zeroise($month, 2) . zeroise($day, 2), $year, $month, $day); … … 218 236 219 237 $permalink = str_replace('%feed%', $feed, $permalink); 220 $permalink = preg_replace('#/+#', '/', "/$permalink /");221 $output = get_option('home') . $permalink;238 $permalink = preg_replace('#/+#', '/', "/$permalink"); 239 $output = get_option('home') . user_trailingslashit($permalink); 222 240 } else { 223 241 if ( false !== strpos($feed, 'comments_') ) … … 436 454 $qstr = preg_replace('|^/+|', '', $qstr); 437 455 if ( $permalink ) 438 $qstr = trailingslashit($qstr);456 $qstr = user_trailingslashit($qstr); 439 457 $qstr = preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', trailingslashit( get_option('home') ) . $qstr ); 440 458 441 459 // showing /page/1/ or ?paged=1 is redundant 442 460 if ( 1 === $pagenum ) { 443 $qstr = str_replace('page/1/', '', $qstr); // for mod_rewrite style 461 $qstr = str_replace(user_trailingslashit('index.php/page/1'), '', $qstr); // for PATHINFO style 462 $qstr = str_replace(user_trailingslashit('page/1'), '', $qstr); // for mod_rewrite style 444 463 $qstr = remove_query_arg('paged', $qstr); // for query style 445 464 }
Note: See TracChangeset
for help on using the changeset viewer.