public static function get_post_or_meta_value($entry, $field, $atts = array()) { $defaults = array('links' => true, 'show' => '', 'truncate' => true, 'sep' => ', '); $atts = wp_parse_args((array) $atts, $defaults); FrmEntry::maybe_get_entry($entry); if (empty($entry) || empty($field)) { return ''; } if ($entry->post_id) { if (!isset($field->field_options['custom_field'])) { $field->field_options['custom_field'] = ''; } if (!isset($field->field_options['post_field'])) { $field->field_options['post_field'] = ''; } $links = $atts['links']; if ($field->type == 'tag' || $field->field_options['post_field']) { $post_args = array('type' => $field->type, 'form_id' => $field->form_id, 'field' => $field, 'links' => $links, 'exclude_cat' => $field->field_options['exclude_cat']); foreach (array('show', 'truncate', 'sep') as $p) { $post_args[$p] = $atts[$p]; unset($p); } $value = self::get_post_value($entry->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], $post_args); unset($post_args); } else { $value = FrmEntryMeta::get_meta_value($entry, $field->id); } } else { $value = FrmEntryMeta::get_meta_value($entry, $field->id); if (('tag' == $field->type || isset($field->field_options['post_field']) && $field->field_options['post_field'] == 'post_category') && !empty($value)) { $value = maybe_unserialize($value); $new_value = array(); foreach ((array) $value as $tax_id) { if (is_numeric($tax_id)) { $cat = get_term($tax_id, $field->field_options['taxonomy']); $new_value[] = $cat ? $cat->name : $tax_id; unset($cat); } else { $new_value[] = $tax_id; } } $value = $new_value; } } return $value; }
public static function maybe_get_entry(&$entry) { _deprecated_function(__FUNCTION__, '2.0.9', 'FrmEntry::maybe_get_entry'); FrmEntry::maybe_get_entry($entry); }
public static function is_new_entry($entry) { FrmEntry::maybe_get_entry($entry); // this function will only be correct if the entry has already gone through FrmProEntriesController::check_draft_status return $entry->created_at == $entry->updated_at; }
private static function get_entry_by_param(&$entry) { if (!$entry || !is_object($entry)) { if (!$entry || !is_numeric($entry)) { $entry = FrmAppHelper::get_post_param('id', false, 'sanitize_title'); } FrmEntry::maybe_get_entry($entry); } }
public static function maybe_delete_entry($entry) { FrmEntry::maybe_get_entry($entry); if (!$entry || !FrmProEntriesHelper::user_can_delete($entry)) { $message = __('There was an error deleting that entry', 'formidable'); return $message; } $result = FrmEntry::destroy($entry->id); return $result; }