I'm using the PHP Markdown plugin, and I'd like to modify it so that it adds some text to the bottom of the comment form indicating that Markdown is supported in comments.

I've been modifying my theme to do this, but the theme is updated quite frequently and I don't want to create a custom version of it for a single line of text to be preserved.

In my comments.php file (Theme is ZBench) I have the following:

$comment_notes='<p class="comment-note">' . __('NOTE - You can use these ','zbench') . sprintf(('<abbr title="HyperText Markup Language">HTML</abbr> '.__('tags and attributes:','zbench').'<br />%s' ), ' <code>' . allowed_tags() . '</code>' ) . '</p>';

I simply want to add to that indicating Markdown is active, and presumably the ideal way to do that is to alter the output of allowed_tags(). Is this possible to do with add_filter(), or am I looking at the wrong function?

I want to modify the plugin itself, so that the extra line is added only if the plugin is active.


Here you go... Use this code:

add_filter('comment_form_defaults', 'change_allowed_fields');

function change_allowed_fields($defaults) 
    //All the comment form fields are available in the $defaults array
    $defaults['comment_notes_after'] = "<b>Markdown for the win!</b>";

    return $defaults;

This will work!

  • That doesn't seem to be altering the output of allowed_tags(). I wish the documentation on filters was more up to date :(
    – Tim Post
    Nov 25 '11 at 6:56
  • The text at the bottom of the comment form doesn't come from the allowed_tags() function, it only specifies the actual tags that are allowed. Your question says so that it adds some text to the bottom of the comment form indicating that Markdown is supported in comments, means help text, that's what my code does. Just put this code in your theme's functions.php file and it will work. Nov 25 '11 at 6:59
  • I ended up making a frankenplugin for this, and several other minor theme tweaks. I'm happy, I don't have to cringe every time a new version of my theme is available :) Thanks for your answer!
    – Tim Post
    Nov 25 '11 at 7:48
  • You're welcome! :) Nice job with the plugin, it's always a good idea to keep all the tweaks in a separate plugin, so that you can use it multiple times, without breaking anything and across updates! Nov 25 '11 at 8:00
  • A relevant link with lots more information for those interested: justintadlock.com/archives/2010/07/21/…
    – its_me
    Mar 1 '13 at 6:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.