谁想要一个虚拟的温暖巧克力曲奇?
我正在寻找一个 Wordpress php 函数来在新选项卡中打开所有出站链接。
我发现了一些类似于下面的功能解决方案,但它们仅适用于帖子/页面,而不适用于硬编码到主题中的项目(如社交媒体按钮):
/* OPEN ALL OUTBOUND LINKS IN NEW TAB */
function autoblank($text) {
$return = str_replace('href=', 'target="_blank" href=', $text);
$return = str_replace('target="_blank"
href="http://csihealth.lenadev.com',
'href="http://csihealth.lenadev.com', $return);
$return = str_replace('target="_blank" href="#', 'href="#', $return);
$return = str_replace(' target = "_blank">', '>', $return);
return $return;
}
add_filter('the_content', 'autoblank');
add_filter('comment_text', 'autoblank');
有没有办法改变它,使其适用于所有出站链接?不仅仅是帖子/页面?