Reputation: 503
I am using this website http://wpbits.wordpress.com/2007/08/15/adding-options-to-wordpress-plugins/ to help me workout how to make a plugin that saves options. Here is my code, but it wont seem to work. Can anyone point me in right direction?
<?php
/*
* Plugin Name: test
* Plugin URI: www.test.com
* Version: 1.0
* Author: J Davies
* Author URI: test.com
* Description: Random Test
*/
function say_test(){
$greeting = get_option('test_greeting');
print "Say ".$greeting;
}
function set_test_options(){
add_option('test_greeting','test','test');
}
function unset_test_options(){
delete_option('test_greeting');
}
register_activation_hook(__FILE__,'set_test_options');
register_deactivation_hook(__FILE__,'unset_test_options');
?>
Upvotes: -1
Views: 195
Reputation: 503
I have found the problem, I needed to wrap each function in if(function_exists()). Thanks
Upvotes: 1
Reputation: 164980
Only strange thing I can see here is that add_option()
should only take two or four arguments (with an empty third). Setting the third causes Wordpress to run its _deprecated_argument()
function which will trigger an error if in debug mode.
Upvotes: 0