Articles in this series

27 Responses

  1. Konstantin Kovshenin
    Konstantin Kovshenin August 21, 2012 at 10:58 am |

    Wow! This is amazing. I did try something similar in the past, but it didn’t work for me for some reason. I like your approach and I think it can work. However, you should consider prefixing actions and filters, for the same reason you prefix functions and classes.

    Cheers and keep up the awesome stuff!

    Reply
  2. Pippin
    Pippin August 21, 2012 at 11:14 am |

    I love the idea but I really don’t think this should be in a theme; it should be built as a plugin designed to complement a theme. Imagine what would happen if someone populated their site with tons of “chat” posts and then switched themes: all of their chats would be broken (missing formatting at least).

    Reply
    1. Andres Hermosilla
      Andres Hermosilla August 21, 2012 at 6:08 pm |

      P2 theme breaks the plugin/theme rule divide and it was created by Auttomatic. I think it’s a matter of using your best judgement.

      Reply
    2. Shea Bunge
      Shea Bunge November 20, 2012 at 5:58 pm |

      Funny you should mention it, but I’m working on a a plugin like that. https://github.com/bungeshea/post-formats

      Reply
  3. Matt
    Matt August 21, 2012 at 11:21 am |

    I never even knew there was a chat function… thanks!

    Reply
  4. Amy Hendrix
    Amy Hendrix August 21, 2012 at 11:23 am |

    I love the filter approach (and I’ve really never seen a proper implementation of the post format in the wild), but the markup seems like a lost opportunity for my very favorite woefully underused element, the definition list — it’d save you a bunch of divs and classes, not to mention that it’s semantically perfect for pairs of names and values!

    Reply
    1. Jesper
      Jesper August 21, 2012 at 11:32 am |

      According to this article on 24ways you shouldn’t use definition lists for dialogues and explains why.

      I was thinking the same thing yesterday when I saw the code.

      Reply
  5. Edward Caissie
    Edward Caissie August 21, 2012 at 12:00 pm |

    Very interesting … and somewhat timely as I am looking at how to implement an appropriate “Chat” format in one of my current projects.

    Reply
  6. Frances
    Frances August 21, 2012 at 12:10 pm |

    Very handy. I’ve just been working on somewhat customised post formats for a blog and I never thought, “Oh, chats, they can be between more than two people, no?”

    I also marked it up using definition lists, and was really surprised at the Working Draft you posted, as I remember from somewhere suggested use for dl was e.g. marking up a script with dialogue.

    (HTML4 and XHTML2 working drafts both say “Another application of dl, for example, is for marking up dialogues, with each dt naming a speaker, and each dd containing his or her words.”)

    Reply
  7. The Frosty
    The Frosty August 21, 2012 at 12:27 pm |

    This would make for a great plugin as well.

    Reply
  8. Dougal Campbell
    Dougal Campbell August 21, 2012 at 12:34 pm |

    My handling of chats in my Formattd theme was a little more simplistic, but had a similar idea:

    https://github.com/dougalcampbell/Formattd/blob/master/functions.php#L639

    It generates markup like
    <p class="chat"><span class="person person-bob">Bob:</span> Hi, Alice!</p>

    I thought I was being pretty clever with my ‘person-NAME’ classes, at the time. But ‘speaker-N’ is much more practical in real use.

    Reply
  9. Vix
    Vix August 21, 2012 at 8:16 pm |

    This filter approach is much more powerful and you’ve both accounted for the fact that their might be colons within chat content.

    I’ve just been working with the styles – never occurred to me to use a filter.

    Reply
  10. David Chandra
    David Chandra August 22, 2012 at 11:20 pm |

    thank you justin.
    you are too kind.
    my original code is very messy, and you clean it, and optimize it.
    it’s readable now :)

    can’t wait for the next series.

    Theme Hybrid forum is the best WordPress forum.
    awesome.

    Reply
  11. Brutally Succinct: curating web designer resources | Post Formats: Chat
  12. Philip Newcomer
    Philip Newcomer August 27, 2012 at 7:01 pm |

    This is great! One observation, however: you have the separator hard-coded into line 51, although you’ve made provision for filtering it earlier. Shouldn’t line 51 be:

    $chat_row_split = explode( $separator, trim( $chat_row ), 2 );

    instead of

    $chat_row_split = explode( ':', trim( $chat_row ), 2 );

    Or am I missing something?

    If this is true, I can’t believe I actually found a bug in the mighty Justin Tadlock’s code! :)

    Reply
  13. Shea Bunge
    Shea Bunge November 20, 2012 at 5:55 pm |

    Are you planning to post a guideline to implementing the link post format soon? I’d really appreciate it. :-)

    Reply
  14. Fyord
    Fyord December 2, 2012 at 7:07 am |

    I’m confused, is this just comments made to look a little more like a chat room conversation?

    Reply
  15. Benni
    Benni March 29, 2013 at 1:22 pm |

    Wow! This is awesome! This saved me hours of thinking and getting a headache while doing so :)

    Best regards,
    Benni

    Reply

Leave a Reply

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/Web site in attribution.

Please use your real name or a pseudonym (i.e., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.