I'm having trouble migrating my plugin to 2.7 - an issue with options where it'll show the options page but upon hitting save says "Error! Options page not found."
I decided to try a very simple example first to isolate the problem, and it's still happening. Could someone take a look at this and tell me what I'm doing wrong options-wise? Would greatly appreciate it...and I'll post later as a generic example for others to use too. The plugin dev docs are kind of fragmented so it's hard to pull together something without looking at about 10 pages...
<?php
/*
Plugin Name: Test
Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
Description: A brief description of the Plugin.
Version: The Plugin's Version Number, e.g.: 1.0
Author: Name Of The Plugin Author
Author URI: http://URI_Of_The_Plugin_Author
*/
function my_plugin_activate() {
add_option("test", "12345");
register_setting('test-options', 'test');
}
function my_plugin_menu() {
add_options_page('My Plugin Options', 'My Plugin', 8, __FILE__, 'my_plugin_options');
}
function my_plugin_options() {
register_setting('test-options', 'test');
?>
<div class="wrap">
<h2>Plugin name</h2>
<form method="post" action="options.php">
<?php wp_nonce_field('update-options'); ?>
<table class="form-table">
<tr valign="top">
<th scope="row">New Option Name</th>
<td><input type="text" name="test" value="<?php echo get_option('test'); ?>" /></td></tr>
</table>
<?php settings_fields('test-options'); ?>
<p class="submit">
<input type="submit" name="Submit" value="Save changes" />
</p>
</form>
</div>
<?php
}
add_action('admin_menu', 'my_plugin_menu');
register_activation_hook( __FILE__, 'my_plugin_activate' );
?>