EDITOR_SETTINGS_DEFAULTS makes it impossible to hide the custom fields toggle #33830
Closed
3 tasks done
Labels
[Feature] Meta Boxes
A draggable box shown on the post editing screen
[Type] Bug
An existing feature does not function as intended
Is there an existing issue for this?
Have you tried deactivating all plugins except Gutenberg?
Have you tried replicating the bug using a default theme e.g. Twenty Twenty?
Description
Summary
The "Custom Fields" settings is designed to be hidden by an editor setting set in WP.org core PHP code, however it cannot be hidden, due to these factors:
Therefore, to hide the "Custom Fields" setting, it wants an undefined to be sent in
getEditorSettings().enableCustomFields
, but it is impossible to send one.Field In Question
Visit the Post Editor -> Click the three dots menu in the top right -> Click preferences at the bottom -> A modal appears -> Click the Panels section on the left side -> See a "custom fields" toggle.
Mechanism
getEditorSettings().enableCustomFields === undefined
, then it is hidden. Code 1, Code 2.enableCustomFields
editor setting.meta-boxes-section.js
checks forgetEditorSettings().enableCustomFields === undefined
, so this seems like a perfect match. However, its state is initialized with a default value of false, so if php does not send a value, false is the value seen bymeta-boxes-section.js
. PHP does not haveundefined
, it hasnull
, but that's not sufficient to pass the check.Step-by-step reproduction instructions
Have a WordPress.org installation.
Create
wp-content/plugins/disable-custom-fields.php
unset( $editor_settings['enableCustomFields'] );
always runs.$editor_settings['enableCustomFields']
is unset by this core code.)Expected Behavior
Expected to see: The entire "Custom Settings" option does not appear, because
$editor_settings['enableCustomFields']
is unset by this core code, and the display of the field is guarded byenableCustomFields
beingundefined
: part1, part2.Current Behavior
Actually see: The "Custom Settings" open does appear, even if I do my best to make
$editor_settings['enableCustomFields']
undefined.I believe it's because the default settings ensure that
enableCustomFields
becomes false if not set. I highly suspect it's impossible to send$editor_settings['enableCustomFields'] === undefined
to gutenberg, because the defaults kick in and always overwrite unset values withfalse
, the default, and php does not have an undefined value, only null or not set at all.Screenshots or screen recording (optional)
No response
Code snippet (optional)
No response
WordPress Information
No response
Gutenberg Information
No response
What browsers are you seeing the problem on?
No response
Device Information
No response
Operating System Information
No response
The text was updated successfully, but these errors were encountered: