我已经为我的插件设置创建了一个表单,并将表单的action属性设置为“options.php”,但当我提交表单时,我得到了“ERROR:options page not found”
add_action(\'admin_menu\', \'create_menu\');
function create_menu(){
// add menu page
add_menu_page(
\'Basic Plugin Menu Page\',
\'Bp Menu\',
\'manage_options\',
\'bp_menu\',
\'bp_menu_cb\',
plugins_url(\'images/wordpress.png\', __FILE__),
76 );
// add submenu page
add_submenu_page(
\'bp_menu\',
\'Besic Plugin Submenu\',
\'Options\',
\'manage_options\',
\'bp_options\',
\'bp_options_cb\' );
add_action(\'admin_init\', \'bp_register_settings_cb\');
} // end add_menu
function bp_register_settings_cb(){
// - register_setting( $option_group, $option_name, $sanitize_callback );
register_setting(\'bp-settings-group\', \'bp_options\', \'bp_options_sanitize\');
} // enb bp_register_settings_cb
function bp_options_sanitize($input){
$input[\'name\'] = sanitize_text_field($input[\'name\']);
$input[\'email\'] = sanitize_email($input[\'email\']);
$input[\'url\'] = esc_url($input[\'url\']);
return $input;
} // end bp_options_sanitize
function bp_menu_cb(){ ?>
<div id="wrap">
<h2>Basic Plugin Settings</h2>
<form method="POST" action="http://localhost/blogger.allaudin/wp-admin/options.php">
<?php settings_fields(\'bp_settings_group\'); ?>
<?php $bp_options = get_option(\'bp_options\') ?>
<table class="form-table">
<tr valign="top">
<th scope="row">Name</th>
<td>
<input type="text" name="bp_options[name]" value="<?php echo esc_attr($bp_options[\'name\']) ?>" />
</td>
</tr>
<tr valign="top">
<th scope="row">Email</th>
<td>
<input type="text" name="bp_options[email]" value="<?php echo esc_attr($bp_options[\'email\']); ?>" />
</td>
</tr>
<tr valign="top">
<th scope="row">URL</th>
<td>
<input type="text" name="bp_options[url]" value="<?php echo esc_url($bp_options[\'url\']) ?>" />
</td>
</tr>
</table>
<p class="submit">
<input type="submit" class="button-primary" value="Save Changes" />
</p>
</form>
</div>
<?php } // end bp_settings_page