[wp-forums] Proposal: No URL shorteners?

Otto otto at ottodestruct.com
Mon Jan 3 18:39:48 UTC 2011


On Mon, Jan 3, 2011 at 10:26 AM, Jane Wells <jane at automattic.com> wrote:
> On 1/3/11 9:12 AM, Peter Westwood wrote:
>>
>> Maybe we should create a bbPress plugin which auto expands the urls or
>> shows the actual target in a tooltip?
>
> +1 for auto-expand. A lot of people don't hover long enough for a tooltip to
> show, and not everyone has status bar showing in their browser.

Could be done. This code should expand any shortlinks given to it to
their full links. I think. Works on the ones I tested it on. Feel free
to pound on it for me.

function expand_shortlink($url) {
	$headers = get_headers($url,1);
	if (!empty($headers['Location'])) {
		$headers['Location'] = (array) $headers['Location'];
		$url = array_pop($headers['Location']);
	}
	return $url;
}

I can implement this as a plugin for the forums, unless anybody can
find fault with my code. :)

-Otto


More information about the wp-forums mailing list