Page 3 of 3 FirstFirst 123
Results 21 to 23 of 23

Thread: WP.ME Shortlink Generator

  1. #21
    andrea_r's Avatar
    andrea_r is offline WordPress Rockstar
    Join Date
    Jan 2009
    Location
    Eastern Canada
    Posts
    1,325

    Default

    I'm still trying to figure out what all they included in "surprise me".

  2. #22
    Otto's Avatar
    Otto is offline On The Rocks
    Join Date
    Apr 2009
    Location
    Memphis, TN
    Posts
    862

    Default

    Humanize tab and the video on Publish is all I know of.

  3. #23
    rilwis's Avatar
    rilwis is offline Hello World
    Join Date
    Apr 2010
    Posts
    9

    Default

    Quote Originally Posted by Otto View Post
    Note: WP 3.0 changed all this. It'll support shortlinks natively, with plugins doing the heavy lifting.

    Default shortlinks will be of the http://example.com/?p=ID format.

    Plugins can override this to make their own shortlink output.

    Functions of use:

    the_shortlink($text = '', $title = '', $before = '', $after = '') - Loop function, outputs the shortlink in the form of an a href link.

    wp_get_shortlink($id = 0, $context = 'post', $allow_slugs = true) - Returns the shortlink. Can optionally return the shortlink for an item defined by the item id and the context. Allow slugs is for use by plugins only.

    wp_shortlink_wp_head() - inserts link tags into the html head.
    wp_shortlink_header() - inserts link tags into the http header.

    These can be disabled like so, if desired (shouldn't be necessary):
    remove_action( 'template_redirect', 'wp_shortlink_header', 11, 0 );
    remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );

    A plugin has two filters it can use to override the shortlink:

    pre_get_shortlink - Happens before default shortlink generation. If this filter gets anything returned to it, then the default stuff gets skipped. Probably should be used by most shortlink plugins.

    get_shortlink - Happens after default shortlink generation. Only should be used to modify default shortlinks.

    Using either of those to modify the shortlink will cause your modification to show up everywhere the shortlink functions are used.

    Example usage:
    PHP Code:
    <?php if (function_exists('wp_get_shortlink')) { ?>
    <div><span class="post-shortlink">Shortlink: 
    <input type='text' value='<?php echo wp_get_shortlink(get_the_ID()); ?>' onclick='this.focus(); this.select();' />
    </span></div>
    <?php ?>
    Shows an input box with the shortlink in it. Clicking the box selects the shortlink for copy/paste.
    Thank you for this information.

Page 3 of 3 FirstFirst 123

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •