33 Responses

  1. Konstantin Kovshenin
    Konstantin Kovshenin Published |

    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 Published |

    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 Published |

      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 Published |

      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 Published |

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

    Reply
  4. Amy Hendrix
    Amy Hendrix Published |

    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 Published |

      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 Published |

    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 Published |

    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 Published |

    This would make for a great plugin as well.

    Reply
  8. Dougal Campbell
    Dougal Campbell Published |

    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 Published |

    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 Published |

    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 Published |

    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 Published |

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

    Reply
  14. Fyord
    Fyord Published |

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

    Reply
  15. Benni
    Benni Published |

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

    Best regards,
    Benni

    Reply
  16. Kevin
    Kevin Published |

    Thanks for the script it works great.

    I did notice on testing that if you password protect a chat post, the following displays prior to the post password protected message.

    ://localhost/wp361_test/wp-login.php?action=postpass" method="post">

    It is fixed by adding the following at the beginning :

    if( post_password_required() )
    
    return $content;
    Reply
  17. Jim
    Jim Published |

    can you please explain how to get this working with get_the_content ?

    thank you

    Reply
  18. Shabby
    Shabby Published |

    I finally figured out how to do a chat post format thanks to this. I did encounter a problem though when I had my chat post password protected. Please see screenshot: http://i336.photobucket.com/albums/n339/sgurd4/Screenshots/HyukTanet_–Wala_pa_rin_sweldo-_2014-02-05_161314_zpsd8f573fc.png

    Help please?

    Reply
  19. Shabby
    Shabby Published |

    Oops, should have checked the comments first. Gonna try then the suggested solution.

    Reply
  20. Jade -- NOT a developer
    Jade -- NOT a developer Published |

    Hi!!

    You’re amazing. I got so tired of sifting through millions of themes to find the one that had the right look AND supported the chat post formats. They’re like unicorns!!

    So I thought.. maybe I can add this function to any theme and found this. WOW.

    I have a few questions, please keep in mind I’m not a developer and barely know how to code. I implemented the code above and it’s worked wonders on my test blog, but I’d like to make adjustments and am not proficient.

    How do I keep the author and text on the same line but make every other author bold. Would it be possible for you to give me a quick example changes in the code?!! I’ll get the idea.

    Also, someone mentioned this should be a plugin not hardwired. Can I make my own plugin with this code????

    Thanks so much, it’s already a million times better than it was.

    Jade

    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.

css.php