I want to make an Options page with multiple settings for my plugin. I want to use this code as a start: http://codex.wordpress.org/Creating_Options_Pages#Example_.232
I just modified the example in the Codex: Creating_Options_Pages#Example_.232. Now it includes a second Settings Field. The sanitization function is simpler to understand and expand. Also changed the names of the variables and added documentation in the code. I think it's easier to follow the logic now. Here it is in full:
options = get_option( 'my_option_name' );
?>
My Settings
',
isset( $this->options['id_number'] ) ? esc_attr( $this->options['id_number']) : ''
);
}
/**
* Get the settings option array and print one of its values
*/
public function title_callback()
{
printf(
'',
isset( $this->options['title'] ) ? esc_attr( $this->options['title']) : ''
);
}
}
if( is_admin() )
$my_settings_page = new MySettingsPage();
If you want to add new Settings Sections, just do it and point the desired Settings Fields to the new section.
Pull the information wherever needed using: get_option( 'my_option_name' );.