[wp-forums] Proposal: No URL shorteners?

Peter Westwood peter.westwood at ftwr.co.uk
Tue Jan 4 08:41:04 UTC 2011


On 3 Jan 2011, at 18:39, Otto <otto at ottodestruct.com> wrote:

> 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. :)


The code reads good - not sure if we should replace or add in brackets

Would make a nice WP plugin too ;)

--
Peter Westwood
http://peter.westwood.name


More information about the wp-forums mailing list