/** * Provide a shortlink. * * @since 3.1.0 */ function nxt_admin_bar_shortlink_menu($nxt_admin_bar) { $short = nxt_get_shortlink(0, 'query'); $id = 'get-shortlink'; if (empty($short)) { return; } $html = '<input class="shortlink-input" type="text" readonly="readonly" value="' . esc_attr($short) . '" />'; $nxt_admin_bar->add_menu(array('id' => $id, 'title' => __('Shortlink'), 'href' => $short, 'meta' => array('html' => $html))); }
?> <div id="titlediv"> <div id="titlewrap"> <label class="hide-if-no-js" style="visibility:hidden" id="title-prompt-text" for="title"><?php echo apply_filters('enter_title_here', __('Enter title here'), $post); ?> </label> <input type="text" name="post_title" size="30" tabindex="1" value="<?php echo esc_attr(htmlspecialchars($post->post_title)); ?> " id="title" autocomplete="off" /> </div> <div class="inside"> <?php $sample_permalink_html = $post_type_object->public ? get_sample_permalink_html($post->ID) : ''; $shortlink = nxt_get_shortlink($post->ID, 'post'); if (!empty($shortlink)) { $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button" onclick="prompt('URL:', jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>'; } if ($post_type_object->public && !('pending' == $post->post_status && !current_user_can($post_type_object->cap->publish_posts))) { ?> <div id="edit-slug-box"> <?php if (!empty($post->ID) && !empty($sample_permalink_html) && 'auto-draft' != $post->post_status) { echo $sample_permalink_html; } ?> </div> <?php } ?>
/** * Display the Short Link for a Post * * Must be called from inside "The Loop" * * Call like the_shortlink(__('Shortlinkage FTW')) * * @since 3.0.0 * * @param string $text Optional The link text or HTML to be displayed. Defaults to 'This is the short link.' * @param string $title Optional The tooltip for the link. Must be sanitized. Defaults to the sanitized post title. * @param string $before Optional HTML to display before the link. * @param string $after Optional HTML to display after the link. */ function the_shortlink($text = '', $title = '', $before = '', $after = '') { global $post; if (empty($text)) { $text = __('This is the short link.'); } if (empty($title)) { $title = the_title_attribute(array('echo' => FALSE)); } $shortlink = nxt_get_shortlink($post->ID); if (!empty($shortlink)) { $link = '<a rel="shortlink" href="' . esc_url($shortlink) . '" title="' . $title . '">' . $text . '</a>'; $link = apply_filters('the_shortlink', $link, $shortlink, $text, $title); echo $before, $link, $after; } }