Complete the code to register a new settings section using the Settings API.
add_settings_section('my_section', 'My Section Title', [1], 'my_plugin_page');
The third parameter of add_settings_section is a callback function that outputs the section description.
Complete the code to register a setting field with the Settings API.
add_settings_field('my_field', 'My Field', [1], 'my_plugin_page', 'my_section');
The third parameter of add_settings_field is a callback function that renders the input field HTML.
Fix the error in the code to properly register a setting with sanitization.
register_setting('my_plugin_options', 'my_option_name', array('sanitize_callback' => [1]));
The sanitize_text_field function is a built-in WordPress function to sanitize text input safely.
Fill both blanks to create a settings page and add a settings section.
add_options_page('My Plugin Settings', 'My Plugin', [1], [2]);
The third parameter is the capability required to access the page, usually 'manage_options'. The fourth parameter is the unique slug for the menu page.
Fill all three blanks to register a setting, add a section, and add a field with proper callbacks.
register_setting('my_group', [1], array('sanitize_callback' => [2])); add_settings_section('my_section', 'Section Title', [3], 'my_page');
The first blank is the option name to register. The second is the sanitization callback. The third is the callback to display the section description.