Widget Options wp_insert_post_data filter strips block attributes on s
-
Hello folks,
I have noticed something on my website that drove me nuts until I found out what the actual problem was, so I wanted to share this with you.
Widget Options registers a closure on the
wp_insert_post_datafilter (priority 10, inincludes/widgets/gutenberg/gutenberg-toolbar.phparound line 383) that strips JSON attributes from Gutenberg block comments when a post is saved.I am using the Kadence Blocks plugin in addition to ACF on my sites. With ACF, I create custom blocks using PHP. The filter mentioned above silently stripped block configuration stored in block comment attributes but only when one of my ACF blocks is present in the Gutenberg editor. In the case of Kadence Blocks, this means that layout settings, column counts, background colors, spacing, and unique IDs are permanently lost on every save.
I was able to identify this issue by logging
wp_insert_post_dataat priority 1 (before any other filters) and priority 10. At priority 1 block attributes were still intact. After the Widget Options closure at priority 10 they were stripped. Confirmed viaReflectionFunctionpointing togutenberg-toolbar.php:383.The problem can be fixed by disabling “Gutenberg Page & Post Block Options” in the Widget Options settings.
Environment:
- WordPress 6.9.4, PHP 8.3.30
- Widget Options (latest)
- Kadence Blocks 3.6.6
- ACF PRO 6.7.1
You must be logged in to reply to this topic.