| | 2132 | /** |
| | 2133 | * Display the Short Link for a Post |
| | 2134 | * |
| | 2135 | * Must be called from inside "The Loop" |
| | 2136 | * |
| | 2137 | * Call like the_shortlink(__('Shortlinkage FTW')) |
| | 2138 | * |
| | 2139 | * @since 3.0.0 |
| | 2140 | * |
| | 2141 | * @param string $text Optional The link text or HTML to be displayed. Defaults to 'This is the short link.' |
| | 2142 | * @param string $title Optional The tooltip for the link. Must be sanitized. Defaults to the sanitized post title. |
| | 2143 | * @param string $before Optional HTML to display before the link. |
| | 2144 | * @param string $before Optional HTML to display after the link. |
| | 2145 | */ |
| | 2146 | function the_shortlink($text = '', $title = '', $before = '', $after = '') { |
| | 2147 | global $post; |
| | 2148 | |
| | 2149 | if ( empty($text) ) |
| | 2150 | $text = __('This is the short link.'); |
| | 2151 | |
| | 2152 | if ( empty($title) ) |
| | 2153 | $title = the_title_attribute( array('echo' => FALSE) ); |
| | 2154 | |
| | 2155 | $shortlink = wp_get_shortlink($post->ID); |
| | 2156 | |
| | 2157 | if ( !empty($shortlink) ) |
| | 2158 | echo "$before<a rel='shortlink' href='$shortlink' title='$title'>$text</a>$after"; |
| | 2159 | } |
| | 2160 | |