Unserialize custom fields#5
Conversation
|
@kurtw You closed the related PR cfpb/cms-toolkit#55. Is this PR still needed? |
|
It is not needed quite yet, BUT it is very important and exciting to have. My vision for the cms-toolkit is to change it so that it saves each field of the metabox in a serialized array. This will take that serialized array and output it nicely in JSON. The referenced and closed array did that for links but it broke sheer processors in it's implementation so I decided to make the transition in a different PR (coming soon). It should be noted that this does not break any existing functionality, it just adds support for serialized data. |
|
Cool cool. One question: Can we leverage this existing WP function? https://developer.wordpress.org/reference/functions/maybe_unserialize/ |
|
Well look at you Scott. I try to make something and you just come and here a drop something even better. I should say that my function does accept arrays that have serialized data within them. I think I'll modify it to use this function. Thanks for bringing it to my attention! |
|
Teamwork! 👯 |
|
Updated to use |
|
Tagging to make visible to more affected parties @cfarm |
|
👍 Ready to rock. |
Currently, custom fields are being output in json literally from the Wordpress database. In Wordpress, arrays are serialized into a string and then saved in the database so your JSON output is serialized. No good. We want a nice json object. This accomplishes that in this case.
Additions
unserialize_custom_field()that accepts one parameter. It is used to unserialize potentially serialized given fields.Changes
Testing
Review
Notes