Search code examples
phpwordpresstemplates

Broken wordpress Astra templates (escaping)


I have very little experience with WordPress, but my attempt to set everything up so far went fairly well. Where I'm struggling with now, is that none of the Astra starter templates seem to work - they all break and generate invalid html like this:

<img src="\&quot;https://websitedemos.net/digital-agency-08/wp-content/uploads/sites/850/2021/05/about.jpg\&quot;" alt="\&quot;\&quot;" class="\&quot;wp-image-47" size-full\"="">

The whole page is covered in these:

enter image description here

This seems some weird code sanitation issue? I tried searching for the problem, but couldn't find anything.

I checked system requirements and Tools > Site Health, everything related to this seems fine.

I'm running an Ubuntu server with PHP8.0 and NGINX. Minimum requirements for Astra templates are met.

Any ideas how to approach this, or where to investigate what could be wrong? What infos could I add to my question to give more clues?


Solution

  • From: https://wordpress.org/support/topic/imported-template-is-broken-with-gutenberg-as-the-page-builder/

    I’ve since tried this with several Astra templates, all have the same problem – wrongly slash-escaped quotes in the post content.

    I tracked the problem down to a “Gutenberg Content Data Fix” as it is named in the Astra plugin code comments.

    In file wp-content/plugins/astra-sites/inc/importers/wxr-importer/class-astra-wxr-importer.php there is an if branch apparently run in the case of Gutenberg builder, explicitly adding the slashes that actually breaks the page content:

    $data['post_content'] = wp_slash( $data['post_content'] );

    If I comment out this line, the template seems to get imported fine.

    That fixes it!!!