WordPress.org

Make WordPress Core

Ticket #12870: 12870.diff

File 12870.diff, 2.5 KB (added by duck_, 12 years ago)
  • wp-admin/admin-ajax.php

     
    10581058        check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' );
    10591059        $post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0;
    10601060        $title = isset($_POST['new_title'])? $_POST['new_title'] : '';
    1061         $slug = isset($_POST['new_slug'])? $_POST['new_slug'] : '';
     1061        $slug = isset($_POST['new_slug'])? $_POST['new_slug'] : null;
    10621062        die(get_sample_permalink_html($post_id, $title, $slug));
    10631063break;
    10641064case 'inline-save':
  • wp-admin/includes/post.php

     
    10261026                $post->post_status = 'publish';
    10271027                $post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID);
    10281028        }
    1029 
    1030         $post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent);
    1031 
     1029       
    10321030        // If the user wants to set a new name -- override the current one
    10331031        // Note: if empty name is supplied -- use the title instead, see #6072
    10341032        if ( !is_null($name) )
    10351033                $post->post_name = sanitize_title($name ? $name : $title, $post->ID);
    10361034
     1035        $post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent);
     1036
    10371037        $post->filter = 'sample';
    10381038
    10391039        $permalink = get_permalink($post, true);
  • wp-includes/link-template.php

     
    271271        else
    272272                $post = &get_post($id);
    273273
    274         $pagestruct = $wp_rewrite->get_page_permastruct();
     274        $link = $wp_rewrite->get_page_permastruct();
    275275
    276         if ( '' != $pagestruct && ( ( isset($post->post_status) && 'draft' != $post->post_status && 'pending' != $post->post_status ) || $sample ) ) {
    277                 $link = get_page_uri($id);
    278                 $link = ( $leavename ) ? $pagestruct : str_replace('%pagename%', $link, $pagestruct);
     276        if ( '' != $link && ( ( isset($post->post_status) && 'draft' != $post->post_status && 'pending' != $post->post_status ) || $sample ) ) {
     277                if ( ! $leavename )
     278                        $link = str_replace('%pagename%', get_page_uri($id), $link);
    279279                $link = home_url($link);
    280280                $link = user_trailingslashit($link, 'page');
    281281        } else {