3567 posts Ruben Bristian
  • Sells items exclusively on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $500,000+ on Envato Market
  • Has been part of the Envato Community for over 6 years
+10 more
KrownThemes says

Are there know issues with the XML importer regarding this? I am finding it really really buggy.

Before import (taken from the import.xml file):

[{"width":2,"height":1,"type":"text","i":0,"title":"","bgcolor":"#fff85f","bgimage":"","bgrepeat":"fill","color":"#000000","customtransform":"center","kmbcontent":"<div class="\"big-text\"">\n<h2>Mail</h2>\n</div>\n<div class="\"btn-link\""><a href="\"mailto:hello@lobo.com\"">hello@lobo.com</a></div>"},

After import (taken from the outputted meta value):

[{"width":2,"height":1,"type":"text","i":0,"title":"","bgcolor":"#fff85f","bgimage":"","bgrepeat":"fill","color":"#000000","customtransform":"center","kmbcontent":"<div class="big-text">n<h2>Mail</h2>n</div>n<div class="btn-link"><a href="mailto:hello@lobo.com">hello@lobo.com</a></div>"},

What in the world happens with the escapes when the WordPress importer does its job? It breaks the entire thing.

3567 posts Ruben Bristian
  • Sells items exclusively on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $500,000+ on Envato Market
  • Has been part of the Envato Community for over 6 years
+10 more
KrownThemes says

bump? :|

186 posts
  • Has been part of the Envato Community for over 4 years
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has collected 100+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+4 more
Artillegence says

hey Ruben, are you serializing the values ? It happens when you serialize it manually. You can try this, when you save the values encode it into base64.

3567 posts Ruben Bristian
  • Sells items exclusively on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $500,000+ on Envato Market
  • Has been part of the Envato Community for over 6 years
+10 more
KrownThemes says

Any other way? I would like to not use base64..

3567 posts Ruben Bristian
  • Sells items exclusively on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $500,000+ on Envato Market
  • Has been part of the Envato Community for over 6 years
+10 more
KrownThemes says

I am serializing arrays with JSON. And in the import file there’s a perfect JSON array, but when WordPress imports it, it breaks.

186 posts
  • Has been part of the Envato Community for over 4 years
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has collected 100+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+4 more
Artillegence says
other option would be to add action for import_end hook , you can check the meta field that if it is not proper json , add the slashes . Something like this
if( ! is_obj( json_decode($array_str) ) )
 $array_str = addslashes($array_str);
or before generating json change double quotes to single in array. Hope this helps :)
1185 posts
  • Has been part of the Envato Community for over 4 years
  • Has sold $40,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 50+ items on Envato Market
+5 more
Smartik says

Export: htmlspecialchars( addslashes($str) );
Import: stripslashes( htmlspecialchars_decode($str) );

3567 posts Ruben Bristian
  • Sells items exclusively on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $500,000+ on Envato Market
  • Has been part of the Envato Community for over 6 years
+10 more
KrownThemes says

Thanks for the help guys. I finally found the root of the error. It’s in the add_post_meta function which is used by the WP importer:

Post meta values are passed through the stripslashes() function upon being stored, so you will need to be careful when passing in values (such as JSON) that might include \ escaped characters.

Every day is a good day for learning :)

I went with the “import_end” filter.

by
by
by
by
by
by