Function Reference: gd_copy_original_translation
Summary
Function to copy custom meta info on WPML copy.
Global Values
- $wpdb
- (object) (required) WordPress Database object.
- Default: None
- $table_prefix
- (string) (required) WordPress Database Table prefix.
- Default: None
- $plugin_prefix
- (string) (required) Geodirectory plugin table prefix.
- Default: None
Package
GeoDirectory
Change Log
Since: 1.0.0
Source File
gd_copy_original_translation() is located in geodirectory-functions/post_functions.php [Line: 2990]
Source Code
function gd_copy_original_translation() { if (geodir_is_wpml()) { global $wpdb, $table_prefix, $plugin_prefix; $post_id = absint($_POST['post_id']); $upload_dir = wp_upload_dir(); $post_type = get_post_type($_POST['post_id']); $table = $plugin_prefix . $post_type . '_detail'; $post_arr = $wpdb->get_results($wpdb->prepare( "SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1", array($post_id) ) , ARRAY_A); $arrImages = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ", array('%image%', $post_id) ) ); if ($arrImages) { $image_arr = array(); foreach ($arrImages as $img) { $image_arr[] = $upload_dir['baseurl'] . $img->file; } $comma_separated = implode(",", $image_arr); $post_arr[0]['post_images'] = $comma_separated; } $cats = $post_arr[0][$post_arr[0]['post_type'] . 'category']; $cat_arr = array_filter(explode(",", $cats)); $trans_cat = array(); foreach ($cat_arr as $cat) { $trans_cat[] = geodir_wpml_object_id($cat, $post_arr[0]['post_type'] . 'category', false); } $post_arr[0]['categories'] = array_filter($trans_cat); //print_r($image_arr); //print_r($arrImages); //echo $_REQUEST['lang']; //print_r($post_arr); //print_r($trans_cat); echo json_encode($post_arr[0]); } die(); }