WordPress.org

Make WordPress Core

Ticket #6265: wordpress-importer-new.patch

File wordpress-importer-new.patch, 2.2 KB (added by jayminkapish, 7 years ago)

new patch for wordpress importer

  • wp-admin/import/wordpress.php

     
    338338                $post_ID = (int) $this->get_tag( $post, 'wp:post_id' ); 
    339339                if ( $post_ID && !empty($this->post_ids_processed[$post_ID]) ) // Processed already 
    340340                        return 0; 
    341                  
     341 
    342342                set_time_limit( 60 ); 
    343343 
    344344                // There are only ever one of these 
     
    379379                        $cat_index++; 
    380380                } 
    381381 
    382                 $post_exists = post_exists($post_title, '', $post_date); 
     382                $post_exists = post_exists($post_title, '', $post_date, $post_name); 
    383383 
    384384                if ( $post_exists ) { 
    385385                        echo '<li>'; 
  • wp-admin/includes/post.php

     
    190190        return $post; 
    191191} 
    192192 
    193 function post_exists($title, $content = '', $post_date = '') { 
     193function post_exists($title, $content = '', $post_date = '', $post_name = '') { 
    194194        global $wpdb; 
    195195 
    196196        if (!empty ($post_date)) 
    197197                $post_date = "AND post_date = '$post_date'"; 
    198198 
    199         if (!empty ($title)) 
    200                 return $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$title' $post_date"); 
     199        if(!empty($post_name)) 
     200                return $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '$post_name' $post_date"); 
    201201        else 
    202                 if (!empty ($content)) 
    203                         return $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_content = '$content' $post_date"); 
     202                if (!empty ($title)) 
     203                        return $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$title' $post_date"); 
     204                else 
     205                        if (!empty ($content)) 
     206                                return $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_content = '$content' $post_date"); 
    204207 
    205208        return 0; 
    206209} 
     
    609612        if (in_array($post->post_status, array('draft', 'pending'))) { 
    610613                $post->post_status = 'publish'; 
    611614                $post->post_date = date('Y-m-d H:i:s'); 
    612                 $post->post_name = sanitize_title($post->post_name? $post->post_name : $post->post_title, $post->ID);  
     615                $post->post_name = sanitize_title($post->post_name? $post->post_name : $post->post_title, $post->ID); 
    613616        } 
    614617 
    615618        // If the user wants to set a new name -- override the current one