Changeset 5019 for trunk/wp-includes/link-template.php
- Timestamp:
- 03/10/2007 06:18:43 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/link-template.php
r4990 r5019 17 17 * @global object Uses $wp_rewrite 18 18 * @param $string string a URL with or without a trailing slash 19 * @param $type_of_url string the type of URL being considered (e.g. single, category, etc) for use in the filter 19 20 * @return string 20 21 */ 21 function user_trailingslashit($string ) {22 function user_trailingslashit($string, $type_of_url = '') { 22 23 global $wp_rewrite; 23 24 if ( $wp_rewrite->use_trailing_slashes ) 24 25 $string = trailingslashit($string); 25 26 else 26 $string = preg_replace('|/$|', '', $string); // untrailing slash 27 $string = preg_replace('|/+$|', '', $string); // untrailing slash 28 29 // Note that $type_of_url can be one of following: 30 // single, single_trackback, single_feed, single_paged, feed, category, page, year, month, day, paged 31 $string = apply_filters('user_trailingslashit', $string, $type_of_url); 27 32 return $string; 28 33 } … … 95 100 $post->post_name, 96 101 ); 97 return apply_filters('post_link', get_option('home') . str_replace($rewritecode, $rewritereplace, $permalink), $post); 102 $permalink = get_option('home') . str_replace($rewritecode, $rewritereplace, $permalink); 103 $permalink = user_trailingslashit($permalink, 'single'); 104 return apply_filters('post_link', $permalink, $post); 98 105 } else { // if they're not using the fancy permalink option 99 106 $permalink = get_option('home') . '/?p=' . $post->ID; … … 135 142 $link = str_replace('%pagename%', $link, $pagestruct); 136 143 $link = get_option('home') . "/$link"; 137 $link = user_trailingslashit($link );144 $link = user_trailingslashit($link, 'page'); 138 145 } else { 139 146 $link = get_option('home') . "/?page_id=$id"; … … 177 184 if ( !empty($yearlink) ) { 178 185 $yearlink = str_replace('%year%', $year, $yearlink); 179 return apply_filters('year_link', get_option('home') . user_trailingslashit($yearlink ), $year);186 return apply_filters('year_link', get_option('home') . user_trailingslashit($yearlink, 'year'), $year); 180 187 } else { 181 188 return apply_filters('year_link', get_option('home') . '/?m=' . $year, $year); … … 193 200 $monthlink = str_replace('%year%', $year, $monthlink); 194 201 $monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink); 195 return apply_filters('month_link', get_option('home') . user_trailingslashit($monthlink ), $year, $month);202 return apply_filters('month_link', get_option('home') . user_trailingslashit($monthlink, 'month'), $year, $month); 196 203 } else { 197 204 return apply_filters('month_link', get_option('home') . '/?m=' . $year . zeroise($month, 2), $year, $month); … … 213 220 $daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink); 214 221 $daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink); 215 return apply_filters('day_link', get_option('home') . user_trailingslashit($daylink ), $year, $month, $day);222 return apply_filters('day_link', get_option('home') . user_trailingslashit($daylink, 'day'), $year, $month, $day); 216 223 } else { 217 224 return apply_filters('day_link', get_option('home') . '/?m=' . $year . zeroise($month, 2) . zeroise($day, 2), $year, $month, $day); … … 237 244 $permalink = str_replace('%feed%', $feed, $permalink); 238 245 $permalink = preg_replace('#/+#', '/', "/$permalink"); 239 $output = get_option('home') . user_trailingslashit($permalink );246 $output = get_option('home') . user_trailingslashit($permalink, 'feed'); 240 247 } else { 241 248 if ( false !== strpos($feed, 'comments_') ) … … 258 265 if ( 'rss2' != $feed ) 259 266 $url .= "/$feed"; 260 $url = user_trailingslashit($url );267 $url = user_trailingslashit($url, 'single_feed'); 261 268 } else { 262 269 $url = get_option('home') . "/?feed=$feed&p=$id"; … … 472 479 $qstr = preg_replace('|^/+|', '', $qstr); 473 480 if ( $permalink ) 474 $qstr = user_trailingslashit($qstr );481 $qstr = user_trailingslashit($qstr, 'paged'); 475 482 $qstr = preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', trailingslashit( get_option('home') ) . $qstr ); 476 483 477 484 // showing /page/1/ or ?paged=1 is redundant 478 485 if ( 1 === $pagenum ) { 479 $qstr = str_replace(user_trailingslashit('index.php/page/1' ), '', $qstr); // for PATHINFO style480 $qstr = str_replace(user_trailingslashit('page/1' ), '', $qstr); // for mod_rewrite style486 $qstr = str_replace(user_trailingslashit('index.php/page/1', 'paged'), '', $qstr); // for PATHINFO style 487 $qstr = str_replace(user_trailingslashit('page/1', 'paged'), '', $qstr); // for mod_rewrite style 481 488 $qstr = remove_query_arg('paged', $qstr); // for query style 482 489 }
Note: See TracChangeset
for help on using the changeset viewer.