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; }
public static function manage_custom_columns($column_name, $id) { switch ($column_name) { case 'id': $val = $id; break; case 'old_id': $old_id = get_post_meta($id, 'frm_old_id', true); $val = $old_id ? $old_id : __('N/A', 'formidable'); break; case 'name': case 'content': $post = get_post($id); $val = FrmAppHelper::truncate(strip_tags($post->{"post_{$column_name}"}), 100); break; case 'description': $post = get_post($id); $val = FrmAppHelper::truncate(strip_tags($post->post_excerpt), 100); break; case 'show_count': $val = ucwords(get_post_meta($id, 'frm_' . $column_name, true)); break; case 'dyncontent': $val = FrmAppHelper::truncate(strip_tags(get_post_meta($id, 'frm_' . $column_name, true)), 100); break; case 'form_id': $form_id = get_post_meta($id, 'frm_' . $column_name, true); $val = FrmFormsHelper::edit_form_link($form_id); break; case 'post_id': $insert_loc = get_post_meta($id, 'frm_insert_loc', true); if (!$insert_loc || $insert_loc == 'none') { $val = ''; break; } $post_id = get_post_meta($id, 'frm_' . $column_name, true); $val = FrmAppHelper::post_edit_link($post_id); break; case 'shortcode': $code = '[display-frm-data id=' . $id . ' filter=1]'; $val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr($code) . '" />'; break; default: $val = $column_name; break; } echo $val; }