Advertisements

popuplinks

Definition:
function popuplinks($text) {}

Adds a element attributes to open links in new windows.
Comment text in popup windows should be filtered through this. Right now it’s a moderately dumb function, ideally it would detect whether a target or rel attribute was already there and adjust its actions accordingly.

Parameters

  • string $text: Content to replace links to open in a new window.

Return values

returns:Content that has filtered links.

Source code

function popuplinks($text) {

	$text = preg_replace('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text);

	return $text;

}

2545

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: