XMLRPC wp.editPost doesn't use update_post_meta
|Reported by:||jmaimarc||Owned by:|
Currently, the code is:
add_post_meta( $post_id, $meta['key'], $meta['value'] );
Since it doesn't know if the key is unique I think the code should be:
update_post_meta( $post_id, $meta['key'], $meta['value'] );
so it checks for an existing meta_key for the post.
FWIW, I tested it locally and it works.
I also wasn't sure about the current_user_can capabilities, so I made the check:
current_user_can( 'edit_post_meta', $post_id, $meta['key'] ) || current_user_can( 'add_post_meta', $post_id, wp_unslash( $meta['key'] ) )
which might be overkill; I didn't see documentation on those capabilities. The wp_unslash is inconsistent, but I just copied from an earlier if statement.