-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Advanced Panels: Add support for the 'Custom Fields' meta box #11084
Conversation
39f67ed
to
691e42b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense unless we have REST API support for custom fields which I don't really expect it to come in 5.0 (or later?)
I'm adding some reviewers more familiar with the PHP side of things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Few things to address.
packages/edit-post/src/components/options-modal/options/enable-custom-fields.js
Outdated
Show resolved
Hide resolved
@@ -1573,14 +1573,27 @@ function gutenberg_editor_scripts_and_styles( $hook ) { | |||
'maxUploadFileSize' => $max_upload_size, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw the error mentioned for other meta boxes elsewhere. I wonder if it's a more generic bug in 5.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did you get this error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bug in 5.0, fixed now.
Noting to myself that since this touches the PHP we'll need to bring over these changes to the 5.0 branch. |
Feedback has been addressed 🙂
How do we feel about this? Would like to get it into the 5.0 RC. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a look at the front-end side of things. The changes seem to be pretty minor there. Looks good to me - seems mergeable if the backend changes also look acceptable.
packages/edit-post/src/components/options-modal/options/enable-custom-fields.js
Outdated
Show resolved
Hide resolved
How does this approach take into account a custom post type where
I would expect the option to not show up in the first place, but from a quick view into the code, I can't see a toggle for that. In the classic editor, when I go to the screen options, the "Custom Fields"-option disappears when the support has been removed. |
- Adds an option which allows the user to enable the existing 'postcustom' meta box included in WordPress. - Don't load the 'postcustom' assets when the option is disabled. - Stores the option as a site option. - Reload the editor when the option is changed.
The 'Enable Tips' checkbox is obscured by the first Tip now that the Options modal is taller. Work around this by only testing that tips can be re-enabled.
We can simply interpolate $post->ID when initializing Custom Fields, rather than selecting from the #post_ID hidden field.
By using `get_user_meta()` instead of `get_option()`, the Custom Fields setting won't affect other users.
Trigger the toggle_custom_fields action using a hidden <form> so that the action is triggered by a POST request rather than a GET request.
292485a
to
c01629c
Compare
c01629c
to
6368b56
Compare
Thanks all. I've responded to feedback and fixed the problem where Custom Fields would display in post types that don't support One issue I've noticed: when the Advanced Custom Fields plugin is enabled, the Custom Fields toggle is displayed even though it doesn't do anything. This is because the ACF plugin removes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, it's undergone a lot of reviews and feedback looks all addressed 👍
🙈 |
Created a follow-up issue for this here: #11386 |
Lastly, created a ticket to remind ourselves to copy over the necessary PHP changes to Core: https://core.trac.wordpress.org/ticket/45257 |
Closes #3228.
Adds an option which allows the user to enable the existing 'postcustom' meta box included in WordPress.
I've implemented this using the super hacky approach described in #10676 (comment) 😎
The benefits of this approach are that:
The downsides are that: