Function Reference: geodir_icl_duplicate_post_details

Summary

Duplicate post general details for WPML translation post.

Global Values

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

Default: None
$plugin_prefix
(string) (required) Geodirectory plugin table prefix.

Default: None

Parameters

$master_post_id
(int) (required) Original Post ID.

Default: None
$tr_post_id
(int) (required) Translation Post ID.

Default: None
$lang
(string) (required) Language code for translating post.

Default: None

Return Values

(bool)
  • True for success, False for fail.

Change Log

Since: 1.5.0

1.6.25 “geodir_icl_duplicate_post_data” filter added.

Filters

‘geodir_icl_duplicate_post_data’ [Line: 2664]

Source File

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

Source Code

function geodir_icl_duplicate_post_details($master_post_id, $tr_post_id, $lang) {
	global $wpdb, $plugin_prefix;

	$post_type = get_post_type($master_post_id);
	$post_table = $plugin_prefix . $post_type . '_detail';

	$query = $wpdb->prepare("SELECT * FROM " . $post_table . " WHERE post_id = %d", array($master_post_id));
	$data = (array)$wpdb->get_row($query);

	if ( !empty( $data ) ) {
		$data = apply_filters( 'geodir_icl_duplicate_post_data', $data, $master_post_id, $tr_post_id, $lang );
		$data['post_id'] = $tr_post_id;
		unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type . 'category']);
		$wpdb->update($post_table, $data, array('post_id' => $tr_post_id));
		return true;
	}

	return false;
}