Skip to content

Instantly share code, notes, and snippets.

Created February 8, 2013 15:49
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ericjuden/4739857 to your computer and use it in GitHub Desktop.
WordPress Options Class
class My_Plugin_Options {
var $options;
var $option_name;
var $is_site_option; // Are we using Multisite and saving to global options?
function My_Plugin_Options($option_name, $is_site_options = false){
$this->option_name = $option_name;
$this->is_site_option = $is_site_options;
$this->options = get_site_option($this->option_name);
} else {
$this->options = get_option($this->option_name);
$this->options = array();
function __get($key){
return $this->options[$key];
function __set($key, $value){
$this->options[$key] = $value;
function __isset($key){
return array_key_exists($key, $this->options);
function save(){
update_site_option($this->option_name, $this->options);
} else {
update_option($this->option_name, $this->options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment