WordPress.org

Make WordPress Core

Ticket #7682: settings_field_test.txt

File settings_field_test.txt, 1.1 KB (added by ryan, 7 years ago)

Test code

Line 
1function writing_default_test_input_field() {
2        echo '<input name="test_input_field" id="test_input_field" type="text" value="' . attribute_escape(get_option('test_input_field')) . '" size="40" />';
3}
4
5add_settings_field('test_input_field', 'Test Input Field', 'writing_default_test_input_field', 'writing', 'default', array('label_for' => 'test_input_field'));
6register_setting('writing', 'test_input_field', 'sanitize_title');
7
8function test_writing_section() {
9        echo '<p>' . __('This is a new section on the writing settings page.') . '</p>';
10}
11add_settings_section('test_writing_section', 'Test Writing Section', 'test_writing_section', 'writing');
12
13function test_writing_section_input_field() {
14        echo '<input name="section_test_input_field" id="section_test_input_field" type="text" value="' . attribute_escape(get_option('section_test_input_field')) . '" size="40" />';
15}
16
17add_settings_field('test_writing_section_input_field', 'Section Test Input Field', 'test_writing_section_input_field', 'writing', 'test_writing_section');
18register_setting('writing', 'section_test_input_field');