Repository navigation
Simple payments: allow read+write access to meta fields via REST API - #10402
Conversation
|
Caution: This PR has changes that must be merged to WordPress.com |
|
Thank you for the great PR description! When this PR is ready for review, please apply the Scheduled Jetpack release: December 4, 2018. Generated by 🚫 dangerJS |
|
Caution: This PR has changes that must be merged to WordPress.com |
| * @link https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-responses/ | ||
| */ | ||
| public function register_meta_fields_in_rest_api() { | ||
| register_meta( 'post', 'spay_price', array( |
There was a problem hiding this comment.
Noting that there seem to be double indentation here (two tabs nesting instead of 1)
jeherve
left a comment
There was a problem hiding this comment.
Adding my 🚢 👍 back. Merge when ready.
|
Caution: This PR has changes that must be merged to WordPress.com |
|
While this does test well, I'm a bit cautious to merge without fully understanding implications of just casting Seems like this value should hold either floats or integers depending on another field. |
...since it's been there since WordPress 3.3.0 https://developer.wordpress.org/reference/functions/register_meta/
9eb3ab7 to
e203f95
Compare
|
I've rebased this without the changes in #10555, which have changed some and are significant enough to warrant an independent PR. |
jeherve
left a comment
There was a problem hiding this comment.
Works for me. Merge when ready.
…10402) Enable Simple payments custom meta values for access through the REST API. Field’s value will be exposed on a `.meta` key in the endpoint response and WordPress will handle setting up the callbacks for reading and writing to that meta key. This is needed for Simple Payments block to be able to read+create+update Simple payment buttons through the REST API. https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-responses/ https://developer.wordpress.org/reference/functions/register_meta/
|
Cherry-picked to |
Enable Simple payments custom meta values for access through the REST API. Field’s value will be exposed on a
.metakey in the endpoint response, and WordPress will handle setting up the callbacks for reading and writing to that meta key.This is needed for Simple Payments block to be able to read+create+update Simple payment buttons through the REST API.
https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-responses/
https://developer.wordpress.org/reference/functions/register_meta/
Changes proposed in this Pull Request:
Enable Simple payments custom meta values for access through the REST API.
Testing instructions:
[simple-payment id="42"])metafield is missing Simple payments meta fields, with the change you should see:You should be able to write to this object as well. The easiest way to test reading+creating+writing would be following instructions from Automattic/wp-calypso#28065
Proposed changelog entry for your changes:
Enable Simple payments custom meta values for access through the REST API.