Changeset 23978
- Timestamp:
- 04/12/2013 10:22:41 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post-formats.php
r23935 r23978 454 454 } 455 455 add_chat_detection_format( 'IM', '#^([^:]+):#', '#[:]#' ); 456 add_chat_detection_format( 'Skype', '# ^(\[.+?\])\s([^:]+):#', '#[:]#' );456 add_chat_detection_format( 'Skype', '#(\[.+?\])\s([^:]+):#', '#[:]#' ); 457 457 458 458 /** … … 493 493 global $_wp_chat_parsers; 494 494 495 $trimmed = trim( $content);495 $trimmed = strip_tags( trim( $content ) ); 496 496 if ( empty( $trimmed ) ) 497 497 return array(); … … 513 513 $author = $time = ''; 514 514 $lines = explode( "\n", make_clickable( $trimmed ) ); 515 515 $found = false; 516 $found_index = 0; 516 517 517 518 foreach ( $lines as $index => $line ) { 519 if ( ! $found ) 520 $found_index = $index; 521 518 522 $line = trim( $line ); 519 523 520 if ( empty( $line ) ) {524 if ( empty( $line ) && $found ) { 521 525 if ( ! empty( $author ) ) { 522 526 $stanza[] = array( … … 528 532 529 533 $stanzas[] = $stanza; 530 $last_index = $index; 534 531 535 $stanza = $data = array(); 532 536 $author = $time = ''; … … 539 543 $matches = array(); 540 544 $matched = preg_match( $newline_regex, $line, $matches ); 545 if ( ! $matched ) 546 continue; 547 548 $found = true; 549 $last_index = $index; 541 550 $author_match = empty( $matches[2] ) ? $matches[1] : $matches[2]; 542 551 // assume username syntax if no whitespace is present … … 573 582 $stanzas[] = $stanza; 574 583 575 if ( $remove ) 576 $content = trim( join( "\n", array_slice( $lines, $last_index ) ) ); 584 if ( $remove ) { 585 if ( 0 === $found_index ) { 586 $removed = array_slice( $lines, $last_index ); 587 } else { 588 $before = array_slice( $lines, 0, $found_index ); 589 $after = array_slice( $lines, $last_index + 1 ); 590 $removed = array_filter( array_merge( $before, $after ) ); 591 } 592 $content = trim( join( "\n", $removed ) ); 593 } 577 594 578 595 return $stanzas;
Note: See TracChangeset
for help on using the changeset viewer.