Archived topic
Issue with Editing Pages with GenerateBlock Icons on WordPress Multisite
3 replies · Started by Sam on July 7, 2022
Hi,
We're encountering a weird issue where SVG icons (code copied from Front Awesome) added to Headline blocks (either directly as SVG code or via the Asset Library) display as a CSS class after making any type of edits to the page; this includes edits to other blocks that are not related to the Headline blocks that have icons.
This issue only happens when users with less than "Super Administrator" at the network level of our WordPress Multisite install make changes to pages. If a Super Administrator makes changes, everything works perfectly with no errors.
Here is a video detailing the issue: https://share.vidyard.com/watch/SV5J1woocxhoGrdd5xmnsk?
Looking through other support tickets, I did come across this one that mentioned only Super Administrators have access to certain permissions that may be critical to the operation of GeneratePress / GenerateBlocks: https://generatepress.com/forums/topic/user-capability-for-editor-role-to-add-additional-css/
More than happy to provide additional details as needed to help understand why this is happening.
Thanks!
Hi Sam,
This article should help: https://docs.generateblocks.com/article/fix-svg-icons-not-saving/
Let us know :)
Hi Tom,
The quick response is really appreciated.
Adding that code for SVG files partially fixed the issue, but there is still something going on with the need for the unfiltered_html permissions for non-Super Admin users on Multisite.
As you can see in the short video here (https://share.vidyard.com/watch/qDwEDkmKR8435NhRATn8VG?) the icons now display but they lose their Duotone styling (probably because the CSS for opacity is getting filtered out).
Here is the code we used to fix this:
/*** For WordPress Multi-Site - Fix SVGs Not Saving Due to unfiltered_html permissions issue ***/
function add_unfiltered_html_capability_to_users( $caps, $cap, $user_id ) {
if ( 'unfiltered_html' === $cap && (user_can( $user_id, 'editor' ) || user_can( $user_id, 'admin' )) ) {
$caps = array( 'unfiltered_html' );
}
return $caps;
}
add_filter( 'map_meta_cap', 'add_unfiltered_html_capability_to_users', 1, 3 );
You can add more attributes to the solution I linked to if there are certain ones you need.
Of course, the solution you posted will work as well if you trust your editors.