/**
  * Get a formatted post_meta value for a given key.
  * These are "formatted" in that the returned value varies based on the field type
  * (assuming it was registered with the SuperCPT Plugin)
  *
  * @param string $key The meta key
  * @return mixed Depending on field type, will return either a string, a boolean value, or an array
  * @author Matthew Boynes
  */
 function get_scpt_formatted_meta($key, $post_id = false)
 {
     global $scpt_known_meta, $scpt_known_custom_fields;
     if (false == $post_id) {
         $post_id = get_the_ID();
     }
     if (isset($scpt_known_meta[$post_id][$key])) {
         return $scpt_known_meta[$post_id][$key];
     }
     $value = get_post_meta($post_id, $key);
     if (!$value || !is_array($value)) {
         return set_known_scpt_meta($key, $value, $post_id);
     }
     if (!($field_info = get_known_field_info($key, $post_id))) {
         return set_known_scpt_meta($key, $value[0], $post_id);
     }
     if (is_array($field_info)) {
         if ($field_info['data']) {
             return set_known_scpt_meta($key, get_posts(array('post_type' => $field_info['data'], 'include' => $value)), $post_id);
         }
     } else {
         switch ($field_info) {
             case 'boolean':
             case 'checkbox':
                 if (1 == count($value) && '1' == $value[0]) {
                     return set_known_scpt_meta($key, true, $post_id);
                 } elseif (1 == count($value)) {
                     return set_known_scpt_meta($key, false, $post_id);
                 }
                 # no break here
             # no break here
             case 'checkbox':
             case 'multiple_select':
                 return set_known_scpt_meta($key, $value, $post_id);
                 break;
             case 'radio':
                 return set_known_scpt_meta($key, $value[0], $post_id);
                 break;
             case 'wysiwyg':
                 return set_known_scpt_meta($key, wpautop($value[0]), $post_id);
                 break;
             case 'date':
             case 'datetime':
                 return set_known_scpt_meta($key, strtotime($value[0]), $post_id);
                 break;
         }
     }
     return set_known_scpt_meta($key, $value[0], $post_id);
 }
 public function format_meta_for_list($data, $key)
 {
     $field_info = get_known_field_info($key);
     if (is_array($field_info)) {
         # This is a cpt relationship
     } else {
         switch ($field_info) {
             case 'date':
                 return $data ? date('Y-m-d', $data) : '';
             case 'boolean':
                 return true === $data ? '✔' : '';
         }
     }
     return $data;
 }
 public function format_meta_for_list($data, $key)
 {
     $field_info = get_known_field_info($key, $this->type);
     if (false == $field_info) {
         switch ($key) {
             case '_thumbnail_id':
                 return wp_get_attachment_image($data, $this->column_thumbnail_size, true);
         }
     } elseif (is_array($field_info)) {
         # This is a cpt relationship
         if (is_array($data)) {
             return implode('<br />', array_map(array($this, 'data_column'), $data));
         }
     } else {
         switch ($field_info) {
             case 'date':
                 return $data ? date('Y-m-d', $data) : '';
             case 'boolean':
                 return true === $data ? '&#10004;' : '';
             case 'media':
                 return $data ? wp_get_attachment_image($data, $this->column_thumbnail_size, true) : '';
         }
     }
     return $data;
 }