: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
class WPML_Comment_Duplication{
public function move_to_original($duplicate_of, $post_duplicates, $comment){
global $wpml_post_translations, $wpdb;
$_orig_lang = $wpml_post_translations->get_element_lang_code ( $duplicate_of );
$post_duplicates[ $_orig_lang ] = $duplicate_of;
$original_parent = get_comment_meta ( $comment[ 'comment_parent' ], '_icl_duplicate_of', true );
'comment_post_ID' => $duplicate_of,
'comment_parent' => $original_parent
), array( 'comment_ID' => $comment['comment_ID'] ), array( '%d', '%d' ), array( '%d' )
wp_update_comment_count_now($duplicate_of);
public function get_correct_parent($comment, $dup_id){
$translated_parent = $wpdb->get_var (
FROM {$wpdb->commentmeta} cm
JOIN {$wpdb->commentmeta} cmb
ON ( cmb.meta_value = cm.meta_value
AND cmb.meta_key = cm.meta_key)
OR cm.comment_id = cmb.meta_value
ON c.comment_ID = cmb.comment_id
WHERE cm.meta_key = '_icl_duplicate_of'
AND ( cm.comment_id = %d OR cm.meta_value = %d )
AND c.comment_post_ID = %d",
$comment[ 'comment_parent' ],
$comment[ 'comment_parent' ],
return $translated_parent;
public function insert_duplicated_comment( $comment, $dup_id, $original_cid ) {
global $wpdb, $iclTranslationManagement;
$dup_comment_id = $this->duplicate_exists ( $dup_id, $original_cid );
remove_action ( 'wp_insert_comment', array( $iclTranslationManagement, 'duplication_insert_comment' ), 100 );
$comment[ 'comment_ID' ] = $dup_comment_id;
wp_update_comment ( $comment );
$wpdb->insert ( $wpdb->comments, $comment );
$dup_comment_id = $wpdb->insert_id;
add_action ( 'wp_insert_comment', array( $iclTranslationManagement, 'duplication_insert_comment' ), 100 );
update_comment_meta ( $dup_comment_id, '_icl_duplicate_of', $original_cid );
$meta = $wpdb->get_results (
"SELECT meta_key, meta_value FROM {$wpdb->commentmeta} WHERE comment_id=%d",
foreach ( $meta as $meta_row ) {
'comment_id' => $dup_comment_id,
'meta_key' => $meta_row->meta_key,
'meta_value' => $meta_row->meta_value
), array( '%d', '%s', '%s' )
wp_update_comment_count_now ( $dup_id );
private function duplicate_exists( $dup_id, $original_cid ) {
$duplicate = $wpdb->get_var (
FROM {$wpdb->comments} comm
JOIN {$wpdb->commentmeta} cm
ON comm.comment_ID = cm.comment_id
WHERE comm.comment_post_ID = %d
AND cm.meta_key = '_icl_duplicate_of'