Gutenberg issue: rich text area content get malformated
Hello,
Lately i got the chance to work on a multi-site WordPress installation and i used GUTENBERG to develop most of the site blocks.
The other sites are a basically a replica of the main site with the need to propagate each change of the principal site on all the other sites. Where came the need to use DISTRIBUTOR which was a bless.
The only issue with GUTENBERG/DISTRIBUTOR is for blocks that contain rich-text areas got there content malformed, probably because they contain HTML.
After a bit of research, we found two useful hooks to resolve this issue. I take this chance to share with you the solution:
-
Insert the following code in functions.php:
// Use a filter to format the contentadd_filter('dt_pull_post_args', 'distributorFilter');add_filter('dt_push_post_args', 'distributorFilter');function distributorFilter($post_array){$post_array['post_content'] = str_replace('\\', '\\\\', $post_array['post_content']);return $post_array;}
@Abouhassane welcome to Distributor and thanks for the feedback! We're working on a related issue, #430, though it's a couple releases out on the roadmap but we will certainly include your input as we get closer to being ready to work on these issues... thanks!