1. Go to this page and download the library: Download ssovit/wp-util library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
add_filter("sovit/settings/{$page_id}/sections",function($sections){
$sections["general_setting"]=[
"label"=>__("General Settings","textdomain"),
"render_callback"=>"my_section_callback"
];
return $sections;
});
function my_section_callback(){
echo "My Section Content";
}
add_filter("sovit/settings/{$page_id}/fields",function($fields){
$fields["fruit"]=[
"label"=>__("Fruit","textdomain"),
'section' => "general_setting",
'tab' => "general",
'type' => 'select',
"options" => [
"apple" => __("Apple", "textdomain"),
],
'desc' => esc_html__('Select a fruit', "textdomain"),
// There are other options based on field types
// see lib/Controls.php
];
return $fields;
});
add_filter("sovit/settings/{$page_id}/fields",function($sections){
$fields["fruit"]=[
"label"=>__("Fruit","textdomain"),
"render_callback"=>"my_custom_field",
// .. other field data
];
return $fields;
});
function my_custom_field($field=array()){
echo "<pre>".print_r($field,true)."</pre>"; // print field data
}
add_filter("sovit/settings/{$page_id}/fields",function($sections){
$fields["age"]=[
"label"=>__("Age","textdomain"),
"render_callback"=>"my_custom_field",
"validate_callback"=>"my_field_validation",
"sanitize_callback"=>"my_field_sanitization",
// other field options
];
return $fields;
});
function validate_callback($value){
return is_int($value) && $value>5; // return true if age is integer and greater than 5
}
function sanitize_callback($value){
return sanitize_text_field($value);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.