[wp-hackers] Overriding the Link button in the Editor?
Chip Bennett
chip at chipbennett.net
Wed Feb 9 20:05:01 UTC 2011
Note: code examples are taken from the WP-Bitly
Plugin<http://wordpress.org/extend/plugins/wp-bitly>
.
It's actually pretty straight-forward; you merely need to hook your own
shortlink into the get_shortlink filter:
add_filter( 'get_shortlink', 'wpbitly_get_shortlink', 10, 3 );
Then, you merely need to define your own shortlink. (Reference the WP-Bitly
Plugin to see how we did it.)
Note, you need to unhook the wp.me shortlink provided by the WordPress.com
Stats Plugin, if active:
remove_action( 'wp', 'wpme_shortlink_header' );
remove_action( 'wp_head', 'wpme_shortlink_wp_head' );
It's actually pretty easy. If you want a lighter code example, Yoast has
also released a bit.ly Plugin that filters the shortlink button.
Chip
On Wed, Feb 9, 2011 at 10:52 AM, Thomas Belknap
<dragonfly at dragonflyeye.net>wrote:
> Thanks for the reply, Gavin. My motivation is for a number of reasons:
>
> 1. Using Bitly Pro, I have a custom shortening domain and it would be
> nice to push most of my links that direction.
> 2. Tracking CTR for all my links - from posts, from Twitter, from
> FaceBook - would be a real convenience.
> 3. I'm working on availing myself of the Bitly API to do more fancy,
> paper.li, type stuff on the blog. One location for all links would be
> hugely helpful in this regard.
>
>
>
> On Wed, Feb 9, 2011 at 11:48 AM, Gavin Pearce <Gavin.Pearce at 3seven9.com
> >wrote:
>
> > Hi Thomas,
> >
> > Out of interest - why would you like to do this?
> >
> > Bit.ly is a great service when you need to shorten the URL (Twitter for
> > example, or TXT emails), however surely if it's part of the link button,
> > then the full URL will do?
> >
> > Maybe if we know your reasons, we can suggest a better solution?
> >
> > Gav
> >
> > -----Original Message-----
> > From: wp-hackers-bounces at lists.automattic.com
> > [mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of Thomas
> > Belknap
> > Sent: 09 February 2011 14:12
> > To: wp-hackers at lists.automattic.com
> > Subject: [wp-hackers] Overriding the Link button in the Editor?
> >
> > I know I can create my own button - which I'm doing. But I'd really like
> > to
> > override the Link button to do what I'd like it to do - namely, to
> > create
> > Bit.ly links instead of standard.
> >
> > Is that possible? Or is this a better question for TinyMCE forums?
> >
> > Thanks.
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list