Make WordPress Core

Changeset 10021


Ignore:
Timestamp:
12/03/2008 05:47:44 PM (16 years ago)
Author:
ryan
Message:

Don't import cat and tags with empty string for name. Check for WP_Error after term insertion. fixes #8474

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/import/wordpress.php

    r10014 r10021  
    462462                $post_cats = array();
    463463                foreach ($categories as $category) {
     464                    if ( '' == $category )
     465                        continue;
    464466                    $slug = sanitize_term_field('slug', $category, 0, 'category', 'db');
    465467                    $cat = get_term_by('slug', $slug, 'category');
     
    470472                        $category = $wpdb->escape($category);
    471473                        $cat_ID = wp_insert_category(array('cat_name' => $category));
     474                        if ( is_wp_error($cat_ID) )
     475                            continue;
    472476                    }
    473477                    $post_cats[] = $cat_ID;
     
    480484                $post_tags = array();
    481485                foreach ($tags as $tag) {
     486                    if ( '' == $tag )
     487                        continue;
    482488                    $slug = sanitize_term_field('slug', $tag, 0, 'post_tag', 'db');
    483489                    $tag_obj = get_term_by('slug', $slug, 'post_tag');
     
    488494                        $tag = $wpdb->escape($tag);
    489495                        $tag_id = wp_insert_term($tag, 'post_tag');
     496                        if ( is_wp_error($tag_id) )
     497                            continue;
    490498                        $tag_id = $tag_id['term_id'];
    491499                    }
Note: See TracChangeset for help on using the changeset viewer.