Created
May 8, 2015 08:24
-
-
Save thefuxia/e5a189d6715e57c7cdf2 to your computer and use it in GitHub Desktop.
WordPress Plugin: T5 Editor Shortlink
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php # -*- coding: utf-8 -*- | |
/** | |
* Plugin Name: T5 Editor Shortlink | |
* Plugin URI: https://gist.github.com/toscho/e5a189d6715e57c7cdf2 | |
* Description: Show the shortlink in the editor. Requires at least PHP 5.3. | |
* Version: 08.05.15 | |
* Required: 4.0 | |
* Author: Thomas Scholz <[email protected]> | |
* Author URI: http://toscho.de | |
* License: MIT | |
* License URI: http://www.opensource.org/licenses/mit-license.php | |
*/ | |
if ( is_admin() ) { | |
add_action( 'load-post.php', function () { | |
add_action( 'post_submitbox_misc_actions', function () { | |
$post = get_post(); | |
if ( ! $post ) | |
return; | |
$url = wp_get_shortlink( $post->ID ); | |
if ( ! $url ) | |
return; | |
$url = esc_url( $url ); | |
printf( | |
' | |
<div class="misc-pub-section"> | |
<label> | |
Shortlink: | |
<input type="text" value="%1$s" onclick="this.select()" class="widefat code" readonly> | |
</label> | |
</div>', | |
$url | |
); | |
} ); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment