/** * Add a duplicate translation for an item, then redirect to the Media/Edit Media screen * * @since 2.11 * * @param string $mla_admin_action the requested action. * @param integer $mla_item_ID zero (0), or the affected attachment. */ public static function mla_list_table_custom_admin_action($mla_admin_action, $mla_item_ID) { if ('wpml_create_translation' == $mla_admin_action) { $new_item = WPML_Media::create_duplicate_attachment($mla_item_ID, $_REQUEST['mla_parent_ID'], $_REQUEST['lang']); $view_args = isset($_REQUEST['mla_source']) ? array('mla_source' => $_REQUEST['mla_source']) : array(); wp_redirect(add_query_arg($view_args, admin_url('post.php') . '?action=edit&post=' . $new_item . '&message=201'), 302); exit; } }
function sync_thumbnail_id($orig_post_id, $trnsl_post_id, $lang) { if (defined('WPML_MEDIA_VERSION')) { $thumbnail_id = get_post_meta($orig_post_id, '_thumbnail_id', true); $trnsl_thumbnail = apply_filters('translate_object_id', $thumbnail_id, 'attachment', false, $lang); if (is_null($trnsl_thumbnail) && $thumbnail_id) { $trnsl_thumbnail = WPML_Media::create_duplicate_attachment($thumbnail_id, wp_get_post_parent_id($thumbnail_id), $lang); } update_post_meta($trnsl_post_id, '_thumbnail_id', $trnsl_thumbnail); update_post_meta($orig_post_id, '_wpml_media_duplicate', 1); update_post_meta($orig_post_id, '_wpml_media_featured', 1); } }