Last active
June 3, 2016 01:24
-
-
Save jakebellacera/7e10134ddde84833f623 to your computer and use it in GitHub Desktop.
Force PDF links to open in a new tab in PHP.
This file contains 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
$new_text = preg_replace( | |
'/((<a (?=.*\.pdf)(?!.*target="_blank").*?)>)/', | |
'$2 target="_blank">', | |
$old_text | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment