Make WordPress Core

Ticket #5816: use-real-slug.diff

File use-real-slug.diff, 2.8 KB (added by nbachiyski, 16 years ago)
  • wp-admin/wp-admin.css

     
    10531053}
    10541054#edit-slug-box strong {color: #777;}
    10551055#editable-post-name {background-color: #FFFBCC;}
     1056#editable-post-name-full {display: none;}
    10561057#editable-post-name input {width: 16em;}
    10571058#edit-slug-buttons a.save {
    10581059        background-color: #ebebeb;
  • wp-admin/includes/post.php

     
    555555        if (false === strpos($permalink, '%postname%')) {
    556556                return '';
    557557        }
    558         $title = __('You can edit this part of the permalink using the Edit button on the right');
     558        $title = __('Click to edit this part of the permalink');
    559559        if (strlen($post_name) > 30) {
    560                 $post_name = substr($post_name, 0, 14). '…' . substr($post_name, -14);
     560                $post_name_abridged = substr($post_name, 0, 14). '…' . substr($post_name, -14);
     561        } else {
     562                $post_name_abridged = $post_name;
    561563        }
    562         $post_name_html = '<span id="editable-post-name" title="'.$title.'">'.$post_name.'</span>';
     564        $post_name_html = '<span id="editable-post-name" title="'.$title.'">'.$post_name_abridged.'</span><span id="editable-post-name-full">'.$post_name.'</span>';
    563565        $display_link = str_replace('%postname%', $post_name_html, $permalink);
    564566        return $display_link;
    565567}
  • wp-admin/js/slug.js

     
    33        var e = jQuery('#editable-post-name');
    44        var revert_e = e.html();       
    55        var real_slug = jQuery('#post_name');
     6        var revert_slug = real_slug.html();
    67        var b = jQuery('#edit-slug-buttons');
    78        var revert_b = b.html();
    8         var old_slug = e.children('span').html();
     9        var full = jQuery('#editable-post-name-full').html();
    910
    1011        b.html('<a href="" class="save">'+slugL10n.save+'</a> <a class="cancel" href="">'+slugL10n.cancel+'</a>');
    1112        b.children('.save').click(function() {
     
    2526        jQuery('#edit-slug-buttons .cancel').click(function() {
    2627                e.html(revert_e);
    2728                b.html(revert_b);
    28                 real_slug.attr('value', revert_e);
     29                real_slug.attr('value', revert_slug);
    2930                return false;
    3031        });
    31         for(i=0; i < revert_e.length; ++i) {
    32                 if ('%' == revert_e.charAt(i)) c++;
     32        for(i=0; i < full.length; ++i) {
     33                if ('%' == full.charAt(i)) c++;
    3334        }
    34         slug_value = (c > revert_e.length/4)? '' : revert_e;
     35        slug_value = (c > full.length/4)? '' : full;
    3536        e.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children('input').keypress(function(e){
    3637                var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
    3738                // on enter, just save the new slug, don't save the post