Last week, I was talking to a couple of developers on Twitter about some of the code that’s required to save custom post meta in WordPress when working with plugins or themes.
For the most part, good serialization functions are consistently formatted in the same way:
- First, we check for security. If the security check fails, then we exit the function.
- If security passes, then we proceed with our serialization functionality.
The thing is, the security checks are generally the same thing across the board so much so that you may even consider it somewhat of a boilerplate.
This seems like an opportunity to improve developer’s processes a bit by abstracting out some of the code that is used to save custom post meta data.
So let’s try this:



