Skip to content

Instantly share code, notes, and snippets.

@alexkingorg
Created July 9, 2012 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexkingorg/3079382 to your computer and use it in GitHub Desktop.
Save alexkingorg/3079382 to your computer and use it in GitHub Desktop.
Sample options data accessor function with defaults.
<?php
// return a value from the options table if it exists,
// or return a default value
my_plugin_get_option($key) {
$defaults = array(
'foo' => 'some string',
'bar' => true,
'baz' => array(
1, 2, 3
)
);
if (!isset($defaults[$key])) {
$defaults[$key] = false;
}
return get_option($key, $defaults[$key]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment