Support » Plugins and Hacks » [Resolved] [Plugin: WP Bit.ly] Display actual link

[Resolved] [Plugin: WP Bit.ly] Display actual link

  • I know you can change the default text from “This is the short link” to whatever you want, but I don’t see a way to have it just display the actual link without other text.

    The old version in 2.9.2 did this by default, but the new version for 3.0.1 doesn’t.

    I basically want to mimic the old output (which you can see in the deprecated.php file):

    $text = $wpbitly_link;
    $wpbitly_print = '<a href="' . $wpbitly_link . '" rel="shortlink" class="wpbitly shortlink">' . $text . '</a>';

    The display text ($text) is set to the link itself ($wpbitly_link).

    So how do I use the parameters in the_shortlink() to do this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • I was able to do it by editing wp-includes/link-template.php. I changed:

    $link = '<a rel="shortlink" href="' . esc_url( $shortlink ) . '" title="' . $title . '">' . $text . '</a>';


    $link = '<a rel="shortlink" href="' . esc_url( $shortlink ) . '" title="' . $title . '">' . $shortlink . '</a>';

    I don’t like having to edit core files to do this kind of stuff, since you always have to remember to make the changes again whenever you upgrade.

    Is there an easier way to do this in a cleaner fashion using the_shortlink()?

    Plugin Author Mark Waterous


    The easiest method to do this would be the following;

    the_shortlink( wp_get_shortlink() );

    Alternatively if you want to ensure that any occurrence of the_shortlink() will default the text to the actual short link itself, you could do the following;

    add_filter( 'the_shortlink', 'my_shortlink', 10, 4 );
    function my_shortlink( $link, $shortlink, $text, $title )
    	return '<a rel="shortlink" href="' . esc_url( $shortlink ) . '" title="' . $title . '">' . $shortlink . '</a>';



    I would like to use the value of the link (so just the text, not wrapped in <a href=""></a>.

    I have tried to play around with the last line of your filter, to delete the link-part of it, but that only results in a totally broken function as it asks for 4 arguments. I have also had a long look at line 192-224 of the wp-bitly file, but I cannot figure it out.

    Is there a simple way to make this possible?

    ok figured it out with the very helpful article over at Otto: http://ottopress.com/tag/wp_get_shortlink/

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] [Plugin: WP Bit.ly] Display actual link’ is closed to new replies.