Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default value of enableCustomFields to undefined #33931

Merged
merged 4 commits into from
Aug 25, 2021

Conversation

mreishus
Copy link
Contributor

@mreishus mreishus commented Aug 6, 2021

Problem

When using a plugin to disable Custom Fields in the post editor, WordPress attempts to change $editor_settings to tell Gutenberg not to render the Custom Fields settings toggle in a preferences modal. However, Gutenberg is listening for a value that is impossible to send in PHP, and the settings toggle remains visible even when the feature itself is disabled.

This change makes it so when PHP uses unset() to not send a value, then undefined is the value, allowing the field to be hidden.

Steps to reproduce and more context

Please see #33912. This is tackling the same problem but in a different way.

@mreishus
Copy link
Contributor Author

@getsource How can I help move this one forward?

@getsource
Copy link
Member

@mreishus My apologies for the wait on a reply -- I was out for a few days and got back today.

Just left a comment here since I wasn't totally clear on the feedback.

@skorasaurus skorasaurus added the [Feature] Meta Boxes A draggable box shown on the post editing screen label Aug 18, 2021
@noisysocks
Copy link
Member

I haven't tested it but this looks right to me 👍

Could you please add a comment explaining the difference between true, false and undefined?

@mreishus mreishus force-pushed the fix/hide-custom-fields-2 branch from aef3920 to 40d8269 Compare August 19, 2021 19:19
@mreishus
Copy link
Contributor Author

Could you please add a comment explaining the difference between true, false and undefined?

Sure, added in 40d8269 - was a bit unsure about location.

@getsource getsource added the [Type] Bug An existing feature does not function as intended label Aug 20, 2021
@getsource getsource linked an issue Aug 20, 2021 that may be closed by this pull request
3 tasks
Copy link
Member

@noisysocks noisysocks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works great! Thanks for the PR.

I tested by installing Advanced Custom Fields which disables custom fields in favour of its own meta boxes.

One (existing) issue I noticed is that we still show the "Additional" section in Preferences when custom fields are disabled and there are no meta boxes. I pushed up a fix for that.

@getsource
Copy link
Member

Ah, sorry, we were testing at the same time!

I tested as well, with the most recent changes, using the plugin provided in #33912 by @mreishus and it looks to work as expected.

Thank you both!

@mreishus
Copy link
Contributor Author

  • Tweaked comments (0659d1c)
  • Tested new changes
    2021-08-24_09-33
    ^ BEFORE: When undefined, the toggle was hidden, but the section header was appearing

2021-08-24_09-34
^ AFTER: When undefined, the toggle and the section is hidden

2021-08-24_09-34_1
^ AFTER: When displayed, the toggle and section appear as before

👍

I do not have the capability to merge, so I'll need you help when it's time for that @noisysocks. :)

@noisysocks
Copy link
Member

Thanks @mreishus!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Meta Boxes A draggable box shown on the post editing screen [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EDITOR_SETTINGS_DEFAULTS makes it impossible to hide the custom fields toggle
4 participants