Saving Plugin settings to the database

I would store the array to the options able as a serialized value.

update_option('dw_quotes', serialize($quotes));

and retrieve with:

$quotes = get_option('dw_quotes', null);
if ($quotes !==  null) { $quotes = unserialize($quotes); }

Other things to consider:

Add handling in case the quotes option does not exist.

Also add handling to delete quotes from the option table when the plugin is deleted. See:
http://codex.wordpress.org/Function_Reference/register_uninstall_hook

Leave a Comment