Implement new-style meta with register_meta
This is a first pass at new-style meta support for the REST API.
With the new register_meta support in 4.6, we can now support meta fully, as it's actually a registered thing instead of being a vague mess.
This PR includes a brand new README as well, which documents how to use this. tl;dr set show_in_rest => true in your register_meta call, then use the meta field on the regular endpoints.
Important note: this is not ready for merge yet, and still requires security checks and further validation.
Current coverage is 100% (diff: 100%)
No coverage report found for master at 70cdd51.
Powered by Codecov. Last update 70cdd51...d2c4126
Coverage is now at 100%, ready for review I think!
I've been playing and noticed some things:
- I can update a metakey to be anything (array, object, etc) if its registered type is not string, number or bool
- a metavalue doesn't update or delete correctly, it would be nice to get a error (it does mostly)
- if I try to update a metakey which was registered single=true with an array it saves it as a serialized array then throws an array to string conversion notice on GET
I haven't been thorough, not sure if that's the type of thing you're looking for.
@tharsheblows Thanks for the feedback! We're discussing these in slack and the update function definitely needs to be tightened up, that array casting issue is definitely a bug and making the update stricter should address the first item too
There are also a slight issue when deleting multiple identical meta_values for a given meta_key in update_multi_meta_value. So eg if you have postmeta_multiple_number: [ 11, 13, 13, 13, 13 ],
you'll get an error when you delete / update it because it tries to do all of the 13s one at a time and they all get done at once by delete_metadata I think. I had an issue when updating to multiple identical meta_values but I can't reproduce it.