The API uses the global $wpdb , make sure you have this declaration before using any function like add_option or get_option .
Also, according to the WordPress Codex, you will not see any changes when using add_option($option, $value, $deprecated, $autoload) if you already have a value for this option:
Note: add_option uses get_option, to determine whether this option is selected, and as get_option returns false as a default, if you set to false in the database (for example, through update_option($option_name, false)) ), then calls add_option will change the value since add_option will look like the option does not exist.
You can use the API API anywhere in your plugin as a log when loading $wpdb .
I would also recommend using update_option instead of add_option , since it can create new parameters, but will not return false, if the option already exists, it will simply overwrite it.
source share