_links_add_target()
Callback to add a target attribute to all links in passed content.
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Returns
String. The processed link.
Usage
_links_add_target( $m );
- $m(string) (required)
- The matched link.
Notes
- Global. String.
$_links_add_target
Changelog
| Since 2.7.0 | Introduced. |
_links_add_target() links add target code WP 6.9.1
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 ) . '">';
}