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

Merged
merged 3 commits into from May 24, 2014

Conversation

Projects
None yet
3 participants
@rachelbaker
Member

rachelbaker commented May 4, 2014

No description provided.

tlovett1 and others added some commits Apr 28, 2014

Post meta handler; Allow for updating, adding, and deleting of post m…
…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

This comment has been minimized.

Show comment
Hide comment
@rachelbaker

rachelbaker May 4, 2014

Member

@rmccue Please review the progress here for post_meta handling.

Member

rachelbaker commented May 4, 2014

@rmccue Please review the progress here for post_meta handling.

@tlovett1

This comment has been minimized.

Show comment
Hide comment
@tlovett1

tlovett1 May 4, 2014

Member

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

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

This comment has been minimized.

Show comment
Hide comment
@rmccue

rmccue May 5, 2014

Member

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! :)

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.

@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

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

This comment has been minimized.

Show comment
Hide comment
@rmccue

rmccue May 5, 2014

Member

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

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.

@rmccue

rmccue May 5, 2014

Member

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

@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.

@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 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

This comment has been minimized.

Show comment
Hide comment
@rmccue

rmccue May 5, 2014

Member

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.

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

This comment has been minimized.

Show comment
Hide comment
@rmccue

rmccue May 12, 2014

Member

Posted for feedback on the o2.

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

continuous-integration/travis-ci The Travis CI build passed
Details

rachelbaker added a commit that referenced this pull request May 24, 2014

Merge pull request #207 from WP-API/post-meta-handling-v4
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

Merge pull request #207 from WP-API/post-meta-handling-v4
Add ability to add, update, delete post_meta.  Fixes #68.  Closes #189 and #168.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment