icon-block
icon-block copied to clipboard
This block contains unexpected or invalid content.
Hi, I keep running into this issue:
When I resolve the block it looks like the invalid content is just empty spaces:
Hi @vibrains, can you share what version of WordPress and/or Gutenberg you are running? Thanks
@ndiego WordPress version: 6.3.1
Hmm interesting. I am not able to replicate this. Is there anything else you can share about your setup?
Hi, it's showing me this error. I have used Insert custom SVG, then paste any svg code, then Insert custom icon, then click on replace and clear icon and again click to Insert custom SVG then it shows this error. I'm using WP 6.3.1, Frost Theme and no plugin.
Getting the same issue. Can only assume it is to do with character encoding, or similar... We're running on WPVIP, WP 6.3.2, PHP 8.0.
FYI: it appears to be related to user capabilities when running a multisite - so in our case, a super admin was the only role that was able to add the icon blocks successfully; even an administrator encountered the same issue. https://wordpress.org/plugins/unfiltered-mu/ - adding this plugin fixes the issue.
Thanks @TheoEnnismore for pointing us in the right direction! It's definitely because the inline SVG is being sanitized without the unfiltered_html capability. On MS, that's removed for pretty much everyone. On a single site, only editors and admins will have this capability. So an author, for example, could add an icon but then be surprised when it never displays.
I think it would be better to not encourage enabling unfiltered_html widely.
@ndiego I wonder if a possible solution might be to only store the reference to the SVG in the block's content, rather than the SVG itself. Then load the SVG into the editor when the editor is loaded, and add it to page views in the backend through PHP.
Two problems I see with that, though:
- Since the SVG isn't stored in
post_content
, if the plugin is disabled in the future the SVGs will be lost - If the block's icon library is changed and an icon is removed, it will also be lost.
But maybe those are reasonable given the risk of folks disabling unfiltered_html.