Absolute-to-Relative URLs

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
Plugin version:0.3.4
Added to WordPress repository:23-03-2011
Last updated:28-03-2013
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.
Rating, %:100
Rated by:2
Plugin URI:http://www.svachon.com/blog/absolute-to-relat...
Total downloads:5 611
Active installs:30+
plugin download
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 ($output_type=1): ../../#anchor

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.


FAQ
ChangeLog