15

I know this is quite an old post and maybe this could help someone. You can replace the class of an element using add_filter(); Here's an example: // filter to replace class on reply link // class name function name add_filter('comment_reply_link', 'replace_reply_link_class'); function replace_reply_link_class($class){ $class = ...


14

That's pretty simple. You just have to take the textarea out of the default fields – filter 'comment_form_defaults' – and print it on the action 'comment_form_top': <?php # -*- coding: utf-8 -*- /** * Plugin Name: T5 Comment Textarea On Top * Description: Makes the textarea the first field of the comment form. * Version: 2012.04.30 * License: ...


10

From WordPress Version 4.1 (trac ticket #20446) it's now added to pass your own class as an argument of comment_form($args) using 'class_submit' array key: $args = array( 'class_submit' => 'btn btn-default' ); No need to do extra hard work. (Edited the Codex too) :)


9

We can use comment_form function's submit_button parameter to change submit button HTML. Default HTML for submit_button is <input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" /> You can change your code like this. $comments_args = array( .... 'submit_button' => '<div class="form-group"> <input name="%...


8

For people that come here looking for a more detailed explanation about the text domain issue instead of just "use a text domain". Here's how it works. Firstly, you have to tell WordPress where the language files should be put in your theme, and what the 'theme slug' is (a unique identifier for your theme) like so: add_action('after_setup_theme', '...


8

You shouldn't copy that file, precisely because it is too bulky. About half of it is implementation of submission form, which was entirely replaced with comment_form() function around that time. So the answer why was it deprecated is roughly: Newer code is more compact Markup belongs in theme For better and more relevant comments.php example look at core ...


7

I'm working with the Foundation framework as well. I've found that the easiest way to add a class to a non-filterable element is to do it with jQuery. jQuery(document).ready(function($) { //noconflict wrapper $('input#submit').addClass('button'); });//end noconflict


6

I was facing same problem and was searching for solution i found the solution Open your function.php file and past below code: function comment_validation_init() { if(is_single() && comments_open() ) { ?> <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></...


6

Ensure that you have Threaded Comments enabled: go to Dashboard -> Settings -> Discussion and enable the option to thread comments Ensure that your Theme enqueues the comment-reply script. Look for the following, usually in header.php, functions.php, etc.: <?php wp_enqueue_script( 'comment-reply' ); ?> Note: this call is usually wrapped in a ...


6

Filter comment_form_field_comment to add a select element with a label. Add a callback to the action comment_post to save the value. Filter comment_text to show the value for a comment. Sample code: add_filter( 'comment_form_field_comment', function( $field ) { global $wp_roles; $user = wp_get_current_user(); $select = '<p><...


5

When we post an empty anonymous reply, we get the following errors: The part of BBPress that's responsible for handling this, is the bbp_new_reply_handler() function, in the file /bbpress/includes/replies/functions.php. It contains these lines that are of interest to us: // User is anonymous if ( bbp_is_anonymous() ) { // Filter ...


5

Comment.php The way I see your comment.php seems messy and more complex than it needs to be, you can post this piece of code to in your comment.php and it should work okay. <?php /** * If the current post is protected by a password and * the visitor has not yet entered the password we will * return early without loading the commend */ if (...


5

Please place below code in your theme's functions.php file and it will wrap the submit button inside div: // define the comment_form_submit_button callback function filter_comment_form_submit_button( $submit_button, $args ) { // make filter magic happen here... $submit_before = '<div class="form-group">'; $submit_after = '</div>'; ...


4

You are probably looking for Jetpack comments system. If so, you can install Jetpack plugin and then activate the Comments module, if it is not activated by default upon plugin activation. After plugin installation, you may also need to connect to your WordPress.com account to enable any (or all) Jetpack features as indicated in the installation instructions....


4

There are obviously a number of ways to accomplish this. For example, to move the comment field to the bottom of the form you would use code like this: add_filter( 'comment_form_fields', 'move_comment_field' ); function move_comment_field( $fields ) { $comment_field = $fields['comment']; unset( $fields['comment'] ); $fields['comment'] = $...


4

I liked toscho answer. However I wanted to use a custom textarea, so it didn't work in that case. I used the same hooks but with separate functions: add_filter( 'comment_form_defaults', 'remove_textarea' ); add_action( 'comment_form_top', 'add_textarea' ); function remove_textarea($defaults) { $defaults['comment_field'] = ''; return $defaults; } ...


4

Filter comment_form_defaults and add your code to the textarea. Sample code, not tested: add_filter( 'comment_form_defaults', 'wpse_120049_extend_textarea' ); function wpse_120049_extend_textarea( $args ) { $args['comment_field'] .= '<p>Extra text.</p>'; return $args; }


4

We could rewrite: wp_list_comments( array( 'callback' => 'bootstrap_comment_callback', )); with the null walker parameter: wp_list_comments( array( 'walker' => null, 'callback' => 'bootstrap_comment_callback', )); which means we are using the default Walker_Comment class: wp_list_comments( array( 'walker' ...


4

This code will allow you to customize the comment field labels and will move the comment form below the fields. Add the code to your functions.php or to a plugin. To change the labels, modify the Name CUSTOMIZED, Email CUSTOMIZED, and Website CUSTOMIZED, and Comment * CUSTOMIZED text. /** * Customize comment form default fields. * Move the comment_field ...


3

Quite old post, but while searching I came here, maybe someone else will find it useful. The only solution I found is to completely rebuilt the button that comment_reply_link returns. I first made two vars reconstructing href and onclick attributes for the reply button: $reply_href = wp_make_link_relative( get_permalink( $comment->comment_post_ID ) ...


3

In the Settings >> Discussion Screen, there is a options tick box, 'Enable threaded (nested) comments [X] levels deep'. From there you can tick to activate threaded comments and set how many levels deep to a maximum of 10. You should also check if your theme has the following piece of code, should normally be in the functions.php template of your theme. ...


3

Open comments.php file inside your theme's folder <?php if ( comments_open() ) : ?> <?php $fields = array( 'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name', 'responsive' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . '<input id="author" name="...


3

This is possible using the comment_post action, and the GFAPI class which handles entries in WordPress. What you need to first is add using comment_form_default_fields a field which is a checkbox. function add_to_email_list_field($fields) { $fields['add-to-email'] = '<p class="comment-form-public"> <input id="addtoemail" name="addtoemail"...


3

If you need to modify the max depth, you could use the thread_comments_depth_max filter: /** * Set max comments depth to 15 on the discussion settings page */ add_filter( 'thread_comments_depth_max', function( $max ) { return 15; } ); then the dropdown on the discussion settings page will show the range 1 - 15. But I can imagine very deep comment ...


3

Ok I feel stupid now. The problem was that for whatever reason some of the posts had comments disabled. I did not know that the only place where they could be toggled was under "Quick Edit". Problem solved...


3

I wonder if you mean this kind of approach: add_filter( 'init', function() { $u = wp_get_current_user(); if( $u->exists() && in_array( 'banned', $u->roles, true ) ) add_filter( 'comments_open', '__return_false' ); } ); where we check if the current user has the custom banned role. If that's the case then we force all ...


3

It seems that WordPress handles the comment field separately than the other fields. If you look at comment_form() in wp-includes/comment-template.php, you can see this. It's possible to set $defaults['comment_field'] to false in alpha_comments_defaults() then add the comment field markup to $fields['comment_field'] in alpha_comments_fields() in the desired ...


3

Any comments_template filter should return an absolute filepath to the comments template - use comment_form_defaults and set the class_form argument: add_filter( 'comment_form_defaults', function ( $args ) { $args['class_form'] = 'my form classes'; return $args; });


3

No, it is not a bug. This is how core handles it. If you look into /wp-includes/comment-template.php, you'll notice, that the only difference in <form> element, is novalidate attribute added, when current_theme_supports( 'html5', 'comment-form' ) is true. But there are other html elements within comment form, which are affected by theme's choice of ...


3

Use this function rather than comment_form() function validate_comment_form(){ ob_start(); comment_form(); echo str_replace('<form','<form attribute="value" ',ob_get_clean()); }


Only top voted, non community-wiki answers of a minimum length are eligible