[wp-trac] [WordPress Trac] #23625: Add function to extract or parse chat as structured data
WordPress Trac
noreply at wordpress.org
Tue Mar 5 23:53:43 UTC 2013
#23625: Add function to extract or parse chat as structured data
-----------------------------+------------------
Reporter: wonderboymusic | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: 3.6
Component: Post Formats | Version:
Severity: normal | Resolution:
Keywords: has-patch |
-----------------------------+------------------
Comment (by obenland):
I was looking at your second diff:
Testing with a copy/paste from Skype was initially unsuccessful, due to
the whitespace check in author names. May I ask why they shouldn't contain
whitespaces?
I also noticed that Skype prepends every line with a timestamp like so:
`[3/5/13 11:41:02 AM]`. So I added a preg replace before the initial trim
of each line to remove that:
`$line = preg_replace( '/\[.+\]\s/', '', $line ); // Skype`
My regex-skills are lacking at best, so I'm sure this could be optimized.
Is this something you'd consider adding in the function?
I found the naming of `get_the_chat()` confusing, initially I expected a
single chat.
This is how I would use it as it currently stands:
{{{
#!php
<?php
$chats = get_the_chat();
$chat = array_shift( $chats );
foreach ( $chat as $row ) :
$message = make_clickable( $row['message'] );
?>
<div class="row">
<strong class="author"><?php echo $row['author'];
?>:</strong>
<span class="message"><?php echo $message; ?></span>
</div>
<?php endforeach; ?>
}}}
I hope you find the feedback constructive. Overall I am super psyched
about the way you implemented this! Chats come finally to life for me! :)
--
Ticket URL: <http://core.trac.wordpress.org/ticket/23625#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list