Function Reference: gepdir_wpml_sync_comment

Summary

Synchronize review for WPML translation post.

Global Values

$wpdb
(object) (required) WordPress Database object.

Default: None
$sitepress
(object) (required) Sitepress WPML object.

Default: None
$gd_wpml_posttypes
(array) (required) Geodirectory post types array.

Default: None

Parameters

$comment_id
(int) (required) The Comment ID.

Default: None

Change Log

Since: 1.6.16

Source File

gepdir_wpml_sync_comment() is located in geodirectory-functions/custom_functions.php [Line: 2858]

Source Code

function gepdir_wpml_sync_comment($comment_id) {
	global $wpdb, $sitepress, $gd_wpml_posttypes;

	if (empty($gd_post_types)) {
		$gd_wpml_posttypes = geodir_get_posttypes();
	}

	$comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_ID=%d", $comment_id), ARRAY_A);
	if (empty($comment)) {
		return;
	}

	$post_id = $comment['comment_post_ID'];
	$post_type = $post_id ? get_post_type($post_id) : NULL;

	if (!($post_type && in_array($post_type, $gd_wpml_posttypes))) {
		return;
	}

	$post_duplicates = $sitepress->get_duplicates($post_id);
	if (empty($post_duplicates)) {
		return;
	}

	foreach ($post_duplicates as $lang => $dup_post_id) {
		if (empty($comment['comment_parent'])) {
			geodir_wpml_duplicate_post_review($comment_id, $post_id, $dup_post_id, $lang);
		}
	}

	return true;
}