[wp-trac] [WordPress Trac] #23625: Add function to extract or parse chat as structured data

WordPress Trac noreply at wordpress.org
Tue Feb 26 08:29:37 UTC 2013


#23625: Add function to extract or parse chat as structured data
----------------------------+-----------------------------
 Reporter:  wonderboymusic  |       Type:  feature request
   Status:  new             |   Priority:  normal
Milestone:  3.6             |  Component:  General
  Version:                  |   Severity:  normal
 Keywords:  has-patch       |
----------------------------+-----------------------------
 Scenarios

 1. You have a blob of content representing a chat transcript and
 optionally some commentary and you want to extract the chat as structured
 data, and optionally, remove it from the content
 2. You want to extract the chat from a post's content to theme it, with or
 without the optional commentary, outside of `the_content()`

 Introduce `get_the_chat( $id = 0 )` and `get_content_chat( &$content,
 $remove = false )`

 Here is an example to test:

 {{{
 $chat =<<<CHAT
 Scott: Hey, let's chat!
         This is more text
 Helen: No.

 Nacin: Cool.

 Scott: Hey, let's chat!
 Helen: No.

 Scott: Hey, let's chat!
 Helen: No.

 Scott: Hey, let's chat!
 Helen: No.

 This is the commentary on the chat.
 CHAT;

 print_r( get_content_chat( $chat, true ) );
 echo $chat;
 exit();
 }}}

 Here is the format of the structured chat data:

 {{{
 $stanzas = array(
       array(
           array(
               'author' => 'Scott',
               'messsage' => "Hey, let's chat!"
           ),
           array(
               'author' => 'Helen',
               'message' => 'No.'
           )
       )
   )
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23625>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list