Skip to content

Config Helpers

Wireframe\Config manipulates a config array before you pass it to App::boot(). Every helper returns a new array.

use Wireframe\Config;
// Add a field after another
$config = Config::addFieldAfter('site_name', [
'id' => 'subtitle', 'type' => 'text', 'label' => 'Subtitle',
], $config);
// Add a field before another
$config = Config::addFieldBefore('email', [
'id' => 'prefix', 'type' => 'text', 'label' => 'Prefix',
], $config);
// Modify an existing field
$config = Config::modifyField('site_name', [
'required' => true,
'validation' => 'min:5',
], $config);
// Remove a field
$config = Config::removeField('tagline', $config);
// Add a section to a tab
$config = Config::addSection('general', [
'id' => 'social', 'title' => 'Social Links', 'fields' => [/* … */],
], $config);
// Add or remove tabs and sections
$config = Config::addTab(['id' => 'integrations', 'title' => 'Integrations', 'sections' => [/* … */]], $config);
$config = Config::removeTab('advanced', $config);
$config = Config::removeSection('deprecated', $config);

Use them to build up an inline config, or to load a base config file and adjust it before boot:

add_action('init', function () {
$config = require __DIR__ . '/config/settings.php';
$config = Config::addFieldAfter('site_name', [
'id' => 'powered_by', 'type' => 'text', 'label' => 'Powered By',
], $config);
Wireframe\App::boot([
'prefix' => 'my-plugin',
'config' => $config,
]);
});

Like every Wireframe\ class, Config must not be used before plugins_loaded.