Wordpress lessons, Sitebuilding

Guide to setting up WordPress API: tab navigation

WordPress API

This part of the article provides for close cooperation with the Settings API. Using Settings API, we asked the WordPress team to develop values for all groups settings in the database. Since we have defined two kinds of settings, the database will be equipped with two rows. After the program using forms displays options directly in the control panel. From here :WordPress API: takes data from the fields and puts them in the database.

Tab navigation
On the tab called “Themes” you can find the tab navigation. This panel is an excellent alternative groups of options. It is located on one page, without sacrificing ease of use. This is exactly what we are implementing in the theme Sandbox.
The plan of our next steps is as follows:

create two tabs. The first is for the display options, the second option for social networking
set the tab “display Option” standard feature while loading the settings page,
make tab active after you save it,
read the success message of conservation.

Adding bookmarks
Open the file functions.php find the function sandbox_theme_display. This function is used to display page options. It will have the following appearance: image……
First create our bookmark. This process is fairly simple. The use of the advantages of CSS classes that are present in WordPress (nav-tab nav-tab-wrapper).
In a feature called sandbox_theme_display, directly after calling the function settings_errors(), you must put the following block: image……
The function will be as follows: image……
Recovery of tabs
For the implementation of switching our bookmarks, we need to develop a certain flag or signal, whereby to display the options. This can be done by using the query variable values, which include data about which of the tabs was made click. Or it can be done with PHP.
You need to edit the markup as follows: image…..
After that I need to write a little PHP code that will handle reading the new query-string values. This code will allow you to toggle bookmarks.
We should start with the development of conventional configuration. It is needed to check the status of query string (set it or not). Save it in a variable before container nav-tab-wrapper.
In WordPress there is a class nav-tab-active. We can apply to our link to change its type, if it is activity.
Next, we compare a variable called $active_tab variable that contains the query string. Then apply the class to this tab.
Your code will look like this: image…..
We put PHP code in data values for all links. This code will give the command: “If the variable tab is equal to the value display_options, the inserted class name nav-tab-active, otherwise no action is produced”. Testing the developed functionality.
Your function should look like this: image……
Switching content in the setting page
This setup guide is almost at an end. We just need to switch the contents of the settings page based on which tab is active at this moment.
Since we store all data in active_tab variable, then we need to go to Settings API, which uses conditional Assembly. Looking for the following block of code: image…….
There are two types of call functions do_settings_section and settings_fields. We want to display only one section, in the case of selecting the appropriate bookmark.
Write a simple condition that will work on checking the value of the variable $active_tab and running as sections of the image…..
Then you only need to update your page and make sure that everything is functioning normally.