/**
  * Apply configuration.
  */
 protected function configure($config = null)
 {
     // gurantee configuration
     $config !== null or $config = array();
     // invoke htmltag instance configuration
     if (isset($config['attrs'])) {
         parent::configure($config['attrs']);
         unset($config['attrs']);
     } else {
         // no html attributes set
         parent::configure(array());
     }
     // setup meta fields
     $this->meta = custom_body_class::instance('CustomBodyClassMeta', $config);
 }
 /**
  * @return string attributes
  */
 function htmlattributes(array $extra = array())
 {
     $attr_segments = array();
     $attributes = custom_body_class::merge($this->attrs->metadata_array(), $extra);
     foreach ($attributes as $key => $value) {
         if ($value !== false && $value !== null) {
             if (!empty($value)) {
                 if (is_array($value)) {
                     $htmlvalue = implode(' ', $value);
                     $attr_segments[] = "{$key}=\"{$htmlvalue}\"";
                 } else {
                     // value is not an array
                     $attr_segments[] = "{$key}=\"{$value}\"";
                 }
             } else {
                 // empty html tag; ie. no value html tag
                 $attr_segments[] = $key;
             }
         }
     }
     return implode(' ', $attr_segments);
 }
<?php

defined('ABSPATH') or die;
$basepath = dirname(__FILE__) . DIRECTORY_SEPARATOR;
$debug = false;
if (isset($_GET['debug']) && $_GET['debug'] == 'true') {
    $debug = true;
}
$debug = true;
$options = get_option('custom_body_class_settings');
$display_settings = false;
if (isset($options['display_settings'])) {
    $display_settings = $options['display_settings'];
}
return array('plugin-name' => 'custom_body_class', 'settings-key' => 'custom_body_class_settings', 'textdomain' => 'custom_body_class_txtd', 'template-paths' => array($basepath . 'core/views/form-partials/', $basepath . 'views/form-partials/'), 'fields' => array('hiddens' => include 'settings/hiddens' . EXT, 'general' => include 'settings/general' . EXT), 'processor' => array('preupdate' => array('save_settings'), 'postupdate' => array()), 'cleanup' => array('switch' => array('switch_not_available')), 'checks' => array('counter' => array('is_numeric', 'not_empty')), 'errors' => array('not_empty' => __('Invalid Value.', custom_body_class::textdomain())), 'callbacks' => array('save_settings' => 'save_custom_body_class_settings'), 'debug' => $debug);
# config
<?php

defined('ABSPATH') or die;
// ensure EXT is defined
if (!defined('EXT')) {
    define('EXT', '.php');
}
$basepath = dirname(__FILE__) . DIRECTORY_SEPARATOR;
require $basepath . 'core' . EXT;
// load classes
$interfacepath = $basepath . 'interfaces' . DIRECTORY_SEPARATOR;
custom_body_class::require_all($interfacepath);
$classpath = $basepath . 'classes' . DIRECTORY_SEPARATOR;
custom_body_class::require_all($classpath);
// load callbacks
$callbackpath = $basepath . 'callbacks' . DIRECTORY_SEPARATOR;
custom_body_class::require_all($callbackpath);
 /**
  * Execute postupdate hooks on input.
  */
 protected function postupdate($input)
 {
     $defaults = custom_body_class::defaults();
     $plugin_hooks = $this->meta->get('processor', array('preupdate' => array(), 'postupdate' => array()));
     // Calculate hooks
     // ---------------
     $hooks = array();
     // check custom_body_class defaults
     if (isset($defaults['processor']['postupdate'])) {
         $hooks = $defaults['processor']['postupdate'];
     }
     // check plugin defaults
     if (isset($plugin_hooks['postupdate'])) {
         $hooks = array_merge($hooks, $plugin_hooks['postupdate']);
     }
     // Execute hooks
     // -------------
     foreach ($hooks as $rule) {
         $callback = custom_body_class::callback($rule, $this->meta);
         call_user_func($callback, $input, $this);
     }
 }
 /**
  * @param string template path
  * @param array  configuration
  *
  * @return string
  */
 function fieldtemplate($templatepath, $conf = array())
 {
     $config = custom_body_class::instance('CustomBodyClassMeta', $conf);
     return $this->fieldtemplate_render($templatepath, $config);
 }
 /**
  * @param string rule
  *
  * @return string error message
  */
 function error_message($rule)
 {
     if (self::$error_message_cache === null) {
         $defaults = custom_body_class::defaults();
         $default_errors = $defaults['errors'];
         $plugin_errors = $this->meta->get('errors', array());
         self::$error_message_cache = array_merge($default_errors, $plugin_errors);
     }
     return self::$error_message_cache[$rule];
 }
<?php

return array('cleanup' => array('switch' => array('switch_not_available')), 'checks' => array('counter' => array('is_numeric', 'not_empty')), 'processor' => array('preupdate' => array(), 'postupdate' => array()), 'errors' => array('is_numeric' => __('Numberic value required.', custom_body_class::textdomain()), 'not_empty' => __('Field is required.', custom_body_class::textdomain())), 'callbacks' => array('switch_not_available' => 'custom_body_class_cleanup_switch_not_available', 'is_numeric' => 'custom_body_class_validate_is_numeric', 'not_empty' => 'custom_body_class_validate_not_empty'));
# config
 /**
  * Sets a custom text domain; if null is passed the text domain will revert
  * to the default text domain.
  */
 static function settextdomain($textdomain)
 {
     if (!empty($textdomain)) {
         self::$textdomain = $textdomain;
     } else {
         // null or otherwise empty value
         // revert to default
         self::$textdomain = 'custom_body_class_txtd';
     }
 }
		<?php 
    }
    ?>

		<?php 
    if ($processor->performed_update()) {
        ?>
			<br/>
			<p class="update-nag">
				<?php 
        _e('Settings have been updated.', 'custom_body_class_txtd');
        ?>
			</p>
		<?php 
    }
    echo $f = custom_body_class::form($config, $processor);
    echo $f->field('hiddens')->render();
    echo $f->field('general')->render();
    ?>

		<button type="submit" class="button button-primary">
			<?php 
    _e('Save Changes', 'custom_body_class_txtd');
    ?>
		</button>

		<?php 
    echo $f->endform();
    ?>

	<?php