diff --git a/wp-directives.php b/wp-directives.php index 526e22c8..f947ffde 100644 --- a/wp-directives.php +++ b/wp-directives.php @@ -1,4 +1,5 @@ next_tag('a')) { + if ($w->get_attribute('target') === '_blank') { + break; + } + + $link = parse_url($w->get_attribute('href')); + if (is_null($link['host']) || ($link['host'] === $site_url['host'])) { + $w->set_attribute('wp-link', 'true'); + } + }; + return (string) $w; +} + +add_filter('render_block', 'add_wp_link_attribute', 10, 2);