add_action('mvx_init', 'after_mvx_init');
function after_mvx_init() {
// add a setting field to wcmp endpoint settings page
add_action('settings_vendor_general_tab_options', 'add_custom_endpoint_option');
// save setting option for custom endpoint
add_filter('settings_vendor_general_tab_new_input', 'save_custom_endpoint_option', 10, 2);
// add custom endpoint
add_filter('mvx_endpoints_query_vars', 'add_mvx_endpoints_query_vars');
// add custom menu to vendor dashboard
add_filter('mvx_vendor_dashboard_nav', 'add_tab_to_vendor_dashboard');
// display content of custom endpoint
add_action('mvx_vendor_dashboard_custom-wcmp-nenu_endpoint', 'custom_menu_endpoint_content');
}
function add_custom_endpoint_option($settings_tab_options) {
$settings_tab_options['sections']['wcmp_vendor_general_settings_endpoint_section']['fields']['wcmp_custom_vendor_endpoint'] = array('title' => __('Custom Menu', 'dc-woocommerce-multi-vendor'), 'type' => 'text', 'id' => 'mvx_custom_vendor_endpoint', 'label_for' => 'mvx_custom_vendor_endpoint', 'name' => 'mvx_custom_vendor_endpoint', 'hints' => __('Set endpoint for custom menu page', 'dc-woocommerce-multi-vendor'), 'placeholder' => 'custom-wcmp-nenu');
return $settings_tab_options;
}
function save_custom_endpoint_option($new_input, $input) {
if (isset($input['mvx_custom_vendor_endpoint']) && !empty($input['mvx_custom_vendor_endpoint'])) {
$new_input['mvx_custom_vendor_endpoint'] = sanitize_text_field($input['mvx_custom_vendor_endpoint']);
}
return $new_input;
}
function add_mvx_endpoints_query_vars($endpoints) {
$endpoints['custom-mvx-nenu'] = array(
'label' => __('Custom Menu', 'dc-woocommerce-multi-vendor'),
'endpoint' => get_mvx_vendor_settings('mvx_custom_vendor_endpoint', 'vendor', 'general', 'custom-mvx-nenu')
);
return $endpoints;
}
function add_tab_to_vendor_dashboard($nav) {
$nav['custom_wcmp_nenu'] = array(
'label' => __('Custom Menu', 'dc-woocommerce-multi-vendor'), // menu label
'url' => mvx_get_vendor_dashboard_endpoint_url('custom-mvx-nenu'), // menu url
'capability' => true, // capability if any
'position' => 75, // position of the menu
'submenu' => array(), // submenu if any
'link_target' => '_self',
'nav_icon' => 'dashicons-admin-generic', // menu icon
);
return $nav;
}
function custom_menu_endpoint_content(){
echo '<div class="mvx_form1">';
echo '<p>Custom Menu content</p>';
echo '</div>';
}
Leave a Reply
You must be logged in to post a comment.