For the scope you define it's a matter of defining the correct filters although the title "managing outbound links" is much wider.
For your scope:
a) setup your range of filters e.g. "replace in post content" : the_content : see http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content (but also see bookmark_list, comment_text, get_comment_author_link, widget_text, etc... for other places to filter)
b) define a regex to search for outgoing links e.g.:
const HTML_REF_REGEX2 = '/<a(.*?)href=[\'"](.*?)[\'"](.*?)>(.*?)<\\/a>/i';
c) from the filter call a function that preg_replace_callback's the found uri's e.g. with
$r_content = preg_replace_callback(self::HTML_REF_REGEX2,
array($this,'DoStuffToToUri'), $content);
d) in DoStuffToUri do whatever you want to the external links e.g. : add no follow, add _blank, place a favicon in front of each link and whatever and "rebuild" the outgoing link with what you have added e.g. :
return '<a' . $arrUrlMatches[1] . 'href="' . $arrUrlMatches[2]
. '"' . $arrUrlMatches[3] .'>' . $arrUrlMatches[4] . '</a>';
However... "managing outgoing links" would mean much more than just adding simple filters: you would want a browsable list of all outgoing links incl. HTTP status returns and possible redirections, their value in terms of facebook links, tweets, google likes, pr, alexa rating and so on, automatic disabling of 404's, the location from where it is called so you can click and edit the outgoing url, etc...
p.s. when validating your outgoing links , you want want to check for the protocol since there will probably be lots of typos e.g.:
if (!((substr($str_original_uri_uri,0,7) == 'http://' ) ||
(substr($str_original_uri_uri,0,8) == 'https://') ||
(substr($str_original_uri_uri,0,7) == 'file://' ) )
)
{
return false;
}
and the stuff inside the "text" area of the outgoing link (if you want to change stuff inside the "content" of the outgoing link (can be weird stuff) e.g.:
if (strstr(trim($str_original_uri_display_text), '<'))
{
return false;
}
you might also want to exclude certain file types e.g.:
$str_original_uri_type_extension
= EdlUtils::GetUriExtension($str_original_uri_uri, '.', 1, 1);
if ($str_original_uri_type_extension != false)
{
if (stristr($this->mStrNotAllowedExtensions,
$str_original_uri_type_extension) != false)
{
$bool_href_valid=false;
}
}
You might also want to log the ones that are excluded so they can be "corrected" if needed.
p.p.s. bits of code for replacing: http://plugins.svn.wordpress.org/wp-favicons/trunk/includes/server/class-metadata.php