Metadata API project reborn: The new Fields API project

Many of you will remember that a couple of years ago, @ericlewis and a group of us set out to start a project to make sense of all of the different APIs that arose from third party plugins and themes to build custom field solutions on top of WordPress. That project was nicknamed “Metamorphosis” and subsequently went by the “Metadata UI/API” project. As plugin authors dealing with and using custom fields and content types, we had been tackling the issues of developing for multiple object types in WordPress for years prior to getting together.

Now, @helen and I are pleased to (re)introduce to you what we’re hoping to be the fruits of all of this labor: Meet the new Fields API project.

function fields_api_example_post_field_register( $wp_fields ) {

   // 1. Define a new section (meta box) for fields to appear in
   $wp_fields->add_section( 'post_type', 'my_cpt', 'my_meta_box',
      array(
         // Visible title of section
         'title'       => __( 'My Meta Box', 'mytheme' ),

         // Determines what order this appears in
         'priority'    => 'high',

         // Determines what order this appears in
         'context'     => 'side',

         // Capability needed to tweak
         'capability'  => 'my_custom_capability'
      )
   );

   // 2. Register new fields
   $wp_fields->add_field( 'post_type', 'my_cpt', 'my_custom_field',
      array(
         // Default field/value to save
         'default'    => 'All about that post',

         // Optional. Special permissions for accessing this field.
         'capability' => 'my_custom_capability',

         // Optional. Add an associated control (otherwise it won't show up in the UI)
         'control' => array(
            // Don't set 'id' and it will automatically be generated for you as
            'id' => 'mysite_my_custom_field',

            // Admin-visible name of the control
            'label'   => __( 'My Custom Field', 'mytheme' ),

            // ID of the section this control should render in (can be one of yours, or a WordPress default section)
            'section' => 'my_meta_box',

            // Control type
            'type'    => 'text'
         )
      )
   );

}
add_action( 'fields_register', 'fields_api_example_post_field_register' );

(Please note: The code above may not be the same as the final implementation, it will especially change over the next few weeks)

First of all, we split off the UI side of the project to focus solely on the API. This way, we’re not held up by anything as we move towards implementation inside of core. We can tackle each UI separately and that helps us keep the project nimble and on track.

