]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/canonical.php
Wordpress 2.6.2
[autoinstalls/wordpress.git] / wp-includes / canonical.php
index 5ad44575028b2e31b87449415ae98b6f6684ef20..4c1e3657f71bfb949a77873a70aa1a54070d6c36 100644 (file)
@@ -2,7 +2,8 @@
 /**
  * Canonical API to handle WordPress Redirecting
  *
 /**
  * Canonical API to handle WordPress Redirecting
  *
- * Based on "Permalink Redirect" from Scott Yang and "Enforce www. Preference" by Mark Jaquith
+ * Based on "Permalink Redirect" from Scott Yang and "Enforce www. Preference"
+ * by Mark Jaquith
  *
  * @author Scott Yang
  * @author Mark Jaquith
  *
  * @author Scott Yang
  * @author Mark Jaquith
  */
 
 /**
  */
 
 /**
- * redirect_canonical() - Redirects incoming links to the proper URL based on the site url
+ * Redirects incoming links to the proper URL based on the site url
  *
  *
- * Search engines consider www.somedomain.com and somedomain.com to be two different URLs
- * when they both go to the same location. This SEO enhancement prevents penality for
- * duplicate content by redirecting all incoming links to one or the other.
+ * Search engines consider www.somedomain.com and somedomain.com to be two
+ * different URLs when they both go to the same location. This SEO enhancement
+ * prevents penality for duplicate content by redirecting all incoming links to
+ * one or the other.
  *
  *
- * Prevents redirection for feeds, trackbacks, searches, comment popup, and admin URLs.
- * Does not redirect on IIS, page/post previews, and on form data.
+ * Prevents redirection for feeds, trackbacks, searches, comment popup, and
+ * admin URLs. Does not redirect on IIS, page/post previews, and on form data.
  *
  *
- * Will also attempt to find the correct link when a user enters a URL that does not exist
- * based on exact WordPress query. Will instead try to parse the URL or query in an attempt
- * to figure the correct page to go to.
+ * Will also attempt to find the correct link when a user enters a URL that does
+ * not exist based on exact WordPress query. Will instead try to parse the URL
+ * or query in an attempt to figure the correct page to go to.
  *
  * @since 2.3
  * @uses $wp_rewrite
  * @uses $is_IIS
  *
  *
  * @since 2.3
  * @uses $wp_rewrite
  * @uses $is_IIS
  *
- * @param string $requested_url Optional. The URL that was requested, used to figure if redirect is needed.
+ * @param string $requested_url Optional. The URL that was requested, used to
+ *             figure if redirect is needed.
  * @param bool $do_redirect Optional. Redirect to the new URL.
  * @param bool $do_redirect Optional. Redirect to the new URL.
- * @return null|false|string Null, if redirect not needed. False, if redirect not needed or the string of the URL
+ * @return null|false|string Null, if redirect not needed. False, if redirect
+ *             not needed or the string of the URL
  */
 function redirect_canonical($requested_url=null, $do_redirect=true) {
        global $wp_rewrite, $is_IIS;
 
  */
 function redirect_canonical($requested_url=null, $do_redirect=true) {
        global $wp_rewrite, $is_IIS;
 
-       if ( is_feed() || is_trackback() || is_search() || is_comments_popup() || is_admin() || $is_IIS || ( isset($_POST) && count($_POST) ) || is_preview() )
+       if ( is_feed() || is_trackback() || is_search() || is_comments_popup() || is_admin() || $is_IIS || ( isset($_POST) && count($_POST) ) || is_preview() || is_robots() )
                return;
 
        if ( !$requested_url ) {
                return;
 
        if ( !$requested_url ) {
@@ -137,7 +141,8 @@ function redirect_canonical($requested_url=null, $do_redirect=true) {
 
        // www.example.com vs example.com
        $user_home = @parse_url(get_option('home'));
 
        // www.example.com vs example.com
        $user_home = @parse_url(get_option('home'));
-       $redirect['host'] = $user_home['host'];
+       if ( isset($user_home['host']) )
+               $redirect['host'] = $user_home['host'];
 
        // Handle ports
        if ( isset($user_home['port']) )
 
        // Handle ports
        if ( isset($user_home['port']) )
@@ -160,11 +165,12 @@ function redirect_canonical($requested_url=null, $do_redirect=true) {
                } else {
                        foreach ( array('single', 'category', 'page', 'day', 'month', 'year') as $type ) {
                                $func = 'is_' . $type;
                } else {
                        foreach ( array('single', 'category', 'page', 'day', 'month', 'year') as $type ) {
                                $func = 'is_' . $type;
-                               if ( call_user_func($func) )
+                               if ( call_user_func($func) ) {
                                        $user_ts_type = $type;
                                        break;
                                }
                        }
                                        $user_ts_type = $type;
                                        break;
                                }
                        }
+               }
                $redirect['path'] = user_trailingslashit($redirect['path'], $user_ts_type);
        } elseif ( is_home() ) {
                $redirect['path'] = trailingslashit($redirect['path']);
                $redirect['path'] = user_trailingslashit($redirect['path'], $user_ts_type);
        } elseif ( is_home() ) {
                $redirect['path'] = trailingslashit($redirect['path']);
@@ -210,12 +216,13 @@ function redirect_canonical($requested_url=null, $do_redirect=true) {
 }
 
 /**
 }
 
 /**
- * redirect_guess_404_permalink() - Tries to guess correct post based on query vars
+ * Attempts to guess correct post based on query vars
  *
  * @since 2.3
  * @uses $wpdb
  *
  *
  * @since 2.3
  * @uses $wpdb
  *
- * @return bool|string Returns False, if it can't find post, returns correct location on success.
+ * @return bool|string Returns False, if it can't find post, returns correct
+ *             location on success.
  */
 function redirect_guess_404_permalink() {
        global $wpdb;
  */
 function redirect_guess_404_permalink() {
        global $wpdb;