function get_display_value($replace_with, $field, $atts = array()) { $sep = isset($atts['sep']) ? $atts['sep'] : ', '; if ($field->type == 'user_id') { $user_info = isset($atts['show']) ? $atts['show'] : 'display_name'; $replace_with = FrmProFieldsHelper::get_display_name($replace_with, $user_info, $atts); if (is_array($replace_with)) { $new_val = ''; foreach ($replace_with as $key => $val) { if (!empty($new_val)) { $new_val .= ', '; } $new_val .= $key . '. ' . $val; } $replace_with = $new_val; } } else { if ($field->type == 'date') { if (isset($atts['time_ago'])) { $atts['format'] = 'Y-m-d H:i:s'; } if (!isset($atts['format'])) { $atts['format'] = false; } $replace_with = FrmProFieldsHelper::get_date($replace_with, $atts['format']); if (isset($atts['time_ago'])) { $replace_with = FrmProAppHelper::human_time_diff(strtotime($replace_with), strtotime(date_i18n('Y-m-d'))); } } else { if (is_numeric($replace_with) and $field->type == 'file') { //size options are thumbnail, medium, large, or full $size = isset($atts['size']) ? $atts['size'] : 'thumbnail'; if ($size != 'id') { $replace_with = FrmProFieldsHelper::get_media_from_id($replace_with, $size); } } else { if ($field->type == 'data') { //and (is_numeric($replace_with) or is_array($replace_with)) $field->field_options = maybe_unserialize($field->field_options); if (isset($field->field_options['form_select']) and $field->field_options['form_select'] == 'taxonomy') { return $replace_with; } $replace_with = explode($sep, $replace_with); if (isset($atts['show'])) { if (in_array($atts['show'], array('key', 'created-at', 'created_at', 'updated-at', 'updated_at', 'post_id'))) { global $frm_entry; if (is_array($replace_with)) { $linked_ids = $replace_with; $replace_with = ''; foreach ($linked_ids as $linked_id) { $linked_entry = FrmEntry::getOne($linked_id); if (!empty($replace_with)) { $replace_with .= $sep; } if ($atts['show'] == 'created-at') { $replace_with .= $linked_entry->created_at; } else { if ($atts['show'] == 'updated-at') { $replace_with .= $linked_entry->updated_at; } else { if ($atts['show'] == 'key') { $replace_with .= $linked_entry->item_key; } else { $replace_with .= isset($linked_entry->{$atts['show']}) ? $linked_entry->{$atts['show']} : $linked_entry->item_key; } } } } } else { $linked_entry = FrmEntry::getOne($replace_with); if ($atts['show'] == 'created-at') { $replace_with = $linked_entry->created_at; } else { if ($atts['show'] == 'updated-at') { $replace_with = $linked_entry->updated_at; } else { if ($atts['show'] == 'key') { $replace_with = $linked_entry->item_key; } else { $replace_with = isset($linked_entry->{$atts['show']}) ? $linked_entry->{$atts['show']} : $linked_entry->item_key; } } } } } else { if ($atts['show'] == 'id') { if (is_array($replace_with)) { $replace_with = implode($sep, $replace_with); } //just keep the value since it's already the id } else { if (is_array($replace_with)) { $linked_ids = $replace_with; $replace_with = array(); foreach ($linked_ids as $linked_id) { $new_val = FrmProFieldsHelper::get_data_value($linked_id, $field, $atts); if ($linked_id != $new_val) { $replace_with[] = $new_val; } unset($new_val); } $replace_with = implode($sep, $replace_with); } else { $replace_with = FrmProFieldsHelper::get_data_value($replace_with, $field, $atts); } } } } else { if (is_array($replace_with)) { $linked_ids = $replace_with; $replace_with = array(); foreach ($linked_ids as $linked_id) { $new_val = FrmProFieldsHelper::get_data_value($linked_id, $field, $atts); if ($linked_id != $new_val) { $replace_with[] = $new_val; } unset($new_val); } $replace_with = implode($sep, $replace_with); } else { $replace_with = FrmProFieldsHelper::get_data_value($replace_with, $field, $atts); } } } else { if ($field->type == 'textarea') { $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; if (apply_filters('frm_use_wpautop', $autop)) { $replace_with = wpautop($replace_with); } unset($autop); } else { if ($field->type == 'number') { if (!isset($atts['decimal'])) { $num = explode('.', $replace_with); $atts['decimal'] = isset($num[1]) ? strlen($num[1]) : 0; } if (!isset($atts['dec_point'])) { $atts['dec_point'] = '.'; } if (!isset($atts['thousands_sep'])) { $atts['thousands_sep'] = ''; } $replace_with = number_format($replace_with, $atts['decimal'], $atts['dec_point'], $atts['thousands_sep']); } } } } } } $replace_with = stripslashes_deep($replace_with); return $replace_with; }