Changeset 9197 for trunk/wp-includes/canonical.php
- Timestamp:
- 10/16/2008 04:08:00 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/canonical.php
r9193 r9197 45 45 if ( !$requested_url ) { 46 46 // build the URL in the address bar 47 $requested_url = ( isset($_SERVER['HTTPS'] ) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';47 $requested_url = ( !empty($_SERVER['HTTPS'] ) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://'; 48 48 $requested_url .= $_SERVER['HTTP_HOST']; 49 49 $requested_url .= $_SERVER['REQUEST_URI']; … … 78 78 } elseif ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) { 79 79 // rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101 80 if ( is_single() && isset($_GET['p']) && ! $redirect_url ) {80 if ( is_single() && !empty($_GET['p']) && ! $redirect_url ) { 81 81 if ( $redirect_url = get_permalink(get_query_var('p')) ) 82 82 $redirect['query'] = remove_query_arg('p', $redirect['query']); 83 83 } elseif ( is_single() && ! $redirect_url ) { 84 84 $redirect_url = get_permalink( url_to_postid( $requested_url ) ); 85 } elseif ( is_page() && isset($_GET['page_id']) && ! $redirect_url ) {85 } elseif ( is_page() && !empty($_GET['page_id']) && ! $redirect_url ) { 86 86 if ( $redirect_url = get_permalink(get_query_var('page_id')) ) 87 87 $redirect['query'] = remove_query_arg('page_id', $redirect['query']); 88 } elseif ( isset($_GET['m']) && ( is_year() || is_month() || is_day() ) ) {88 } elseif ( !empty($_GET['m']) && ( is_year() || is_month() || is_day() ) ) { 89 89 $m = get_query_var('m'); 90 90 switch ( strlen($m) ) { … … 102 102 $redirect['query'] = remove_query_arg('m', $redirect['query']); 103 103 // now moving on to non ?m=X year/month/day links 104 } elseif ( is_day() && get_query_var('year') && get_query_var('monthnum') && isset($_GET['day']) ) {104 } elseif ( is_day() && get_query_var('year') && get_query_var('monthnum') && !empty($_GET['day']) ) { 105 105 if ( $redirect_url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day')) ) 106 106 $redirect['query'] = remove_query_arg(array('year', 'monthnum', 'day'), $redirect['query']); 107 } elseif ( is_month() && get_query_var('year') && isset($_GET['monthnum']) ) {107 } elseif ( is_month() && get_query_var('year') && !empty($_GET['monthnum']) ) { 108 108 if ( $redirect_url = get_month_link(get_query_var('year'), get_query_var('monthnum')) ) 109 109 $redirect['query'] = remove_query_arg(array('year', 'monthnum'), $redirect['query']); 110 } elseif ( is_year() && isset($_GET['year']) ) {110 } elseif ( is_year() && !empty($_GET['year']) ) { 111 111 if ( $redirect_url = get_year_link(get_query_var('year')) ) 112 112 $redirect['query'] = remove_query_arg('year', $redirect['query']); 113 } elseif ( is_category() && isset($_GET['cat']) ) {113 } elseif ( is_category() && !empty($_GET['cat']) ) { 114 114 if ( $redirect_url = get_category_link(get_query_var('cat')) ) 115 115 $redirect['query'] = remove_query_arg('cat', $redirect['query']); 116 } elseif ( is_author() && isset($_GET['author']) ) {116 } elseif ( is_author() && !empty($_GET['author']) ) { 117 117 $author = get_userdata(get_query_var('author')); 118 118 if ( false !== $author && $redirect_url = get_author_link(false, $author->ID, $author->user_nicename) ) … … 167 167 // www.example.com vs example.com 168 168 $user_home = @parse_url(get_option('home')); 169 if ( isset($user_home['host']) )169 if ( !empty($user_home['host']) ) 170 170 $redirect['host'] = $user_home['host']; 171 if ( !isset($user_home['path']) )171 if ( empty($user_home['path']) ) 172 172 $user_home['path'] = '/'; 173 173 174 174 // Handle ports 175 if ( isset($user_home['port']) )175 if ( !empty($user_home['port']) ) 176 176 $redirect['port'] = $user_home['port']; 177 177 else … … 184 184 $redirect['path'] = preg_replace( '#(%20| )+$#', '', $redirect['path'] ); 185 185 186 if ( isset( $redirect['query'] ) ) {186 if ( !empty( $redirect['query'] ) ) { 187 187 // Remove trailing slashes from certain terminating query string args 188 188 $redirect['query'] = preg_replace( '#((p|page_id|cat|tag)=[^&]*?)(%20| )+$#', '$1', $redirect['query'] ); … … 225 225 $compare_original = array($original['host'], $original['path']); 226 226 227 if ( isset( $original['port'] ) )227 if ( !empty( $original['port'] ) ) 228 228 $compare_original[] = $original['port']; 229 229 230 if ( isset( $original['query'] ) )230 if ( !empty( $original['query'] ) ) 231 231 $compare_original[] = $original['query']; 232 232 233 233 $compare_redirect = array($redirect['host'], $redirect['path']); 234 234 235 if ( isset( $redirect['port'] ) )235 if ( !empty( $redirect['port'] ) ) 236 236 $compare_redirect[] = $redirect['port']; 237 237 238 if ( isset( $redirect['query'] ) )238 if ( !empty( $redirect['query'] ) ) 239 239 $compare_redirect[] = $redirect['query']; 240 240 241 241 if ( $compare_original !== $compare_redirect ) { 242 242 $redirect_url = $redirect['scheme'] . '://' . $redirect['host']; 243 if ( isset($redirect['port']) )243 if ( !empty($redirect['port']) ) 244 244 $redirect_url .= ':' . $redirect['port']; 245 245 $redirect_url .= $redirect['path']; 246 if ( isset($redirect['query']) )246 if ( !empty($redirect['query']) ) 247 247 $redirect_url .= '?' . $redirect['query']; 248 248 }
Note: See TracChangeset
for help on using the changeset viewer.