Created
December 11, 2012 15:25
-
-
Save tollmanz/4259320 to your computer and use it in GitHub Desktop.
Update option without autoloading it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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