-
-
Save lnked/f5df8450270cd12e3d59a0bcd8bf25ce to your computer and use it in GitHub Desktop.
Force PDF links to open in a new tab in PHP.
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
$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