Quick and dirty inline commenting with a filter

0 views
Skip to first unread message

Ivar Vong

unread,
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 :)

Ivar

Scott Z. Bressler

unread,
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.

Ivar

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

http://www.copress.org/

Andrew Nacin

unread,
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" /]
etc.

Nacin

Daniel Bachhuber

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