WordPress.org

Make WordPress Core

Ticket #5526: canonical.phpdoc.r6494.diff

File canonical.phpdoc.r6494.diff, 2.3 KB (added by darkdragon, 10 years ago)

Complete phpdoc documentation for canonical.php based off of r6494

  • canonical.php

     
    11<?php
    2 // Based on "Permalink Redirect" from Scott Yang and "Enforce www. Preference" by Mark Jaquith
     2/**
     3 * Canonical API to handle WordPress Redirecting
     4 *
     5 * Based on "Permalink Redirect" from Scott Yang and "Enforce www. Preference" by Mark Jaquith
     6 *
     7 * @author Scott Yang
     8 * @author Mark Jaquith
     9 * @package WordPress
     10 * @since 2.3
     11 */
    312
    4 function redirect_canonical($requested_url=NULL, $do_redirect=true) {
     13/**
     14 * redirect_canonical() - Redirects incoming links to the proper URL based on the site url
     15 *
     16 * Search engines consider www.somedomain.com and somedomain.com to be two different URLs
     17 * when they both go to the same location. This SEO enhancement prevents penality for
     18 * duplicate content by redirecting all incoming links to one or the other.
     19 *
     20 * Prevents redirection for feeds, trackbacks, searches, comment popup, and admin URLs.
     21 * Does not redirect on IIS, page/post previews, and on form data.
     22 *
     23 * Will also attempt to find the correct link when a user enters a URL that does not exist
     24 * based on exact WordPress query. Will instead try to parse the URL or query in an attempt
     25 * to figure the correct page to go to.
     26 *
     27 * @since 2.3
     28 * @uses $wp_rewrite
     29 * @uses $is_IIS
     30 *
     31 * @param string $requested_url Optional. The URL that was requested, used to figure if redirect is needed.
     32 * @param bool $do_redirect Optional. Redirect to the new URL.
     33 * @return null|false|string Null, if redirect not needed. False, if redirect not needed or the string of the URL
     34 */
     35function redirect_canonical($requested_url=null, $do_redirect=true) {
    536        global $wp_rewrite, $is_IIS;
    637
    738        if ( is_feed() || is_trackback() || is_search() || is_comments_popup() || is_admin() || $is_IIS || ( isset($_POST) && count($_POST) ) || is_preview() )
     
    175206        }
    176207}
    177208
     209/**
     210 * redirect_guess_404_permalink() - Tries to guess correct post based on query vars
     211 *
     212 * @since 2.3
     213 * @uses $wpdb
     214 *
     215 * @return bool|string Returns False, if it can't find post, returns correct location on success.
     216 */
    178217function redirect_guess_404_permalink() {
    179218        global $wpdb;
    180219        if ( !get_query_var('name') )