Skip to content

Instantly share code, notes, and snippets.

@nayemDevs
Forked from sabbir1991/load_settings_menu.php
Last active October 14, 2021 17:40
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nayemDevs/b2dd4b81d343220d90a1 to your computer and use it in GitHub Desktop.
Save nayemDevs/b2dd4b81d343220d90a1 to your computer and use it in GitHub Desktop.
Add extra menu in Settings menu in Dokan Dashboard
/** Adding Settings extra menu in Settings tabs Dahsboard */
add_filter( 'dokan_get_dashboard_settings_nav', 'dokan_add_settings_menu' );
function dokan_add_settings_menu( $settings_tab ) {
$settings_tab['nayem'] = array(
'title' => __( 'Nayem', 'dokan'),
'icon' => '<i class="fa fa-user"></i>',
'url' => dokan_get_navigation_url( 'settings/nayem' ),
'pos' => 32
);
return $settings_tab;
}
add_filter( 'dokan_dashboard_settings_heading_title', 'dokan_load_settings_header', 11, 2 );
function dokan_load_settings_header( $header, $query_vars ) {
if ( $query_vars == 'nayem' ) {
$header = __( 'Nayem Profiles', 'dokan' );
}
return $header;
}
add_filter( 'dokan_dashboard_settings_helper_text', 'load_helper', 10, 2 );
function load_helper( $helper_txt, $query_var ) {
if ( $query_var == 'nayem' ) {
$helper_txt = 'Nayem is a good boy';
}
return $helper_txt;
}
add_action( 'dokan_render_settings_content', 'dokan_render_settings_content', 10 );
function dokan_render_settings_content( $query_vars ) {
if ( isset( $query_vars['settings'] ) && $query_vars['settings'] == 'nayem' ) {
?>
<form action="">
<label for="">Text</label>
<input type="text">
</form>
<?php
}
}
@wankhedeamol20
Copy link

Hi,
Thanks for this post, it's really helpful for me.
I have one question, How to save this form data.

@naeemkhan25
Copy link

how can I add sub menu like settings please help

@naeemkhan25
Copy link

how can I add custom menu with sub menu like settings please help

@tayyabwork
Copy link

Thanks. It's really helpful.

@tayyabwork
Copy link

tayyabwork commented Oct 14, 2021

Hi @nayemDevs,
How can I save newly created form fields? Is there any hook or some other method available? I need to save a form field via ajax.

I am talking about this form

add_action( 'dokan_render_settings_content', 'dokan_render_settings_content', 10 );
function dokan_render_settings_content( $query_vars ) {
	if ( isset( $query_vars['settings'] ) && $query_vars['settings'] == 'nayem' ) {
        ?>
		<form action="">
			<label for="">Text</label>
			<input type="text">
		</form>
        <?php
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment