From 40485c7ee92bdb329cf033c1036fb4220f318bfc Mon Sep 17 00:00:00 2001 From: Scott Walkinshaw Date: Mon, 4 Apr 2011 15:56:19 -0600 Subject: [PATCH] Updated relative path function to work with sub dirs - fixes #13 --- includes/roots-cleanup.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/roots-cleanup.php b/includes/roots-cleanup.php index 3270ead..5e1e2ec 100644 --- a/includes/roots-cleanup.php +++ b/includes/roots-cleanup.php @@ -57,7 +57,8 @@ add_action('template_redirect', 'roots_nice_search_redirect'); // inspired by http://www.456bereastreet.com/archive/201010/how_to_make_wordpress_urls_root_relative/ // thanks to Scott Walkinshaw (scottwalkinshaw.com) function roots_root_relative_url($input) { - return preg_replace('!' . get_home_url() . '/!', '/', $input); + preg_match('/(https?:\/\/[^\/]+)/', $input, $matches); + return str_replace(end($matches), '', $input); } //add_filter('site_url', 'roots_root_relative_url'); // this will break URLs sent out in emails, possibly more