A **function()** for use in shortening URL links. This plugin is meant for dev work and does not automatically shorten URLs.
|Author:||Steven Vachon (profile at wordpress.org)|
|WordPress version required:||3.2|
|WordPress version tested:||3.4.2|
|Added to WordPress repository:||23-03-2011|
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
|Total downloads:||5 129|
Click to start download
If you were to use this on a website like http;//example.com/test/testing/, you would get results like these:
- Before: http;//example.com/test/another-test/#anchor
- After: ../another-test/#anchor
- Before: http;//example.com/wp-content/themes/twentyten/style.css
- After: /wp-content/themes/twentyten/style.css
- Before: https;//example.com/wp-content/themes/twentyten/style.css
- After: https;//example.com/wp-content/themes/twentyten/style.css
- Before: http;//google.com/test/
- After: //google.com/test/
- Before: ../../../../../../../../#anchor
- After: /#anchor
- After (
All string parsing. No directory browsing.
If you’re looking for a plugin that will automatically convert all URLs on your WordPress site, instead check out my other plugin, WP-HTML-Compression.
Before you copy this code and add it into your own, keep in mind that there will probably be future updates. Keeping the code within an installed plugin will make sure that you’re notified.
Why isn’t this automatic?
Check out WP-HTML-Compression instead.
How does this work?
Will this plugin work for WordPress version x.x.x?
This plugin has only been tested with versions of WordPress as early as 3.2. For anything older, you’ll have to see for yourself.
- Empty, hash-only anchors (
"#") are no longer invalidated to
- Data URIs (
"data:") are no longer invalidated as paths
- Domains with and without “www.” are no longer considered to be identical by default, but can still be overridden
- Scheme-relative URLs (
//domain.com) now supported on input and output
- Cleans up the ports and paths of external URLs
- Optionally, output only host-relative URLs (
- Speed optimizations
- Minor bug fixes
- Path-relatve URLs (
../), or parenting, now supported on input and output
- Differentiates schemes/protocols, usernames, passwords, hosts, ports, paths, resources/files, queries and fragments/hashes
- Considers domains with and without “www.” to be identical, and can be overridden
- Outputs the shortest url (host- or path-relative) by default, and can be overridden
- Custom site URL support, but only with a separate
- Initial release