Function Reference: themeblvd_add_option_section
This function adds a section of options to a pre-existing options tab.
Usage
themeblvd_add_option_section( $tab_id, $section_id, $section_name, $section_desc, $options, $top );
Parameters
- $tab_id
- (string) (required) The ID of the tab that the new section will be added to.
- Default: None
- $section_id
- (string) (required) The ID of the new section.
- Default: None
- $section_name
- (string) (required) The name of the new section.
- Default: None
- $section_desc
- (string) (optional) The description of the new section.
- Default: None
- $options
- (array) (optional) The array of options for the section. Note that you could initially leave this empty if you'd like to add options individually to this new section with
themeblvd_add_option()
function.- Default: None
- $top
- (boolean) (optional) Whether the new option section should appear at the top of the tab or not. By default, this will be false, and so the new option section will appear at the end of the tab.
- Default: false
Examples
In this example, we’ll add a new tab called “Styles” and then add a section to the top of this new tab. Let’s say we want the user to have an option to select dark or light color for three sections of the theme – the header, the main content, and the footer.
So this will be a section called “Colors” and will consist of three option values.
/** * Add "Styles" tab. */ themeblvd_add_option_tab('styles', 'Styles'); /** * Add section of options. */ themeblvd_add_option_section('styles', 'colors', 'Colors', 'This is the description for our section.', array( array( 'name' => 'Header Color', 'desc' => 'Select a color for the header.', 'id' => 'header_color', 'std' => 'light', 'type' => 'select', 'options' => array( 'light' => 'Light', 'dark' => 'Dark' ) ), array( 'name' => 'Main Content Color', 'desc' => 'Select a color for the main content area.', 'id' => 'main_color', 'std' => 'light', 'type' => 'select', 'options' => array( 'light' => 'Light', 'dark' => 'Dark' ) ), array( 'name' => 'Footer Color', 'desc' => 'Select a color for the footer.', 'id' => 'footer_color', 'std' => 'light', 'type' => 'select', 'options' => array( 'light' => 'Light', 'dark' => 'Dark' ) ) ));
The result will look something like this:
And on the frontend of the site, we could retrieve these three options like this:
$hcolor = themeblvd_get_option('header_color'); $mcolor = themeblvd_get_option('main_color'); $fcolor = themeblvd_get_option('footer_color');
Function Reference: themeblvd_remove_option_section
This function removes a section and all options within.
Usage
themeblvd_remove_option_section( $tab_id, $section_id );
Parameters
- $tab_id
- (string) (required) ID of tab, that the section belongs to.
- Default: None
- $section_id
- (string) (required) ID of section to be removed.
- Default: None
Examples
Let’s say you’ve hooked in and created an entirely custom footer for your client. To avoid confusion it might make sense to just remove the entire section of options for controlling the footer.
You’d just do the following.
themeblvd_remove_option_section('layout', 'footer');