WordPress Options Class
I came up with an object-oriented way of working with my plugin’s options for my work projects.
So then all I have to do in my class is create an instance of this:
$options = new My_Plugin_Options('my_plugin_options_name');
It will store all of your plugin options in 1 record in the database as an array. You can easily access one of the options by doing this:
After updating all the options, we need to save them at once.
I’ve created a folder inside wp-content/plugins for some code that I use on multiple plugins/themes at work. I don’t have the plugin declaration at the top of the main file, so it doesn’t get recognized as something needing activation. All I do is require the main file in my plugins and themes and that file includes the rest of my classes; the Options class being one of them. I’ve also created a couple classes for dealing with custom post types and taxonomies.