I trying to add an Import and export function to my settings page. First, I have created settings page with Metabox plugin using following code
// Register myplugin settings page
add_filter( 'mb_settings_pages', 'myplugin_options_page' );
function myplugin_options_page( $settings_pages ) {
$settings_pages[] = array(
'id' => 'myplugin_settings',
'option_name' => 'myplugin_settings',
'menu_title' => 'Plugin settings',
'icon_url' => 'dashicons-edit',
'style' => 'boxes',
'columns' => 1,
'capability' => 'edit_theme_options',
'tabs' => array(
'settings_tab' => esc_html__('Settings', 'myplugin'),
'help' => esc_html__('Help', 'myplugin'),
),
'position' => 68,
);
$settings_pages[] = array(
'id' => 'myplugin-export',
'option_name' => 'myplugin-export,
'menu_title' => esc_html__('Export settings', 'myplugin'),
'parent' => 'myplugin_settings',
'style' => 'boxes',
'columns' => 1,
'capability' => 'edit_theme_options',
);
return $settings_pages;
}
As metabox plugin doesn't have settings import feature I am trying to add a custom page for importing and tried to add a sub menu inside the Parent menu created with the Metabox plugin with the menu slug 'myplugin_settings'.
add_action('admin_menu', 'add_import_menu');
function add_import_menu() {
add_submenu_page( 'myplugin_settings', 'Import settings', 'Import settings', 'edit_theme_options', 'new-submenu', 'plugin_submenu_page' );
}
This is replacing the parent menu "Plugin settings" ('myplugin_settings') with Import settings. Not sure what I am doing wrong.