WordPress.org

Make WordPress Core

Ticket #23222: new-permalink.diff

File new-permalink.diff, 2.4 KB (added by MikeHansenMe, 2 years ago)
  • wp-admin/includes/post.php

     
    981981 * @return array With two entries of type string 
    982982 */ 
    983983function get_sample_permalink($id, $title = null, $name = null) { 
     984        //wp_die( $id."|".$title."|".$name ); 
    984985        $post = get_post($id); 
    985986        if ( !$post->ID ) 
    986987                return array('', ''); 
     
    995996        // drafts, so we will fake, that our post is published 
    996997        if ( in_array($post->post_status, array('draft', 'pending')) ) { 
    997998                $post->post_status = 'publish'; 
    998                 $post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID); 
     999                $use_for_permalink = $post->post_name ? $post->post_name : $post->post_title; 
     1000                $use_for_permalink = str_replace( '%', '', $use_for_permalink ); 
     1001                $post->post_name = sanitize_title( $use_for_permalink, $post->ID ); 
    9991002        } 
    10001003 
    10011004        // If the user wants to set a new name -- override the current one 
    10021005        // Note: if empty name is supplied -- use the title instead, see #6072 
    1003         if ( !is_null($name) ) 
    1004                 $post->post_name = sanitize_title($name ? $name : $title, $post->ID); 
    1005  
     1006        if ( !is_null($name) ) { 
     1007                $use_for_permalink = $name ? $name : $title; 
     1008                $use_for_permalink = str_replace( '%', '', $use_for_permalink ); 
     1009                $post->post_name = sanitize_title( $use_for_permalink, $post->ID ); 
     1010        } 
    10061011        $post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent); 
    10071012 
    10081013        $post->filter = 'sample'; 
  • wp-includes/post.php

     
    27702770        // Create a valid post name. Drafts and pending posts are allowed to have an empty 
    27712771        // post name. 
    27722772        if ( empty($post_name) ) { 
    2773                 if ( !in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) 
    2774                         $post_name = sanitize_title($post_title); 
    2775                 else 
     2773                if ( !in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) { 
     2774                        $post_name = str_replace( '%', '', $post_title ); 
     2775                        $post_name = sanitize_title( $post_name ); 
     2776                } else { 
    27762777                        $post_name = ''; 
     2778                } 
    27772779        } else { 
    27782780                // On updates, we need to check to see if it's using the old, fixed sanitization context. 
    27792781                $check_name = sanitize_title( $post_name, '', 'old-save' );