Home > plugin development > How do I alter the comment form 'allowed tags' text in a plugin?

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

November 21Hits:0
Advertisement

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.

Answers

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!

Related Articles

  • How do I alter the comment form 'allowed tags' text in a plugin?November 21

    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 freque

  • Deleting commented lines in a text file using sedJuly 1

    I am a sed novice. I would like to use sed to delete commented lines in a text file. In my series of text files, commented lines begin with either the # symbol or the @ symbol (i.e., they are files originally intended for plotting in xmgrace). Suppos

  • Shortcut comment next to tags in BBeditJune 5

    In Sublime Text 2 I can create a comment next to a tag by using shortcut alt+cmd+/ which results in something like this: <a href=""></a><!-- --> How can I shortcut comments next to tags in BBedit or is this not possible? I do s

  • Alter the comment formJanuary 4

    I have the following code to alter the way comment form is displayed. After the bellow code everything is displayed as i want to but it does not add the comments. global $user; if ($user->uid) { $form['author']['_author'] = array ( '#tittle' => 'Nam

  • What is your suggestion for creating & sharing comments and/or highlighted texts of a web page?December 21

    I'm looking for a tool that help me & my wife to share our comments/hightlighted-texts on web pages that we have read. It would be lovely to have such a tool that: Allow us to create user account Create comments & highlighted texts (called commhil

  • Download lastfm tags into mp3 comment or genre tagAugust 23

    for a long time I dream to have a songs lastfm tags in my music library, so I can use them to quickly generate playlists. There used to be a way to do that in amarok 1.4, but it never was stable. Than there is MusicBrainz Picard's lastfm/lastfmplus p

  • How to strip html comments plus all tags inside it?December 19

    Any idea how can I remove this in $vars['closure']; ? <!-- SiteCatalyst code version: H.19.4 Copyright 1997-2009 Omniture, Inc. More info available at http://www.omniture.com --> <script type="text/javascript" language="JavaScript&

  • Comment out sections of text in bib fileJanuary 15

    What's the correct way to comment out sections of explanatory text (included for humans to read) in a .bib file? I would like biber/biblatex to simply ignore this text. When I put in text like #########################################################

  • Disabling autocomplete in comment blocks in Sublime TextAugust 21

    I have autocomplete activated with "auto_complete_selector": "source", however when I'm writing long-form comment blocks the autocomplete suggestions are distracting (i.e. typing current attempts to autocomplete to current). Can autoco

  • Filtering the Comment Form Allowed TagsAugust 17

    How can I remove some of the allowed HTML tags in comments/posts? For whatever reason, the following code, placed in my theme's functions.php, didn't work: add_action('init', 'my_html_tags_code', 10); function my_html_tags_code() { define('CUSTOM_TAG

  • How Can I Comment a Block of Text in Microsoft Office Visual Basic Editor?

    How Can I Comment a Block of Text in Microsoft Office Visual Basic Editor?November 5

    Sometimes when I'm writing a macro in Excel's Visual Basic Editor (VBE), I want to comment out a block of code to test the macro without it. I know I could go to each line and type an apostrophe ('), but this is tedious! Can I do this for a larger bl

  • alter a line and remove tag using perl from xml file?September 17

    I have an xml file (client_23.xml) in which I need to alter one line and remove one whole tag from it so I came up with perl script: In my xml file, I have a block like this. There will be only one instance of <hello>collect_model = 1</hello>

  • Is there any drawback in altering an existing column datatype from TEXT to VARCHAR(n)?December 4

    I have an existing column whose data type is TEXT. Now I realized that the values are just single strings. So, the data type VARCHAR(n) should have been proper in my case. So, I wanted to change the data type from TEXT to VARCHAR(n). Now my question

  • In Lightroom, where are the equivalents of the "Comments" and "Subject" tags from Windows File Explorer?December 7

    I wrote some info on a couple JPEGs using Windows File Explorer. In Explorer, I wrote info on the "Comments" and the "Subject" tags. However, when I import the JPEGs into Adobe Lightroom, I can't find the info I wrote. Does Lightroom n

  • Theme Customizer - Text without a setting (a comment or p tag)December 19

    In the Theme Customizer, is it possible to just have text (for example a comment, or a HTML <p> tag with text), or a setting that has no type (but a title of Text I need to display). For example, I may want to say - Go to XXX to do this at the botto

  • How to stop wrapping comments in P tagJanuary 2

    When I update a comment in wordpress, the comment is wrapped with p tag. Here's my code remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' ); remove_filter( 'pre_comment_content', 'wp_filter_kses'); return wp_update_co

  • displaying and sorting comments by a custom field (using PODS plugin)February 8

    In my blog, i answer comments inline by editing them to add "admin says: blah blah". i do this so i won't bump up the comment count with all my admin comments. I am using the PODS plugin to add a custom field to all of my comments, and when i ed

  • Replace comments with a dummy textDecember 18

    I want to hide comments for a certain time and show a sample text in the comment text area. Say, there are 50 comments on a post. What I want is- hide every comments on this post and there will be a text saying "this comment is hidden". Is it po

  • Comment an equation without creating extra spaceApril 14

    I try to make a comment on the right (or left) of one line of proof. But the align* environment automatically move the whole equations to the left to leave space for the comment. But I still want the equations to be in the center (the comment is shor

  • Getting Started with SQLite3 - Basic Commands

    Getting Started with SQLite3 - Basic CommandsMarch 23

    SQLite is a C library that implements an SQL database engine. It is a Relational Database Management System (or RDBMS). Most of the SQL databases work with the client/server model. Take MySQL for an example. To enter and receive data from a MySQL dat

Copyright (C) 2018 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.559 s.