Created
July 5, 2012 09:35
-
-
Save thefuxia/3052614 to your computer and use it in GitHub Desktop.
T5 Unabridged Permalink Slug
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 Unabridged Permalink Slug | |
* Description: Disable shortening of of sample slug in post editor. | |
* Version: 2012.07.05 | |
* Author: Thomas Scholz <info@toscho.de> | |
* Author URI: http://toscho.de | |
* License: MIT | |
* License URI: http://www.opensource.org/licenses/mit-license.php | |
* | |
* Copyright (c) 2012 Thomas Scholz | |
*/ | |
add_filter( 'get_sample_permalink_html', 't5_unabridge_sample_permalink', 10, 2 ); | |
/** | |
* Replaces the shortened permalink with its full form. | |
* | |
* @param string $sample Permalink HTML | |
* @param int $id Post ID | |
* @return string | |
*/ | |
function t5_unabridge_sample_permalink( $sample, $id ) | |
{ | |
$link = get_sample_permalink( $id ); | |
$s1 = '<span id="editable-post-name" '; | |
$s2 = '</span>'; | |
return preg_replace( | |
'~' . $s1 . '([^>]*)>([^<]*)' . $s2 . '~Ui', | |
$s1 . '$1>' . $link[1] . $s2, | |
$sample | |
); | |
} |
Author
thefuxia
commented
Jul 5, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment