Make WordPress Core


Ignore:
Timestamp:
03/29/2013 09:06:37 PM (13 years ago)
Author:
markjaquith
Message:

Chat post format code cleanup.

see #23625. props obenland.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post-formats.php

    r23847 r23876  
    418418
    419419/**
    420  * Add chat detection support to the `get_content_chat()` chat parser
     420 * Add chat detection support to the `get_content_chat()` chat parser.
    421421 *
    422422 * @since 3.6.0
     
    485485                return array();
    486486
    487         $has_match = false;
    488487        $matched_parser = false;
    489488        foreach ( $_wp_chat_parsers as $parser ) {
    490                 @list( $newline_regex ) = $parser;
     489                @list( $newline_regex, $delimiter_regex ) = $parser;
    491490                if ( preg_match( $newline_regex, $trimmed ) ) {
    492                         $has_match = true;
    493491                        $matched_parser = $parser;
    494492                        break;
     
    499497                return array();
    500498
    501         @list( $newline_regex, $delimiter_regex ) = $parser;
    502 
    503499        $last_index = 0;
    504         $stanzas = array();
     500        $stanzas = $data = $stanza = array();
     501        $author = $time = '';
    505502        $lines = explode( "\n", make_clickable( $trimmed ) );
    506503
    507         $author = $time = '';
    508         $data = array();
    509         $stanza = array();
    510504
    511505        foreach ( $lines as $index => $line ) {
     
    515509                        if ( ! empty( $author ) ) {
    516510                                $stanza[] = array(
    517                                         'time' => $time,
    518                                         'author' => $author,
     511                                        'time'    => $time,
     512                                        'author'  => $author,
    519513                                        'message' => join( ' ', $data )
    520514                                );
     
    523517                        $stanzas[] = $stanza;
    524518                        $last_index = $index;
    525                         $stanza = array();
     519                        $stanza = $data = array();
    526520                        $author = $time = '';
    527                         $data = array();
    528521                        if ( ! empty( $lines[$index + 1] ) && ! preg_match( $delimiter_regex, $lines[$index + 1] ) )
    529522                                break;
     
    540533                        if ( ! empty( $author ) ) {
    541534                                $stanza[] = array(
    542                                         'time' => $time,
    543                                         'author' => $author,
     535                                        'time'    => $time,
     536                                        'author'  => $author,
    544537                                        'message' => join( ' ', $data )
    545538                                );
     
    557550        if ( ! empty( $author ) ) {
    558551                $stanza[] = array(
    559                         'time' => $time,
    560                         'author' => $author,
     552                        'time'    => $time,
     553                        'author'  => $author,
    561554                        'message' => trim( join( ' ', $data ) )
    562555                );
     
    603596 */
    604597function the_chat() {
    605         $output = '<dl class="chat-transcript">';
    606 
     598        $output  = '<dl class="chat">';
    607599        $stanzas = get_the_chat();
    608600
     
    611603                        $time = '';
    612604                        if ( ! empty( $row['time'] ) )
    613                                 $time = sprintf( '<time>%s</time>', esc_html( $row['time'] ) );
     605                                $time = sprintf( '<time class="chat-timestamp">%s</time>', esc_html( $row['time'] ) );
    614606
    615607                        $output .= sprintf(
     
    617609                                        <dd class="chat-text">%4$s</dd>
    618610                                ',
    619                                 esc_attr( strtolower( $row['author'] ) ), // Slug.
     611                                esc_attr( sanitize_title_with_dashes( $row['author'] ) ), // Slug.
    620612                                $time,
    621613                                esc_html( $row['author'] ),
    622                                 esc_html( $row['message'] )
     614                                $row['message']
    623615                        );
    624616                }
    625617        }
    626618
    627         $output .= '</dl><!-- .chat-transcript -->';
     619        $output .= '</dl><!-- .chat -->';
    628620
    629621        echo $output;
Note: See TracChangeset for help on using the changeset viewer.