Repository navigation
Conversation
|
|
||
| return { | ||
| // This setting should not live in the block editor's store. | ||
| areCustomFieldsRegistered: getEditorSettings().enableCustomFields !== undefined, |
There was a problem hiding this comment.
What's the purpose of the previous enableCustomFields setting?
I assume it's meant to be set in WordPress Core. is there code we need to remove from there?
There was a problem hiding this comment.
supportsCustomFields defines if the post type supports this feature. enableCustomFields is the setting if this meta-box is visible. Before enableCustomFields had the default value false we checked with !== undefined if the post type supports this feature. Now enableCustomFields can't be undefined anymore, so we need to check supportsCustomFields.
We still need enableCustomFields for checking if the meta-box should be visible. This logic is already merged into core.
There was a problem hiding this comment.
Ok, makes sense. Changes look good to me. I'll wait for @talldan or @noisysocks to confirm.
There was a problem hiding this comment.
Thanks for looking into this!
Unfortunately we can't rely on checking if the CPT supports custom fields because plugins will disable custom fields by modifying the $wp_meta_boxes global during the do_meta_boxes action.
You can see this problem by following these steps:
- Check out this branch
- Install the Advanced Custom Fields plugin
- Create a new Field Group with a filed in it by going to Custom Fields > Add New
- Create a new post by going to Posts > Add New
- Select More tools & options > Options
Expected result: There should be no Custom Fields checkbox because ACF replaces the Core Custom Fields functionality.
Actual result: There's a Custom Fields checkbox which doesn't do anything.
This is why WordPress will check the $wp_meta_boxes global and unset the enableCustomFields editor setting (making it undefined) if custom fields were disabled by a plugin:
Are we able to stick with the undefined|true|false approach that existed before #14082? I think that the error is in having the default setting for enableCustomFields be false. The default should be undefined.
|
Still having this issue on Version 5.3.2. My custom post type And I can see the Options checkbox to activate 'Custom Fields'. Am I missing something? |
|
Hello everyone. What is needed to move this PR forward? It would be great with an update @Soean @ntsekouras Nik perhaps this is a PR you are able to move forward? |
Hey Paal. I think some other person with previous work on custom fields could be more effective here. I'll keep this in my queue though. |
Description
Fixes #16333
The custom field option should only be visible, if the post type supports this feature. The old solution doesn't work anymore, because
enableCustomFieldshas now a default valuefalse(added in #14082).So this new solution checks the supports array of the post type for the value
custom-fields.How has this been tested?
Register a post type without custom field support, so the option should be hidden. If you add the custom fields support, the option should be visible.
Screenshot