I wrote a simple test code for testing saving data using Setting API, but it doesn't seem to work. it realy driving me crazy. Please help me point out the problem, thanks!
function test_add_options_page() {
add_menu_page(
'Test Save Option',
'Test Save',
'manage_options',
'testpage',
'test_save_page'
);
}
add_action('admin_menu', 'test_add_options_page');
function test_save_page() {
?>
<form action="options.php" method="post">
<?php
settings_errors();
settings_fields('testpage');
do_settings_sections('testpage');
submit_button();
?>
</form>
<?php
}
function test_add_settings() {
add_settings_section(
'section_1',
'Section 1',
'output_section_desc',
'testpage'
);
add_settings_field(
'field_id',
'Field Title',
'add_field_callback',
'testpage',
'section_1'
);
register_setting('testpage', 'testpage');
}
add_action('admin_init', 'test_add_settings');
function output_section_desc() {
echo 'Section Description...';
}
function add_field_callback() {
echo '<input type="test" id="field_id" />';
}