Make WordPress Core

Ticket #11354: wordpress-importer.patch

File wordpress-importer.patch, 1.3 KB (added by briancolinger, 14 years ago)

patch for process_categories() and process_tags() methods

  • .php

    old new  
    290290        function process_categories() {
    291291                global $wpdb;
    292292
    293                 $cat_names = (array) get_terms('category', 'fields=names');
     293                if ( !is_array( $this->categories ) )
     294                        return;
    294295
    295296                while ( $c = array_shift($this->categories) ) {
    296297                        $cat_name = trim($this->get_tag( $c, 'wp:cat_name' ));
    297298
    298299                        // If the category exists we leave it alone
    299                         if ( in_array($cat_name, $cat_names) )
     300                        $cat_id = (int) category_exists( $cat_name );
     301                        if ( 0 < $cat_id ) {
    300302                                continue;
     303                        }
    301304
    302305                        $category_nicename      = $this->get_tag( $c, 'wp:category_nicename' );
    303306                        $category_description = $this->get_tag( $c, 'wp:category_description' );
     
    320323        function process_tags() {
    321324                global $wpdb;
    322325
    323                 $tag_names = (array) get_terms('post_tag', 'fields=names');
     326                if ( !is_array( $this->tags ) )
     327                        return;
    324328
    325329                while ( $c = array_shift($this->tags) ) {
    326330                        $tag_name = trim($this->get_tag( $c, 'wp:tag_name' ));
    327331
    328                         // If the category exists we leave it alone
    329                         if ( in_array($tag_name, $tag_names) )
     332                        // If the tag exists we leave it alone
     333                        if ( is_term( $tag_name, 'post_tag' ) ) {
    330334                                continue;
     335                        }
    331336
    332337                        $slug = $this->get_tag( $c, 'wp:tag_slug' );
    333338                        $description = $this->get_tag( $c, 'wp:tag_description' );