1. Go to this page and download the library: Download sergeliatko/wpsettings 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/ */
sergeliatko / wpsettings example snippets
//make use of the class once in your file
use \SergeLiatko\WPSettings\Setting;
//then create setting like this
$my_option = new Setting( array(
'option' => 'option_name_in_db',
'label' => __( 'My option label', 'my-text-domain' )
) );
//...
//make use of the Setting class once in your file
use \SergeLiatko\WPSettings\Setting;
//...
//then create setting like this
$my_option = Setting::createInstance( array(
'option' => 'option_name_in_db',
'label' => __( 'My option label', 'my-text-domain' )
) );
//...
//...
//make use of the Section class once in your file
use SergeLiatko\WPSettings\Section;
//...
//then create settings section like this
$my_section = Section::createInstance( array(
'id' => 'custom-section-id',
'title' => __( 'My section title', 'my-text-domain' ),
'description' => __( 'This is section description text that appears above setting fields.', 'my-text-domain' ),
'settings' => array(
array(
'option' => 'option_1_name_in_db',
'label' => __( 'My option 1 label', 'my-text-domain' ),
),
array(
'option' => 'option_2_name_in_db',
'label' => __( 'My option 2 label', 'my-text-domain' ),
),
),
) );
//...
//...
//make use of the Page class once in your file
use SergeLiatko\WPSettings\Page;
//...
//then create admin page like this
$my_section = Page::createInstance( array(
'slug' => 'my-admin-page',
'label' => __( 'My Admin Page', 'my-text-domain' ),
'sections' => array(
array(
'id' => 'default',
'title' => __( 'My section title', 'my-text-domain' ),
'description' => __( 'In this section my setting fields will appear', 'my-text-domain' ),
'settings' => array(
array(
'option' => 'option_1_name_in_db',
'label' => __( 'My option 1 label', 'my-text-domain' ),
),
array(
'option' => 'option_2_name_in_db',
'label' => __( 'My option 2 label', 'my-text-domain' ),
),
),
),
),
) );
//...