From 986f038d02b7aad3fed334c92412f93c328591a1 Mon Sep 17 00:00:00 2001 From: Dougal Campbell Date: Fri, 16 Apr 2004 21:17:09 +0000 Subject: [PATCH] Added Alex Stapleton's add_option() code. git-svn-id: https://develop.svn.wordpress.org/trunk@1084 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/functions.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index f0ce486d79..275df0949e 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -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) {