Make WordPress Core

Ticket #24159: 24159.diff

File 24159.diff, 2.5 KB (added by belloswan, 12 years ago)
  • post-formats.php

     
    556556        $found_index = 0;
    557557
    558558        foreach ( $lines as $index => $line ) {
    559                 if ( ! $found )
    560                         $found_index = $index;
    561 
     559                $data = array();
    562560                $line = trim( $line );
    563 
    564                 if ( empty( $line ) && $found ) {
    565                         if ( ! empty( $author ) ) {
    566                                 $stanza[] = array(
    567                                         'time'    => $time,
    568                                         'author'  => $author,
    569                                         'message' => join( ' ', $data )
    570                                 );
    571                         }
    572 
    573                         $stanzas[] = $stanza;
    574 
    575                         $stanza = $data = array();
    576                         $author = $time = '';
    577                         if ( ! empty( $lines[$index + 1] ) && ! preg_match( $delimiter_regex, $lines[$index + 1] ) )
    578                                 break;
    579                         else
    580                                 continue;
    581                 }
    582 
     561                if ( empty( $line ) )
     562                        continue;
    583563                $matched = preg_match( $newline_regex, $line, $matches );
    584564                if ( ! $matched )
    585565                        continue;
    586 
    587                 $found = true;
    588                 $last_index = $index;
    589                 $author_match = empty( $matches[2] ) ? $matches[1] : $matches[2];
    590                 // assume username syntax if no whitespace is present
    591                 $no_ws = $matched && ! preg_match( '#[\r\n\t ]#', $author_match );
    592                 // allow script-like stanzas
    593                 $has_ws = $matched && preg_match( '#[\r\n\t ]#', $author_match ) && empty( $lines[$index + 1] ) && empty( $lines[$index - 1] );
    594                 if ( $matched && ( ! empty( $matches[2] ) || ( $no_ws || $has_ws ) ) ) {
    595                         if ( ! empty( $author ) ) {
    596                                 $stanza[] = array(
    597                                         'time'    => $time,
    598                                         'author'  => $author,
    599                                         'message' => join( ' ', $data )
    600                                 );
    601                                 $data = array();
    602                         }
    603 
    604                         $time = empty( $matches[2] ) ? '' : $matches[1];
    605                         $author = $author_match;
    606                         $data[] = trim( str_replace( $matches[0], '', $line ) );
    607                 } elseif ( preg_match( '#\S#', $line ) ) {
    608                         $data[] = $line;
     566                if ( ! empty( $matches[2] ) ) { // Time is present
     567                        $time = $matches[1];
     568                        $author = $matches[2];
     569                } else {
     570                        $time = '';
     571                        $author = $matches[1];
    609572                }
    610         }
    611 
    612         if ( ! empty( $author ) ) {
     573                $data[] = trim( str_replace( $matches[0], '', $line ) );
     574                $i = $index;
     575                do {
     576                        $i++;
     577                        $data[] = $lines[$i];
     578                } while ( preg_match( $newline_regex, $lines[$i], $matches ) );
    613579                $stanza[] = array(
    614                         'time'    => $time,
     580                        'time'    => $time,
    615581                        'author'  => $author,
    616                         'message' => trim( join( ' ', $data ) )
    617                 );
     582                        'message' => trim( join( ' ', $data ) ) );
    618583        }
    619584
    620585        if ( ! empty( $stanza ) )
     
    1010975                $data['post_title'] = _post_formats_generate_title( $data['post_content'], $post_format );
    1011976
    1012977        return $data;
    1013 }
    1014  Pas de retour chariot à la fin du fichier
     978}