Skip to content
This repository has been archived by the owner. It is now read-only.

Initial pass at handling post_meta based on feedback in #68. #168

Merged
merged 3 commits into from May 24, 2014

Conversation

@rachelbaker
Copy link
Member

rachelbaker commented May 4, 2014

No description provided.

tlovett1 and others added 3 commits Apr 28, 2014
…eta. Filter for passing sanitization callbacks; filter for requiring santizition callbacks. This method assumes values are passed as they are intended to be stored (array or single). In response to #68

Remove sanitization callback functionality - see #68
@rachelbaker
Copy link
Member Author

rachelbaker commented May 4, 2014

@rmccue Please review the progress here for post_meta handling.

@tlovett1
Copy link
Member

tlovett1 commented May 4, 2014

Looks good. Although, I think we should at least allow for arrays to be updated/added to post meta.

@rmccue
Copy link
Member

rmccue commented May 5, 2014

Looks good. Although, I think we should at least allow for arrays to be updated/added to post meta.

👎 for now, I want to make sure we skip serialized data completely for now until we can consider it a bit more. There's always 1.1 and afterwards! :)

protected function maybe_update_post_meta( $post_id, $meta_key, $data ) {
$old_data = get_post_meta( $post_id, $meta_key );

if ( is_object( $old_data ) || is_serialized( $old_data ) ) {

This comment has been minimized.

Copy link
@rmccue

rmccue May 5, 2014

Member

Can we refactor this out? A generic can_set_meta that we can reuse, and fold this into handle_post_meta_action instead.

@rmccue
Copy link
Member

rmccue commented May 5, 2014

If we're doing to change the format of post_meta for update/creation, we should change the format from retrieval (prepare_meta) too. :)


foreach ( $data as $meta_array ) {
if ( empty( $meta_array['key'] ) ) {
return new WP_Error( 'json_post_invalid_action', __( 'Invalid meta action. Missing meta key.' ), array( 'status' => 400 ) );

This comment has been minimized.

Copy link
@rmccue

rmccue May 5, 2014

Member

This should use a different code and message, since it's not actually an invalid action.

* {
* "key" : "meta_key",
* "value" : "meta_value", (OPTIONAL)
* "action" : "meta_action" (OPTIONAL, add|update|delete, default=update)

This comment has been minimized.

Copy link
@rmccue

rmccue May 5, 2014

Member

I'd prefer for this to be non-optional if we use this format, so that it's explicit for users.

@rmccue rmccue added this to the 1.0 milestone May 5, 2014
@rmccue rmccue added the Enhancement label May 5, 2014
@rmccue
Copy link
Member

rmccue commented May 5, 2014

Cool; looking like a good start, and reasonably simple for now. 🎆

I'll also post this to the o2 for feedback, as we need to get this right.

@rmccue
Copy link
Member

rmccue commented May 12, 2014

Posted for feedback on the o2.

@rachelbaker rachelbaker merged commit e4438c9 into master May 24, 2014
1 check passed
1 check passed
continuous-integration/travis-ci The Travis CI build passed
Details
rachelbaker added a commit that referenced this pull request May 24, 2014
Add ability to add, update, delete post_meta.  Fixes #68.  Closes #189 and #168.
@rmccue rmccue deleted the post-meta-handling branch May 25, 2014
kellbot pushed a commit to kellbot/WP-API that referenced this pull request Aug 1, 2014
Add ability to add, update, delete post_meta.  Fixes WP-API#68.  Closes WP-API#189 and WP-API#168.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.