Add unit tests for `links_add_target()`. Alter the patterns in `links_add_target()` and `_links_add_target()` slightly based on learnings after running tests.

Props mdbitz.
Fixes #26164.


Built from https://develop.svn.wordpress.org/trunk@26328


git-svn-id: http://core.svn.wordpress.org/trunk@26230 1a063a9b-81f0-0310-95a4-ce76da25c4cd