The goals of this new API proposal will be to be implemented across WordPress objects as an API to register fields and sections for. We aim to cover these objects (not necessarily in this order):

  • Customizer (retrofitting it beneath the existing Customizer API)
  • User profile screen
  • Post editor
  • Settings screens (retrofitting it beneath the existing Settings API)
  • And other areas in the future (Comment editor, Network Settings screens [see #15691], Media modals, etc)

This API offers a great deal of standardization across all of WordPress and code reusability. It’s paramount for third-party developers, who will be able to utilize these structures in their own plugins and themes, build apps and give access to other developers so they can contextually see what a site really contains. I see the biggest use-case being able to expose the entirety of WordPress to the REST API and giving apps like the WordPress iOS app access to meta boxes and custom fields to display real editor screens with field inputs based on the control types natively.

Areas we need help currently:

  • Examples and use cases for Customizer, User profile screen, Post editor, and Settings screens (submit issues in GitHub with your ideas, coordinate with us to refine them if you want)
  • Unit tests for core
  • Testing Customizer implementation, you’ll find the core files to replace under the /implementations/ folder in the repo
  • Brainstorming implementation classes for other object types to implement in the UI, starting with User profile screen

If you’re interested in joining our merry crew which includes @helen and a few of us, hop into Slack #core-fields and join our weekly meetings every Monday (Monday 20:00 UTC 2015). You can check out the Fields API and submit PRs on GitHub, or ping us in #core-fields throughout the week with questions or concerns.

#customize, #fields-api, #options-meta, #team-update

WP Metadata UI / API project update and new meeting time/place

It’s been a few weeks since we’ve posted an update, @mikeschinkel has been working hard on some new commits to give us some shortcuts for option arrays and things have stabilized there finally. We’re now focused on documenting field type development so we can get some contributors in there fleshing out the remaining field types.

We are also moving our “Office Hours” time and place, to Mondays @ 1800 UTC , but instead of IRC where people can’t sync up and collaborate, we’re moving it to our public Gitter room. Some other WP projects are using it and we’ve found it incredibly helpful to keep up with GitHub activity along with chat that can happen at all times of the day and it sticks around for you to read anytime you want to.

Our Gitter chat can be found here: https://gitter.im/wordpress-metadata/metadata-ui-api

Anyone can see the chat messages, and if you want to participate it’s just a GitHub login away. They have iOS / Mac apps too, so that’s helpful to some people as well.

If you’re interested in contributing, or if you want to check out what we’ve got and need some insight, just ping us — anytime — in Gitter 🙂

#fields-api, #options-meta

WP Metadata API / UI office hours this Friday

We will continue our weekly meetings this Friday. As no other suggestions have been made, it will remain at 18:00 UTC on Fridays in #wordpress-core-plugins on Freenode IRC.

We may be transitioning from meeting into office hours as we haven’t had as many contributors joining us at the meetings as we had hoped. We will continue developing some awesomeness over at https://github.com/wordpress-metadata/metadata-ui-api

Feel free to hop into the issues and take ownership of new field types or documentation. We’re also looking for help with styling of the form fields and JS in relation to support for repeatable fields.

#fields-api, #options-meta

WP Metadata API / UI team meeting hours vote

It was brought up that our current meeting time at 18:00 UTC on Fridays in #wordpress-core-plugins on Freenode IRC is not necessarily the best for everyone.

What day would be better? Around what time would be better?

This week’s meeting will continue as planned at the existing time on Friday, but next Friday’s meeting will be postponed due to a scheduling conflict with @mikeschinkel and I.

#fields-api, #options-meta

We’re ready for more contributors to join us on the WP Metadata UI / API project

Where we need help most

  • Field Types – We need help building new field types, we currently have a few basic fields to start off with including the Text, Textarea, URL, Date, and Hidden field types.
  • Actions / Filters – We are now seeking to add in the hooks necessary to extend things further, feel free to request hooks anywhere you see a need for them.
  • Repeatable Fields – We are architecting a solution for repeatable fields, in which you can take a single field and make it have repeatable inputs that let someone add multiple values. These values would be stored in multiple meta values for the same meta key for the specific object ID.
  • Unit Testing – If your UT fu is strong, then strong would the use of your fu be on our team!

Have any other ideas you’d like to help out with? Hop in, the world is your oyster and we’re eager to help you get those pearls!

Join us in #wordpress-core-plugins on Freenode IRC and seek out @sc0ttkclark or @mikeschinkel if you need anything to help you get started, or open up an issue on our GitHub with your questions/feedback.

We’re also still meeting 18:00 UTC on Fridays in #wordpress-core-plugins on Freenode IRC, feel free to search IRC logs for <#metadata> for a history of our previous conversations.

So… ready to start? Head over to the WordPress Metadata UI / API GitHub now, see you there! Happy coding!

#fields-api, #options-meta

Metadata UI / API status update

We’ve been hard at work the past many weeks on getting something ready for contributors to start adding their PR’s against. @mikeschinkel took the helm for the initial base, after many discussions came up with a brilliant first code PR to the project. In our Friday meeting, we presented the PR and merged it into the official master for the project.

You can start browsing through it now over at: https://github.com/wordpress-metadata/metadata-ui-api

Some notable items from this initial first draft:

  • Global functions to access class/method based architecture (register_*)
  • register_post_form( ‘meta_box_name’, ‘post_type’, $args ) — Add new forms to a post type (like meta boxes)
  • register_post_field( ‘meta_key’, ‘post_type’, $args ) — Add new fields to a post type
  • Initial support to expand the API for use with Comment types, Option Groups, and Users
  • Support for custom object types that aren’t WP object types, like for plugins that have their own custom tables
  • Very efficient registration limits ‘fixups’ until fields are called, so registering hundreds of fields won’t detrimentally affect timing (confirmed by initial benchmarking)
  • Storage handling broken up into meta, options, taxonomy terms, can be extended by plugins to add additional storage options (like in Pods, we have custom tables/columns available for custom fields)
  • WP_Html_Element class methods handle html element building and auto-sanitization for attributes

Our next steps are to continue testing the API and start having contributors join in (read: yes, YOU!). We’d like to start getting PR’s that add new field types and start working on unit testing next.

Also, a call-out to our UI / JS team, we’re ready for you now 🙂

#fields-api, #options-meta

Metadata API/UI Meeting 04/11

As discussed in the previous meetings, we’re pushing the time back one hour from 19:00 UTC to the new time at 18:00 UTC on Fridays. We’ll be in #wordpress-core-plugins tomorrow, April 11th, 2014 as usual.

We will be talking about the progress on form and field registration and move into some new modeling oriented based on objects (post types) instead of forms as previously discussed.

See you all there!

#fields-api, #options-meta

Metadata API/UI Meeting Today

We’re having a low-key meeting today, as people are out enjoying WordCamp Atlanta and others this weekend. Don’t forget about the time change, it’s still at 19:00 UTC which is 2pm CDT now with day light savings time. We’ll be in #wordpress-core-plugins as usual.

We’ll be discussing the overall API plan and ironing out some ideas that should help us be ready to discuss pros/cons of some new concerns with the structure and usage of classifiers for performance.

#fields-api, #options-meta

Metadata project meeting notes

Our meeting today was a great reboot for us, we had a small handful of people attend, with a few additional folks listening in.

Meetings

Going forward, we will now meet every Friday at 19:00 UTC, in #wordpress-core-plugins. We will talk about status of various tasks and make any big decisions necessary during these meetings.

Teams

We have split our contributors into teams to help delegate responsibilities in a more formal fashion. As a result, we have two primary teams and a “Lead” that will be responsible for vetting proposals and providing direction. We’re still figuring out the best method of communication between members of each team, but the end solution will be public and available for anyone to join and contribute to the discussions throughout the week between our official Friday meetings.

Please please please please, if you are interested in contributing, get in touch with me or any of the team leads. We are actively looking for help, so don’t be shy and jump on in.

API

The registration, initialization, input sanitization, validation, and saving processes.

UI

The markup and styling (CSS/SASS) of the meta boxes and fields that are registered by the API.

JS

The JS needed for various field types and potentially what we’ll need for repeatable fields functionality.

Tom, Justin, Micah, and Devin will be reviewing Backbone implementations they are familiar with to discern any areas we may want to implement it’s usage for potentially covering Repeatable fields.

API team GoToMeeting

Mike Schinkel will be running a GoToMeeting to go over his ideas for API direction this upcoming Thursday, March 6th, 2014 19:00 UTC, feel free to contact him or watch the recording later. We’ll post a link in the comments here next week and include it in next week’s meeting notes.

New GitHub repository

We have also moved our GitHub repo to a new location and setup teams to the corresponding members listed above. It’s now located in the WordPress Metadata org on GitHub

#fields-api, #options-meta

Metadata project update

Greetings all! I’m Scott, I’ve been involved as the secondary lead on the project, with primary co-lead Eric Andrew Lewis (@ericlewis). As of today, Eric and I have switched roles. Eric’s time has had a few schedule conflicts pop up, but he’ll still be participating.

Next Meeting

We haven’t posted any updates here since January, but I aim to get us back track, starting with a meeting this Friday, February 28th, 2014 19:00 UTC to reboot contributor involvement.

If you’re interested in joining us and contributing help, please join us, we’ll help assign people tasks and areas to participate.

Donating dev time to core

My employer, WebDevStudios, has graciously donated a block of time each week that will be devoted to me working on this project. I’m excited to be more involved and active on a core project. I’ll also be following trac tickets for the Options/Meta component on Trac to help out where I can there. I encourage others to also step up if this project is one your company or team has a vested interest in.

More info

If you’d like more information about the Metadata project currently in progress, check out our previous blog posts.

Also check out the cool dashboard for the Options/Meta API component!

#fields-api, #options-meta