Toggle
The toggle
lets you add a field toggle.

Parameters
Here are the parameters in adding toggle
.
id
string | required
a unique slug-like string to use as an id and also as index in saving data in database.
label
string | optional
the label of the field.
description
string | optional
the description of the field and display under the label.
section
string | requiredl
the section where the field will be displayed.
default
boolean | optional
the default value of the field.
priority
integer | optional
determines the order of fields in section.
Example
Yano::field( 'toggle', [
'id' => 'toggledb1',
'label' => 'Do you want to show?',
'description' => 'Some description',
'section' => 'section_id',
'priority' => 1,
] );
Example with default
value! note: default value must be provided boolean
.
Yano::field( 'toggle', [
'id' => 'toggledb1',
'label' => 'Do you want to show?',
'description' => 'Some description',
'section' => 'section_id',
'default' => true,
'priority' => 1,
] );
Usage
The get_theme_mod()
function is recommended to retrieve data.
// Returns boolean
$is_checked = get_theme_mod('toggledb1');