Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 3 down vote accepted
+50

Here you go... Use this code:

<?php
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!

share|improve this answer
    
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. –  Rutwick Gangurde Nov 25 '11 at 6:59
    
Thanks for accepting and for the bounty! –  Rutwick Gangurde Nov 25 '11 at 7:12
    
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! –  Rutwick Gangurde Nov 25 '11 at 8:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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