I didn't make it optional because it would require a bigger rewrite of our rending to include more options. That could happen in the future but isn't necessary since optional was my idea, not part of the user's feature request.
What Was Accomplished
Added a render_link function which accepts a URL, the content of the anchor and an array of HTML attributes. It produces an <a> while checking if the URL starts with the same characters as the result of home_url(). If there's a mismatch the link gets target="_blank"
I expect that calling home_url() is faster than doing a regex each time, but I haven't tested that theory.
How It Was Tested
[x] Local plugin development environment
[x] Remote site environment
How To Test
[x] Links to the same domain stay in the same tab
[x] Links to another domain open in a new tab where available
Related Issues
What Was Accomplished
render_link
function which accepts a URL, the content of the anchor and an array of HTML attributes. It produces an<a>
while checking if the URL starts with the same characters as the result ofhome_url()
. If there's a mismatch the link getstarget="_blank"
home_url()
is faster than doing a regex each time, but I haven't tested that theory.How It Was Tested
How To Test