distributor icon indicating copy to clipboard operation
distributor copied to clipboard

Gutenberg issue: rich text area content get malformated

Open Abouhassane opened this issue 4 years ago • 1 comments

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 content add_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 avatar Apr 27 '21 11:04 Abouhassane

@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!

jeffpaul avatar Apr 28 '21 01:04 jeffpaul