Exemple #1
0
<?php

echo $wrapper_before;
if (isset($field['slug']) && isset($_GET[$field['slug']])) {
    $field_value = Caldera_Forms_Sanitize::sanitize($_GET[$field['slug']]);
}
?>
	<?php 
echo $field_label;
?>
	<?php 
echo $field_before;
?>
		<select <?php 
echo $field_placeholder;
?>
 id="<?php 
echo $field_id;
?>
" data-field="<?php 
echo $field_base_id;
?>
" class="<?php 
echo $field_class;
?>
" name="<?php 
echo $field_name;
?>
" <?php 
echo $field_required;
?>
/**
 * Change form to be rendered
 *
 * @since 0.1.0
 *
 * @uses "caldera_forms_render_get_form" filter
 *
 * @param array $form The form config
 *
 * @return array
 */
function cf_form_connector_change_form($form)
{
    if (isset($_GET['cf_con']) && isset($_GET['cf_con_form_id']) && isset($_GET['cf_con_nonce']) && $_GET['cf_con'] && wp_verify_nonce($_GET['cf_con_nonce'], 'cf_con_nonce')) {
        remove_filter('caldera_forms_render_get_form', 'cf_form_connector_change_form');
        $_form = Caldera_Forms_Forms::get_form(Caldera_Forms_Sanitize::sanitize($_GET['cf_con_form_id']));
        if (is_array($_form)) {
            if (isset($_GET['cf_id']) && 0 < absint($_GET['cf_id'])) {
                add_filter('caldera_forms_render_entry_id', function ($entry_id) {
                    return (int) $_GET['cf_id'];
                });
            }
            $form = $_form;
        }
    }
    return $form;
}
Exemple #3
0
 /**
  * Get entries from a form
  *
  * @since 1.2.1
  *
  * @param string|array $form Form ID or form config.
  * @param int $page Optional. Page of entries to get per page. Default is 1.
  * @param int $perpage Optional. Number of entries per page. Default is 20.
  * @param string $status Optional. Form status. Default is active.
  *
  * @return array
  */
 public static function get_entries($form, $page = 1, $perpage = 20, $status = 'active')
 {
     if (is_string($form)) {
         $form = Caldera_Forms::get_form($form);
     }
     if (isset($form['ID'])) {
         $form_id = $form['ID'];
     } else {
         return;
     }
     global $wpdb;
     $field_labels = array();
     $backup_labels = array();
     $selects = array();
     // get all fieldtype
     $field_types = Caldera_Forms::get_field_types();
     $fields = array();
     if (!empty($form['fields'])) {
         foreach ($form['fields'] as $fid => $field) {
             $fields[$field['slug']] = $field;
             if (!empty($field['entry_list'])) {
                 $selects[] = "'" . $field['slug'] . "'";
                 $field_labels[$field['slug']] = $field['label'];
             }
             $has_vars = array();
             if (!empty($form['variables']['types'])) {
                 $has_vars = $form['variables']['types'];
             }
             if (count($backup_labels) < 4 && !in_array('entryitem', $has_vars) && in_array($field['type'], array('text', 'email', 'date', 'name'))) {
                 // backup only first 4 fields
                 $backup_labels[$field['slug']] = $field['label'];
             }
         }
     }
     if (empty($field_labels)) {
         $field_labels = $backup_labels;
     }
     //ksort($field_labels);
     $data = array();
     $filter = null;
     $data['trash'] = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(`id`) AS `total` FROM `" . $wpdb->prefix . "cf_form_entries` WHERE `form_id` = %s AND `status` = 'trash';", $form_id));
     $data['active'] = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(`id`) AS `total` FROM `" . $wpdb->prefix . "cf_form_entries` WHERE `form_id` = %s AND `status` = 'active';", $form_id));
     // set current total
     if (!empty($status) && isset($data[$status])) {
         $data['total'] = $data[$status];
     } else {
         $data['total'] = $data['active'];
     }
     $data['pages'] = ceil($data['total'] / $perpage);
     if (!empty($page)) {
         $page = abs($page);
         if ($page > $data['pages']) {
             $page = $data['pages'];
         }
     }
     $data['current_page'] = $page;
     $gmt_offset = get_option('gmt_offset');
     if ($data['total'] > 0) {
         $data['form'] = $form_id;
         $data['fields'] = $field_labels;
         $offset = ($page - 1) * $perpage;
         $limit = $offset . ',' . $perpage;
         $rawdata = $wpdb->get_results($wpdb->prepare("\n\t\t\tSELECT\n\t\t\t\t`id`,\n\t\t\t\t`form_id`\n\t\t\tFROM `" . $wpdb->prefix . "cf_form_entries`\n\n\t\t\tWHERE `form_id` = %s AND `status` = %s ORDER BY `datestamp` DESC LIMIT " . $limit . ";", $form_id, $status));
         if (!empty($rawdata)) {
             $ids = array();
             foreach ($rawdata as $row) {
                 $ids[] = $row->id;
             }
             $rawdata = $wpdb->get_results("\n\t\t\t\tSELECT\n\t\t\t\t\t`entry`.`id` as `_entryid`,\n\t\t\t\t\t`entry`.`form_id` AS `_form_id`,\n\t\t\t\t\t`entry`.`datestamp` AS `_date_submitted`,\n\t\t\t\t\t`entry`.`user_id` AS `_user_id`,\n\t\t\t\t\t`value`.*\n\n\t\t\t\tFROM `" . $wpdb->prefix . "cf_form_entries` AS `entry`\n\t\t\t\tLEFT JOIN `" . $wpdb->prefix . "cf_form_entry_values` AS `value` ON (`entry`.`id` = `value`.`entry_id`)\n\n\t\t\t\tWHERE `entry`.`id` IN (" . implode(',', $ids) . ")\n\t\t\t\t" . $filter . "\n\t\t\t\tORDER BY `entry`.`datestamp` DESC;");
             $data['entries'] = array();
             $dateformat = get_option('date_format');
             $timeformat = get_option('time_format');
             foreach ($rawdata as $row) {
                 if (!empty($row->_user_id)) {
                     $user = get_userdata($row->_user_id);
                     if (!empty($user)) {
                         $data['entries']['E' . $row->_entryid]['user']['ID'] = $user->ID;
                         $data['entries']['E' . $row->_entryid]['user']['name'] = $user->data->display_name;
                         $data['entries']['E' . $row->_entryid]['user']['email'] = $user->data->user_email;
                         $data['entries']['E' . $row->_entryid]['user']['avatar'] = get_avatar($user->ID, 64);
                     }
                 }
                 $data['entries']['E' . $row->_entryid]['_entry_id'] = $row->_entryid;
                 $data['entries']['E' . $row->_entryid]['_date'] = date_i18n($dateformat . ' ' . $timeformat, get_date_from_gmt($row->_date_submitted, 'U'));
                 // setup default data array
                 if (!isset($data['entries']['E' . $row->_entryid]['data'])) {
                     if (isset($field_labels)) {
                         foreach ($field_labels as $slug => $label) {
                             // setup labels ordering
                             $data['entries']['E' . $row->_entryid]['data'][$slug] = null;
                         }
                     }
                 }
                 if (!empty($field_labels[$row->slug])) {
                     $label = $field_labels[$row->slug];
                     // check view handler
                     $field = $fields[$row->slug];
                     // filter the field to get field data
                     $field = apply_filters('caldera_forms_render_get_field', $field, $form);
                     $field = apply_filters('caldera_forms_render_get_field_type-' . $field['type'], $field, $form);
                     $field = apply_filters('caldera_forms_render_get_field_slug-' . $field['slug'], $field, $form);
                     // maybe json?
                     $is_json = json_decode($row->value, ARRAY_A);
                     if (!empty($is_json)) {
                         $row->value = $is_json;
                     }
                     if (is_string($row->value)) {
                         $row->value = esc_html(stripslashes_deep($row->value));
                     } else {
                         $row->value = stripslashes_deep(Caldera_Forms_Sanitize::sanitize($row->value));
                     }
                     $row->value = apply_filters('caldera_forms_view_field_' . $field['type'], $row->value, $field, $form);
                     if (isset($data['entries']['E' . $row->_entryid]['data'][$row->slug])) {
                         // array based - add another entry
                         if (!is_array($data['entries']['E' . $row->_entryid]['data'][$row->slug])) {
                             $tmp = $data['entries']['E' . $row->_entryid]['data'][$row->slug];
                             $data['entries']['E' . $row->_entryid]['data'][$row->slug] = array($tmp);
                         }
                         $data['entries']['E' . $row->_entryid]['data'][$row->slug][] = $row->value;
                     } else {
                         $data['entries']['E' . $row->_entryid]['data'][$row->slug] = $row->value;
                     }
                 }
                 if (!empty($form['variables']['types'])) {
                     foreach ($form['variables']['types'] as $var_key => $var_type) {
                         if ($var_type == 'entryitem') {
                             $data['fields'][$form['variables']['keys'][$var_key]] = ucwords(str_replace('_', ' ', $form['variables']['keys'][$var_key]));
                             $data['entries']['E' . $row->_entryid]['data'][$form['variables']['keys'][$var_key]] = Caldera_Forms::do_magic_tags($form['variables']['values'][$var_key], $row->_entryid);
                         }
                     }
                 }
             }
         }
     }
     return $data;
 }
