How do I alter the comment form ‘allowed tags’ text in a plugin?

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.

Read More

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.

Related posts

Leave a Reply

1 comment

  1. 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!