Tag Info

Hot answers tagged

6

Pingbacks/Trackbacks: This is most likely a harmless case of link notifications to your blog (A) from the other blog (B), where: the comment_author_email field is usually empty, the comment_type field is either pingback or trackback, the comment_author field has the form: The title of the post that contains a link to a post of blog A | The site ...


6

You can try to modify it with the comment_form_defaults filter: /** * Modify the "must_log_in" string of the comment form. * * @see http://wordpress.stackexchange.com/a/170492/26350 */ add_filter( 'comment_form_defaults', function( $fields ) { $fields['must_log_in'] = sprintf( __( '<p class="must-log-in"> You must ...


5

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


4

Yes, it is possible, but it is a bit of a pain. Looking at the codex page, only arguments of note are number and offset. We need these two to create our paginated pages. First, we set the $paged parameter, which is the current page: $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; Then number of comments to display: $number = 3; ...


4

The comment_notification_text filter is in wp-includes/pluggable.php in the wp_notify_postauthor function. You can copy and paste the $notify_message stuff and edit out what you don't want. function wpd_comment_notification_text( $notify_message, $comment_id ){ // get the current comment and post data $comment = get_comment( $comment_id ); $post ...


4

There is definitely a performance advantage in keeping your comment spam to a minimum. If you have a lot of comments, the query time can get pretty out of control. To make it easier, you should install Akismet if you haven't already. Akismet will automatically detect spam comments and move them to WordPress spam section. You can then delete all the spam ...


3

I skimmed through the source of the wp_notify_postauthor() function and noticed the comment_notification_recipients filter. I wonder if you could simplify your plugin to the following code snippet: <?php /** * Plugin Name: Disable comment/trackback/pingback notifications emails * Plugin URI: http://wordpress.stackexchange.com/a/150141/26350 */ ...


3

I wonder if you mean this kind of check: if( $comment->user_id > 0 ) { // Registered comment author } in your comment's template callback. This is determined in the the wp-comments-post.php file: $commentdata = compact('comment_post_ID', ..., 'user_ID' ); $comment_id = wp_new_comment( $commentdata ); but it's not obvious where the user_ID ...


3

Try this: if( get_comment_author() == get_comment_author_link() ) echo get_avatar( $comment, $size='75' ); else echo '<a href="' . get_comment_author_url . '">' . get_avatar( $comment, $size='75' ) . '</a>';


3

There is no need for a plugin. The reason people get this confused is because posts can have comments enabled or disabled on an individual basis. There is no "global" option, because it's per post. So really, it just takes two main steps to disable comments in WordPress: Settings > Discussion. Turn off both "Allow link notifications from other blogs ...


3

You should consider hooking into the comment_class() and post_class() filters, if your theme supports it. Using the comment_class filter: We can add the following filter: /** * Add a custom comment class, based on a given comment author's user meta field. * * @see http://wordpress.stackexchange.com/a/170443/26350 */ add_filter( 'comment_class', ...


3

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) :)


2

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" ...


2

So after some time I done exactly what I wanted and I thought it would be nice to share. So in functions.php add function c_parent_comment_counter($pid,$uid){ global $wpdb; $query = "SELECT COUNT(comment_post_id) AS count FROM $wpdb->comments WHERE <code>comment_approved</code> = 1 AND <code>comment_post_ID</code> = $pid ...


2

wp_update_comment triggers the edit_comment action (source), you're creating an infinite loop.


2

Look at the function wp_delete_comment(). It fires an action before the comment is deleted: /** * Fires immediately before a comment is deleted from the database. * * @since 1.2.0 * * @param int $comment_id The comment ID. */ do_action( 'delete_comment', $comment_id ); … and one after deletion: /** * Fires immediately after a comment is deleted ...


2

You can use the get_comment_author_link hook, which is part of the get_comment_author_link() template tag, like your question already suggests. Then you only have to get the according user_id, which can be done via the $comment global, and construct the link you want accordingly. Exemplary usage like shown below: add_filter( 'get_comment_author_link', ...


2

This can be done, there is even a possibility to control this via the backend, just go to: → Settings → Discussion And there under: → Other comment settings You have the point: → Enable threaded (nested) comments | X | levels deep


2

The plugin you mentioned is only a single function so it shouldn't be too heavy on your setup. It uses the comments_template filter to inject the pingbacks/trackbacks list into your page. But the plugin is using an extra manual SQL query and the template is constructed by hand, so there's a room for improvements/simplifications. A simple demo plugin with ...


2

After reading a bit on regex and preg, starting from a previous example of a similar problem and testing it I was able to answer my own question. I added this function to functions.php: <?php /** Plugin Name: WPSE (#167237) Redirect after comment */ add_filter('comment_post_redirect', 'redirect_after_comment'); function ...


2

You could try to count the number of unique comment author emails per post: /** * Number of unique comment author emails per post: * * @see http://wordpress.stackexchange.com/a/168606/26350 * @param int $pid * @return int */ function get_unique_commenters_by_post_id( $post_id ) { global $wpdb; $sql = "SELECT COUNT(1) as uc FROM ( ...


2

When you are editing the post or page. You can disable comments from the "Discussion" box. By default this box is hidden. Show the Discussion meta box If you don't see a box labeled Discussion: Open the Screen Options by clicking the tab near the upper right-hand corner of the screen with the name Screen Options. Check the checkbox before Discussion. ...


2

The wp_list_comments() function uses the HTML comment list class Walker_Comment by default: A single comment is then displayed with the Walker_Comment::comment() method (#source). If the comment format is HTML5 then the Walker_Comment::html5_comment() is used instead (#source). The pingbacks are rendered with the Walker_Comment::ping() method (#source). ...


2

parent : Comments can be replies to other comments. Every comment has an ID number. When the comment is a reply, then it will have a "parent" which is the ID of the comment it is replying to. Putting a comment ID in here will get all the replies to that comment. post_parent : Posts can be children of other posts as well. This is how things like hierarchical ...


1

Here are two solutions that can be placed in functions.php. They are not really what I need, but perhaps they are of some use to someone else. Solution 1 Can be used to close comments for certain posts: function close_comment_form( $open, $post_id ) { $post = get_post( $post_id ); if( $post->post_type == 'post' ) { return false; } ...


1

declaring max-width: 100%; works for me. it looks like the selector in your example code is incorrect. try: .commentlist iframe { max-width: 100%; }


1

Constructing the SQL query: You can try the following: /** * Fetch comments' IDs for the most recently commented posts * (only one comment per post) * * @param integer $count * @return array */ function get_cids_wpse ( $count = 5 ) { global $wpdb; $sql = "SELECT MAX( comment_ID ) as cid FROM {$wpdb->comments} ...


1

If you are using WordPress 4.0+ you can do this using the wp_editor_settings and the global $pagenow to determine if you are on the comments page. add_filter( 'wp_editor_settings', 'remove_editor_quicktags', 10, 2 ); function remove_editor_quicktags( $settings, $id ){ global $pagenow; if ( $id == 'content' && $pagenow === 'comment.php' ){ ...


1

Livefyre Sidenotes plugin for WordPress does exactly this: https://wordpress.org/plugins/livefyre-sidenotes/ It enables contextual inline commenting not only per paragraph, but, within this, commenting on a particular section highlighted by the user, which would be closer to the MS Word implementation: Start by highlighting the text: When the ...


1

This will display them before the DISQUS comment form but not the count add_filter( 'comments_template', function( $pings_before_dsq_comments) { if( !function_exists( 'dsq_is_installed' ) || !dsq_is_installed() ) return $pings_before_dsq_comments; wp_list_comments( array( 'style' => 'ul', 'type' => 'pings' )); ...



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