1. Home
  2. Docs
  3. Developer Info & API
  4. Custom Tabs

Custom Tabs

There will be times when you want to be able to create a new tab in the quiz settings. Luckily, we have a function in the plugin helper class to take care of this for you.

create a new settings tab

When a user clicks “Edit” on their quiz or survey, the plugin displays a “Settings” page with a variety of tabs such as “Questions”, “Emails”, etc. You can add new tabs to this page using a function in the API.

First, we add a function to the ‘plugins_loaded’ hook that will add our new tab. We will call this function ‘qsm_example_settings_tab’. Inside, we will call the global $mlwQuizMasterNext.

function qsm_example_settings_tab() {
global $mlwQuizMasterNext;
$mlwQuizMasterNext->pluginHelper->register_quiz_settings_tabs( __( "My New Tab", 'quiz-master-next' ), 'qsm_example_settings_tab_content' );
}
add_action("plugins_loaded", 'qsm_example_settings_tab');

function qsm_example_settings_tab_content() {
echo "This is my tab's content!";
}

Now, we will use the plugin helper function ‘register_quiz_settings_tabs’ to create our tab. This function has two parameters. The first parameter is the title which is the string that is displayed on the tab. The second parameter is the function to display the contents.

In our example above the “qsm_example_settings_tab_content” function displays the content when a user clicks on the “My New Tab” tab.

create a new add-ons settings tab

There will probably be times that you need to add settings that affect all quizzes. Adding a tab in the Addons Settings page is the perfect spot to list your new settings. Creating a new tab is almost identical to creating a new tab on the quiz settings page.
First, we add a function to the ‘plugins_loaded’ hook that will add your new tab. We will call this function ‘add_new_addons_tab’. Inside, we will call the global $mlwQuizMasterNext. Then, we will use the plugin helper function ‘register_addon_settings_tab’ to create out tab. This function has two parameters.


$title is the string for the tab and $function is your function to display the contents. From here, you will want to create a function to display the contents. So, utilizing this function, we will create a new tab:

function add_new_addons_tab()
{
	global $mlwQuizMasterNext;
	$mlwQuizMasterNext->pluginHelper->register_addon_settings_tab(__("My Addon's Settings", 'quiz-master-next'), "my_addon_settings_tab_content");
}
add_action("plugins_loaded", 'add_new_addons_tab');
function my_addon_settings_tab_content
{
    //Your content goes here!
}

How can we help?