This post summarizes the weekly REST 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/. chat meeting for November 7, 2019. (Slack transcript, Agenda). Weekly REST API component office hours are held every Thursday at 18:00 UTC in the #core-restapi room in the Make WordPress Slack Slack is a Collaborative Group Chat Platform https://slack.com/. The WordPress community has its own Slack Channel at https://make.wordpress.org/chat/..
A new wp-api/authentication GitHub repository was created last week to facilitate the design & development of a REST API authentication solution for WordPress Core Core is the set of software required to run WordPress. The Core Development Team builds WordPress..
We continue to be in the information gathering stage. For all interested in contributing to this effort, we will be using part of our weekly REST API office hours each Thursday at 18:00 UTC (Thursday, November 14, 2019, 01:00 PM EST) as a weekly standup to coordinate work.
We also invite you to log issues describing use cases the authentication solution should support.
Registered Block Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. Types REST API
#47620 aims to create REST API routes to discover the list of registered block types. It is based off the Gutenberg Block Type Registration RFC. @spacedmonkey worked on a patch 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 is in the process of soliciting feedback from the Gutenberg The Gutenberg project is the new Editor Interface for WordPress. The editor improves the process and experience of creating new content, making writing rich content much simpler. It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc. https://wordpress.org/gutenberg/ team, Mobile team, and other members of the REST API team.
A particular point of concern @spacedmonkey brought up was the difficulties about handling the asset fields (
style ). The RFC defines the fields as either absolute URLs or relative paths to the source files. However the
WP_Block_Type class defines those fields as asset handles.
Further the asset URL A specific web address of a website or web page on the Internet, such as a website’s URL www.wordpress.org or handle is not sufficient to make the asset functional. The list of dependencies, inline scripts, translations, and localized data are all necessary for the script to work.
@timothyblynjacobs mentioned that the RFC discusses statically discovering that information from an associated
.asset.json file located “next” to the script file. @aduth mentioned that section is slightly out of date since
@wordpress/scripts now outputs a
The participants discussed whether it would be better to include this additional information inline in the Block Type response, or to develop a separate
wp/v2/dependencies API 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..
@timothyblynjacobs suggested that including this information inline would be simpler. @spacedmonkey pointed out that then we’d be including full data from a separate resource within the block type response. Elsewhere in the REST API that would be handled by creating a separate API and linking to it.
Additionally, @timothyblynjacobs pointed out that just exposing the list of dependencies isn’t sufficient. The client needs access to the entire dependency graph to ensure each dependency’s dependencies are loaded, and that all scripts are loaded in the correct order.
This all points to a dedicated REST API endpoint being a better solution. The team then discussed the potential privacy and security ramifications about retrieving this information about any registered asset.
A developer may include sensitive data in a
wp_add_inline_script after registering the script with
wp_register_script. Currently, this data would only be exposed when the script is enqueued, which may be protected by a
$hook-suffix check. If the REST API allowed returning information about an arbitrary asset handle, this data may be exposed.
Additionally, a developer may conditionally registers asset based on a plugin 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’s settings. By allowing a user to check if a handle is registered via the REST API, it may be possible to determine the setting configuration of a plugin. This may not be desirable for security or privacy related plugins.
@kadamwhite mentioned that historically the REST API has been pretty conservative about what data is exposed. If possible, he’d like to continue along that path. Or theoretically authentication could be required for some pieces of the API since the use case seems to mostly be for editorial interfaces which would require auth anyway. @spacedmonkey also suggested a capability check.
@spacedmonkey and @timothyblynjacobs proposed limiting the assets exposed to ones registered via
WP_Block_Type and all WordPress Core assets. Additional assets could be exposed via a registration flag of some kind, like
@youknowriad opened a ticket Created for both bug reports and feature development on the bug tracker., #48654, to continue the discussion on Trac An open source project by Edgewall Software that serves as a bug tracker and project management tool for WordPress..
Agenda for November 21
The next REST API meeting is happening in
#core-restapi at Thursday, November 21 at 18:00 UTC. Agenda:
- REST API Authentication project weekly meeting
- Menus API discussion
- WP Dependencies API
- Review open tickets which should be provisionally milestoned for 5.4
- Open floor