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 fieldCustom Field Custom Field, also referred to as post meta, is a feature in WordPress. It allows users to add additional information when writing a post, eg contributors’ names, auth. WordPress stores this information as metadata. Users can display this meta data by using template tags in their WordPress themes. solutions on top of WordPress. That project was nicknamed “Metamorphosis” and subsequently went by the “Metadata UIUI User interface/APIAPI An API or Application Programming Interface is a software intermediary that allows programs to interact with each other and share data in limited, clearly defined ways.” project. As pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party 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 coreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress.. 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):

  • CustomizerCustomizer Tool built into WordPress core that hooks into most modern themes. You can use it to preview and modify many of your site’s appearance settings. (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, Networknetwork (versus site, blog) 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 APIREST API The REST API is an acronym for the RESTful Application Program Interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data. It is how the front end of an application (think “phone app” or “website”) can communicate with the data store (think “database” or “file system”) https://developer.wordpress.org/rest-api/. and giving apps like the WordPress iOSiOS The operating system used on iPhones and iPads. app access to metaMeta Meta is a term that refers to the inside workings of a group. For us, this is the team that works on internal WordPress sites like WordCamp Central and Make WordPress. 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 GitHubGitHub GitHub is a website that offers online implementation of git repositories that can easily be shared, copied and modified by other developers. Public repositories are free to host, private repositories require a paid subscription. GitHub introduced the concept of the ‘pull request’ where code changes done in branches by contributors can be reviewed and discussed before being merged be the repository owner. https://github.com/ 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 SlackSlack Slack is a Collaborative Group Chat Platform https://slack.com/. The WordPress community has its own Slack Channel at https://make.wordpress.org/chat/. #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 pingPing The act of sending a very small amount of data to an end point. Ping is used in computer science to illicit a response from a target server to test it’s connection. Ping is also a term used by Slack users to @ someone or send them a direct message (DM). Users might say something along the lines of “Ping me when the meeting starts.” us in #core-fields throughout the week with questions or concerns.

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

Call For Bugs

At the start of the 4.3 cycle, I posted an open call for tickets that generated a list of 74 tickets including 25 bugs. All of the bugs reported have received some sort of comment since then, so it’s time to add onto the list. Starting with next week’s bugbug A bug is an error or unexpected result. Performance improvements, code optimization, and are considered enhancements, not defects. After feature freeze, only bugs are dealt with, with regressions (adverse changes from the previous version) being the highest priority. scrubs we will use these bugs (along with the original list of 25) and continue to work on making sure they move forward.

If you have a bug that needs eyes on it, please comment with the ticketticket Created for both bug reports and feature development on the bug tracker..  In the immortal words of @wonderboymusic: “Help us help you.”

#4-3

Dev Chat Agenda for May 27

Here’s the agenda for today’s Dev Chat in the #core channel on Slack.

Time/Date: May 27 2015 20:00 UTC:

  1. #32396: Settings Reduction for 4.3
  2. Feature Updates
    1. Adminadmin (and super admin) UIUI User interface@helen
    2. Multisitemultisite Used to describe a WordPress installation with a network of multiple blogs, grouped by sites. This installation type has shared users tables, and creates separate database tables for each blog (wp_posts becomes wp_0_posts). See also network, blog, site Admin UI – @jeremyfelt
    3. Partial Refresh – @westonruter
    4. Menu CustomizerCustomizer Tool built into WordPress core that hooks into most modern themes. You can use it to preview and modify many of your site’s appearance settings.@celloexpressions / @westonruter / @voldemortensen
    5. Passwords – @markjaquith
    6. Site Icon – @johnbillion
  3. Component Updates

Feature Leads: Let’s review last weeks goals and set new ones for next week.

#4-3, #agenda

Multisite Office Hours Recap (May 26, 2015)

Multisitemultisite Used to describe a WordPress installation with a network of multiple blogs, grouped by sites. This installation type has shared users tables, and creates separate database tables for each blog (wp_posts becomes wp_0_posts). See also network, blog, site office hours are held every Tuesday at 20:00 UTC in #core-multisite.

Today’s chat log

Overall 4.3 Release Objectives

Last week’s objectives for dev chat:

  • Continued work on mock-ups, discussion around edit site and add site flows.
  • Android and iPad flows posted to Make/Flow.
  • Conversation around and updated `WP_Network` patchpatch A special text file that describes changes to code, by identifying the files and lines which are added, removed, and altered. It may also be referred to as a diff. A patch can be applied to a codebase for testing. and a first attempt at `WP_Site`.

Today’s meeting agenda:

  • Arbitrary domain/path combinations. #22383 (and now #32434)
  • `WP_Network` #31985 and `WP_Site` #32450
  • Thoughts on how to track scheme for a site. #14172
  • More flows (and tickets) needed. 🙂

Topic Details:

Arbitrary domain/path combinations in edit site:

  • Tickets: #22383, #32434, #32503
  • chat log
  • @hugubaeta explored things some more and left some good feedback on #22383. We agreed to push ahead with the single entry for scheme, domain, and path in #22383.
  • During that discussion, we started to address the question of the checkbox for updating home and siturl. This resulted in #32503. After some further discussion there, we’re going to try removing that checkbox entirely and using some logic to determine when to update home and siturl. @earnjam is working on the patch for this.
  • @ocean90 is working on updating a patch for #32434 after discussion there and in #22383.

Progress on `WP_Network` and `WP_Site`:

  • Tickets: #31985, #32450
  • chat log
  • second chat log
  • Initial brief conversation. @earnjam is going to take a closer look at the existing patches. We need to start brainstorming where `WP_Network_Query` starts.
  • Continued this conversation with @johnjamesjacoby later in the day. He’ll be working on the patches a bit more this weekend as well.
  • #25293 was brought up to consider so that the correct networknetwork (versus site, blog) ID is available after `switch_to_blog`. Also #14867 to ensure the correct scheme is attached to the site object.

Thoughts on how to track scheme for a site:

  • Tickets: #14172
  • chat log
  • @johnbillion agreed that `wp_blogs` seemed like the right place to track scheme. We’ll need to worry some about the upgrade process, though larger networks should be able to handle something like this.
  • Some more discussion on the ticketticket Created for both bug reports and feature development on the bug tracker. would be great. We should get a patch going sooner than later. This is up for grabs, claim it in the comments! 🙂

More flows for Make/Flow:

  • chat log
  • @ubernaut is almost done with iPhone 5s videos.
  • @johnbillion mentioned trying some recordings with Android.
  • @jeremyfelt is still claiming that he’ll do an iPad capture one night.
  • We need to get more of these up on Make/Flow to capture a good visual record. As they go up, please create tickets for things that look off. Even if you haven’t posted a flow of your own, please browse through the existing ones and look for issues.

Thanks to everyone in office hours today! Chime in with any comments, tickets, etc… or join us in #core-multisite. 🙂

#multisite