Make WordPress Core

Ticket #18523: 18523-rt.diff

File 18523-rt.diff, 3.1 KB (added by iamfriendly, 11 years ago)

Remove the slugdiv metabox, amend js to work with hidden field and add hidden field only for with-js. Works for no-js by showing the hidden field.

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

    diff --git wp-admin/edit-form-advanced.php wp-admin/edit-form-advanced.php
    index e656dd5..74bb57e 100644
    if ( post_type_supports($post_type, 'comments') ) 
    181181if ( ( 'publish' == get_post_status( $post ) || 'private' == get_post_status( $post ) ) && post_type_supports($post_type, 'comments') )
    182182        add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', null, 'normal', 'core');
    183183
    184 if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) )
    185         add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', null, 'normal', 'core');
    186 
    187184if ( post_type_supports($post_type, 'author') ) {
    188185        if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) )
    189186                add_meta_box('authordiv', __('Author'), 'post_author_meta_box', null, 'normal', 'core');
    if ( !empty($shortlink) ) 
    373370
    374371if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && !current_user_can( $post_type_object->cap->publish_posts ) ) ) {
    375372        $has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status;
     373
     374        $no_js_permalink = get_sample_permalink($post->ID);
     375        $up_to_permalink = str_replace( '%pagename%/', '', $no_js_permalink[0] );
     376        $slug = $no_js_permalink[1];
    376377?>
     378        <div class="hide-if-js">
     379                <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" />
     380        </div>
    377381        <div id="edit-slug-box" class="hide-if-no-js">
    378382        <?php
    379383                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 cefa5a9..73fb6d9 100644
    function post_comment_meta_box( $post ) { 
    588588 * @param object $post
    589589 */
    590590function post_slug_meta_box($post) {
     591        _deprecated_function( __FUNCTION__, '3.7' );
    591592?>
    592593<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) ); ?>" />
    593594<?php
  • wp-admin/js/post.js

    diff --git wp-admin/js/post.js wp-admin/js/post.js
    index 7b7d4c3..97f9dd7 100644
    jQuery(document).ready( function($) { 
    679679                });
    680680        } // end submitdiv
    681681
     682        // Hidden permalink box which has replaced slugdiv metabox
     683        $('#new_post_name').val( $('#editable-post-name-full').html() );
     684
    682685        // permalink
    683686        if ( $('#edit-slug-box').length ) {
    684687                editPermalink = function(post_id) {
    jQuery(document).ready( function($) { 
    691694                                if ( new_slug == $('#editable-post-name-full').text() ) {
    692695                                        return $('.cancel', '#edit-slug-buttons').click();
    693696                                }
     697                                $('#new_post_name').val( new_slug ); // hidden input field (which replaced old slugdiv metabox) - ensure value is same as what is entered in fancy ui
    694698                                $.post(ajaxurl, {
    695699                                        action: 'sample-permalink',
    696700                                        post_id: post_id,