此配置页有很多问题。我遵循了文档(很少)并进行了一些搜索以寻求帮助。
我的问题很简单,我的配置选项没有被创建或保存。任何帮助都将不胜感激!
以下是总体设置:
public $view;
function __construct()
{
$this->view = new My_View;
// hook the settings menu
add_action(\'admin_menu\', array($this, \'index\'));
// hook the settings\' settings
add_action(\'admin_init\', array($this, \'registerSettings\'));
}
/**
* setup the settings menu Page Title, Menu Title, Permissions, Menu Slug, View to render
*/
public function index()
{
add_options_page("My Settings", "My menu", "manage_options", "My_Settings", array($this->view, \'index_view\'));
}
public function registerSettings()
{
//options, name of option, validate function
register_setting(\'my_general_settings\', \'my_general_settings\');
}
接下来,表格:
public function index_view()
{ ?>
<div class="wrap" style="display:block;">
<h2>Settings</h2>
<hr>
<form method="POST" action="">
<h3>General Settings</h3>
<?php settings_fields(\'my_general_settings\'); ?>
<?php $settings = get_option(\'my_general_settings\') ?>
<label for="my_settings[publisher_id]">Enter your Publisher ID:</label>
<input type="text" name="my_general_settings[publisher_id]" value="<?php echo $settings[\'publisher_id\']?>" />
<input type="submit" value="Save Changes" />
<p>Forgot your ID? <a href="">Click here</a></p>
</form>
</div>
<?php }