A reusable, namespaced wrapper around the native WordPress Settings API that powers the admin interfaces across WebberZone plugins. It ships with opinionated helpers for:
- Building tabbed settings pages with reusable field renderers.
- Managing sanitization, defaults, upgrades, and Help tabs from a single configuration array.
- Rendering meta boxes that reuse the same field definitions as your settings screens.
- Providing setup wizards, CSS/JS assets, and an extendable Hook Registry utility.
Use the package as-is or as a reference implementation when building complex plugin settings screens.
Settings_API/
├── class-settings.php # Example settings-controller implementation
├── class-metabox.php # Example post meta box integration
├── sidebar.php # Default help/CTA sidebar partial
├── util/
│ └── class-hook-registry.php # Lightweight registry for actions/filters
└── settings/
├── class-settings-api.php # Core Settings API wrapper
├── class-settings-form.php # Field renderer callbacks
├── class-settings-sanitize.php # Sanitization helpers per field type
├── class-settings-wizard-api.php # Optional multi-step setup wizard
├── class-metabox-api.php # Meta box helper using the same fields
├── css/ # Admin styles (tabs, wizard, RTL variants)
└── js/ # Admin scripts (media, CodeMirror glue, etc.)
Everything is namespaced under WebberZone\Settings_API\Admin (or ...\Admin\Settings). Update the namespace to match your plugin if you integrate the code directly into your project root.
-
Copy the files. Bring the entire
settingsdirectory plus the exampleclass-settings.php,class-metabox.php,sidebar.php, andutil/class-hook-registry.phpinto your plugin (adjust paths to suit your structure). -
Autoload the classes. Either map the
WebberZone\Settings_APInamespace via Composer/PSR-4 orrequire_oncethe files before usage. -
Update identifiers. Replace the sample prefix (
ata), option key (ata_settings), text domain (add-to-all), post types, and URLs with values from your plugin. -
Wire into WordPress. Instantiate your customized
Settingsclass onplugins_loaded/admin_initso it can register menus, fields, and assets:add_action( 'plugins_loaded', function () { $settings = new \WebberZone\Settings_API\Admin\Settings(); $settings->initialise_settings(); } );
-
Hook sanitization + upgrades. Each settings prefix registers filters such as
{$prefix}_settings_sanitizeand{$prefix}_translation_stringsso your plugin can inject or adjust data.
class-settings.php is a full implementation showing how to:
- Define translation strings, admin menus, sections, and fields via dedicated methods.
- Inject the
Settings_APIclass with arrays generated by those methods. - Extend the UI with help tabs, contextual sidebars, and custom admin footer text.
Copy the class into your plugin’s namespace, rename the class (e.g. Settings → Plugin_Settings), and edit the arrays returned by methods such as get_registered_settings() to match your data.
class-metabox.php and settings/class-metabox-api.php illustrate how to reuse the same field definitions within meta boxes. Supply the field array via get_registered_settings() and the API will render/save the data with nonce and capability checks.
The repo includes two sidebar templates (sidebar.php at the root and settings/sidebar.php). Replace the copy with content relevant to your plugin (support links, upsells, etc.) and include it through the help_sidebar argument passed to Settings_API.
- Issues & PRs: https://github.com/WebberZone/Settings_API
- Documentation & usage examples live across WebberZone plugins such as Better Search, Contextual Related Posts, and Knowledge Base.
If you ship this code in your plugin, please keep the copyright headers intact and share improvements back via pull requests.