Wordpress - Prevent Wordpress from abbreviating-long-slugs...-in-the-admin

There is a filter at the end of the function: 'get_sample_permalink_html'. Hook into this and just replace the shortened form with the full length.

<?php # -*- coding: utf-8 -*-
/* Plugin Name: T5 Unabridge Permalink Slug */

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
    );
}

Result

Post title: This is a rather long post title. WordPress would shorten it by default, but our nice plugin prevents that.

enter image description here

Download from GitHub.


It's not possible via filter or action hook. WordPress cut the strings hard in core. See wp-admin/includes/post.php line 1110 in WP 3.4 alpha.

if ( function_exists('mb_strlen') ) {
    if ( mb_strlen($post_name) > 30 ) {
        $post_name_abridged = mb_substr($post_name, 0, 14). '&hellip;' . mb_substr($post_name, -14);
    } else {
        $post_name_abridged = $post_name;
    }
} else {
    if ( strlen($post_name) > 30 ) {
        $post_name_abridged = substr($post_name, 0, 14). '&hellip;' . substr($post_name, -14);
    } else {
        $post_name_abridged = $post_name;
    }
}

You can open a ticket on the Trac of WordPress for include an filter.