[wp-trac] [WordPress Trac] #53479: Unable to add widgets after Opting out of the Widgets Block Editor in WordPress 5.8-Beta2
WordPress Trac
noreply at wordpress.org
Tue Jun 22 14:11:06 UTC 2021
#53479: Unable to add widgets after Opting out of the Widgets Block Editor in
WordPress 5.8-Beta2
--------------------------+-----------------------------------------
Reporter: jamesros161 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Customize | Version: trunk
Severity: blocker | Keywords: needs-patch has-screenshots
Focuses: |
--------------------------+-----------------------------------------
So, in the process of testing our theme Crio to ensure compatibility with
WordPress 5.8 once it is released, I seem to have stumbled upon a rather
breaking bug in the Customizer > Widgets panel when opting out of the new
Widgets Block Editor.
Long story short, some of our custom controls don't play nicely with the
new widget editor, so we are choosing to opt-out of the new widget editor
at the time of the 5.8 release, to give us time to overhaul the controls
to be more Gutenberg friendly. In the following ticket,
[https://core.trac.wordpress.org/ticket/53424], it has been made clear
that the instructions for opting out are not correct in the documentation,
so instead of hooking the `remove_theme_support` to `after_setup_theme`
hook as instructed in the article, I am hooking to `widgets_init` as
suggested by @Mamaduka in the ticket thread. This seems to work fine to
force the traditional widget editor to be used, however; anytime I try to
add a widget, I receive an 'invalid data' error, and the added widget does
not save. I tested this in our theme, Crio, and then I also tested it on
Twenty Fifteen ( I chose an older default theme, because I wanted to test
this on a theme that also did not have block support built in to it, but
afterwards I tested in Twenty Twenty One as well, and had the same results
). and was able to replicate in both, which is why I believe it is a core
bug.
So.... Steps to replicate.
1. Install any theme, however i've only tested this with Crio, Twenty
Fifteen, and Twenty Twenty One.
2. Create a function in the functions.php ( or wherever is most fitting
for your theme ), in that function place `remove_theme_support( 'widgets-
block-editor' );` and then add that function as an action on the
`widgets_init` hook.
3. Open the customizer, and as expected, you should see the old familiar
widgets interface.
4. Attempt to add a widget. Any widget will do.
5. After adding the widget, the 'Invalid value' error will display within
that widget's box in the customizer panel, and the widget will fail to
appear in the preview pane.
NOTE: While there are no console or PHP errors logged at this point, there
is a customizer_changeset XHR response, indicating that for the widget
added, there is an invalid_value object with the message being 'invalid
value' and the data being 'null'
My particular response was as follows:
{{{
{"success":true,"data":{"contents":{"widget[media_gallery-3]":[""]},"errors":[],"setting_validities":{"sidebars_widgets[sidebar-1]":true,"widget_media_gallery[3]":{"invalid_value":{"message":"Invalid
value.","data":null}}},"nav_menu_instance_args":[]}}
}}}
7. Upon trying to then publish, the 'Unable to save due to 1 invalid
setting' error is displayed. Once again, no console log errors or php
errors logged at this point, but this time an admin_ajax.php XHR response
indicated the same error as before. My particular response was this:
{{{
{"success":false,"data":{"message":"Unable to save due to 1 invalid
setting.","code":"transaction_fail","setting_validities":{"sidebars_widgets[sidebar-1]":true,"widget_media_gallery[3]":{"invalid_value":{"message":"Invalid
value.","data":null}}}}}
}}}
I am also attached some screenshots, and a gif demonstrating this.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/53479>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list