diff --git a/CHANGELOG.md b/CHANGELOG.md index 80ac64f..1956f2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ### 6.4.0: May 1st, 2013 +* Fix relative external URLs issue * Fix Theme Activation page issues * Fix issues with root relative URLs and rewrites on non-standard setups * Make sure rewrites are added to .htaccess immediately after activation diff --git a/lib/cleanup.php b/lib/cleanup.php index 1b0d369..3b50a70 100644 --- a/lib/cleanup.php +++ b/lib/cleanup.php @@ -138,8 +138,16 @@ add_filter('body_class', 'roots_body_class'); * @author Scott Walkinshaw */ function roots_root_relative_url($input) { - $output = wp_make_link_relative($input); - return $output; + $parsed_url = parse_url(site_url()); + $site_domain = $parsed_url['host']; + + preg_match('|https?://([^/]+)(/.*)|i', $input, $matches); + + if (isset($matches[1]) && isset($matches[2]) && $matches[1] === $site_domain) { + return wp_make_link_relative($input); + } else { + return $input; + } } function roots_enable_root_relative_urls() { @@ -152,7 +160,7 @@ if (roots_enable_root_relative_urls()) { 'the_permalink', 'wp_list_pages', 'wp_list_categories', - 'wp_nav_menu', + 'roots_wp_nav_menu_item', 'the_content_more_link', 'the_tags', 'get_pagenum_link', diff --git a/lib/nav.php b/lib/nav.php index 3ce0314..8a071b1 100644 --- a/lib/nav.php +++ b/lib/nav.php @@ -34,6 +34,7 @@ class Roots_Nav_Walker extends Walker_Nav_Menu { $item_html = preg_replace('/]*>(.*)<\/a>/iU', '$1', $item_html); } + $item_html = apply_filters('roots_wp_nav_menu_item', $item_html); $output .= $item_html; }