Skip to content

Instantly share code, notes, and snippets.

@thefuxia
Created July 5, 2012 09:35
Show Gist options
  • Save thefuxia/3052614 to your computer and use it in GitHub Desktop.
Save thefuxia/3052614 to your computer and use it in GitHub Desktop.
T5 Unabridged Permalink Slug
<?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
);
}
@thefuxia
Copy link
Author

thefuxia commented Jul 5, 2012

screen shot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment