Changeset 6149
- Timestamp:
- 09/21/2007 06:34:28 PM (17 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/export.php
r6130 r6149 140 140 141 141 echo '<wp:tag_description>' . wxr_cdata($t->description) . '</wp:tag_description>'; 142 } 143 144 function wxr_post_taxonomy() { 145 $categories = get_the_category(); 146 $tags = get_the_tags(); 147 $cat_names = array(); 148 $tag_names = array(); 149 $the_list = ''; 150 $filter = 'rss'; 151 152 if ( !empty($categories) ) foreach ( (array) $categories as $category ) { 153 $cat_name = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter); 154 $the_list .= "\n\t\t<category><![CDATA[$cat_name]]></category>\n"; 155 } 156 157 if ( !empty($tags) ) foreach ( (array) $tags as $tag ) { 158 $tag_name = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter); 159 $the_list .= "\n\t\t<category domain=\"tag\"><![CDATA[$tag_name]]></category>\n"; 160 } 161 162 echo $the_list; 142 163 } 143 164 … … 202 223 <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate> 203 224 <dc:creator><?php the_author() ?></dc:creator> 204 <?php the_category_rss() ?>225 <?php wxr_post_taxonomy() ?> 205 226 206 227 <guid isPermaLink="false"><?php the_guid(); ?></guid> -
trunk/wp-admin/import/wordpress.php
r6129 r6149 317 317 $post_content = str_replace('<hr>', '<hr />', $post_content); 318 318 319 preg_match_all('|<category domain="tag">(.*?)</category>|is', $post, $tags); 320 $tags = $tags[1]; 321 322 $tag_index = 0; 323 foreach ($tags as $tag) { 324 $tags[$tag_index] = $wpdb->escape($this->unhtmlentities(str_replace(array ('<![CDATA[', ']]>'), '', $tag))); 325 $tag_index++; 326 } 327 319 328 preg_match_all('|<category>(.*?)</category>|is', $post, $categories); 320 329 $categories = $categories[1]; … … 372 381 } 373 382 wp_set_post_categories($post_id, $post_cats); 383 } 384 385 // Add tags. 386 if (count($tags) > 0) { 387 $post_tags = array(); 388 foreach ($tags as $tag) { 389 $slug = sanitize_term_field('slug', $tag, 0, 'post_tag', 'db'); 390 $tag_obj = get_term_by('slug', $slug, 'post_tag'); 391 $tag_id = 0; 392 if ( ! empty($tag_obj) ) 393 $tag_id = $tag_obj->term_id; 394 if ( $tag_id == 0 ) { 395 $tag = $wpdb->escape($tag); 396 $tag_id = wp_insert_term($tag, 'post_tag'); 397 $tag_id = $tag_id['term_id']; 398 } 399 $post_tags[] = $tag_id; 400 } 401 wp_set_post_tags($post_id, $post_tags); 374 402 } 375 403 }
Note: See TracChangeset
for help on using the changeset viewer.