[Plugin: WPML comment merging] Amends to make WPML Comment Merging work again
-
We’ve got the comment merging working with the latest WordPress and WPML for all post types. Caveat: I have a very strong feeling that this patch won’t help if you want to use translated comments, but I may be wrong about that (so test if you want to use this feature and don’t just trust me).
Replace the
merge_comments
function in the latest version of the plugin with this:function merge_comments($comments, $post_ID) { global $sitepress; remove_filter( 'comments_clauses', array( $sitepress, 'comments_clauses' ) ); // get all the languages for which this post exists $languages = icl_get_languages('skip_missing=1'); $post = get_post( $post_ID ); $type = $post->post_type; foreach($languages as $code => $l) { // in $comments are already the comments from the current language if(!$l['active']) { $otherID = icl_object_id($post_ID, $type, false, $l['language_code']); $othercomments = get_comments( array('post_id' => $otherID, 'status' => 'approve', 'order' => 'ASC') ); $comments = array_merge($comments, $othercomments); } } if ($languages) { // if we merged some comments in we need to reestablish an order usort($comments, 'sort_merged_comments'); } // add_filter( 'comments_clauses', array( $sitepress, 'comments_clauses' ) ); return $comments; }
If you want a diff, you can find one here: https://pastebin.com/f1VFG4t2
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘[Plugin: WPML comment merging] Amends to make WPML Comment Merging work again’ is closed to new replies.