[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/ -> canonical.php (summary)

Canonical API to handle WordPress Redirecting Based on "Permalink Redirect" from Scott Yang and "Enforce www. Preference" by Mark Jaquith

File Size: 1020 lines (33 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 6 functions

  redirect_canonical()
  lowercase_octets()
  _remove_qs_args_if_not_in_url()
  strip_fragment_from_url()
  redirect_guess_404_permalink()
  wp_redirect_admin_locations()

Functions
Functions that are not part of a class:

redirect_canonical( $requested_url = null, $do_redirect = true )   X-Ref
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 penalty for duplicate content by redirecting all incoming links to
one or the other.

Prevents redirection for feeds, trackbacks, searches, and
admin URLs. Does not redirect on non-pretty-permalink-supporting IIS 7+,
page/post previews, WP admin, Trackbacks, robots.txt, favicon.ico, searches,
or on POST requests.

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.0
return: string|void The string of the URL, if redirect needed.
param: string $requested_url Optional. The URL that was requested, used to
param: bool   $do_redirect   Optional. Redirect to the new URL.

lowercase_octets( $matches )   X-Ref
Converts the first hex-encoded octet match to lowercase.

since: 3.1.0
return: string Lowercased version of the first match.
param: array $matches Hex-encoded octet matches for the requested URL.

_remove_qs_args_if_not_in_url( $query_string, array $args_to_check, $url )   X-Ref
Removes arguments from a query string if they are not present in a URL
DO NOT use this in plugin code.

since: 3.4.0
return: string The altered query string
param: string $query_string
param: array  $args_to_check
param: string $url

strip_fragment_from_url( $url )   X-Ref
Strips the #fragment from a URL, if one is present.

since: 4.4.0
return: string The altered URL.
param: string $url The URL to strip.

redirect_guess_404_permalink()   X-Ref
Attempts to guess the correct URL for a 404 request based on query vars.

since: 2.3.0
return: string|false The correct URL if one is found. False on failure.

wp_redirect_admin_locations()   X-Ref
Redirects a variety of shorthand URLs to the admin.

If a user visits example.com/admin, they'll be redirected to /wp-admin.
Visiting /login redirects to /wp-login.php, and so on.

since: 3.4.0



Generated: Tue Mar 19 01:00:02 2024 Cross-referenced by PHPXref 0.7.1