ionfish / absolutify

WordPress plugin to turn relative URIs in posts, pages and comments into absolute ones.

This URL has Read+Write access

absolutify / absolutify.php
100644 22 lines (19 sloc) 0.688 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
/*
Plugin Name: Absolutify
Plugin URI: http://extralogical.net/
Description: Turn relative URIs in posts, pages and comments into absolute ones, fixing the issues you'll otherwise have when your content is loaded in a context outside your site.
Author: Benedict Eastaugh
Version: 1.0
Author URI: http://extralogical.net/
.
Works for links using both single and double quotes. Also handy if you ever move your domain.
.
*/
 
function absolutify_content_urls($content) {
$url = get_bloginfo('url');
return preg_replace("/href=(\"|')\//", "href=\${1}$url/", $content);
}
 
add_filter('the_content', 'absolutify_content_urls');
add_filter('comment_text', 'absolutify_content_urls');
 
?>