Advertisements

links_add_target

Definition:
function links_add_target( $content, $target = '_blank', $tags = array('a') {}

Adds a Target attribute to all links in passed content.
This function by default only applies to <a> tags, however this can be modified by the 3rd param.

Parameters

  • string $content: String to search for links in.
  • string $target: The Target to add to the links.
  • array $tags: An array of tags to apply to.

Return values

returns:The processed content.

Source code

function links_add_target( $content, $target = '_blank', $tags = array('a') ) {

	global $_links_add_target;

	$_links_add_target = $target;

	$tags = implode('|', (array)$tags);

	return preg_replace_callback( "!<($tags)(.+?)>!i", '_links_add_target', $content );

}

2247

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: