Example #1
0
 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;
 }
Example #2
0
 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') . "</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') . "</a>";
     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']);
         }
     }
     $actions = apply_filters('frm_row_actions', $actions, $item);
     $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 = $item->{$col_name};
                 break;
             case 'name':
             case 'description':
             case 'content':
             case 'dyncontent':
                 $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
                 break;
             case 'created_at':
             case 'updated_at':
                 $date = FrmProAppHelper::get_formatted_time($item->{$col_name}, $frmpro_settings->date_format);
                 $val = "<abbr title='" . FrmProAppHelper::get_formatted_time($item->{$col_name}, $frmpro_settings->date_format, 'g:i:s A') . "'>" . $date . "</abbr>";
                 break;
             case 'is_draft':
                 $val = empty($item->is_draft) ? __('No') : __('Yes');
                 break;
             case 'form_id':
                 $frm_form = new FrmForm();
                 $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($form, 40) . '</a>';
                 } else {
                     $val = '';
                 }
                 break;
             case 'post_id':
                 $post = get_post($item->{$col_name});
                 if ($post) {
                     $val = '<a href="' . admin_url('post.php') . '?post=' . $item->{$col_name} . '&amp;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':
                 $code = '';
                 $val = '<input type="text" readonly="true" class="frm_select_box" value="' . esc_attr($code) . '" />';
                 break;
             default:
                 if ($this->plural == 'entries') {
                     global $frm_field;
                     if (strpos($col_name, 'frmsep_') === 0) {
                         $sep_val = true;
                         $col_name = str_replace('frmsep_', '', $col_name);
                     } else {
                         $sep_val = false;
                     }
                     $col = $frm_field->getOne($col_name);
                     $field_value = isset($item->metas[$col->id]) ? $item->metas[$col->id] : false;
                     if (!$field_value and $col->type == 'data' and (!isset($col->field_options['data_type']) or $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]);
                             }
                         }
                     }
                     $atts = array('type' => $col->type, 'truncate' => true, 'post_id' => $item->post_id, 'entry_id' => $item->id);
                     if ($sep_val) {
                         $atts['saved_value'] = true;
                     }
                     $val = FrmProEntryMetaHelper::display_value($field_value, $col, $atts);
                 } 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;
 }
Example #3
0
                    <div class="inside">
                        <table class="form-table"><tbody> 
                        <?php 
    foreach ($comments as $comment) {
        $meta = $comment->meta_value;
        if (!isset($meta['comment'])) {
            continue;
        }
        ?>
                            <tr class="frm_comment_block">
                                <th scope="row"><p><strong><?php 
        echo FrmProFieldsHelper::get_display_name($meta['user_id'], 'display_name', array('link' => true));
        ?>
</strong><br/>
                                    <?php 
        echo FrmProAppHelper::get_formatted_time($comment->created_at, $date_format, $time_format);
        ?>
</p>
                                </th>
                                <td><div class="frm_comment"><?php 
        echo wpautop(strip_tags($meta['comment']));
        ?>
</div></td>
                            </tr>
                        <?php 
    }
    ?>
                        </table>
                        <a onclick="jQuery('#frm_comment_form').toggle('slow');" class="button-secondary alignright">+ <?php 
    _e('Add Note/Comment', 'formidable');
    ?>
 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;
 }
Example #5
0
                unset($co);
                $v = FrmProEntriesHelper::encode_value(FrmProFieldsHelper::get_display_name($c['user_id'], 'user_login'), $charset, $to_encoding);
                unset($c);
                echo '"' . $v . '"' . $col_sep;
                $v = FrmProEntriesHelper::encode_value(FrmProAppHelper::get_formatted_time($comment->created_at, $wp_date_format, ' '), $charset, $to_encoding);
                echo '"' . $v . '"' . $col_sep;
                unset($v);
            }
        }
        if ($place_holder) {
            for ($i = 0; $i < $place_holder; $i++) {
                echo '""' . $col_sep . '""' . $col_sep . '""' . $col_sep;
            }
            unset($i);
        }
        unset($place_holder);
        $formatted_date = FrmProAppHelper::get_formatted_time($entry->created_at, $wp_date_format, ' ');
        echo '"' . $formatted_date . '"' . $col_sep;
        $formatted_date = FrmProAppHelper::get_formatted_time($entry->updated_at, $wp_date_format, ' ');
        echo '"' . $formatted_date . '"' . $col_sep;
        unset($formatted_date);
        echo '"' . FrmProEntriesHelper::encode_value(FrmProFieldsHelper::get_display_name($entry->user_id, 'user_login'), $charset, $to_encoding) . '"' . $col_sep;
        echo '"' . FrmProEntriesHelper::encode_value(FrmProFieldsHelper::get_display_name($entry->updated_by, 'user_login'), $charset, $to_encoding) . '"' . $col_sep;
        echo '"' . ($entry->is_draft ? '1' : '0') . '"' . $col_sep;
        echo '"' . $entry->ip . '"' . $col_sep;
        echo '"' . $entry->id . '"' . $col_sep;
        echo '"' . $entry->item_key . '"' . "\n";
        unset($entry);
    }
    unset($entries);
}