Ticket #12578: mt-import-tags-basename.patch
| File mt-import-tags-basename.patch, 2.4 KB (added by nacin, 3 years ago) |
|---|
-
wp-admin/import/mt.php
239 239 $this->mt_authors_form(); 240 240 } 241 241 242 function save_post(&$post, &$comments, &$pings ) {242 function save_post(&$post, &$comments, &$pings, &$tags) { 243 243 // Reset the counter 244 244 set_time_limit(30); 245 245 $post = get_object_vars($post); … … 274 274 } 275 275 } 276 276 277 if ( $tags != '' ) { 278 wp_set_post_tags( $post_id, $tags ); 279 } 280 277 281 $num_comments = 0; 278 282 foreach ( $comments as $comment ) { 279 283 $comment = get_object_vars($comment); … … 324 328 $comments = array(); 325 329 $ping = new StdClass(); 326 330 $pings = array(); 331 $tags = ''; 327 332 328 333 echo "<div class='wrap'><ol>"; 329 334 … … 343 348 } else if ( '--------' == $line ) { 344 349 // Finishing a post. 345 350 $context = ''; 346 $result = $this->save_post($post, $comments, $pings );351 $result = $this->save_post($post, $comments, $pings, $tags); 347 352 if ( is_wp_error( $result ) ) 348 353 return $result; 349 354 $post = new StdClass; … … 351 356 $ping = new StdClass(); 352 357 $comments = array(); 353 358 $pings = array(); 359 $tags = ''; 354 360 } else if ( 'BODY:' == $line ) { 355 361 $context = 'body'; 356 362 } else if ( 'EXTENDED BODY:' == $line ) { … … 375 381 $post->post_title = $title; 376 382 else if ( 'ping' == $context ) 377 383 $ping->title = $title; 378 } else if ( 0 === strpos($line, "STATUS:") ) { 384 } else if ( 0 === strpos($line, "BASENAME:") ) { 385 $basename = trim( strtolower( substr($line, strlen("BASENAME:")) ) ); 386 if ( '' == $context ) 387 $post->post_name = $basename; 388 } else if ( 0 === strpos($line, "TAGS:") ) { 389 # Does not properly handle tags containing a comma 390 $tags = trim( strtolower( substr($line, strlen("TAGS:")) ) ); 391 $tags = preg_replace('/^"|"$/', '', $tags); 392 $tags = preg_replace('/(?:",")|(?:,")|(?:",)/', ',', $tags); 393 } else if ( 0 === strpos($line, "STATUS:") ) { 379 394 $status = trim( strtolower( substr($line, strlen("STATUS:")) ) ); 380 395 if ( empty($status) ) 381 396 $status = 'publish';
