I have set up my plugin option on admin panel with
/**
* Register and add settings
*/
public function page_init()
{
register_setting(
'my_option_group', // Option group
'write_here_options', // Option name
array( $this, 'sanitize' ) // Sanitize
);
add_settings_section(
'setting_section_id', // ID
'Set Edit Page', // Title
array( $this, 'print_section_info' ), // Callback
'write-here-setting' // Page
);
add_settings_field(
"pid_num",
"Select Page >>",
array( $this, 'wh_select_list' ),
"write-here-setting",
"setting_section_id"
);
add_settings_field(
'num_of_posts', // ID
'Number of Posts to show', // Title
array( $this, 'num_of_posts_callback' ), // Callback
'write-here-setting', // Page
'setting_section_id' // Section
);
}
So in DB, my plugin setting saved in wp_options
table under column name option_name
as write_here_options
in my case as object.
When people activate the plugin, I want to save default values in the DB for pid_num => 0
and num_of_posts => 10
.
How do I make this work??