Added Alex Stapleton's add_option() code.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1084 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
emc3 2004-04-16 21:17:09 +00:00
parent 9b3163412c
commit 2c3e14a0ea
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) {