Overriding the Link button in the Editor?

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Overriding the Link button in the Editor?

Thomas Belknap
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
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Overriding the Link button in the Editor?

Gavin Pearce
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: [hidden email]
[mailto:[hidden email]] On Behalf Of Thomas
Belknap
Sent: 09 February 2011 14:12
To: [hidden email]
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
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Overriding the Link button in the Editor?

Thomas Belknap
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 <[hidden email]>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: [hidden email]
> [mailto:[hidden email]] On Behalf Of Thomas
> Belknap
> Sent: 09 February 2011 14:12
> To: [hidden email]
> 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
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Overriding the Link button in the Editor?

William P. Davis-2
In reply to this post by Thomas Belknap
Try using the YOURLS plugin: http://wordpress.org/extend/plugins/yourls-wordpress-to-twitter/ 
. I believe you have have it return shortlinks for bit.ly.

Will

William P. Davis
[hidden email]
207.660.5342
http://twitter.com/williampd
http://www.wpdavis.com



On Feb 9, 2011, at 9:12 AM, Thomas Belknap wrote:

> 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
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Overriding the Link button in the Editor?

Chip Bennett
In reply to this post by Thomas Belknap
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
<[hidden email]>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 <[hidden email]
> >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: [hidden email]
> > [mailto:[hidden email]] On Behalf Of Thomas
> > Belknap
> > Sent: 09 February 2011 14:12
> > To: [hidden email]
> > 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
> > [hidden email]
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> > _______________________________________________
> > wp-hackers mailing list
> > [hidden email]
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Overriding the Link button in the Editor?

Thomas Belknap
Let's not focus on Bit.ly.

Does anyone know how to override the Link button, or if it's even possible.
Why I want to do it is irrelevant.
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Overriding the Link button in the Editor?

William P. Davis-2
In reply to this post by Thomas Belknap
Any reason you can't use the shortlink button?
------Original Message------
From: Thomas Belknap
Sender: [hidden email]
To: [hidden email]
ReplyTo: [hidden email]
Subject: Re: [wp-hackers] Overriding the Link button in the Editor?
Sent: Feb 9, 2011 3:08 PM

Let's not focus on Bit.ly.

Does anyone know how to override the Link button, or if it's even possible.
Why I want to do it is irrelevant.
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers


Sent from my BlackBerry® wireless device
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Overriding the Link button in the Editor?

Thomas Belknap
I'm not creating a link for the blog post. I am creating links internal to
the subject of the post.
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Overriding the Link button in the Editor?

Chip Bennett
Sorry; misunderstood you. You meant the TinyMCE hyperlink button; I thought
you meant the post shortlink button.

I'm not sure how to filter existing TinyMCE buttons, but I assume that there
must be a way.

Chip

On Wed, Feb 9, 2011 at 2:10 PM, Thomas Belknap
<[hidden email]>wrote:

> I'm not creating a link for the blog post. I am creating links internal to
> the subject of the post.
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Overriding the Link button in the Editor?

Helen Hou-Sandi
The advlink plugin for TinyMCE overrides the link button - you could take a
look and see how it does that (don't know enough to break it down myself).

Internal linking in 3.1 relies on using the regular link button as far as I
can tell though, so if you override it, you'll lose the internal linking
piece if/when you make the jump. Just tried it myself by replacing with
advlink.

Why not just unset the regular link button and put your custom button there
instead? If you use the same icon, a user probably won't know the difference
anyway.

--
Helen Hou-Sandi
http://www.helenhousandi.com



On Wed, Feb 9, 2011 at 3:13 PM, Chip Bennett <[hidden email]> wrote:

> Sorry; misunderstood you. You meant the TinyMCE hyperlink button; I thought
> you meant the post shortlink button.
>
> I'm not sure how to filter existing TinyMCE buttons, but I assume that
> there
> must be a way.
>
> Chip
>
> On Wed, Feb 9, 2011 at 2:10 PM, Thomas Belknap
> <[hidden email]>wrote:
>
> > I'm not creating a link for the blog post. I am creating links internal
> to
> > the subject of the post.
> > _______________________________________________
> > wp-hackers mailing list
> > [hidden email]
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Overriding the Link button in the Editor?

Thomas Belknap
Thanks Helen and Chip. I'm going to start playing around with the array of
buttons and see what I can come up with. Helen, that's a great lead, thank
you!
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers