Quick and dirty inline commenting with a filter

Skip to first unread message

Ivar Vong

Apr 13, 2011, 4:36:21 PM4/13/11
to cop...@googlegroups.com
I realized a regular expression filter would be an easy and quick way
to make inline commenting work, so here's a two line way to do it:

function filter_remove_inline_comments($content) {
return preg_replace('/@@.*?@@/', '', $content);
add_filter('the_content', 'filter_remove_inline_comments', 5);

(Also on github: https://gist.github.com/918336)

Inline commenting would allow news staff to put stuff into a post (CQ
info, source phone #s, whatever) and have it stripped out when the
content is pulled for web display with a filter. I haven't tested this
much at all, so the normal disclaimers should be appended. Maybe I'm
talking crazy, but the lack of inline commenting has been a sticking
point for the copy editors as we plan our web-based copy flow. But
maybe someone's got a fancy solution that I've missed and my fifteen
minutes trying to figure out that regular expression will be wasted :)


Scott Z. Bressler

Apr 14, 2011, 6:29:30 AM4/14/11
to cop...@googlegroups.com
Inline commenting is on the roadmap for a future version of Edit Flow.


You received this message because you are a part of CoPress
- To post a message to this group, send email to cop...@googlegroups.com
- To unsubscribe from this group, send an email to
- For more options, visit this group at
- Get connected on Twitter http://www.twitter.com/copress or Facebook


Andrew Nacin

Apr 14, 2011, 6:41:48 AM4/14/11
to cop...@googlegroups.com
You might want to just use a shortcode. The regex for firing shortcodes will be run anyway.

So something like:
add_shortcode( 'note', 'nacin_shortcode_note' );
function nacin_shortcode_note( $atts, $content = null ) {
    return '';

Next steps would be to allow comments to be displayed with special formatting when a post is previewed (or viewed by an editor, etc.). You could also even format the shortcode's styling in the visual editor. But since you don't care about content or attributes, the code above gives you various formatting options, like this:

[note "this is a note"]
[note this is a note]
[note]this is a note[/note]
[note name="scott" "this is a note" /]


Daniel Bachhuber

Apr 14, 2011, 7:23:42 AM4/14/11
to cop...@googlegroups.com
And we take code contributions :)
Reply all
Reply to author
0 new messages