Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

On post edit pages, when a slug exceeds a certain number of characters, Wordpress abridges it with an ellipsis (...). For example, if my slug is i-want-to-be-able-to-see-this-slug, it appears on the edit page like this:

Permalink: http://example.com/2012/i-want-to-be-a...-see-this-slug/ [ Edit ]

Can I prevent Wordpress from doing this?

I like to be able to see (and copy) a full URL without obfuscation, so I'm dying to find out how to get rid with this feature.

share|improve this question
    
only edit tags for better related –  bueltge Jan 27 '12 at 20:05
add comment

3 Answers

up vote 4 down vote accepted

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.

share|improve this answer
    
Hey toscho - I looked all over for the answer to this; it's nowhere else AFAICT! Thanks!!!! –  MikeSchinkel Mar 15 at 7:57
add comment

Its not possibel via filter or action hook, WordPress cut the strings hard in core. see wp-admin/includes/post.php line 1110 in WP 3.4alpha

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.

share|improve this answer
add comment

As @bueltge notes in his answer, there's currently no filter or action hook that would allow this. Here is the hack I did to prevent ... abbreviation.

In the file wp-admin/includes/post.php, find this line (in Wordpress 3.4.1, it is line 1117):

$post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name_abridged . '</span>';

Change it to this:

// Changed $post_name_abridged to $post_name to prevent "..." abridgement of long slugs
$post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name . '</span>';

Of course, because this edits a core file, the change will be overwritten whenever a new version of Wordpress updates this file.

If anyone can recommend a non-core-hacking way to achieve this, I'd certainly use that over this.

share|improve this answer
1  
You should not edit core files. See @toscho's answer for a work around. –  Stephen Harris Jul 4 '12 at 20:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.