I have a JSON encoded string $json_string which needs to be stored into the post meta data.
Doing the following damages the JSON encoded data:
add_post_meta($post_id, 'json-data', $json_string);
After searching the Internet I found that somebody else had a similar issue, and it looks as though the following addresses the issue:
add_post_meta($post_id, 'json-data', $wpdb->escape($json_string));
3 Questions:
#1) Is this a fault with WordPress?
#2) Is the above safe? Is it likely to damage my clients data?
#3) Could there be a security risk with the default “add_post_meta” functionality?
Kind regards,
Lea Hayes