The function register one option or a settings group. So yes, you register the group of a section and use all fields inside this group because the group store all settings fields as array in one item.
register_setting(
'_example_plugin_settings',
'_example_object_settings',
array(
'type' => 'object',
'default' => array(
'some_str' => 'A',
'some_int' => 3,
),
)
);
add_action( 'admin_init', 'example_register_settings' );
/**
* One settings group with two items.
*/
function example_register_settings() {
register_setting(
'_example_plugin_settings',
'_example_object_settings',
'_validate_example_plugin_settings'
);
add_settings_section(
'section_one',
'Section One',
'_section_one_text',
'_example_plugin'
);
add_settings_field(
'some_text_field',
'Some Text Field',
'_render_some_text_field',
'_example_plugin',
'section_one'
);
add_settings_field(
'another_number_field',
'Another Number Field',
'_render_another_number_field',
'_example_plugin',
'section_one'
);
}
If you get the settings entry, use get_option('_example_plugin_settings')
, and you get all content of this item, like
$options = get_option('_example_plugin_settings');
print_r($options['some_text_field']);
The documentation of the function also has helpful examples.