PHP code example of rockschtar / wordpress-settings
1. Go to this page and download the library: Download rockschtar/wordpress-settings 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/ */
rockschtar / wordpress-settings example snippets
use Rockschtar\WordPress\Settings\Fields\InputText;
use Rockschtar\WordPress\Settings\Fields\SelectBox;
use Rockschtar\WordPress\Settings\Models\ListItem;
use Rockschtar\WordPress\Settings\Models\Section;
use Rockschtar\WordPress\Settings\Models\SettingsPage;
add_action('rswp_create_settings', function (): void {
$page = SettingsPage::create('my-plugin-settings')
->setPageTitle('My Plugin')
->setMenuTitle('My Plugin')
->setCapability('manage_options');
$section = Section::create('my-plugin-general', $page)
->setTitle('General');
InputText::create('my_plugin_api_key')
->setLabel('API Key')
->setDescription('Your API key.')
->setPlaceholder('sk-...')
->addToSection($section);
SelectBox::create('my_plugin_environment')
->setLabel('Environment')
->addItem(ListItem::create('production', 'Production'))
->addItem(ListItem::create('staging', 'Staging'))
->addItem(ListItem::create('development', 'Development'))
->addToSection($section);
rswp_register_settings_page($page);
});