Skip to content

Instantly share code, notes, and snippets.

@tollmanz
Created December 11, 2012 15:25
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 tollmanz/4259320 to your computer and use it in GitHub Desktop.
Save tollmanz/4259320 to your computer and use it in GitHub Desktop.
Update option without autoloading it
/**
* Wrapper for adding/updating an option without autoloading it.
*
* @author tollmanz
*
* @uses get_option
* @uses add_option
* @uses update_option
*
* @param string $key Option name.
* @param mixed $value Value to save.
* @return bool True on success; false on failure.
*/
function zdt_update_option_without_autoload( $key, $value ) {
$option = get_option( $key, false );
if ( false === $option )
return add_option( $key, $value, '', 'no' );
else
return update_option( $key, $value );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment