Request: Only Replace Local URLs
-
Suggestion: instead of filtering using the
wp_make_link_relative
function, perhaps you should add an intermediary filter function that first tests that links share the home url… I think that’s the only time relative links make sense anyway. This seems to work:Note: I used an anonymous function that uses $home_url, to avoid problems when home_url itself was being filtered.
$home_url = home_url(); $filter_fn = function($link) use ($home_url) { if ( strpos($link, $home_url) === 0 ) { return wp_make_link_relative( $link ); } else { return $link; } }; foreach ( $filters as $filter ) { add_filter( $filter, $filter_fn); }
- The topic ‘Request: Only Replace Local URLs’ is closed to new replies.