I'm kind of glad they force people to upgrade in order to use it. :)
I'm kind of glad they force people to upgrade in order to use it. :)
Fun bit of code I added to a theme for this:
In the theme header:
In the Loop:HTML Code:<script language="JavaScript"> function highlight(field) { field.focus(); field.select(); }</script>
Result: A text box with the shortlink in it. Click it, it selects the whole thing for easy copy/paste.PHP Code:<?php if (function_exists('get_shortlink')) { ?>
<div><span class="shortlink">Shortlink:
<input type='text'
value='<?php echo get_shortlink(get_the_ID()); ?>'
onclick='highlight(this);' />
</span></div>
<?php } ?>
Addendum: I was mistaken about shortlink formats. The post-links start with "p". Individual blog links do not. Other than that I was dead on.
Example:
My blog: http://wp.me/4uuB
Post on my blog: http://wp.me/p4uuB-9l
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:
Shows an input box with the shortlink in it. Clicking the box selects the shortlink for copy/paste.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 } ?>
I noticed that short URL link in the new admin panel a few days ago. It looks pretty handy. I often go manually creating those URLs via the post/page ID, but it will be nice to have it right there in front of me from now on.
Speaking of the wp.com stats plugin, I just noticed a new tab in the stats are called "Humanize".
That shows up if you turn on the Surprise Me option: http://en.blog.wordpress.com/2010/04/17/surprise-me/
More info: http://www.psfk.com/2010/04/the-whim...xperiment.html