As you may have noticed in a post I made a few days ago about widetizing wordpress plugins, I mentioned that we needed to serialize our variables before we created them as options in wordpress. As it turns out, this isn’t the case – WordPress does it for you when you go to update or create an option. This morning, while reading a post on wpengineer.com about wordpress options, I noticed that in their sample code, they weren’t serializing arrays or objects before creating them as options. Michael, the author, set me straight on why this is ok.
As it turns out, WordPress is one step ahead of me. Maybe_serialize() is called a number of times throughout wordpress, relating to these items:
So there you go. Use all the arrays and objects you want in post meta, user meta, and options – throw caution to the wind, and put them straight in. WordPress will handle the boring stuff.
Recent Comments