cristinaC-5
I am trying to translate image excerpts with Media Translation, but it seems it doesn't support newlines.
I have tried with '<br>', '\n' and the simple enter but after i save the translation it removes them (except for the '\n' which is stored as text).
Is there a way, even by code with an action or a filter, to keep newlines?
Best Regards
Kor
Supporter
Languages:
English (English )
Timezone:
Asia/Singapore (GMT+08:00)
Hi there,
Thanks for contacting WPML support.
I've checked your screenshot and I think I know what you're trying to do there. These media fields are actually being sanitized.
To prevent this, you can use this workaround:-
IMPORTANT : Please make sure you've backed up.
Edit the file \wpml-media-translation\classes\media-translation\class-wpml-media-save-translation.php line 53 to line 61 and replace
if ( isset( $_POST['translation']['title'] ) ) {
$post_array['post_title'] = sanitize_text_field( $_POST['translation']['title'] );
}
if ( isset( $_POST['translation']['caption'] ) ) {
$post_array['post_excerpt'] = sanitize_text_field( $_POST['translation']['caption'] );
}
if ( isset( $_POST['translation']['description'] ) ) {
$post_array['post_content'] = sanitize_text_field( $_POST['translation']['description'] );
}
with
if ( isset( $_POST['translation']['title'] ) ) {
$post_array['post_title'] = ( $_POST['translation']['title'] );
}
if ( isset( $_POST['translation']['caption'] ) ) {
$post_array['post_excerpt'] = ( $_POST['translation']['caption'] );
}
if ( isset( $_POST['translation']['description'] ) ) {
$post_array['post_content'] = ( $_POST['translation']['description'] );
}
Then, please try again and see if it works for you.
Thanks!
Kor