A few days ago, I submitted a ticket to the WordPress core trac to Filter Glyph for Comment Required Fields. The idea behind the patch I submitted being:
Currently the comment-template.php file uses an asterisk (*) as the default glyph for required fields used in the comment_form() function. This glyph is not easily manipulated without having to essentially over-write the entire comment_form() function.
I suggest the glyph be filtered. Therefore if one wants to change it, for example, to a hash (#) symbol then they can simply filter the output; or, if for any other reason one might want to enhance the glyph visibility or utility the filter would then allow for this while minimizing the impact on the default comment form.
A response was made to the ticket providing an example snippet to accomplish the basics of the ticket description but not the entire idea as I envisioned it. Here is Sergey’s snippet:
function change_required_fields_glyph_23870( $defaults ) {
$defaults['fields']['author'] = str_replace( '*', '#', $defaults['fields']['author'] );
$defaults['fields']['email'] = str_replace( '*', '#', $defaults['fields']['email'] );
$defaults['comment_notes_before'] = str_replace( '*', '#', $defaults['comment_notes_before'] );
return $defaults;
}
add_filter( 'comment_form_defaults', 'change_required_fields_glyph_23870' );
I replied (twice) with the second response providing some modifications to Sergey’s snippet that does complete the idea if the patch I submitted does not get included. Here is what I would suggest to make the Comment Required Field symbol, or glyph, filterable:
function required_fields_glyph_23870() {
$glyph = apply_filters( 'comment_required_glyph_23870', '*' );
return $glyph;
}
function change_required_fields_glyph_23870( $defaults ) {
$defaults['fields']['author'] = str_replace( '*', required_fields_glyph_23870(), $defaults['fields']['author'] );
$defaults['fields']['email'] = str_replace( '*', required_fields_glyph_23870(), $defaults['fields']['email'] );
$defaults['comment_notes_before'] = str_replace( '*', required_fields_glyph_23870(), $defaults['comment_notes_before'] );
return $defaults;
}
add_filter( 'comment_form_defaults', 'change_required_fields_glyph_23870' );
You will find a version of this code being used by Opus Primus version 1.2 and later …
… and here’s a plugin idea for this code: link the comment required field glyph, via the filter, to a privacy policy.
View original entry