UPDATE: This error came from WP_DEBUG...of course, embedded_url didn't exist yet. However, when I set the value of $options[embedded_url] using the form, the $options array magically adds both the new value of embedded_url AND somehow remembers an old value of text_string. I've added
unset($options['text_string']);
to my code, but as soon as I press the Save Settings button, it's right back in the $options again. text_string does not exist anywhere in my code anymore. It's totally gone. Where is this text_string ghost?!
I followed this tutorial almost word for word to create a custom admin/settings page for a plugin I created. I tried to change the option name text_string
to something else – embedded_url
. I have WP_DEBUG enabled. When I loaded my plugin’s settings page, right above my text input field is this error:
Notice: Undefined index: embedded_url in ….
and then it points to the echo line of this function:
function plugin_setting_url() {
$options = get_option('plugin_options');
echo "<input id='plugin_url' name='plugin_options[embedded_url]' size='40' type='text' value='{$options['embedded_url']}' />";
}
Since this is the only place that text_string
appears in the tutorial other than the validation method, I do not understand why embedded_url
is not defined in the same manner as text_string
was. What am I doing incorrectly?