diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php
index 7d142d9..fc52137 100644
--- a/wp-admin/edit-form-advanced.php
+++ b/wp-admin/edit-form-advanced.php
@@ -331,10 +331,8 @@ wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
 </div>
 <div class="inside">
 <?php
+add_filter( 'get_sample_permalink_html', '_get_sample_permalink_html_shortlink_button', 10, 4 );
 $sample_permalink_html = $post_type_object->public ? get_sample_permalink_html($post->ID) : '';
-$shortlink = wp_get_shortlink($post->ID, 'post');
-if ( !empty($shortlink) )
-    $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>';
 
 if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?>
 	<div id="edit-slug-box" class="hide-if-no-js">
diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php
index e4866ad..7537ecd 100644
--- a/wp-admin/includes/post.php
+++ b/wp-admin/includes/post.php
@@ -1307,3 +1307,21 @@ function post_preview() {
 
 	return $url;
 }
+
+
+/**
+ * Append the Get Shortlink button to the sample permalink HTML.
+ *
+ * This is attached to the 'sample_permalink_html' filter. Do not call this directly in plugins or theme templates.
+ *
+ * @uses get_sample_permalink_html()
+ *
+ * @return string The HTML of the sample permalink slug editor.
+ */
+function _get_sample_permalink_html_shortlink_button( $sample_permalink_html, $post_id, $new_title, $new_slug ) {
+	$shortlink = wp_get_shortlink($post_id, 'post');
+	if ( !empty($shortlink) )
+		$sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>';
+
+	return $sample_permalink_html;
+}
