Added Alex Stapleton's add_option() code.

git-svn-id: https://develop.svn.wordpress.org/trunk@1084 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dougal Campbell 2004-04-16 21:17:09 +00:00
parent 9db213767e
commit 986f038d02
1 changed files with 15 additions and 2 deletions

View File

@ -337,10 +337,23 @@ function update_option($option_name, $newvalue) {
return true;
}
function add_option() {
// thx Alex Stapleton, http://alex.vort-x.net/blog/
function add_option($name, $value='') {
// Adds an option if it doesn't already exist
global $wpdb, $tableoptions;
// TODO
if(!get_settings($name)) {
$name = $wpdb->escape($name);
$value = $wpdb->escape($value);
$wpdb->query("INSERT INTO $tableoptions (option_name, option_value) VALUES ('$name', '$value')");
global $use_cache;
if($wpdb->insert_id && $use_cache) {
global $cache_settings;
$cache_settings->{$name} = $value;
}
}
return;
}
function get_postdata($postid) {