public function get_options_data($options = 0)
 {
     $structure = cwpposConfig::$structure;
     $defaults = cwppos_get_config_defaults($structure);
     $option = get_option(cwppos_config("menu_slug"));
     $options = array_merge($defaults, is_array($option) ? $option : array());
     $data = array();
     foreach ($structure as $k => $fields) {
         if ($fields['type'] == 'tab') {
             foreach ($fields['options'] as $r => $field) {
                 if ($field['type'] == 'group') {
                     foreach ($field['options'] as $m => $gfield) {
                         if ($gfield["type"] != 'title') {
                             $data[$gfield['id']] = array("default" => $options[$gfield['id']], "type" => $gfield['type']);
                         }
                     }
                 } else {
                     if ($field["type"] != 'title') {
                         $data[$field['id']] = array("default" => $options[$field['id']], "type" => $field['type']);
                     }
                 }
             }
         }
     }
     return $data;
 }
Example #2
0
function cwppos_load_defaults_callback()
{
    $errors = cwppos_check_config();
    if (!empty($errors)) {
        return false;
    }
    delete_option(cwppos_config("menu_slug"));
    $validator = new cwpposOptionsValidator();
    $structure = cwpposConfig::$structure;
    $defaults = cwppos_get_config_defaults($structure);
    $defaults = $validator->validate_defaults();
    add_option(cwppos_config("menu_slug"), $defaults, "", "no");
    die;
}