Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Open Links in new window


_ck_
Participant

@_ck_

I just realized I am not escaping < and > in that code.

It most probably should be.

So anywhere you do not see a slash in front, add one, ie.

<

>

actually to be more clear, try this

$text = preg_replace('|<a (.*)rel=['"]nofollow['"]([^>]+)?>|iU','<a $1>', $text);	// strip ALL nofollow
$text = preg_replace('|<a (?=([^>]+http://))(?!([^>]+'.$domain.'))([^>]+)>|iU', '<a $1 rel="nofollow" target="_blank">', $text);

sorry, don’t have time to debug it more, someone will have to throw it into a regex tester and check it against some same sample links

Skip to toolbar