Make WordPress Core

Ticket #18523: 18523.3.diff

File 18523.3.diff, 3.2 KB (added by iamfriendly, 11 years ago)

Refreshed patch. Now fixes the %postname% issue highlighted by Helen

  • wp-admin/edit-form-advanced.php

    diff --git wp-admin/edit-form-advanced.php wp-admin/edit-form-advanced.php
    index 8dc4815..59a5445 100644
    if ( post_type_supports($post_type, 'comments') ) 
    204204if ( ( 'publish' == get_post_status( $post ) || 'private' == get_post_status( $post ) ) && post_type_supports($post_type, 'comments') )
    205205        add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', null, 'normal', 'core');
    206206
    207 if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) )
    208         add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', null, 'normal', 'core');
    209 
    210207if ( post_type_supports($post_type, 'author') ) {
    211208        if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) )
    212209                add_meta_box('authordiv', __('Author'), 'post_author_meta_box', null, 'normal', 'core');
    if ( !empty( $shortlink ) && $shortlink !== $permalink && $permalink !== home_ur 
    455452
    456453if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && !current_user_can( $post_type_object->cap->publish_posts ) ) ) {
    457454        $has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status;
     455
     456$no_js_permalink = get_sample_permalink($post->ID);
     457$up_to_permalink = str_replace( '%pagename%/', '', $no_js_permalink[0] );
     458$up_to_permalink = str_replace( '%postname%/', '', $up_to_permalink );
     459$slug = $no_js_permalink[1];
    458460?>
     461
     462        <div class="hide-if-js">
     463                <strong><?php _e( 'Permalink' ); ?>: </strong><span><?php echo $up_to_permalink; ?></span><input type="text" name="post_name" id="new_post_name" value="<?php echo $slug; ?>" class="hide-if-js" />
     464        </div>
     465
    459466        <div id="edit-slug-box" class="hide-if-no-js">
    460467        <?php
    461468                if ( $has_sample_permalink )
  • wp-admin/includes/meta-boxes.php

    diff --git wp-admin/includes/meta-boxes.php wp-admin/includes/meta-boxes.php
    index b5bc75b..a043ff1 100644
    function post_comment_meta_box( $post ) { 
    658658 * @param object $post
    659659 */
    660660function post_slug_meta_box($post) {
     661_deprecated_function( __FUNCTION__, '4.0' );
    661662/** This filter is documented in wp-admin/edit-tag-form.php */
    662663?>
    663664<label class="screen-reader-text" for="post_name"><?php _e('Slug') ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo esc_attr( apply_filters( 'editable_slug', $post->post_name ) ); ?>" />
  • wp-admin/js/post.js

    diff --git wp-admin/js/post.js wp-admin/js/post.js
    index 21f28e7..02f955f 100644
    jQuery(document).ready( function($) { 
    875875                });
    876876        } // end submitdiv
    877877
     878        // Hidden permalink box which has replaced slugdiv metabox
     879        $('#new_post_name').val( $('#editable-post-name-full').html() );
     880
    878881        // permalink
    879882        function editPermalink() {
    880883                var i, slug_value,
    jQuery(document).ready( function($) { 
    894897                        if ( new_slug == $('#editable-post-name-full').text() ) {
    895898                                return $('#edit-slug-buttons .cancel').click();
    896899                        }
     900
     901                        // hidden input field (which replaced old slugdiv metabox) - ensure value is same as what is entered in fancy ui
     902                        $('#new_post_name').val( new_slug );
     903
    897904                        $.post(ajaxurl, {
    898905                                action: 'sample-permalink',
    899906                                post_id: postId,