-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Should WP Core "Custom Fields" UI be present by default? #3228
Comments
Hi tomjn, Thank you for bringing this up. This is something I probably overlooked while implementing the meta boxes. Since most of the core meta boxes have been replaced by JS counterparts, one of the goals was to filter out any core meta boxes. This I believe is currently filtered out, if you want to re-enable it use the Maybe it should be enabled by default though as it has not been replaced yet, nor will it probably be replaced on the JS side of things. |
+1, a lot of older sites with no active devs rely on this functionality, and without it they'll break |
I rely on it, since I'm using really simple text custom fields (for instance, to memorize the original title of a movie I'm reviewing). This is probably the last item I need to use Gutenberg on a daily basis. |
I took a shot at Itmw, even when I commented out Can we get some specialist help here @BE-Webdesign tyvm. |
Sounds like a good idea. |
How will these fields be editable through the REST API? |
To clarify, the REST API doesn't permit arbitrary modification of custom fields. Custom fields must be registered with register_meta before they're accessible through the REST API. See https://core.trac.wordpress.org/ticket/35658 for the long, sordid history. If we want to keep arbitrary modification of custom fields, we'll need to save the data through the standard form submission process. This is an important detail to reflect in the design process. |
Right now, "core meta boxes" are being filtered out, I think the easiest potential solution is to not filter out the custom fields meta box, only if the post type supports custom fields. |
My current thinking is that we should leave the Custom Fields disabled entirely by default, but then make it easy to re-enable with a WordPress.org plugin. Because we don't have a Screen Options API (#5841) the Custom Fields metabox would always be visible if we restore it in Gutenberg. |
I've documented this in the Gutenberg migration guide. |
The design by @jasmussen doesn't feature a metabox, so that's not really a concern. There's no need to break BC here. Instead I think we need to make those fields accessible in the REST API through a separate property. Native custom fields are heavily relied on by Yoast SEO power users in metadata management. It would be a big regression for those users if this stuff is no longer core. I've asked @felixarntz to look into making the fields accessible through the REST API. |
@omarreiss Do you acknowledge and understand the following statement?
Any implementation would need to continue to use |
@danielbachhuber I don’t understand why they must be. Can’t make that up from the thread either. Could you enlighten me? |
@omarreiss Did you read WP-API/WP-API#1425 and WP-API/WP-API#2149 ? |
Keep in mind that for a lot of custom fields added this way, the only corresponding code is In those cases I think the classic method of doing things and showing any that don't have |
My preference is still:
|
Scanned through, still can’t see why we couldn’t do it. Maybe you could explain your point of view (and not make a fellow contributor feel stupid / ignorant with rethorical questions)? |
Thanks for pushing me on this, @omarreiss. I took the opportunity to do a bit more research and share my findings. First, I created a new post with ID
Of these test values, only two ( This logic is defined in the
Strings, integers, and serialized strings are editable through the Classic Custom Fields meta box. Objects and arrays are not. Ryan McCue's post, "The (Complex) State of Meta in the WordPress REST API", is a great articulation of these nuances around meta handling. I'll defer further explanation there. In order to make strings, integers, and serialized strings editable through the REST API, we'd need to do the following:
To my knowledge, the REST API doesn't yet support these requirements, and interacting with custom fields over REST requires use of Notably, when arbitrary custom fields are exposed in a At the end of the day, this is why I think it's more straightforward to use the existing Custom Fields Metabox when it's absolutely necessary, instead of trying to solve for REST API support and recreating the user interface. Hope this helps clarify. Happy to take any follow-up questions you might have. |
I completely agree with this. I'm thinking that we could expose those unregistered metadata in a separate property outside of To clarify, while metadata are essentially custom fields, only post types that support |
@danielbachhuber Thanks a lot for sharing your context. So, I've changed my mind... a bit. Here's what I'm thinking:
|
💯 I love this idea. This seems like an excellent approach from a UX perspective. |
I would also note that Gutenberg is just UI, it wouldn't delete or erase things, and it's only active on an edit screen, the same way that if you create a custom field with a key starting with |
Whew! When will Custom Fields be available in Gutenberg beta? I don't see them now, which is why I worry. |
Unknown at this time. It's just one of many things that need to be worked on. |
@bkjproductions A few of us were actually just talking about the best way to implement it this afternoon. Hopefully we'll have a working example up soon that we can iterate on. |
Custom Fields are returning indirectly through #10210. Once Screen Options are restored, the Custom Fields meta box can return. |
Wondering about the statement by @omarriess, I don't see that they have anything to do with Gutenberg because they are used in many different ways-- not necessarily as displayable content-- or why they would need to prove themselves. They're very useful semi-structured data, in that people are attaching all sorts of data to a Post, and can do so without having to register them ahead of time (easy for the novice to understand). Sometimes the data is content and sometimes the data is just data. Examples: I have a client who creates custom fields seemingly at the drop of a hat, and we are able to then take that field and display it in a certain area of the page, with very little coding effort. One example is that he creates a custom field called "link" and then populates it. So a Post may have four or five links. On the coding side, in PHP we loop through the custom fields and output the links in an unordered list. Now that he knows this is possible, it makes the layout of the page much more consistent, because he can put those links in an area separate from the regular "body" content, and as a bonus now we can generate a list of links from all Posts. In another situation, a client chooses a color for the page, adding a custom field called "color" and puts in "red" or some other color. Then we take that custom field value and add it as a class to the BODY tag of the page. Our stylesheet then can affect the look of the page based on the body class. At one site, there is a custom field called "notes" that may or may not be on all Posts. This can contain non-published information about the Post, and the ability to have it or not is very useful. If custom fields are buried in a panel in the Post Editor, then we lose the immediacy of seeing the note. Another use is to simply count the number of views of a post, hooking into the "loop" and incrementing a value held in custom field "pageviews" -- which also allows the author to re-set this if needed. I was actually wondering at the beginning of Gutenberg if you were going to turn every block into a custom field. Something like that would give you a lot of power, because then the blocks would be useful, granular, data that could be displayed or simply used as data. Of course then you'd probably need to expand the key-value nature of it to include sort and taxonomy, etc. Anyway, glad to hear that they are returning. Please keep them visible rather than buried in a settings panel or dialog box. |
Just a note that I'm working on this as part of #10210. |
What is the status of Custom Fields for WordPress 5.0? I see the new options panel from #10210 in beta 1, but no clear way to enable a Custom Fields UI. Workarounds such as https://wordpress.org/plugins/custom-fields-gutenberg/ don't currently work with 5.0 (they deactivate if the Gutenberg plugin is not active, probably because custom fields were promised for 5.0 so they're intended as temporary workarounds). As a result it appears there's no way to edit custom fields in WP 5.0 at this time. |
Custom Fields were a part of #10676 but had to be reverted due to a performance regression (see #10676 (comment)). I'm currently exploring some different approaches, and will have an update soon. Stay tuned! |
Very anxious about this! If WP 5.0 ships without custom fields, does installing the Classic Editor plugin bring them back? |
@bkjproductions Classic Editor will show all metaboxes correctly, including Custom Fields. I also think it's unlikely we'll ship 5.0 without having a solution for custom fields, but don't quote me on that! |
So what's the deal? Still no custom fields in native support and we're now in 5.2.1.... This has been dropped off the radar too. What's going on? |
@leecollings It is there. You have to click the three dots on the top right of the screen to bring up the global menu. Then, click on |
Issue Overview
Core provides a default custom fields metabox, but it has no equivalent in Gutenberg
Current Behavior
Plugin metaboxes get shown, but this one is missing, and the screen options tab to turn it on isn't in Gutenberg
Todos
The text was updated successfully, but these errors were encountered: