Closed gtuser10 closed 1 year ago
I've been having failing imports on some themes lately and finally tracked it down to this same issue. I can confirm that adding the following fixed it for me.
add_filter( 'wp_import_post_data_processed', function( $postdata, $data ) {
return wp_slash( $postdata );
});
Actually, this seems to be a duplicate of https://github.com/humanmade/WordPress-Importer/pull/161
Thanks! Closing in favour of #174 for a best practice approach.
In content created with Gutenberg editor, some characters (used in block attribute) are encoded into unicode character codes that start with a backslash, e.g.
Before inserting into database,
wp_insert_post()
function runs the post object throughwp_unslash()
function which strips all backslashes. This breaks unicode character codes (and content). To mitigate that, we should run the post object throughwp_slash()
functions before passing it towp_insert_post()
. The original WordPress Importer does this.