Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

_links_add_target() WordPress Function

The _links_add_target() function is used to add a target attribute to the links in a WordPress post. This is useful for making the links open in a new window or tab.

_links_add_target( string $m ) #

Callback to add a target attribute to all links in passed content.


Parameters

$m

(string)(Required)The matched link.


Top ↑

Return

(string) The processed link.


Top ↑

Source

File: wp-includes/formatting.php

function _links_add_target( $m ) {
	global $_links_add_target;
	$tag  = $m[1];
	$link = preg_replace( '|( target=([\'"])(.*?)\2)|i', '', $m[2] );
	return '<' . $tag . $link . ' target="' . esc_attr( $_links_add_target ) . '">';
}


Top ↑

Changelog

Changelog
VersionDescription
2.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.