Changeset 3352
- Timestamp:
- 12/23/05 23:16:20 (3 years ago)
- Files:
-
- trunk/wp-admin/import/mt.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/wp-admin/import/mt.php
r3262 r3352 173 173 174 174 function process_posts() { 175 global $wpdb; 175 176 $i = -1; 176 177 echo "<ol>"; 177 foreach ($ posts as $post) {178 foreach ($this->posts as $post) { 178 179 if ('' != trim($post)) { 179 180 ++ $i; 180 181 unset ($post_categories); 181 echo '<li>'.__('Processing post...');182 182 183 183 // Take the pings out first … … 225 225 case 'TITLE' : 226 226 $post_title = $wpdb->escape($value); 227 echo '<i>'.stripslashes($post_title).'</i>... ';228 227 break; 229 228 case 'STATUS' : … … 253 252 break; 254 253 case 'PRIMARY CATEGORY' : 255 $post_categories[] = $wpdb->escape($value); 254 if (! empty ($value) ) 255 $post_categories[] = $wpdb->escape($value); 256 256 break; 257 257 case 'CATEGORY' : 258 $post_categories[] = $wpdb->escape($value); 258 if (! empty ($value) ) 259 $post_categories[] = $wpdb->escape($value); 259 260 break; 260 261 case 'DATE' : … … 262 263 $post_modified = date('Y-m-d H:i:s', $post_modified); 263 264 $post_modified_gmt = get_gmt_from_date("$post_modified"); 265 $post_date = $post_modified; 266 $post_date_gmt = $post_modified_gmt; 264 267 break; 265 268 default : … … 270 273 271 274 // Let's check to see if it's in already 272 if ($post_id = posts_exists($post_title, '', $post_date)) { 273 _e('Post already imported.'); 275 if ($post_id = post_exists($post_title, '', $post_date)) { 276 echo '<li>'; 277 printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title)); 274 278 } else { 275 $post_author = checkauthor($post_author); //just so that if a post already exists, new users are not created by checkauthor 279 echo '<li>'; 280 printf(__('Importing post <i>%s</i>...'), stripslashes($post_title)); 281 282 $post_author = $this->checkauthor($post_author); //just so that if a post already exists, new users are not created by checkauthor 276 283 277 284 $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt'); … … 279 286 // Add categories. 280 287 if (0 != count($post_categories)) { 281 wp_create_categories($post_categories );288 wp_create_categories($post_categories, $post_id); 282 289 } 283 _e(' Post imported successfully...');284 290 } 285 291 … … 288 294 // Now for comments 289 295 $comments = explode("-----\nCOMMENT:", $comments[0]); 296 $num_comments = 0; 290 297 foreach ($comments as $comment) { 291 298 if ('' != trim($comment)) { … … 318 325 $commentdata = wp_filter_comment($commentdata); 319 326 wp_insert_comment($commentdata); 320 echo "Comment added.";327 $num_comments++; 321 328 } 322 329 } 323 330 } 331 if ( $num_comments ) 332 printf(__('(%s comments)'), $num_comments); 324 333 325 334 // Finally the pings … … 327 336 $pings[0] = str_replace("-----\n\n", "-----\n", $pings[0]); 328 337 $pings = explode("-----\nPING:", $pings[0]); 338 $num_pings = 0; 329 339 foreach ($pings as $ping) { 330 340 if ('' != trim($ping)) { … … 363 373 $commentdata = wp_filter_comment($commentdata); 364 374 wp_insert_comment($commentdata); 365 _e('Comment added.');375 $num_pings++; 366 376 } 367 377 } 368 378 } 379 if ( $num_pings ) 380 printf(__('(%s pings)'), $num_pings); 381 369 382 echo "</li>"; 370 383 } … … 413 426 $mt_import = new MT_Import(); 414 427 415 //register_importer('mt', 'Movable Type', 'Import posts and comments from your Movable Type blog', array ($mt_import, 'dispatch'));428 register_importer('mt', 'Movable Type', 'Import posts and comments from your Movable Type blog', array ($mt_import, 'dispatch')); 416 429 ?>
