public
Description: WordPress plugin to turn relative URIs in posts, pages and comments into absolute ones.
Homepage: http://extralogical.net/projects/#absolutify
Clone URL: git://github.com/ionfish/absolutify.git
absolutify / absolutify.php
100644 35 lines (32 sloc) 0.956 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
/*
Plugin Name: Absolutify
Plugin URI: http://extralogical.net/
Description: Turn relative URIs in posts, pages and comments into absolute ones.
Author: Benedict Eastaugh
Version: 1.1
Author URI: http://extralogical.net/
.
Absolutify is released under the GPL. Please see the LICENCE file for details.
.
*/
 
/**
* Turns relative URIs into absolute ones.
*
* This plugin fixes the issues you'll otherwise have when using relative URIs
* if your content is loaded in a context outside your site. Works for links
* using both single and double quotes. It can also be handy if you ever move
* your domain.
*
* @uses get_bloginfo
*
* @param string $content
* @return string
*/
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');
 
?>