Skip to content

ConfigRegistry

Daniel M. Hendricks edited this page Aug 26, 2017 · 2 revisions

ConfigRegistry loads plugin/theme settings from an array or JSON file.

Instantiation

You can load settings from a JSON file (example):

use WordPress_ToolKit\ConfigRegistry;

$cache = new ConfigRegistry( '/path/to/config.json' );

...or you can load from an array:

use WordPress_ToolKit\ConfigRegistry;

$config = new ConfigRegistry(
  'name' => 'My Plugin',
  'slug' => 'my-plugin',
  'data' => array(
    'version' => '1.0.0',
    'textdomain' => 'my-text-domain'
  )
);

Usage Examples

Getting a configuration option:

$version = $config->get('data/version');

Merging two ConfigRegistry objects:

$config = $config->merge( new ConfigRegistry( '/path/to/other.json' ) );
Clone this wiki locally