WPML after translating page, WPML cut off spaces and blank rows after media

Hello,

I checked this issue with WPML support extensively and they come back to me with solution, which idk if its safe, as they want me to add php code into theme-functions.php. I dont want the code to break the theme. Can you check it please if its ok to add it there ?

Whole service topic you can find here:

This is the final reply:


Hi,

Please check the following steps:

1- Edit the (wp-content/themes/betheme/functions/theme-functions.php) file

2- Replace the "mfn_wpml_encode_custom_field" and "mfn_wpml_decode_custom_field" functions with the following code


function mfn_wpml_encode_custom_field( $custom_field_val, $custom_field_name ) {

  if ( $custom_field_name === 'mfn-page-items' ) {

  $custom_field_val = mb_convert_encoding($custom_field_val, 'UTF-8', 'auto');

    $custom_field_val = base64_encode( serialize($custom_field_val) );

  }

  return $custom_field_val;

}

add_filter( 'wpml_encode_custom_field', 'mfn_wpml_encode_custom_field', 10, 2 );

 

function mfn_wpml_decode_custom_field( $custom_field_val, $custom_field_name ) {

    if ( $custom_field_name === 'mfn-page-items' && is_string($custom_field_val) ) {

        $custom_field_val = mb_convert_encoding($custom_field_val, 'UTF-8', 'auto');

        $custom_field_val = maybe_unserialize( base64_decode($custom_field_val) );

    }

    return $custom_field_val;

}

add_filter( 'wpml_decode_custom_field', 'mfn_wpml_decode_custom_field', 10, 2 );

3- Edit the page in the default language

4- Make a minor edit in the column text widget and update it

5- Update its translation

I applied those steps to your test site. Please check this translated page and let me know if it works correctly.



Thanks for your time

Martin

Comments

Sign In or Register to comment.