Created
September 18, 2017 09:37
-
-
Save bogdanpopa90/2504e43aa0a591f4c3495c6bff5be105 to your computer and use it in GitHub Desktop.
Function that adds target blank to external links in WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function is_external_url( $url ) { | |
$link_url = parse_url( $url ); | |
$home_url = parse_url( home_url() ); | |
if ( ! empty( $link_url['host'] ) ) { | |
if ( $link_url['host'] !== $home_url['host'] ) { | |
return 'target="_blank"'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It does not works !