function wp_pages_dropdown($field_name, $page_id, $truncate = false) { $pages = FrmAppHelper::get_pages(); ?> <select name="<?php echo $field_name; ?> " id="<?php echo $field_name; ?> " class="frm-dropdown frm-pages-dropdown"> <option value=""></option> <?php foreach ($pages as $page) { ?> <option value="<?php echo $page->ID; ?> " <?php echo (isset($_POST[$field_name]) and $_POST[$field_name] == $page->ID or !isset($_POST[$field_name]) and $page_id == $page->ID) ? ' selected="selected"' : ''; ?> ><?php echo $truncate ? FrmAppHelper::truncate($page->post_title, $truncate) : $page->post_title; ?> </option> <?php } ?> </select> <?php }
public static function create($values) { global $wpdb; self::sanitize_entry_post($values); $values = apply_filters('frm_pre_create_entry', $values); if (!isset($values['item_key'])) { $values['item_key'] = ''; } $item_name = self::get_new_entry_name($values, $values['item_key']); $new_values = array('item_key' => FrmAppHelper::get_unique_key($values['item_key'], $wpdb->prefix . 'frm_items', 'item_key'), 'name' => FrmAppHelper::truncate($item_name, 255, 1, ''), 'ip' => FrmAppHelper::get_ip_address(), 'is_draft' => isset($values['frm_saving_draft']) && $values['frm_saving_draft'] == 1 || isset($values['is_draft']) && $values['is_draft'] == 1 ? 1 : 0, 'form_id' => isset($values['form_id']) ? (int) $values['form_id'] : null, 'post_id' => isset($values['post_id']) ? (int) $values['post_id'] : 0, 'parent_item_id' => isset($values['parent_item_id']) ? (int) $values['parent_item_id'] : 0, 'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1), 'updated_at' => isset($values['updated_at']) ? $values['updated_at'] : (isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1))); if (is_array($new_values['name'])) { $new_values['name'] = reset($new_values['name']); } if (isset($values['description']) && !empty($values['description'])) { $new_values['description'] = maybe_serialize($values['description']); } else { $new_values['description'] = serialize(array('browser' => FrmAppHelper::get_server_value('HTTP_USER_AGENT'), 'referrer' => FrmAppHelper::get_server_value('HTTP_REFERER'))); } //if(isset($values['id']) and is_numeric($values['id'])) // $new_values['id'] = $values['id']; if (isset($values['frm_user_id']) && (is_numeric($values['frm_user_id']) || FrmAppHelper::is_admin())) { $new_values['user_id'] = $values['frm_user_id']; } else { $user_ID = get_current_user_id(); $new_values['user_id'] = $user_ID ? $user_ID : 0; } $new_values['updated_by'] = isset($values['updated_by']) ? $values['updated_by'] : $new_values['user_id']; // don't create duplicate entry if (self::is_duplicate($new_values, $values)) { return false; } $query_results = $wpdb->insert($wpdb->prefix . 'frm_items', $new_values); if (!$query_results) { return false; } $entry_id = $wpdb->insert_id; global $frm_vars; if (!isset($frm_vars['saved_entries'])) { $frm_vars['saved_entries'] = array(); } $frm_vars['saved_entries'][] = (int) $entry_id; if (isset($values['item_meta'])) { FrmEntryMeta::update_entry_metas($entry_id, $values['item_meta']); } self::clear_cache(); // this is a child entry $is_child = isset($values['parent_form_id']) && isset($values['parent_nonce']) && !empty($values['parent_form_id']) && wp_verify_nonce($values['parent_nonce'], 'parent'); do_action('frm_after_create_entry', $entry_id, $new_values['form_id'], compact('is_child')); do_action('frm_after_create_entry_' . $new_values['form_id'], $entry_id, compact('is_child')); return $entry_id; }
function forms_dropdown($field_name, $field_value = '', $blank = true, $field_id = false, $onchange = false) { global $frm_form; if (!$field_id) { $field_id = $field_name; } $where = apply_filters('frm_forms_dropdown', "is_template=0 AND (status is NULL OR status = '' OR status = 'published')", $field_name); $forms = $frm_form->getAll($where, ' ORDER BY name'); ?> <select name="<?php echo $field_name; ?> " id="<?php echo $field_id; ?> " class="frm-dropdown" <?php if ($onchange) { echo 'onchange="' . $onchange . '"'; } ?> > <?php if ($blank) { ?> <option value=""><?php echo $blank == 1 ? '' : '- ' . $blank . ' -'; ?> </option> <?php } ?> <?php foreach ($forms as $form) { ?> <option value="<?php echo $form->id; ?> " <?php selected($field_value, $form->id); ?> ><?php echo FrmAppHelper::truncate($form->name, 33); ?> </option> <?php } ?> </select> <?php }
public static function manage_columns($columns) { global $frm_vars, $wpdb; $form_id = FrmForm::get_current_form_id(); $columns[$form_id . '_id'] = 'ID'; $columns[$form_id . '_item_key'] = esc_html__('Entry Key', 'formidable'); if (!$form_id) { return $columns; } $form_cols = FrmField::get_all_for_form($form_id, '', 'include'); foreach ($form_cols as $form_col) { if (FrmField::is_no_save_field($form_col->type)) { continue; } if ($form_col->type == 'form' && isset($form_col->field_options['form_select']) && !empty($form_col->field_options['form_select'])) { $sub_form_cols = FrmField::get_all_for_form($form_col->field_options['form_select']); if ($sub_form_cols) { foreach ($sub_form_cols as $k => $sub_form_col) { if (FrmField::is_no_save_field($sub_form_col->type)) { unset($sub_form_cols[$k]); continue; } $columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate($sub_form_col->name, 35); unset($sub_form_col); } } unset($sub_form_cols); } else { $col_id = $form_col->field_key; if ($form_col->form_id != $form_id) { $col_id .= '-_-form' . $form_col->form_id; } if (isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value']) { $columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate($form_col->name, 35); } $columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate($form_col->name, 35); } } $columns[$form_id . '_created_at'] = __('Entry creation date', 'formidable'); $columns[$form_id . '_updated_at'] = __('Entry update date', 'formidable'); $columns[$form_id . '_ip'] = 'IP'; $frm_vars['cols'] = $columns; $action = FrmAppHelper::simple_get('frm_action', 'sanitize_title'); if (FrmAppHelper::is_admin_page('formidable-entries') && in_array($action, array('', 'list', 'destroy'))) { add_screen_option('per_page', array('label' => __('Entries', 'formidable'), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page')); } return $columns; }
function display_value($value, $field, $atts = array()) { global $wpdb; $defaults = array('type' => '', 'show_icon' => true, 'show_filename' => true, 'truncate' => false, 'sep' => ', ', 'post_id' => 0, 'form_id' => $field->form_id, 'field' => $field); $atts = wp_parse_args($atts, $defaults); $field->field_options = maybe_unserialize($field->field_options); if (!isset($field->field_options['post_field'])) { $field->field_options['post_field'] = ''; } if (!isset($field->field_options['custom_field'])) { $field->field_options['custom_field'] = ''; } if ($atts['post_id'] and ($field->field_options['post_field'] or $atts['type'] == 'tag')) { $atts['pre_truncate'] = $atts['truncate']; $atts['truncate'] = true; $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); $atts['truncate'] = $atts['pre_truncate']; } if ($value == '') { return $value; } $value = maybe_unserialize($value); if (is_array($value)) { $value = stripslashes_deep($value); } $value = apply_filters('frm_display_value_custom', $value, $field, $atts); $new_value = ''; if (is_array($value)) { foreach ($value as $val) { if (is_array($val)) { //TODO: add options for display (li or ,) $new_value .= implode($atts['sep'], $val); if ($atts['type'] != 'data') { $new_value .= "<br/>"; } } unset($val); } } if (!empty($new_value)) { $value = $new_value; } else { if (is_array($value)) { $value = implode($atts['sep'], $value); } } if ($atts['truncate'] and $atts['type'] != 'image') { $value = FrmAppHelper::truncate($value, 50); } if ($atts['type'] == 'image') { $value = '<img src="' . $value . '" height="50px" alt="" />'; } else { if ($atts['type'] == 'user_id') { $value = FrmProFieldsHelper::get_display_name($value); } else { if ($atts['type'] == 'file') { $old_value = $value; $value = ''; if ($atts['show_icon']) { $value .= FrmProFieldsHelper::get_file_icon($old_value); } if ($atts['show_icon'] and $atts['show_filename']) { $value .= '<br/>'; } if ($atts['show_filename']) { $value .= FrmProFieldsHelper::get_file_name($old_value); } } else { if ($atts['type'] == 'date') { $value = FrmProFieldsHelper::get_date($value); } else { if ($atts['type'] == 'data') { if (!is_numeric($value)) { $value = explode($atts['sep'], $value); if (is_array($value)) { $new_value = ''; foreach ($value as $entry_id) { if (!empty($new_value)) { $new_value .= $atts['sep']; } if (is_numeric($entry_id)) { $new_value .= FrmProFieldsHelper::get_data_value($entry_id, $field, $atts); } else { $new_value .= $entry_id; } } $value = $new_value; } } else { //replace item id with specified field $value = FrmProFieldsHelper::get_data_value($value, $field, $atts); if ($field->field_options['data_type'] == 'data' or $field->field_options['data_type'] == '') { $linked_field = FrmField::getOne($field->field_options['form_select']); if ($linked_field->type == 'file') { $old_value = $value; $value = '<img src="' . $value . '" height="50px" alt="" />'; if ($atts['show_filename']) { $value .= '<br/>' . $old_value; } } } } } } } } } $value = stripslashes_deep($value); return apply_filters('frm_display_value', $value, $field, $atts); }
public static function replace_shortcodes($content, $entry, $shortcodes, $display = false, $show = 'one', $odd = '', $args = array()) { global $frm_field, $frm_entry_meta, $post, $frmpro_settings; if ($display) { $param_value = $display->frm_type == 'id' ? $entry->id : $entry->item_key; if ($entry->post_id) { $detail_link = get_permalink($entry->post_id); } else { $param = isset($display->frm_param) && !empty($display->frm_param) ? $display->frm_param : 'entry'; if ($post) { $detail_link = add_query_arg($param, $param_value, get_permalink($post->ID)); } else { $detail_link = add_query_arg($param, $param_value); } //if( FrmProAppHelper::rewriting_on() && $frmpro_settings->permalinks ) // $detail_link = get_permalink($post->ID) .$param_value .'/'; } } foreach ($shortcodes[0] as $short_key => $tag) { $conditional = preg_match('/^\\[if/s', $shortcodes[0][$short_key]) ? true : false; $atts = shortcode_parse_atts($shortcodes[3][$short_key]); if (!empty($shortcodes[3][$short_key])) { $tag = str_replace($conditional ? '[if ' : '[', '', $shortcodes[0][$short_key]); $tag = str_replace(']', '', $tag); $tags = explode(' ', $tag); if (is_array($tags)) { $tag = $tags[0]; } } else { $tag = $shortcodes[2][$short_key]; } switch ($tag) { case 'entry_count': $content = str_replace($shortcodes[0][$short_key], isset($args['record_count']) ? $args['record_count'] : '', $content); break; case 'detaillink': if ($display and $detail_link) { $content = str_replace($shortcodes[0][$short_key], $detail_link, $content); } break; case 'id': $content = str_replace($shortcodes[0][$short_key], $entry->id, $content); break; case 'post-id': case 'post_id': $content = str_replace($shortcodes[0][$short_key], $entry->post_id, $content); break; case 'key': $content = str_replace($shortcodes[0][$short_key], $entry->item_key, $content); break; case 'ip': $content = str_replace($shortcodes[0][$short_key], $entry->ip, $content); break; case 'user_agent': case 'user-agent': $entry->description = maybe_unserialize($entry->description); $content = str_replace($shortcodes[0][$short_key], $entry->description['browser'], $content); break; case 'created_at': case 'created-at': case 'updated_at': case 'updated-at': if (!isset($atts['format'])) { $atts['format'] = get_option('date_format'); $time_format = false; } else { $time_format = ' '; } $this_tag = str_replace('-', '_', $tag); if ($conditional) { $atts['short_key'] = $shortcodes[0][$short_key]; $content = self::check_conditional_shortcode($content, $entry->{$this_tag}, $atts, $tag); } else { if (isset($atts['time_ago'])) { $date = FrmProAppHelper::human_time_diff(strtotime($entry->{$this_tag})); } else { $date = FrmProAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); } $content = str_replace($shortcodes[0][$short_key], $date, $content); } unset($this_tag); break; case 'created_by': case 'created-by': case 'updated_by': case 'updated-by': $this_tag = str_replace('-', '_', $tag); $replace_with = self::get_display_value($entry->{$this_tag}, (object) array('type' => 'user_id'), $atts); if ($conditional) { $atts['short_key'] = $shortcodes[0][$short_key]; $content = self::check_conditional_shortcode($content, $entry->{$this_tag}, $atts, $tag); } else { $content = str_replace($shortcodes[0][$short_key], $replace_with, $content); } unset($this_tag); unset($replace_with); break; case 'evenodd': $content = str_replace($shortcodes[0][$short_key], $odd, $content); break; case 'siteurl': $content = str_replace($shortcodes[0][$short_key], FrmAppHelper::site_url(), $content); break; case 'frmurl': $content = str_replace($shortcodes[0][$short_key], FrmAppHelper::plugin_url(), $content); break; case 'sitename': $content = str_replace($shortcodes[0][$short_key], get_option('blogname'), $content); break; case 'get': if (isset($atts['param'])) { $param = $atts['param']; $replace_with = FrmAppHelper::get_param($param); if (is_array($replace_with)) { $replace_with = implode(', ', $replace_with); } $content = str_replace($shortcodes[0][$short_key], $replace_with, $content); unset($param); unset($replace_with); } break; default: if ($tag == 'deletelink') { $page_id = isset($atts['page_id']) ? $atts['page_id'] : ($post ? $post->ID : 0); if (!isset($atts['label'])) { $atts['label'] = false; } $delete_atts = $atts; $delete_atts['id'] = $entry->id; $delete_atts['page_id'] = $page_id; $replace_with = FrmProEntriesController::entry_delete_link($delete_atts); unset($delete_atts); $field = false; } else { if ($tag == 'editlink') { $replace_with = ''; $link_text = isset($atts['label']) ? $atts['label'] : false; if (!$link_text) { $link_text = isset($atts['link_text']) ? $atts['link_text'] : __('Edit'); } $class = isset($atts['class']) ? $atts['class'] : ''; $page_id = isset($atts['page_id']) ? $atts['page_id'] : ($post ? $post->ID : 0); if (isset($atts['location']) && $atts['location'] == 'front' || isset($atts['prefix']) && !empty($atts['prefix']) || isset($atts['page_id']) && !empty($atts['page_id'])) { $edit_atts = $atts; $edit_atts['id'] = $entry->id; $delete_atts['page_id'] = $page_id; $replace_with = FrmProEntriesController::entry_edit_link($edit_atts); } else { if ($entry->post_id) { $replace_with = get_edit_post_link($entry->post_id); } else { if (current_user_can('frm_edit_entries')) { $replace_with = esc_url(admin_url('admin.php?page=formidable-entries&frm_action=edit&id=' . $entry->id)); } } if (!empty($replace_with)) { $replace_with = '<a href="' . $replace_with . '" class="frm_edit_link ' . $class . '">' . $link_text . '</a>'; } } unset($class); } else { $field = $frm_field->getOne($tag); } } $sep = isset($atts['sep']) ? $atts['sep'] : ', '; if (!isset($field)) { $field = false; } if ($field) { $replace_with = FrmProEntryMetaHelper::get_post_or_meta_value($entry, $field, $atts); $atts['entry_id'] = $entry->id; $atts['entry_key'] = $entry->item_key; $atts['post_id'] = $entry->post_id; $replace_with = apply_filters('frmpro_fields_replace_shortcodes', $replace_with, $tag, $atts, $field); } if ($field and $field->type == 'file') { //size options are thumbnail, medium, large, or full, label $size = isset($atts['size']) ? $atts['size'] : (isset($atts['show']) ? $atts['show'] : 'thumbnail'); $inc_html = (isset($atts['html']) and $atts['html']) ? true : false; $inc_links = (isset($atts['links']) and $atts['links']) ? true : false; $sep = isset($atts['sep']) ? $atts['sep'] : ' '; $show_filename = (isset($atts['show_filename']) and $atts['show_filename']) ? true : false; if ($size != 'id' && !empty($replace_with)) { $replace_with = FrmProFieldsHelper::get_media_from_id($replace_with, $size, array('html' => $inc_html, 'links' => $inc_links, 'show_filename' => $show_filename)); } else { if (is_array($replace_with)) { $replace_with = array_filter($replace_with); } } unset($size); } if (isset($replace_with) and is_array($replace_with)) { $replace_with = implode($sep, $replace_with); } if ($conditional) { if (!isset($replace_with)) { $replace_with = ''; } $replace_with = apply_filters('frm_conditional_value', $replace_with, $atts, $field, $tag); $start_pos = strpos($content, $shortcodes[0][$short_key]); if ($start_pos !== false) { $start_pos_len = strlen($shortcodes[0][$short_key]); $end_pos = strpos($content, '[/if ' . $tag . ']', $start_pos); $end_pos_len = strlen('[/if ' . $tag . ']'); if ($end_pos !== false) { if (empty($replace_with)) { $total_len = $end_pos + $end_pos_len - $start_pos; $content = substr_replace($content, '', $start_pos, $total_len); } else { $content = substr_replace($content, '', $end_pos, $end_pos_len); $content = substr_replace($content, '', $start_pos, $start_pos_len); } } } } else { if ($field) { if (isset($atts['show']) and $atts['show'] == 'field_label') { $replace_with = $field->name; } else { if (isset($atts['show']) and $atts['show'] == 'description') { $replace_with = $field->description; } else { if (empty($replace_with) and $replace_with != '0') { $replace_with = ''; if ($field->type == 'number') { $replace_with = '0'; } } else { $replace_with = FrmProFieldsHelper::get_display_value($replace_with, $field, $atts); } } } } if (isset($atts['sanitize'])) { $replace_with = sanitize_title_with_dashes($replace_with); } if (isset($atts['sanitize_url'])) { if (seems_utf8($replace_with)) { $replace_with = utf8_uri_encode($replace_with, 200); } $replace_with = urlencode(htmlentities($replace_with)); } if (isset($atts['truncate'])) { if (isset($atts['more_text'])) { $more_link_text = $atts['more_text']; } else { $more_link_text = isset($atts['more_link_text']) ? $atts['more_link_text'] : '. . .'; } if ($display and $display->frm_show_count == 'dynamic') { $more_link_text = ' <a href="' . $detail_link . '">' . $more_link_text . '</a>'; $replace_with = FrmAppHelper::truncate($replace_with, (int) $atts['truncate'], 3, $more_link_text); } else { $replace_with = wp_specialchars_decode(strip_tags($replace_with), ENT_QUOTES); $part_one = substr($replace_with, 0, (int) $atts['truncate']); $part_two = substr($replace_with, (int) $atts['truncate']); if (!empty($part_two)) { $replace_with = $part_one . '<a href="#" onclick="jQuery(this).next().css(\'display\', \'inline\');jQuery(this).css(\'display\', \'none\');return false;" class="frm_text_exposed_show"> ' . $more_link_text . '</a><span style="display:none;">' . $part_two . '</span>'; } } } if (isset($atts['clickable'])) { $replace_with = make_clickable($replace_with); } if (!isset($replace_with)) { $replace_with = ''; } $content = str_replace($shortcodes[0][$short_key], $replace_with, $content); } unset($replace_with); if (isset($field)) { unset($field); } } unset($atts); unset($conditional); } return $content; }
public static function display_value($value, $field, $atts = array()) { global $wpdb, $frm_field; $defaults = array('type' => '', 'show_icon' => true, 'show_filename' => true, 'truncate' => false, 'sep' => ', ', 'post_id' => 0, 'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0); $atts = wp_parse_args($atts, $defaults); $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); if (!isset($field->field_options['post_field'])) { $field->field_options['post_field'] = ''; } if (!isset($field->field_options['custom_field'])) { $field->field_options['custom_field'] = ''; } if ($atts['post_id'] and ($field->field_options['post_field'] or $atts['type'] == 'tag')) { $atts['pre_truncate'] = $atts['truncate']; $atts['truncate'] = true; $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); $atts['truncate'] = $atts['pre_truncate']; } if ($value == '') { return $value; } $value = maybe_unserialize($value); $value = apply_filters('frm_display_value_custom', $value, $field, $atts); $new_value = ''; if (is_array($value)) { foreach ($value as $val) { if (is_array($val)) { //TODO: add options for display (li or ,) $new_value .= implode($atts['sep'], $val); if ($atts['type'] != 'data') { $new_value .= "<br/>"; } } unset($val); } } if (!empty($new_value)) { $value = $new_value; } else { if (is_array($value)) { $value = implode($atts['sep'], $value); } } if ($atts['truncate'] and $atts['type'] != 'image') { $value = FrmAppHelper::truncate($value, 50); } if ($atts['type'] == 'image') { $value = '<img src="' . $value . '" height="50px" alt="" />'; } else { if ($atts['type'] == 'user_id') { $value = FrmProFieldsHelper::get_display_name($value); } else { if ($atts['type'] == 'file') { $old_value = explode(', ', $value); $value = ''; foreach ($old_value as $mid) { $value .= '<div class="frm_file_container">'; if ($atts['show_icon']) { $img = FrmProFieldsHelper::get_file_icon($mid); $value .= $img; if ($atts['show_filename'] and $img and preg_match("/wp-includes\\/images\\/crystal/", $img)) { //prevent two filenames $atts['show_filename'] = $show_filename = false; } unset($img); } if ($atts['show_icon'] and $atts['show_filename']) { $value .= '<br/>'; } if ($atts['show_filename']) { $value .= FrmProFieldsHelper::get_file_name($mid); } if (isset($show_filename)) { //if skipped filename, show it for the next file $atts['show_filename'] = true; unset($show_filename); } $value .= '</div>'; } } else { if ($atts['type'] == 'date') { $value = FrmProFieldsHelper::get_date($value); } else { if ($atts['type'] == 'data') { if (!is_numeric($value)) { $value = explode($atts['sep'], $value); if (is_array($value)) { $new_value = ''; foreach ($value as $entry_id) { if (!empty($new_value)) { $new_value .= $atts['sep']; } if (is_numeric($entry_id)) { $dval = FrmProFieldsHelper::get_data_value($entry_id, $field, $atts); if (is_array($dval)) { $dval = implode($atts['sep'], $dval); } $new_value .= $dval; } else { $new_value .= $entry_id; } } $value = $new_value; } } else { //replace item id with specified field $new_value = FrmProFieldsHelper::get_data_value($value, $field, $atts); if ($field->field_options['data_type'] == 'data' or $field->field_options['data_type'] == '') { $linked_field = $frm_field->getOne($field->field_options['form_select']); if ($linked_field->type == 'file') { $old_value = explode(', ', $new_value); $new_value = ''; foreach ($old_value as $v) { $new_value .= '<img src="' . $v . '" height="50px" alt="" />'; if ($atts['show_filename']) { $new_value .= '<br/>' . $v; } unset($v); } } else { $new_value = $value; } } $value = $new_value; } } } } } } if (!$atts['keepjs']) { $value = wp_kses_post($value); } return apply_filters('frm_display_value', $value, $field, $atts); }
public static function render_meta_box_content($post) { global $frm_vars; $i = 1; echo '<p>'; foreach ((array) $frm_vars['post_forms'] as $form) { if ($i != 1) { echo ' | '; } $i++; echo '<a href="javascript:frmCreatePostEntry(' . (int) $form->id . ',' . (int) $post->ID . ')">' . esc_html(FrmAppHelper::truncate($form->name, 15)) . '</a>'; unset($form); } echo '</p>'; }
/** * Prepare the saved value for display * @return string */ public static function display_value($value, $field, $atts = array()) { $defaults = array('type' => '', 'html' => false, 'show_filename' => true, 'truncate' => false, 'sep' => ', ', 'post_id' => 0, 'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0, 'return_array' => false); $atts = wp_parse_args($atts, $defaults); $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); if (!isset($field->field_options['post_field'])) { $field->field_options['post_field'] = ''; } if (!isset($field->field_options['custom_field'])) { $field->field_options['custom_field'] = ''; } if (FrmAppHelper::pro_is_installed() && $atts['post_id'] && ($field->field_options['post_field'] || $atts['type'] == 'tag')) { $atts['pre_truncate'] = $atts['truncate']; $atts['truncate'] = true; $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); $atts['truncate'] = $atts['pre_truncate']; } if ($value == '') { return $value; } $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); $value = apply_filters('frm_display_' . $field->type . '_value_custom', $value, compact('field', 'atts')); $new_value = ''; if (is_array($value) && $atts['type'] != 'file') { foreach ($value as $val) { if (is_array($val)) { //TODO: add options for display (li or ,) $new_value .= implode($atts['sep'], $val); if ($atts['type'] != 'data') { $new_value .= '<br/>'; } } unset($val); } } if (!empty($new_value)) { $value = $new_value; } else { if (is_array($value) && $atts['type'] != 'file' && !$atts['return_array']) { $value = implode($atts['sep'], $value); } } if ($atts['truncate'] && $atts['type'] != 'image') { $value = FrmAppHelper::truncate($value, 50); } if (!$atts['keepjs'] && !is_array($value)) { $value = wp_kses_post($value); } return apply_filters('frm_display_value', $value, $field, $atts); }
public function search_box($text, $input_id) { if (!$this->has_items() && !isset($_REQUEST['s'])) { return; } if (isset($this->params['form'])) { $form = FrmForm::getOne($this->params['form']); } else { $form = FrmForm::get_published_forms(array(), 1); } if ($form) { $field_list = FrmField::getAll(array('fi.form_id' => $form->id, 'fi.type not' => FrmField::no_save_fields()), 'field_order'); } $fid = isset($_REQUEST['fid']) ? esc_attr(stripslashes($_REQUEST['fid'])) : ''; $input_id = $input_id . '-search-input'; $search_str = isset($_REQUEST['s']) ? esc_attr(stripslashes($_REQUEST['s'])) : ''; foreach (array('orderby', 'order') as $get_var) { if (!empty($_REQUEST[$get_var])) { echo '<input type="hidden" name="' . esc_attr($get_var) . '" value="' . esc_attr($_REQUEST[$get_var]) . '" />'; } } ?> <div class="search-box frm_sidebar"> <label class="screen-reader-text" for="<?php echo esc_attr($input_id); ?> "><?php echo esc_attr($text); ?> :</label> <input type="text" id="<?php echo esc_attr($input_id); ?> " name="s" value="<?php echo esc_attr($search_str); ?> " /> <?php if (isset($field_list) && !empty($field_list)) { ?> <select name="fid" class="hide-if-js"> <option value="">— <?php _e('All Fields', 'formidable'); ?> —</option> <option value="created_at" <?php selected($fid, 'created_at'); ?> ><?php _e('Entry creation date', 'formidable'); ?> </option> <option value="id" <?php selected($fid, 'id'); ?> ><?php _e('Entry ID', 'formidable'); ?> </option> <?php foreach ($field_list as $f) { ?> <option value="<?php echo $f->type == 'user_id' ? 'user_id' : $f->id; ?> " <?php selected($fid, $f->id); ?> ><?php echo FrmAppHelper::truncate($f->name, 30); ?> </option> <?php } ?> </select> <div class="button dropdown hide-if-no-js"> <a href="#" id="frm-fid-search" class="frm-dropdown-toggle" data-toggle="dropdown"><?php _e('Search', 'formidable'); ?> <b class="caret"></b></a> <ul class="frm-dropdown-menu pull-right" id="frm-fid-search-menu" role="menu" aria-labelledby="frm-fid-search"> <li><a href="#" id="fid-">— <?php _e('All Fields', 'formidable'); ?> —</a></li> <li><a href="#" id="fid-created_at"><?php _e('Entry creation date', 'formidable'); ?> </a></li> <li><a href="#" id="fid-id"><?php _e('Entry ID', 'formidable'); ?> </a></li> <?php foreach ($field_list as $f) { ?> <li><a href="#" id="fid-<?php echo $f->type == 'user_id' ? 'user_id' : $f->id; ?> "><?php echo FrmAppHelper::truncate($f->name, 30); ?> </a></li> <?php unset($f); } ?> </ul> </div> <?php submit_button($text, 'button hide-if-js', false, false, array('id' => 'search-submit')); } else { submit_button($text, 'button', false, false, array('id' => 'search-submit')); if (!empty($search_str)) { ?> <a href="<?php echo esc_url(admin_url('admin.php?page=formidable-entries&frm_action=list&form=' . $form->id)); ?> "><?php _e('Reset', 'formidable'); ?> </a> <?php } } ?> </div> <?php }
public function single_row($item, $style = '') { // Set up the hover actions for this user $actions = array(); $view_link = '?page=formidable-entries&frm_action=show&id=' . $item->id; $this->get_actions($actions, $item, $view_link); $action_links = $this->row_actions($actions); // Set up the checkbox ( because the user is editable, otherwise its empty ) $checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />"; $r = "<tr id='item-action-{$item->id}'{$style}>"; list($columns, $hidden, , $primary) = $this->get_column_info(); $action_col = false; foreach ($columns as $column_name => $column_display_name) { $class = $column_name . ' column-' . $column_name; if ($column_name === $primary) { $class .= ' column-primary'; } if (in_array($column_name, $hidden)) { $class .= ' frm_hidden'; } else { if (!$action_col && !in_array($column_name, array('cb', 'id', 'form_id', 'post_id'))) { $action_col = $column_name; } } $attributes = 'class="' . esc_attr($class) . '"'; unset($class); $attributes .= ' data-colname="' . $column_display_name . '"'; $col_name = preg_replace('/^(' . $this->params['form'] . '_)/', '', $column_name); $this->column_name = $col_name; switch ($col_name) { case 'cb': $r .= "<th scope='row' class='check-column'>{$checkbox}</th>"; break; case 'ip': case 'id': case 'item_key': $val = $item->{$col_name}; break; case 'name': case 'description': $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100); break; case 'created_at': case 'updated_at': $date = FrmAppHelper::get_formatted_time($item->{$col_name}); $val = '<abbr title="' . esc_attr(FrmAppHelper::get_formatted_time($item->{$col_name}, '', 'g:i:s A')) . '">' . $date . '</abbr>'; break; case 'is_draft': $val = empty($item->is_draft) ? __('No') : __('Yes'); break; case 'form_id': $val = FrmFormsHelper::edit_form_link($item->form_id); break; case 'post_id': $val = FrmAppHelper::post_edit_link($item->post_id); break; case 'user_id': $user = get_userdata($item->user_id); $val = $user->user_login; break; default: $val = apply_filters('frm_entries_' . $col_name . '_column', false, compact('item')); if ($val === false) { $this->get_column_value($item, $val); } break; } if (isset($val)) { $r .= "<td {$attributes}>"; if ($column_name == $action_col) { $edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id; $r .= '<a href="' . esc_url(isset($actions['edit']) ? $edit_link : $view_link) . '" class="row-title" >' . $val . '</a> '; $r .= $action_links; } else { $r .= $val; } $r .= '</td>'; } unset($val); } $r .= '</tr>'; return $r; }
function render_meta_box_content($post) { global $frm_post_forms, $frm_ajax_url; $count = count($frm_post_forms); $i = 1; echo '<p>'; foreach ($frm_post_forms as $form) { if ($i != 1) { echo ' | '; } $i++; echo '<a href="javascript:frm_create_post_entry(' . $form->id . ',' . $post->ID . ')">' . stripslashes(FrmAppHelper::truncate($form->name, 15)) . '</a>'; unset($form); } unset($i); echo '</p>'; echo "<script type='text/javascript'>function frm_create_post_entry(id,post_id){\njQuery('#frm_create_entry p').replaceWith('<img src=\"" . FRM_IMAGES_URL . "/wpspin_light.gif\" alt=\"" . __('Loading...', 'formidable') . "\" />');\njQuery.ajax({type:'POST',url:'{$frm_ajax_url}',data:'action=frm_create_post_entry&id='+id+'&post_id='+post_id,\nsuccess:function(msg){jQuery('#frm_create_entry').fadeOut('slow');}\n});\n};</script>"; }
/** * Prepare the new values for inserting into the database * * @since 2.0.16 * @param array $values * @return array $new_values */ private static function package_entry_data(&$values) { global $wpdb; if (!isset($values['item_key'])) { $values['item_key'] = ''; } $item_name = self::get_new_entry_name($values, $values['item_key']); $new_values = array('item_key' => FrmAppHelper::get_unique_key($values['item_key'], $wpdb->prefix . 'frm_items', 'item_key'), 'name' => FrmAppHelper::truncate($item_name, 255, 1, ''), 'ip' => FrmAppHelper::get_ip_address(), 'is_draft' => self::get_is_draft_value($values), 'form_id' => self::get_form_id($values), 'post_id' => self::get_post_id($values), 'parent_item_id' => self::get_parent_item_id($values), 'created_at' => self::get_created_at($values), 'updated_at' => self::get_updated_at($values), 'description' => self::get_entry_description($values), 'user_id' => self::get_entry_user_id($values)); if (is_array($new_values['name'])) { $new_values['name'] = reset($new_values['name']); } $new_values['updated_by'] = isset($values['updated_by']) ? $values['updated_by'] : $new_values['user_id']; return $new_values; }
function single_row($item, $style = '') { global $frmpro_is_installed, $frm_entry; $checkbox = ''; // Set up the hover actions for this user $actions = array(); $title = esc_attr(strip_tags(stripslashes($item->name))); $edit_link = "?page=formidable&frm_action=edit&id={$item->id}"; $actions['edit'] = "<a href='" . wp_nonce_url($edit_link) . "'>" . __('Edit', 'formidable') . "</a>"; $duplicate_link = "?page=formidable&frm_action=duplicate&id={$item->id}"; $view_link = "?page=formidable-{$this->page_name}&frm_action=show&id={$item->id}"; if ($this->params['template']) { $actions['duplicate'] = "<a href='" . wp_nonce_url($duplicate_link) . "'>" . __('Create Form from Template', 'formidable') . "</a>"; } else { $actions['settings'] = "<a href='" . wp_nonce_url("?page=formidable&frm_action=settings&id={$item->id}") . "'>" . __('Settings', 'formidable') . "</a>"; $actions['entries'] = "<a href='" . wp_nonce_url("?page=formidable-entries&form={$item->id}") . "' title='{$title} " . __('Entries', 'formidable') . "'>" . __('Entries', 'formidable') . "</a>"; $actions['reports'] = "<a href='" . wp_nonce_url("?page=formidable-reports&form={$item->id}") . "' title='{$title} " . __('Reports', 'formidable') . "'>" . __('Reports', 'formidable') . "</a>"; if ($frmpro_is_installed and current_user_can('frm_create_entries')) { $actions['entry'] = "<a href='" . wp_nonce_url("?page=formidable-entries&frm_action=new&form={$item->id}") . "' title='" . __('New', 'formidable') . " {$title} " . __('Entry', 'formidable') . "'>" . __('New Entry', 'formidable') . "</a>"; } $actions['duplicate'] = "<a href='" . wp_nonce_url($duplicate_link) . "' title='" . __('Copy', 'formidable') . " {$title}'>" . __('Duplicate', 'formidable') . "</a>"; if ($frmpro_is_installed) { $actions['template'] = "<a href='" . wp_nonce_url("?page=formidable&frm_action=duplicate&id={$item->id}&template=1") . "' title='" . __('Create Template', 'formidable') . "'>" . __('Create Template', 'formidable') . "</a>"; } } if ($frmpro_is_installed) { $actions['export_template'] = "<a href='" . wp_nonce_url(FRM_SCRIPT_URL . "&controller=forms&frm_action=export&id={$item->id}") . "' title='{$title} " . __('Export Template', 'formidable') . "'>" . __('Export Template', 'formidable') . "</a>"; } $delete_link = "?page=formidable&frm_action=destroy&id={$item->id}"; $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url($delete_link) . "' onclick='return confirm(\"" . __('Are you sure you want to delete that?', 'formidable') . "\")'>" . __('Delete', 'formidable') . "</a>"; if (!current_user_can('frm_view_entries')) { if (isset($actions['entries'])) { unset($actions['entries']); } if (isset($actions['reports'])) { unset($actions['reports']); } } if (!current_user_can('frm_edit_forms')) { unset($actions['edit']); unset($actions['duplicate']); if (isset($actions['settings'])) { unset($actions['settings']); } if (!$frmpro_is_installed) { unset($actions['duplicate']); } } if (!current_user_can('frm_delete_forms')) { unset($actions['delete']); } $action_links = $this->row_actions($actions); // Set up the checkbox ( because the user is editable, otherwise its empty ) $checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />"; $r = "<tr id='item-action-{$item->id}'{$style}>"; list($columns, $hidden) = $this->get_column_info(); $action_col = false; foreach ($columns as $column_name => $column_display_name) { $class = "class=\"{$column_name} column-{$column_name}\""; $style = ''; if (in_array($column_name, $hidden)) { $style = ' style="display:none;"'; } else { if (!$action_col and !in_array($column_name, array('cb', 'id'))) { $action_col = $column_name; } } $attributes = "{$class}{$style}"; switch ($column_name) { case 'cb': $r .= "<th scope='row' class='check-column'>{$checkbox}</th>"; break; case 'id': case 'form_key': $val = stripslashes($item->{$column_name}); break; case 'name': case 'description': $val = FrmAppHelper::truncate(strip_tags(stripslashes($item->{$column_name})), 100); break; case 'created_at': $format = 'Y/m/d'; //get_option('date_format'); $date = date($format, strtotime($item->{$column_name})); $val = "<abbr title='" . date($format . ' g:i:s A', strtotime($item->{$column_name})) . "'>" . $date . "</abbr>"; break; case 'shortcode': $val = "<input type='text' style='font-size:10px;width:100%;' readonly='true' onclick='this.select();' onfocus='this.select();' value='[formidable id={$item->id}]' /><br/>"; $val .= "<input type='text' style='font-size:10px;width:100%;' readonly='true' onclick='this.select();' onfocus='this.select();' value='[formidable key={$item->form_key}]' />"; break; case 'entries': $text = $frm_entry->getRecordCount($item->id); $text = sprintf(_n('%1$s Entry', '%1$s Entries', $text, 'formidable'), $text); $val = current_user_can('frm_view_entries') ? '<a href="' . esc_url(admin_url('admin.php') . '?page=formidable-entries&form=' . $item->id) . '">' . $text . '</a>' : $text; unset($text); break; case 'link': $target_url = FrmFormsHelper::get_direct_link($item->form_key, $item->prli_link_id); $val = '<input type="text" style="font-size:10px;width:100%;" readonly="true" onclick="this.select();" onfocus="this.select();" value="' . esc_html($target_url) . '" /><br/><a href="' . esc_html($target_url) . '" target="blank">' . __('View Form', 'formidable') . '</a>'; unset($target_url); break; default: $val = $column_name; break; } if (isset($val)) { $r .= "<td {$attributes}>"; if ($column_name == $action_col) { $r .= '<a class="row-title" href="' . (isset($actions['edit']) ? $edit_link : $view_link) . '">' . $val . '</a> '; $r .= $action_links; } else { $r .= $val; } $r .= '</td>'; } unset($val); } $r .= '</tr>'; return $r; }
function replace_shortcodes($content, $entry, $shortcodes, $display = false, $show = 'one', $odd = '') { global $frm_field, $frm_entry_meta, $post, $frmpro_settings; if ($display) { $param_value = $display->type == 'id' ? $entry->id : $entry->item_key; if ($entry->post_id) { $detail_link = get_permalink($entry->post_id); } else { $param = isset($display->param) && !empty($display->param) ? $display->param : 'entry'; if ($post) { $detail_link = add_query_arg($param, $param_value, get_permalink($post->ID)); } else { $detail_link = add_query_arg($param, $param_value); } //if( FrmProAppHelper::rewriting_on() && $frmpro_settings->permalinks ) // $detail_link = get_permalink($post->ID) .$param_value .'/'; } } foreach ($shortcodes[0] as $short_key => $tag) { $conditional = preg_match('/^\\[if/s', $shortcodes[0][$short_key]) ? true : false; $atts = shortcode_parse_atts($shortcodes[3][$short_key]); if (!empty($shortcodes[3][$short_key])) { if ($conditional) { $tag = str_replace('[if ', '', $shortcodes[0][$short_key]); } else { $tag = str_replace('[', '', $shortcodes[0][$short_key]); } $tag = str_replace(']', '', $tag); $tags = explode(' ', $tag); if (is_array($tags)) { $tag = $tags[0]; } } else { $tag = $shortcodes[2][$short_key]; } switch ($tag) { case 'detaillink': if ($display and $detail_link) { $content = str_replace($shortcodes[0][$short_key], $detail_link, $content); } break; case 'id': $content = str_replace($shortcodes[0][$short_key], $entry->id, $content); break; case 'post-id': case 'post_id': $content = str_replace($shortcodes[0][$short_key], $entry->post_id, $content); break; case 'key': $content = str_replace($shortcodes[0][$short_key], $entry->item_key, $content); break; case 'ip': $content = str_replace($shortcodes[0][$short_key], $entry->ip, $content); break; case 'user_agent': case 'user-agent': $entry->description = maybe_unserialize($entry->description); $content = str_replace($shortcodes[0][$short_key], $entry->description['browser'], $content); break; case 'created-at': case 'updated-at': if (!isset($atts['format'])) { $atts['format'] = get_option('date_format'); $time_format = false; } else { $time_format = ' '; } $this_tag = str_replace('-', '_', $tag); if ($conditional) { $replace_with = apply_filters('frm_conditional_value', $entry->{$this_tag}, $atts, false, $tag); if ($atts) { $content = str_replace($shortcodes[0][$short_key], '[if ' . $tag . ']', $content); } if (empty($replace_with)) { $content = preg_replace('/(\\[if\\s+' . $tag . '\\])(.*?)(\\[\\/if\\s+' . $tag . '\\])/mis', '', $content); } else { $content = preg_replace('/(\\[if\\s+' . $tag . '\\])/', '', $content, 1); $content = preg_replace('/(\\[\\/if\\s+' . $tag . '\\])/', '', $content, 1); } } else { if (isset($atts['time_ago'])) { $date = FrmProAppHelper::human_time_diff(strtotime($entry->{$this_tag})); } else { $date = FrmProAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); } $content = str_replace($shortcodes[0][$short_key], $date, $content); } unset($this_tag); break; case 'evenodd': $content = str_replace($shortcodes[0][$short_key], $odd, $content); break; case 'siteurl': global $frm_siteurl; $content = str_replace($shortcodes[0][$short_key], $frm_siteurl, $content); break; case 'sitename': $content = str_replace($shortcodes[0][$short_key], get_option('blogname'), $content); break; case 'get': if (isset($atts['param'])) { $param = $atts['param']; $replace_with = FrmAppHelper::get_param($param); if (is_array($replace_with)) { $replace_with = implode(', ', $replace_with); } $content = str_replace($shortcodes[0][$short_key], $replace_with, $content); unset($param); unset($replace_with); } break; default: if ($tag == 'deletelink') { $page_id = isset($atts['page_id']) ? $atts['page_id'] : $post->ID; $can_delete = FrmProEntriesHelper::allow_delete($entry); if ($can_delete) { if (isset($atts['label'])) { $delete_atts = $atts; $delete_atts['id'] = $entry->id; $delete_atts['page_id'] = $page_id; $replace_with = FrmProEntriesController::entry_delete_link($delete_atts); unset($delete_atts); } else { $replace_with = add_query_arg(array('frm_action' => 'destroy', 'entry' => $entry->id), get_permalink($page_id)); } } else { $replace_with = ''; } $field = false; } else { if ($tag == 'editlink') { $replace_with = ''; $link_text = isset($atts['label']) ? $atts['label'] : false; if (!$link_text) { $link_text = isset($atts['link_text']) ? $atts['link_text'] : __('Edit', 'formidable'); } $class = isset($atts['class']) ? $atts['class'] : ''; $page_id = isset($atts['page_id']) ? $atts['page_id'] : $post->ID; if (isset($atts['location']) and $atts['location'] == 'front') { $edit_atts = $atts; $edit_atts['id'] = $entry->id; $delete_atts['page_id'] = $page_id; $replace_with = FrmProEntriesController::entry_edit_link($edit_atts); } else { if ($entry->post_id) { $replace_with = get_edit_post_link($entry->post_id); } else { global $frm_siteurl; if (current_user_can('frm_edit_entries')) { $replace_with = esc_url($frm_siteurl . '/wp-admin/admin.php?page=formidable-entries&frm_action=edit&id=' . $entry->id); } } if (!empty($replace_with)) { $replace_with = '<a href="' . $replace_with . '" class="frm_edit_link ' . $class . '">' . $link_text . '</a>'; } } unset($class); } else { $field = $frm_field->getOne($tag); } } $sep = isset($atts['sep']) ? $atts['sep'] : ', '; if (!isset($field)) { $field = false; } if ($field) { $field->field_options = maybe_unserialize($field->field_options); $replace_with = FrmProEntryMetaHelper::get_post_or_meta_value($entry, $field, $atts); $replace_with = maybe_unserialize($replace_with); $atts['entry_id'] = $entry->id; $atts['entry_key'] = $entry->item_key; $atts['post_id'] = $entry->post_id; $replace_with = apply_filters('frmpro_fields_replace_shortcodes', $replace_with, $tag, $atts, $field); } if (isset($replace_with) and is_array($replace_with)) { $replace_with = implode($sep, $replace_with); } if ($field 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); } } if ($conditional) { $replace_with = apply_filters('frm_conditional_value', $replace_with, $atts, $field, $tag); if ($atts) { $content = str_replace($shortcodes[0][$short_key], '[if ' . $tag . ']', $content); } if (empty($replace_with)) { $content = preg_replace('/(\\[if\\s+' . $tag . '\\])(.*?)(\\[\\/if\\s+' . $tag . '\\])/mis', '', $content); } else { $content = preg_replace('/(\\[if\\s+' . $tag . '\\])/', '', $content, 1); $content = preg_replace('/(\\[\\/if\\s+' . $tag . '\\])/', '', $content, 1); } } else { if ($field) { if (isset($atts['show']) and $atts['show'] == 'field_label') { $replace_with = stripslashes($field->name); } else { if (empty($replace_with) and $replace_with != '0') { $replace_with = ''; if ($field->type == 'number') { $replace_with = '0'; } } else { $replace_with = FrmProFieldsHelper::get_display_value($replace_with, $field, $atts); } } } if (isset($atts['sanitize'])) { $replace_with = sanitize_title_with_dashes($replace_with); } if (isset($atts['sanitize_url'])) { $replace_with = urlencode(htmlentities($replace_with)); } if (isset($atts['truncate'])) { if (isset($atts['more_text'])) { $more_link_text = $atts['more_text']; } else { $more_link_text = isset($atts['more_link_text']) ? $atts['more_link_text'] : '. . .'; } if ($display and $show == 'all') { $more_link_text = ' <a href="' . $detail_link . '">' . $more_link_text . '</a>'; $replace_with = FrmAppHelper::truncate($replace_with, (int) $atts['truncate'], 3, $more_link_text); } else { $replace_with = wp_specialchars_decode(strip_tags($replace_with), ENT_QUOTES); $part_one = substr($replace_with, 0, (int) $atts['truncate']); $part_two = substr($replace_with, (int) $atts['truncate']); $replace_with = $part_one . '<a onclick="jQuery(this).next().css(\'display\', \'inline\');jQuery(this).css(\'display\', \'none\')" class="frm_text_exposed_show"> ' . $more_link_text . '</a><span style="display:none;">' . $part_two . '</span>'; } } if (isset($atts['clickable'])) { $replace_with = make_clickable($replace_with); } if (!isset($replace_with)) { $replace_with = ''; } $content = str_replace($shortcodes[0][$short_key], $replace_with, $content); } unset($replace_with); if (isset($field)) { unset($field); } } unset($atts); unset($conditional); } return $content; }
public static function atts_truncate($replace_with, $atts, $display, $args) { if (isset($atts['more_text'])) { $more_link_text = $atts['more_text']; } else { $more_link_text = isset($atts['more_link_text']) ? $atts['more_link_text'] : '. . .'; } // If we're on the listing page of a Dynamic View, use detail link for truncate link if ($display && $display->frm_show_count == 'dynamic' && $args['show'] == 'all') { $more_link_text = ' <a href="' . esc_url($args['detail_link']) . '">' . $more_link_text . '</a>'; return FrmAppHelper::truncate($replace_with, (int) $atts['truncate'], 3, $more_link_text); } $replace_with = wp_specialchars_decode(strip_tags($replace_with), ENT_QUOTES); $part_one = FrmAppHelper::mb_function(array('mb_substr', 'substr'), array($replace_with, 0, (int) $atts['truncate'])); $part_two = FrmAppHelper::mb_function(array('mb_substr', 'substr'), array($replace_with, (int) $atts['truncate'])); if (!empty($part_two)) { $replace_with = $part_one . '<a href="#" onclick="jQuery(this).next().css(\'display\', \'inline\');jQuery(this).css(\'display\', \'none\');return false;" class="frm_text_exposed_show"> ' . $more_link_text . '</a><span style="display:none;">' . $part_two . '</span>'; } return $replace_with; }
function entries_dropdown($form_id, $field_name, $field_value = '', $blank = true, $blank_label = '', $onchange = false) { global $wpdb, $frmdb; $entries = $frmdb->get_records($frmdb->entries, array('form_id' => $form_id), 'name', 999, 'id,item_key,name'); ?> <select name="<?php echo $field_name; ?> " id="<?php echo $field_name; ?> " class="frm-dropdown" <?php if ($onchange) { echo 'onchange="' . $onchange . '"'; } ?> > <?php if ($blank) { ?> <option value=""><?php echo $blank_label; ?> </option> <?php } ?> <?php foreach ($entries as $entry) { ?> <option value="<?php echo $entry->id; ?> " <?php selected($field_value, $entry->id); ?> ><?php echo FrmAppHelper::truncate(!empty($entry->name) ? stripslashes($entry->name) : $entry->item_key, 40); ?> </option> <?php unset($entry); } ?> </select> <?php }
public static function register_form_settings() { $settings = array(); $error = false; // Settings if (class_exists('RGFormsModel') && method_exists('RGFormsModel', 'get_forms')) { $gravity_options = array(0 => self::__('No forms found')); if (class_exists('RGFormsModel') && method_exists('RGFormsModel', 'get_forms')) { $all_grav_forms = RGFormsModel::get_forms(1, 'title'); $gravity_options = array(); foreach ($all_grav_forms as $form) { $gravity_options[absint($form->id)] = esc_html($form->title); } } $settings = array(self::GRAVITY_FORM_ID => array('label' => self::__('GravityForms ID'), 'option' => array('type' => 'select', 'options' => $gravity_options, 'default' => self::$gravity_form_id, 'description' => sprintf(self::__('Select the submission form built with <a href="%s">Gravity Forms</a>.'), 'https://sproutapps.co/link/gravity-forms')))); } elseif (function_exists('ninja_forms_get_all_forms')) { $ninja_options = array(0 => self::__('No forms found')); if (function_exists('ninja_forms_get_all_forms')) { $all_ninja_forms = ninja_forms_get_all_forms(); $ninja_options = array(); foreach ($all_ninja_forms as $form) { $ninja_options[$form['id']] = $form['data']['form_title']; } } // Settings $settings = array(self::NINJA_FORM_ID => array('label' => self::__('NinjaForms ID'), 'option' => array('type' => 'select', 'options' => $ninja_options, 'default' => self::$ninja_form_id, 'description' => sprintf(self::__('Select the submission form built with <a href="%s">Ninja Forms</a>.'), 'https://sproutapps.co/link/ninja-forms')))); } elseif (function_exists('frm_forms_autoloader')) { $frdbl_options = array(0 => self::__('No forms found')); $forms = FrmForm::get_published_forms(); if (!empty($forms)) { $frdbl_options = array(); foreach ($forms as $form) { $frdbl_options[$form->id] = !isset($form->name) ? __('(no title)', 'formidable') : esc_attr(FrmAppHelper::truncate($form->name, 33)); } } // Settings $settings = array(self::FORMIDABLE_FORM_ID => array('label' => self::__('Formidable ID'), 'option' => array('type' => 'select', 'options' => $frdbl_options, 'default' => self::$frdbl_form_id, 'description' => sprintf(self::__('Select the submission form built with <a href="%s">Formidable</a>.'), 'https://sproutapps.co/link/formidable')))); } else { // Settings $settings = array(self::NINJA_FORM_ID => array('label' => self::__('Integration Error'), 'option' => array('type' => 'bypass', 'output' => sprintf(self::__('It looks like neither <a href="%s">Gravity Forms</a> or <a href="%s">Ninja Forms</a> or <a href="%s">Formidable</a> is active.'), 'https://sproutapps.co/link/gravity-forms', 'https://sproutapps.co/link/ninja-forms', 'https://sproutapps.co/link/formidable')))); $error = true; } $map_settings = array(); if (!$error) { // Settings $map_settings = array(self::FORM_ID_MAPPING => array('label' => self::__('Form ID Mapping'), 'option' => array(__CLASS__, 'show_form_field_mapping'), 'sanitize_callback' => array(__CLASS__, 'save_form_field_mapping'))); } return array_merge($settings, $map_settings); }
function search_form($sort_str, $sdir_str, $search_str, $fid = false) { if (isset($_GET['page']) and $_GET['page'] == 'formidable-entries') { global $frm_form, $frm_field; if (isset($_GET['form'])) { $form = $frm_form->getOne($_GET['form']); } else { $form = $frm_form->getAll("is_template=0 AND (status is NULL OR status = '' OR status = 'published')", ' ORDER BY name', ' LIMIT 1'); } if ($form) { $field_list = $frm_field->getAll("fi.type not in ('divider','captcha','break','html') and fi.form_id=" . $form->id, 'field_order'); } } ?> <div id="search_pane" style="float: right;"> <form method="post" > <p class="search-box"> <input type="hidden" name="paged" id="paged" value="1" /> <input type="hidden" name="sort" id="sort" value="<?php echo esc_attr($sort_str); ?> " /> <input type="hidden" name="sdir" id="sort" value="<?php echo esc_attr($sdir_str); ?> " /> <?php if (isset($field_list) and !empty($field_list)) { ?> <select name="fid"> <option value="">- <?php _e('All Fields', 'formidable'); ?> -</option> <option value="created_at" <?php selected($fid, 'created_at'); ?> ><?php _e('Entry creation date', 'formidable'); ?> </option> <?php foreach ($field_list as $f) { ?> <option value="<?php echo $f->id; ?> " <?php selected($fid, $f->id); ?> ><?php echo FrmAppHelper::truncate($f->name, 30); ?> </option> <?php } ?> </select> <?php } ?> <input type="text" name="search" id="search" value="<?php echo esc_attr($search_str); ?> "/> <input type="submit" class="button" value="<?php _e('Search', 'formidable'); ?> "/> <?php if (!empty($search_str)) { ?> or <a href=""><?php _e('Reset', 'formidable'); ?> </a> <?php } ?> </p> </form> </div> <?php }
private static function popup_opts_frm_graph(array &$opts, $shortcode) { $form_list = FrmForm::getAll(array('status' => 'published', 'is_template' => 0), 'name'); ?> <h4 class="frm_left_label"><?php _e('Select a field:', 'formidable'); ?> </h4> <select class="frm_get_field_selection" id="frm_form_frmsc_<?php echo esc_attr($shortcode); ?> _id"> <option value="">— <?php _e('Select Form', 'formidable'); ?> —</option> <?php foreach ($form_list as $form_opts) { ?> <option value="<?php echo esc_attr($form_opts->id); ?> "><?php echo '' == $form_opts->name ? __('(no title)', 'formidable') : esc_html(FrmAppHelper::truncate($form_opts->name, 30)); ?> </option> <?php } ?> </select> <span id="frm_form_frmsc_<?php echo esc_attr($shortcode); ?> _id_fields"> </span> <div class="frm_box_line"></div> <?php $opts = array('type' => array('val' => 'default', 'label' => __('Graph Type', 'formidable'), 'type' => 'select', 'opts' => array('default' => __('Default', 'formidable'), 'bar' => __('Bar', 'formidable'), 'column' => __('Column', 'formidable'), 'pie' => __('Pie', 'formidable'), 'line' => __('Line', 'formidable'), 'area' => __('Area', 'formidable'), 'SteppedArea' => __('Stepped Area', 'formidable'), 'geo' => __('Geolocation Map', 'formidable'))), 'data_type' => array('val' => 'count', 'label' => __('Data Type', 'formidable'), 'type' => 'select', 'opts' => array('count' => __('The number of entries', 'formidable'), 'total' => __('Add the field values together', 'formidable'), 'average' => __('Average the totaled field values', 'formidable'))), 'height' => array('val' => '', 'label' => __('Height', 'formidable'), 'type' => 'text'), 'width' => array('val' => '', 'label' => __('Width', 'formidable'), 'type' => 'text'), 'bg_color' => array('val' => '', 'label' => __('Background color', 'formidable'), 'type' => 'text'), 'truncate_label' => array('val' => '', 'label' => __('Truncate graph labels', 'formidable'), 'type' => 'text'), 'truncate' => array('val' => '', 'label' => __('Truncate title', 'formidable'), 'type' => 'text'), 'title' => array('val' => '', 'label' => __('Graph title', 'formidable'), 'type' => 'text'), 'title_size' => array('val' => '', 'label' => __('Title font size', 'formidable'), 'type' => 'text'), 'title_font' => array('val' => '', 'label' => __('Title font name', 'formidable'), 'type' => 'text'), 'is3d' => array('val' => 1, 'label' => __('Turn your pie graph three-dimensional', 'formidable'), 'show' => array('type' => 'pie')), 'include_zero' => array('val' => 1, 'label' => __('When using dates for the x_axis parameter, you can also fill in dates with a zero value. This will also apply to dropdown, radio, and checkbox fields with no x_axis defined.', 'formidable')), 'show_key' => array('val' => 1, 'label' => __('Include the key with the graph', 'formidable'))); /* 'ids' => false, 'colors' => '', 'grid_color' => '#CCC', 'response_count' => 10, 'user_id' => false, 'entry_id' => false, 'x_axis' => false, 'limit' => '', 'x_start' => '', 'x_end' => '', 'min' => '', 'max' => '', 'y_title' => '', 'x_title' => '', 'field' => false, 'tooltip_label' => '', 'start_date' => '', 'end_date' => '', 'group_by' => '', 'x_order' => '1', any field id in this form => value */ }
]</a> <a href="javascript:void(0)" class="frmkeys alignright frm_insert_code" data-code="if <?php echo esc_attr($f->field_key); ?> ]something[/if <?php echo esc_attr($f->field_key); ?> ">[if <?php echo FrmAppHelper::truncate($f->field_key, 10); ?> ]</a> <a href="javascript:void(0)" class="frm_insert_code" data-code="<?php echo esc_attr($f->id); ?> "><?php echo FrmAppHelper::truncate($f->name, 60); ?> </a> </li> <?php if ($f->type == 'user_id') { $uid = $f; } else { if ($f->type == 'file') { $file = $f; } } unset($f); } } ?>
public static function edit_form_link($form_id) { if (is_object($form_id)) { $form = $form_id; $name = $form->name; $form_id = $form->id; } else { $name = FrmForm::getName($form_id); } if ($form_id) { $val = '<a href="' . esc_url(admin_url('admin.php') . '?page=formidable&frm_action=edit&id=' . $form_id) . '">' . ('' == $name ? __('(no title)') : FrmAppHelper::truncate($name, 40)) . '</a>'; } else { $val = ''; } return $val; }
if (is_array($ff)) { $ff = (object) $ff; } if (in_array($ff->type, $exclude_fields) || FrmProField::is_list_field($ff)) { continue; } $selected = isset($condition['hide_field']) && $ff->id == $condition['hide_field'] ? ' selected="selected"' : ''; ?> <option value="<?php echo esc_attr($ff->id); ?> "<?php echo $selected; ?> ><?php echo FrmAppHelper::truncate($ff->name, 25); ?> </option> <?php unset($ff); } ?> </select> <?php _e('is', 'formidable'); ?> <select name="<?php echo $names['hide_field_cond']; ?> ">
function single_row($item, $style = '') { global $frm_vars, $frm_entry; $checkbox = ''; // Set up the hover actions for this user $actions = array(); $title = esc_attr(strip_tags($item->name)); if (current_user_can('frm_edit_forms')) { $edit_link = "?page=formidable&frm_action=edit&id={$item->id}"; $duplicate_link = "?page=formidable&frm_action=duplicate&id={$item->id}"; $actions['frm_edit'] = "<a href='" . esc_url($edit_link) . "'>" . __('Edit') . "</a>"; if ($this->params['template']) { $actions['frm_duplicate'] = "<a href='" . wp_nonce_url($duplicate_link) . "'>" . __('Create Form from Template', 'formidable') . "</a>"; } else { $actions['frm_settings'] = "<a href='" . wp_nonce_url("?page=formidable&frm_action=settings&id={$item->id}") . "'>" . __('Settings', 'formidable') . "</a>"; if ($frm_vars['pro_is_installed']) { $actions['duplicate'] = '<a href="' . wp_nonce_url($duplicate_link) . '">' . __('Duplicate', 'formidable') . '</a>'; } } } $delete_link = "?page=formidable&frm_action=destroy&id={$item->id}"; if (current_user_can('frm_delete_forms')) { $actions['trash'] = '<a class="submitdelete" href="' . wp_nonce_url($delete_link) . '" onclick="return confirm(\'' . __('Are you sure you want to delete that?', 'formidable') . '\')">' . __('Delete') . '</a>'; } $actions['view'] = '<a href="' . FrmFormsHelper::get_direct_link($item->form_key, $item) . '" target="_blank">' . __('Preview') . '</a>'; $action_links = $this->row_actions($actions); // Set up the checkbox ( because the user is editable, otherwise its empty ) $checkbox = '<input type="checkbox" name="item-action[]" id="cb-item-action-' . $item->id . '" value="' . $item->id . '" />'; $r = '<tr id="item-action-' . $item->id . '"' . $style . '>'; list($columns, $hidden) = $this->get_column_info(); $action_col = false; foreach ($columns as $column_name => $column_display_name) { $class = 'class="' . $column_name . ' column-' . $column_name . '"'; $style = ''; if (in_array($column_name, $hidden)) { $style = ' style="display:none;"'; } else { if (!$action_col and !in_array($column_name, array('cb', 'id'))) { $action_col = $column_name; } } $attributes = "{$class}{$style}"; switch ($column_name) { case 'cb': $r .= '<th scope="row" class="check-column">' . $checkbox . '</th>'; break; case 'id': case 'form_key': $val = $item->{$column_name}; break; case 'name': if (trim($item->{$column_name}) == '') { $val = __('(no title)'); } else { $val = FrmAppHelper::truncate(strip_tags($item->{$column_name}), 50); } break; case 'description': $val = FrmAppHelper::truncate(strip_tags($item->{$column_name}), 50); break; case 'created_at': $format = 'Y/m/d'; //get_option('date_format'); $date = date($format, strtotime($item->{$column_name})); $val = "<abbr title='" . date($format . ' g:i:s A', strtotime($item->{$column_name})) . "'>" . $date . "</abbr>"; break; case 'shortcode': $val = '<input type="text" readonly="true" class="frm_select_box" value="' . esc_attr("[formidable id={$item->id}]") . '" /><br/>'; $val .= '<input type="text" readonly="true" class="frm_select_box" value="' . esc_attr("[formidable key={$item->form_key}]") . '" />'; break; case 'entries': $text = $frm_entry->getRecordCount($item->id); //$text = sprintf(_n( '%1$s Entry', '%1$s Entries', $text, 'formidable' ), $text); $val = current_user_can('frm_view_entries') ? '<a href="' . esc_url(admin_url('admin.php') . '?page=formidable-entries&form=' . $item->id) . '">' . $text . '</a>' : $text; unset($text); break; case 'link': $links = array(); if ($frm_vars['pro_is_installed'] and current_user_can('frm_create_entries')) { $links[] = '<a href="' . wp_nonce_url("?page=formidable-entries&frm_action=new&form={$item->id}") . '" class="frm_add_entry_icon frm_icon_font frm_bstooltip" title="' . __('Add Entry', 'formidable') . '" data-toggle="tooltip"> </a>'; } if (current_user_can('frm_edit_forms')) { $links[] = '<a href="' . wp_nonce_url("?page=formidable&frm_action=duplicate&id={$item->id}&template=1") . '" class="frm_icon_font frm_new_template_icon frm_bstooltip" title="' . __('Create template from form', 'formidable') . '" data-toggle="tooltip"> </a>'; } $val = implode(' ', $links); break; default: $val = $column_name; break; } if (isset($val)) { $r .= "<td {$attributes}>"; if ($column_name == $action_col) { $r .= '<a class="row-title" href="' . (isset($actions['frm_edit']) ? $edit_link : FrmFormsHelper::get_direct_link($item->form_key, $item)) . '">' . $val . '</a> '; $r .= $action_links; } else { $r .= $val; } $r .= '</td>'; } unset($val); } $r .= '</tr>'; return $r; }
<div class="wrap"> <div id="icon-edit-pages" class="icon32"><br/></div> <h2><?php echo $form ? FrmAppHelper::truncate(stripslashes($form->name), 25) . ' ' : ''; _e('Entries', 'formidable'); ?> </h2> <?php require FRM_VIEWS_PATH . '/shared/errors.php'; ?> <?php require FRM_VIEWS_PATH . '/shared/nav.php'; ?> <?php if ($form) { FrmAppController::get_form_nav($form->id, true); } ?> <?php FrmAppController::update_message('view, search, export, and bulk delete your saved entries'); ?> <?php if (!$form or $entry_count) { ?> <img src="<?php echo FRM_URL; ?> /screenshot-3.png" alt="Entries List" style="max-width:100%"/>
][]"> <option value=""><?php echo $new_field->type == 'data' ? 'Anything' : 'Select'; ?> </option> <?php if ($new_field->options) { foreach ($new_field->options as $opt_key => $opt) { $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $temp_field); //use VALUE instead of LABEL $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $temp_field); unset($field_array); $selected = isset($field) && ($new_field->type == 'data' && $field['hide_opt'][$meta_name] == $opt_key || $field['hide_opt'][$meta_name] == $opt) ? ' selected="selected"' : ''; ?> <option value="<?php echo esc_attr($field_val); ?> "<?php echo $selected; ?> ><?php echo FrmAppHelper::truncate($opt, 25); ?> </option> <?php } } ?> </select> <?php }
"> <option value=""></option> <?php foreach ($fields as $field) { if (in_array($field->type, array('break', 'divider', 'captcha', 'html'))) { continue; } ?> <option value="<?php echo $field->id; ?> " <?php selected(strtolower(strip_tags($field->name)), strtolower(htmlspecialchars($header))); ?> ><?php echo FrmAppHelper::truncate($field->name, 50); ?> </option> <?php unset($field); } ?> <option value="post_id"><?php _e('Post ID', 'formidable'); ?> </option> <option value="created_at" <?php selected(strtolower(__('Timestamp', 'formidable')), strtolower(htmlspecialchars($header))) . selected(strtolower(__('Created at', 'formidable')), strtolower(htmlspecialchars($header))) . selected('created_at', $header); ?> ><?php _e('Created at', 'formidable');
function single_row($item, $style = '') { global $frmpro_settings; $checkbox = ''; // Set up the hover actions for this user $actions = array(); $edit_link = "?page=formidable-{$this->page_name}&frm_action=edit&id={$item->id}"; $actions['edit'] = "<a href='" . wp_nonce_url($edit_link) . "'>" . __('Edit', 'formidable') . "</a>"; $duplicate_link = "?page=formidable-{$this->page_name}&frm_action=duplicate&id={$item->id}"; $delete_link = "?page=formidable-{$this->page_name}&frm_action=destroy&id={$item->id}"; if ($this->plural == 'entries') { $duplicate_link .= "&form=" . $this->params['form']; $delete_link .= "&form=" . $this->params['form']; $view_link = "?page=formidable-{$this->page_name}&frm_action=show&id={$item->id}"; $actions['view'] = "<a href='" . wp_nonce_url($view_link) . "'>" . __('View', 'formidable') . "</a>"; } $actions['duplicate'] = "<a href='" . wp_nonce_url($duplicate_link) . "'>" . __('Duplicate', 'formidable') . "</a>"; $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url($delete_link) . "' onclick='return confirm(\"" . __('Are you sure you want to delete that?', 'formidable') . "\")'>" . __('Delete', 'formidable') . "</a>"; if ($this->plural == 'displays' and !current_user_can('frm_edit_displays')) { $actions = array(); } else { if ($this->plural == 'entries') { if (!current_user_can('frm_edit_entries')) { unset($actions['edit']); } if (!current_user_can('frm_create_entries')) { unset($actions['duplicate']); } if (!current_user_can('frm_delete_entries')) { unset($actions['delete']); } } } $action_links = $this->row_actions($actions); // Set up the checkbox ( because the user is editable, otherwise its empty ) $checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />"; $r = "<tr id='item-action-{$item->id}'{$style}>"; list($columns, $hidden) = $this->get_column_info(); $action_col = false; foreach ($columns as $column_name => $column_display_name) { $class = "class=\"{$column_name} column-{$column_name}\""; $style = ''; if (in_array($column_name, $hidden)) { $style = ' style="display:none;"'; } else { if (!$action_col and !in_array($column_name, array('cb', 'id', 'form_id', 'post_id'))) { $action_col = $column_name; } } $attributes = "{$class}{$style}"; $col_name = preg_replace('/^(' . $this->params['form'] . '_)/', '', $column_name); switch ($col_name) { case 'cb': $r .= "<th scope='row' class='check-column'>{$checkbox}</th>"; break; case 'ip': case 'id': case 'item_key': case 'display_key': case 'show_count': $val = stripslashes($item->{$col_name}); break; case 'name': case 'description': case 'content': case 'dyncontent': $val = FrmAppHelper::truncate(strip_tags(stripslashes($item->{$col_name})), 100); break; case 'created_at': case 'updated_at': $date = date($frmpro_settings->date_format, strtotime($item->{$col_name})); $val = "<abbr title='" . date($frmpro_settings->date_format . ' g:i:s A', strtotime($item->{$col_name})) . "'>" . $date . "</abbr>"; break; case 'form_id': global $frm_form; $form = $frm_form->getName($item->form_id); if ($form) { $val = '<a href="' . admin_url('admin.php') . '?page=formidable&frm_action=edit&id=' . $item->form_id . '">' . FrmAppHelper::truncate(stripslashes($form), 40) . '</a>'; } else { $val = ''; } break; case 'post_id': if ($this->plural == 'displays' and $item->insert_loc == 'none') { $val = ''; break; } $post = get_post($item->{$col_name}); if ($post) { $val = '<a href="' . admin_url('post.php') . '?post=' . $item->{$col_name} . '&action=edit">' . FrmAppHelper::truncate($post->post_title, 50) . '</a>'; } else { $val = ''; } break; case 'user_id': $user = get_userdata($item->user_id); $val = $user->user_login; break; case 'shortcode': if ($this->plural == 'displays') { $code = "[display-frm-data id={$item->id} filter=1]"; } else { $code = ''; } $val = "<input type='text' style='font-size:10px;width:100%;' readonly='true' onclick='this.select();' onfocus='this.select();' value='{$code}' />"; break; default: if ($this->plural == 'entries') { global $frm_field; $col = $frm_field->getOne($col_name); $field_value = isset($item->metas[$col->id]) ? $item->metas[$col->id] : false; $col->field_options = maybe_unserialize($col->field_options); if (!$field_value and $col->type == 'data' and $col->field_options['data_type'] == 'data' and isset($col->field_options['hide_field'])) { $field_value = array(); foreach ((array) $col->field_options['hide_field'] as $hfield) { if (isset($item->metas[$hfield])) { $field_value[] = maybe_unserialize($item->metas[$hfield]); } } } $val = FrmProEntryMetaHelper::display_value($field_value, $col, array('type' => $col->type, 'truncate' => true, 'post_id' => $item->post_id, 'entry_id' => $item->id)); } else { $val = $col_name; } break; } if (isset($val)) { $r .= "<td {$attributes}>"; if ($column_name == $action_col) { $r .= '<a class="row-title" href="' . (isset($actions['edit']) ? $edit_link : $view_link) . '">' . $val . '</a> '; $r .= $action_links; } else { $r .= $val; } $r .= '</td>'; } unset($val); } $r .= '</tr>'; return $r; }
$fo->field_options = maybe_unserialize($fo->field_options); if (isset($fo->field_options['form_select'])) { $fo->form_select = $fo->field_options['form_select']; } $fo = (array) $fo; } if (in_array($fo['type'], array('checkbox', 'radio', 'select', 'tag')) || $fo['type'] == 'data' && isset($fo['form_select']) && $fo['form_select'] == 'taxonomy') { ?> <option value="<?php echo $fo['id']; ?> " <?php selected($field_vars['field_id'], $fo['id']); ?> ><?php echo FrmAppHelper::truncate($fo['name'], 50); ?> </option> <?php if ($field_vars['field_id'] == $fo['id']) { $selected_type = $fo['type']; } } unset($fo); } } ?> </select> <?php if ($selected_type == 'tag') {
public static function manage_columns($columns) { global $frm_vars; $form_id = FrmProAppHelper::get_current_form_id(); $columns['cb'] = '<input type="checkbox" />'; $columns[$form_id . '_id'] = 'ID'; $columns[$form_id . '_item_key'] = __('Entry Key', 'formidable'); $frm_field = new FrmField(); $form_cols = $frm_field->getAll("fi.type not in ('divider', 'captcha', 'break', 'html') and fi.form_id=" . (int) $form_id, 'field_order ASC'); foreach ($form_cols as $form_col) { if (isset($form_col->field_options['separate_value']) and $form_col->field_options['separate_value']) { $columns[$form_id . '_frmsep_' . $form_col->field_key] = FrmAppHelper::truncate($form_col->name, 35); } $columns[$form_id . '_' . $form_col->field_key] = FrmAppHelper::truncate($form_col->name, 35); } $columns[$form_id . '_post_id'] = __('Post', 'formidable'); $columns[$form_id . '_created_at'] = __('Entry creation date', 'formidable'); $columns[$form_id . '_updated_at'] = __('Entry update date', 'formidable'); $columns[$form_id . '_ip'] = 'IP'; $columns[$form_id . '_is_draft'] = __('Draft', 'formidable'); //TODO: allow custom order of columns $frm_vars['cols'] = $columns; if (isset($_GET['page']) and $_GET['page'] == 'formidable-entries' and (!isset($_GET['frm_action']) or $_GET['frm_action'] == 'list' or $_GET['frm_action'] == 'destroy')) { add_screen_option('per_page', array('label' => __('Entries', 'formidable'), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page')); } return $columns; }