Exemple #4
0
 /**
  * Parse magic tags
  *
  * @param string $value
  * @param null|int $entry_id Optional. Entry ID to test by.
  * @param array $magic_caller The form/processorr/entry to evaluate against. May also be a powerful wizard.
  *
  * @return mixed
  */
 public static function do_magic_tags($value, $entry_id = null, $magic_caller = array())
 {
     global $processed_meta, $form, $referrer;
     /// get meta entry for magic tags defined.
     $input_value = $value;
     $this_form = $form;
     // pull in the metadata for entry ID
     if (null !== $entry_id) {
         $entry_details = self::get_entry_detail($entry_id);
         $this_form = Caldera_Forms_Forms::get_form($entry_details['form_id']);
         if (!empty($entry_details['meta'])) {
             foreach ($entry_details['meta'] as $meta_block) {
                 if (!empty($meta_block['data'])) {
                     foreach ($meta_block['data'] as $meta_process_id => $proces_meta_data) {
                         foreach ($proces_meta_data['entry'] as $process_meta_key => $process_meta_entry) {
                             $processed_meta[$this_form['ID']][$meta_process_id][$process_meta_key] = $process_meta_entry['meta_value'];
                         }
                     }
                 }
             }
         }
     }
     // check for magics
     preg_match_all("/\\{(.+?)\\}/", $value, $magics);
     if (!empty($magics[1])) {
         foreach ($magics[1] as $magic_key => $magic_tag) {
             $magic = explode(':', $magic_tag, 2);
             if (count($magic) == 2) {
                 switch (strtolower($magic[0])) {
                     case 'get':
                         if (isset($_GET[$magic[1]])) {
                             $magic_tag = Caldera_Forms_Sanitize::sanitize($_GET[$magic[1]]);
                         } else {
                             // check on referer.
                             if (isset($referrer['query'][$magic[1]])) {
                                 $magic_tag = $referrer['query'][$magic[1]];
                             } else {
                                 $magic_tag = null;
                             }
                         }
                         break;
                     case 'post':
                         if (isset($_POST[$magic[1]])) {
                             $magic_tag = Caldera_Forms_Sanitize::sanitize($_POST[$magic[1]]);
                         } else {
                             $magic_tag = null;
                         }
                         break;
                     case 'request':
                         if (isset($_REQUEST[$magic[1]])) {
                             $magic_tag = Caldera_Forms_Sanitize::sanitize($_REQUEST[$magic[1]]);
                         } else {
                             $magic_tag = null;
                         }
                         break;
                     case 'variable':
                         if (!empty($this_form['variables']['keys'])) {
                             foreach ($this_form['variables']['keys'] as $var_index => $var_key) {
                                 if ($var_key == $magic[1]) {
                                     if (!in_array($magic_tag, $magic_caller)) {
                                         $magic_caller[] = $magic_tag;
                                         $magic_tag = self::do_magic_tags($this_form['variables']['values'][$var_index], $entry_id, $magic_caller);
                                     } else {
                                         $magic_tag = $this_form['variables']['values'][$var_index];
                                     }
                                 }
                             }
                         }
                         break;
                     case 'date':
                         $magic_tag = get_date_from_gmt(date('Y-m-d H:i:s'), $magic[1]);
                         break;
                     case 'user':
                         if (is_user_logged_in()) {
                             $user = get_userdata(get_current_user_id());
                             if (isset($user->data->{$magic[1]})) {
                                 $magic_tag = $user->data->{$magic[1]};
                             } else {
                                 if (strtolower($magic[1]) == 'id') {
                                     $magic_tag = $user->ID;
                                 } else {
                                     $magic_tag = get_user_meta($user->ID, $magic[1], true);
                                 }
                             }
                         } else {
                             $magic_tag = null;
                         }
                         break;
                     case 'embed_post':
                         global $post;
                         if (is_object($post)) {
                             if (isset($post->{$magic[1]})) {
                                 $magic_tag = $post->{$magic[1]};
                             } else {
                                 // extra post data
                                 switch ($magic[1]) {
                                     case 'permalink':
                                         $magic_tag = get_permalink($post->ID);
                                         break;
                                 }
                             }
                         } else {
                             $magic_tag = null;
                         }
                         break;
                     case 'post_meta':
                         global $post;
                         if (is_object($post)) {
                             $post_metavalue = get_post_meta($post->ID, $magic[1]);
                             if (false !== strpos($magic[1], ':')) {
                                 $magic[3] = explode(':', $magic[1]);
                             }
                             if (empty($post_metavalue)) {
                                 $magic_tag = null;
                             } else {
                                 if (empty($magic[3])) {
                                     $magic_tag = implode(', ', $post_metavalue);
                                 } else {
                                     $outmagic = array();
                                     foreach ($magic[3] as $subkey => $subvalue) {
                                         foreach ((array) $post_metavalue as $subsubkey => $subsubval) {
                                             if (isset($subsubval[$subvalue])) {
                                                 $outmagic[] = $post_metavalue;
                                             }
                                         }
                                     }
                                     $magic_tag = implode(', ', $outmagic);
                                 }
                             }
                         } else {
                             $magic_tag = null;
                         }
                         break;
                 }
             } else {
                 switch ($magic_tag) {
                     case 'entry_id':
                         $magic_tag = self::get_field_data('_entry_id', $this_form);
                         if ($magic_tag === null) {
                             // check if theres an entry
                             if (!empty($_GET['cf_ee'])) {
                                 $entry = self::get_entry_detail($_GET['cf_ee'], $this_form);
                                 if (!empty($entry)) {
                                     $magic_tag = $entry['id'];
                                 }
                             }
                         }
                         break;
                     case 'entry_token':
                         $magic_tag = self::get_field_data('_entry_token', $this_form);
                         break;
                     case 'ip':
                         $ip = $_SERVER['REMOTE_ADDR'];
                         if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
                             $ip = $_SERVER['HTTP_CLIENT_IP'];
                         } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
                             $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
                         }
                         $magic_tag = $ip;
                         break;
                     case 'ua':
                         $magic_tag = $_SERVER['HTTP_USER_AGENT'];
                         break;
                     case 'summary':
                         if (!empty($this_form['fields'])) {
                             $out = array();
                             foreach ($this_form['fields'] as $field_id => $field) {
                                 if (in_array($field['type'], array('button', 'recaptcha', 'html'))) {
                                     continue;
                                 }
                                 // filter the field to get field data
                                 $field = apply_filters('caldera_forms_render_get_field', $field, $this_form);
                                 $field = apply_filters('caldera_forms_render_get_field_type-' . $field['type'], $field, $this_form);
                                 $field = apply_filters('caldera_forms_render_get_field_slug-' . $field['slug'], $field, $this_form);
                                 $field_values = (array) self::get_field_data($field_id, $this_form);
                                 if (isset($field_values['label'])) {
                                     $field_values = $field_values['value'];
                                 } else {
                                     foreach ($field_values as $field_key => $field_value) {
                                         if (isset($field_value['label']) && isset($field_value['value'])) {
                                             $field_value[$field_key] = $field_value['value'];
                                         }
                                     }
                                 }
                                 $field_value = implode(', ', (array) $field_values);
                                 if ($field_value !== null && strlen($field_value) > 0) {
                                     $out[] = $field['label'] . ': ' . $field_value;
                                 }
                             }
                             // vars
                             if (!empty($this_form['variables'])) {
                                 foreach ($this_form['variables']['keys'] as $var_key => $var_label) {
                                     if ($this_form['variables']['types'][$var_key] == 'entryitem') {
                                         $label = ucfirst(str_replace('_', ' ', $var_label));
                                         $out[] = $label . ': ' . $this_form['variables']['values'][$var_key];
                                     }
                                 }
                             }
                             if (!empty($out)) {
                                 $magic_tag = implode("\r\n", $out);
                             } else {
                                 $magic_tag = '';
                             }
                         }
                         break;
                     case 'login_url':
                         $magic_tag = wp_login_url();
                         break;
                     case 'logout_url':
                         $magic_tag = wp_logout_url();
                         break;
                     case 'register_url':
                         $magic_tag = wp_registration_url();
                         break;
                     case 'lostpassword_url':
                         $magic_tag = wp_lostpassword_url();
                         break;
                 }
             }
             $filter_value = apply_filters('caldera_forms_do_magic_tag', $magic_tag, $magics[0][$magic_key]);
             if (!empty($this_form['ID'])) {
                 // split processor
                 if (!empty($magic[1])) {
                     if (false !== strpos($magic[1], ':')) {
                         $magic = array_reverse(explode(':', $magic[1]));
                     }
                 }
                 // check if its a process id or processor slug
                 if (empty($processed_meta[$this_form['ID']][$magic[0]]) && !empty($this_form['processors'])) {
                     // if not a direct chec if theres a slug
                     foreach ($this_form['processors'] as $processid => $processor) {
                         if ($processor['type'] === $magic[0]) {
                             if (!empty($processed_meta[$this_form['ID']][$processid])) {
                                 $magic[0] = $processid;
                                 break;
                             }
                         }
                     }
                 }
                 if (!empty($processed_meta[$this_form['ID']][$magic[0]])) {
                     if (isset($processed_meta[$this_form['ID']][$magic[0]][$magic[1]])) {
                         // direct fined
                         $filter_value = implode(', ', (array) $processed_meta[$this_form['ID']][$magic[0]][$magic[1]]);
                     } else {
                         foreach ($processed_meta[$this_form['ID']][$magic[0]] as $return_array) {
                             foreach ($return_array as $return_line) {
                                 if (isset($return_line[$magic[1]])) {
                                     $filter_value = $return_line[$magic[1]];
                                 }
                             }
                         }
                     }
                 }
             }
             if ($filter_value != $magics[1][$magic_key]) {
                 $value = str_replace($magics[0][$magic_key], $filter_value, $value);
             }
         }
     }
     // fields
     $regex = "/%([a-zA-Z0-9_:]*)%/";
     preg_match_all($regex, $value, $matches);
     if (!empty($matches[1])) {
         foreach ($matches[1] as $key => $tag) {
             // check for parts
             $part_tags = explode(':', $tag);
             if (!empty($part_tags[1])) {
                 $tag = $part_tags[0];
             }
             $entry = self::get_slug_data($tag, $this_form, $entry_id);
             if ($entry !== null) {
                 $field = self::get_field_by_slug($tag, $this_form);
             }
             if (!empty($field) && !empty($part_tags[1]) && $part_tags[1] == 'label') {
                 if (!is_array($entry)) {
                     $entry = (array) $entry;
                 }
                 foreach ((array) $entry as $entry_key => $entry_line) {
                     if (!empty($field['config']['option'])) {
                         foreach ($field['config']['option'] as $option) {
                             if ($option['value'] == $entry_line) {
                                 $entry[$entry_key] = $option['label'];
                             }
                         }
                     }
                 }
             }
             if (is_array($entry)) {
                 if (count($entry) === 1) {
                     $entry = array_shift($entry);
                 } elseif (count($entry) === 2) {
                     $entry = implode(', ', $entry);
                 } elseif (count($entry) > 2) {
                     $last = array_pop($entry);
                     $entry = implode(', ', $entry) . ', ' . $last;
                 } else {
                     $entry = null;
                 }
             }
             $value = str_replace($matches[0][$key], $entry, $value);
         }
     }
     return $value;
 }
 /**
  * Get a field's data.
  *
  * @param string $field_id ID of field.
  * @param string|array $form Form config array or ID of form.
  * @param bool|false $entry_id Optional. Entry ID to save in.
  *
  * @return bool
  */
 public static function get_field_data($field_id, $form, $entry_id = false)
 {
     global $processed_data;
     //echo $field_id.'<br>';
     if (is_string($form)) {
         $form = self::get_form($form);
         if (!isset($form['ID']) || $form['ID'] !== $form) {
             return null;
         }
     }
     $indexkey = $form['ID'];
     if (!empty($entry_id)) {
         $indexkey = $form['ID'] . '_' . $entry_id;
     }
     // is ID or slug?
     if (!isset($form['fields'][$field_id])) {
         foreach ($form['fields'] as $field) {
             if ($field['slug'] == $field_id) {
                 $field_id = $field['ID'];
                 break;
             }
         }
     }
     // get processed cached item
     if (isset($processed_data[$indexkey][$field_id])) {
         return $processed_data[$indexkey][$field_id];
     }
     // entry fetch
     if (!empty($entry_id) && isset($form['fields'][$field_id])) {
         global $wpdb;
         $entry = $wpdb->get_results($wpdb->prepare("\n\t\t\t\tSELECT `value` FROM `" . $wpdb->prefix . "cf_form_entry_values` WHERE `entry_id` = %d AND `field_id` = %s AND `slug` = %s", $entry_id, $field_id, $form['fields'][$field_id]['slug']), ARRAY_A);
         //allow plugins to alter the value
         $entry = apply_filters('caldera_forms_get_field_entry', $entry, $field_id, $form, $entry_id);
         if (!empty($entry)) {
             if (count($entry) > 1) {
                 $out = array();
                 foreach ($entry as $item) {
                     $out[] = $item['value'];
                 }
                 $processed_data[$indexkey][$field_id] = $out;
             } else {
                 $processed_data[$indexkey][$field_id] = $entry[0]['value'];
             }
         } else {
             $processed_data[$indexkey][$field_id] = null;
         }
         return $processed_data[$indexkey][$field_id];
         //return $processed_data[$indexkey][$field_id] = ;
     }
     if (isset($form['fields'][$field_id])) {
         // get field
         $field = apply_filters('caldera_forms_render_setup_field', $form['fields'][$field_id], $form);
         if (empty($field) || !isset($field['ID'])) {
             return null;
         }
         // get field types
         $field_types = self::get_field_types();
         if (!isset($field_types[$field['type']])) {
             return null;
         }
         $entry = null;
         // dont bother if conditions say it shouldnt be here.
         if (!empty($field['conditions']['type'])) {
             if (!self::check_condition($field['conditions'], $form, $entry_id)) {
                 $processed_data[$indexkey][$field_id] = $entry;
                 return $entry;
             }
         }
         // check condition to see if field should be there first.
         // check if conditions match first. ignore vailators if not part of condition
         if (isset($_POST[$field_id])) {
             $entry = Caldera_Forms_Sanitize::sanitize($_POST[$field_id]);
         } elseif (isset($_POST[$field['slug']])) {
             // is slug maybe?
             $entry = Caldera_Forms_Sanitize::sanitize($_POST[$field['slug']]);
         }
         // apply field filter
         if (has_filter('caldera_forms_process_field_' . $field['type'])) {
             $entry = apply_filters('caldera_forms_process_field_' . $field['type'], $entry, $field, $form);
             if (is_wp_error($entry)) {
                 $processed_data[$indexkey][$field_id] = $entry;
                 return $entry;
             }
         }
         if (is_string($entry) && strlen($entry) <= 0) {
             $entry = null;
         }
         // is static
         if (!empty($field_types[$field['type']]['static'])) {
             // is options or not
             if (!empty($field_types[$field['type']]['options'])) {
                 if (is_array($entry)) {
                     $out = array();
                     foreach ($entry as $option_id => $option) {
                         if (isset($field['config']['option'][$option_id])) {
                             if (!isset($field['config']['option'][$option_id]['value'])) {
                                 $field['config']['option'][$option_id]['value'] = $field['config']['option'][$option_id]['label'];
                             }
                             $out[$option_id] = self::do_magic_tags($field['config']['option'][$option_id]['value']);
                             //$out[ $option_id ] = array( 'value' => self::do_magic_tags($field['config']['option'][$option_id]['value']), 'label' => $field['config']['option'][$option_id]['label'] );
                         } elseif (isset($field['config']['option'][$option])) {
                             if (!isset($field['config']['option'][$option]['value'])) {
                                 $field['config']['option'][$option]['value'] = $field['config']['option'][$option]['label'];
                             }
                             $out[$option_id] = self::do_magic_tags($field['config']['option'][$option]['value']);
                             //$out[ $option_id ] = array( 'value' => self::do_magic_tags($field['config']['option'][$option]['value']), 'label' => $field['config']['option'][$option]['label'] );
                         }
                     }
                     $processed_data[$indexkey][$field_id] = $out;
                 } else {
                     if (!empty($field['config']['option'])) {
                         foreach ($field['config']['option'] as $option) {
                             if ($option['value'] == $entry) {
                                 $processed_data[$indexkey][$field_id] = self::do_magic_tags($entry);
                                 break;
                             }
                         }
                     }
                 }
             } else {
                 $processed_data[$indexkey][$field_id] = self::do_magic_tags($field['config']['default']);
             }
         } else {
             // dynamic
             $processed_data[$indexkey][$field_id] = $entry;
         }
     } else {
         $is_tag = self::do_magic_tags($field_id);
         if ($is_tag !== $field_id) {
             $processed_data[$indexkey][$field_id] = $is_tag;
         }
     }
     if (isset($processed_data[$indexkey][$field_id])) {
         return $processed_data[$indexkey][$field_id];
     }
     return null;
 }